mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-24 19:40:45 +08:00
cleanup: remove copy contructors when the compiler is able to generate a satisfactory
default copy constructor; remove useless static_cast's; some misc cleanup.
This commit is contained in:
parent
86220784b6
commit
42f6590bb2
@ -64,10 +64,6 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
||||
&& startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= matrix.cols());
|
||||
}
|
||||
|
||||
Block(const Block& other)
|
||||
: m_matrix(other.m_matrix),
|
||||
m_startRow(other.m_startRow), m_startCol(other.m_startCol) {}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
|
||||
|
||||
private:
|
||||
|
@ -56,9 +56,6 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals,
|
||||
|
||||
Cast(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
Cast(const Cast& other)
|
||||
: m_matrix(other.m_matrix) {}
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
@ -78,7 +75,7 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals,
|
||||
/** \returns an expression of *this with the \a Scalar type casted to
|
||||
* \a NewScalar.
|
||||
*
|
||||
* \param NewScalar the type we are casting the scalars to
|
||||
* The template parameter \a NewScalar is the type we are casting the scalars to.
|
||||
*
|
||||
* Example: \include MatrixBase_cast.cpp
|
||||
* Output: \verbinclude MatrixBase_cast.out
|
||||
@ -90,7 +87,7 @@ template<typename NewScalar>
|
||||
const Cast<NewScalar, Derived>
|
||||
MatrixBase<Scalar, Derived>::cast() const
|
||||
{
|
||||
return Cast<NewScalar, Derived>(static_cast<const Derived*>(this)->ref());
|
||||
return Cast<NewScalar, Derived>(ref());
|
||||
}
|
||||
|
||||
#endif // EIGEN_CAST_H
|
||||
|
@ -60,9 +60,6 @@ template<typename MatrixType> class Column
|
||||
assert(col >= 0 && col < matrix.cols());
|
||||
}
|
||||
|
||||
Column(const Column& other)
|
||||
: m_matrix(other.m_matrix), m_col(other.m_col) {}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column)
|
||||
|
||||
private:
|
||||
@ -89,8 +86,8 @@ template<typename MatrixType> class Column
|
||||
|
||||
/** \returns an expression of the \a i-th column of *this. Note that the numbering starts at 0.
|
||||
*
|
||||
* Example: \include MatrixBase_column.cpp
|
||||
* Output: \verbinclude MatrixBase_column.out
|
||||
* Example: \include MatrixBase_col.cpp
|
||||
* Output: \verbinclude MatrixBase_col.out
|
||||
*
|
||||
* \sa row(), class Column */
|
||||
template<typename Scalar, typename Derived>
|
||||
|
@ -48,9 +48,6 @@ template<typename MatrixType> class Conjugate : NoOperatorEquals,
|
||||
|
||||
Conjugate(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
Conjugate(const Conjugate& other)
|
||||
: m_matrix(other.m_matrix) {}
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
@ -75,7 +72,7 @@ template<typename Scalar, typename Derived>
|
||||
const Conjugate<Derived>
|
||||
MatrixBase<Scalar, Derived>::conjugate() const
|
||||
{
|
||||
return Conjugate<Derived>(static_cast<const Derived*>(this)->ref());
|
||||
return Conjugate<Derived>(ref());
|
||||
}
|
||||
|
||||
/** \returns an expression of the adjoint (i.e. conjugate transpose) of *this.
|
||||
|
@ -48,8 +48,6 @@ template<typename MatrixType> class DiagonalCoeffs
|
||||
|
||||
DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
DiagonalCoeffs(const DiagonalCoeffs& other) : m_matrix(other.m_matrix) {}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
|
||||
|
||||
private:
|
||||
|
@ -41,9 +41,6 @@ template<typename Lhs, typename Rhs> class Difference : NoOperatorEquals,
|
||||
assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
|
||||
}
|
||||
|
||||
Difference(const Difference& other)
|
||||
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = Rhs::ColsAtCompileTime;
|
||||
|
@ -64,11 +64,6 @@ template<typename MatrixType> class DynBlock
|
||||
&& startCol >= 0 && blockCols >= 1 && startCol + blockCols <= matrix.cols());
|
||||
}
|
||||
|
||||
DynBlock(const DynBlock& other)
|
||||
: m_matrix(other.m_matrix),
|
||||
m_startRow(other.m_startRow), m_startCol(other.m_startCol),
|
||||
m_blockRows(other.m_blockRows), m_blockCols(other.m_blockCols) {}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DynBlock)
|
||||
|
||||
private:
|
||||
|
@ -32,14 +32,7 @@ template<typename MatrixType> class Map
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Map<MatrixType> >;
|
||||
|
||||
Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0 && cols > 0);
|
||||
}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
|
||||
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
@ -65,6 +58,17 @@ template<typename MatrixType> class Map
|
||||
else // RowDominant
|
||||
return const_cast<Scalar*>(m_data)[col + row * m_cols];
|
||||
}
|
||||
|
||||
public:
|
||||
Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0
|
||||
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
|
||||
&& cols > 0
|
||||
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
|
||||
}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
|
||||
|
||||
protected:
|
||||
const Scalar* m_data;
|
||||
|
@ -34,7 +34,6 @@ template<typename MatrixType> class MatrixRef
|
||||
friend class MatrixBase<Scalar, MatrixRef>;
|
||||
|
||||
MatrixRef(const MatrixType& matrix) : m_matrix(matrix) {}
|
||||
MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {}
|
||||
~MatrixRef() {}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef)
|
||||
|
@ -54,9 +54,6 @@ template<typename MatrixType> class Minor
|
||||
&& col >= 0 && col < matrix.cols());
|
||||
}
|
||||
|
||||
Minor(const Minor& other)
|
||||
: m_matrix(other.m_matrix), m_row(other.m_row), m_col(other.m_col) {}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
|
||||
|
||||
private:
|
||||
|
@ -32,12 +32,7 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Ones<MatrixType> >;
|
||||
|
||||
Ones(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0 && cols > 0);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
@ -50,6 +45,15 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
|
||||
{
|
||||
return static_cast<Scalar>(1);
|
||||
}
|
||||
|
||||
public:
|
||||
Ones(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0
|
||||
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
|
||||
&& cols > 0
|
||||
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_rows, m_cols;
|
||||
|
@ -36,9 +36,6 @@ template<typename MatrixType> class Opposite : NoOperatorEquals,
|
||||
|
||||
Opposite(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
Opposite(const Opposite& other)
|
||||
: m_matrix(other.m_matrix) {}
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
@ -60,7 +57,7 @@ template<typename Scalar, typename Derived>
|
||||
const Opposite<Derived>
|
||||
MatrixBase<Scalar, Derived>::operator-() const
|
||||
{
|
||||
return Opposite<Derived>(static_cast<const Derived*>(this)->ref());
|
||||
return Opposite<Derived>(ref());
|
||||
}
|
||||
|
||||
#endif // EIGEN_OPPOSITE_H
|
||||
|
@ -75,9 +75,6 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
||||
assert(lhs.cols() == rhs.rows());
|
||||
}
|
||||
|
||||
Product(const Product& other)
|
||||
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = Rhs::ColsAtCompileTime;
|
||||
|
@ -32,12 +32,7 @@ template<typename MatrixType> class Random : NoOperatorEquals,
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Random<MatrixType> >;
|
||||
|
||||
Random(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0 && cols > 0);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
@ -50,6 +45,15 @@ template<typename MatrixType> class Random : NoOperatorEquals,
|
||||
{
|
||||
return random<Scalar>();
|
||||
}
|
||||
|
||||
public:
|
||||
Random(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0
|
||||
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
|
||||
&& cols > 0
|
||||
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_rows, m_cols;
|
||||
|
@ -60,9 +60,6 @@ template<typename MatrixType> class Row
|
||||
assert(row >= 0 && row < matrix.rows());
|
||||
}
|
||||
|
||||
Row(const Row& other)
|
||||
: m_matrix(other.m_matrix), m_row(other.m_row) {}
|
||||
|
||||
template<typename OtherDerived>
|
||||
Row& operator=(const MatrixBase<Scalar, OtherDerived>& other)
|
||||
{
|
||||
|
@ -37,9 +37,6 @@ template<typename FactorType, typename MatrixType> class ScalarMultiple : NoOper
|
||||
ScalarMultiple(const MatRef& matrix, FactorType factor)
|
||||
: m_matrix(matrix), m_factor(factor) {}
|
||||
|
||||
ScalarMultiple(const ScalarMultiple& other)
|
||||
: m_matrix(other.m_matrix), m_factor(other.m_factor) {}
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
@ -41,8 +41,6 @@ template<typename Lhs, typename Rhs> class Sum : NoOperatorEquals,
|
||||
assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
|
||||
}
|
||||
|
||||
Sum(const Sum& other) : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = Rhs::ColsAtCompileTime;
|
||||
|
@ -48,9 +48,6 @@ template<typename MatrixType> class Transpose
|
||||
|
||||
Transpose(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
Transpose(const Transpose& other)
|
||||
: m_matrix(other.m_matrix) {}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
|
||||
|
||||
private:
|
||||
|
@ -32,12 +32,7 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Zero<MatrixType> >;
|
||||
|
||||
Zero(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0 && cols > 0);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
@ -51,6 +46,15 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||
return static_cast<Scalar>(0);
|
||||
}
|
||||
|
||||
public:
|
||||
Zero(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0
|
||||
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
|
||||
&& cols > 0
|
||||
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
|
||||
}
|
||||
|
||||
protected:
|
||||
int m_rows, m_cols;
|
||||
};
|
||||
|
@ -1,16 +1,16 @@
|
||||
o /** @mainpage Eigen
|
||||
|
||||
<h3>If you see this page, then you have not properly generated the documentation.</h3>
|
||||
<h3>If you see this page, then you have not properly generated the documentation. Namely, you have run doxygen from the source directory, which is not appropriate for generating the documentation of Eigen.</h3>
|
||||
|
||||
In order to generate the documentation for Eigen, follow these steps:
|
||||
In order to generate the documentation of Eigen, please follow these steps:
|
||||
<ul>
|
||||
<li>make sure you have the required software installed: cmake, doxygen, and a C++ compiler.
|
||||
<li>create a new directory, which we will call the "build directory", outside of the Eigen source directory.</li>
|
||||
<li>enter the build directory</li>
|
||||
<li>configure the project: <pre>cmake -DBUILD_DOC=ON /path/to/source/directory</pre></li>
|
||||
<li>now generate the documentaion: <pre>make</pre> or, if you have two CPUs, <pre>make -j2</pre> Note that this will compile the examples, run them, and integrate their output into the documentation. This is why it can take some time.</li>
|
||||
<li>now generate the documentaion: <pre>make</pre> or, if you have two CPUs, <pre>make -j2</pre> Note that this will compile the examples, run them, and integrate their output into the documentation, which can take some time.</li>
|
||||
</ul>
|
||||
|
||||
You will now find the HTML documentation in the doc/html/ subdirectory of the build directory.
|
||||
After doing that, you will find the HTML documentation in the doc/html/ subdirectory of the build directory.
|
||||
|
||||
*/
|
||||
|
@ -14,7 +14,7 @@ int main(int argc, char *argv[])
|
||||
I(i,j) = (i==j);
|
||||
m(i,j) = (i+3*j);
|
||||
}
|
||||
for(int a = 0; a < 100000000; a++)
|
||||
for(int a = 0; a < 400000000; a++)
|
||||
{
|
||||
m = I + 0.00005 * (m + m*m);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user