diff --git a/doc/tutorial.cpp b/doc/tutorial.cpp index 2eec7be3e..38943ec50 100644 --- a/doc/tutorial.cpp +++ b/doc/tutorial.cpp @@ -12,7 +12,7 @@ int main(int, char **) cout << "Here is a 2x2 matrix m:" << endl << m << endl; cout << "Let us now build a 4x4 matrix m2 by assembling together four 2x2 blocks." << endl; - MatrixXd m2(4,4); // dynamic matrix with initial size 4x4 and uninitialized entries + EiMatrixXd m2(4,4); // dynamic matrix with initial size 4x4 and uninitialized entries // notice how we are mixing fixed-size and dynamic-size types. cout << "In the top-left block, we put the matrix m shown above." << endl; diff --git a/src/internal/Block.h b/src/internal/Block.h index 72181abb7..93ddddcb7 100644 --- a/src/internal/Block.h +++ b/src/internal/Block.h @@ -26,19 +26,19 @@ #ifndef EIGEN_BLOCK_H #define EIGEN_BLOCK_H -template class MatrixBlock - : public EigenBase > +template class EiBlock + : public EiObject > { public: typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Ref MatRef; - friend class EigenBase >; - typedef MatrixBlock Ref; + friend class EiObject >; + typedef EiBlock Ref; - static const int RowsAtCompileTime = DynamicSize, - ColsAtCompileTime = DynamicSize; + static const int RowsAtCompileTime = EiDynamic, + ColsAtCompileTime = EiDynamic; - MatrixBlock(const MatRef& matrix, + EiBlock(const MatRef& matrix, int startRow, int endRow, int startCol = 0, int endCol = 0) : m_matrix(matrix), m_startRow(startRow), m_endRow(endRow), @@ -48,11 +48,11 @@ template class MatrixBlock && startCol >= 0 && startCol <= endCol && endCol < matrix.cols()); } - MatrixBlock(const MatrixBlock& other) + EiBlock(const EiBlock& other) : m_matrix(other.m_matrix), m_startRow(other.m_startRow), m_endRow(other.m_endRow), m_startCol(other.m_startCol), m_endCol(other.m_endCol) {} - EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixBlock) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(EiBlock) private: const Ref& _ref() const { return *this; } @@ -75,10 +75,10 @@ template class MatrixBlock }; template -MatrixBlock > -EigenBase::block(int startRow, int endRow, int startCol, int endCol) +EiBlock > +EiObject::block(int startRow, int endRow, int startCol, int endCol) { - return MatrixBlock(ref(), startRow, endRow, startCol, endCol); + return EiBlock(ref(), startRow, endRow, startCol, endCol); } #endif // EIGEN_BLOCK_H diff --git a/src/internal/EigenBase.h b/src/internal/EiObject.h similarity index 87% rename from src/internal/EigenBase.h rename to src/internal/EiObject.h index ad39df599..290d60b15 100644 --- a/src/internal/EigenBase.h +++ b/src/internal/EiObject.h @@ -28,7 +28,7 @@ #include "Util.h" -template class EigenBase +template class EiObject { static const int RowsAtCompileTime = Derived::RowsAtCompileTime, ColsAtCompileTime = Derived::ColsAtCompileTime; @@ -57,7 +57,7 @@ template class EigenBase } template - Derived& operator=(const EigenBase& other) + Derived& operator=(const EiObject& other) { assert(rows() == other.rows() && cols() == other.cols()); for(int i = 0; i < rows(); i++) @@ -68,7 +68,7 @@ template class EigenBase //special case of the above template operator=. Strangely, g++ 4.1 failed to use //that template when OtherDerived == Derived - Derived& operator=(const EigenBase& other) + Derived& operator=(const EiObject& other) { assert(rows() == other.rows() && cols() == other.cols()); for(int i = 0; i < rows(); i++) @@ -77,18 +77,18 @@ template class EigenBase return *static_cast(this); } - MatrixRow row(int i); - MatrixCol col(int i); - MatrixMinor minor(int row, int col); - MatrixBlock + MatrixRow row(int i); + MatrixCol col(int i); + MatrixMinor minor(int row, int col); + EiBlock block(int startRow, int endRow, int startCol= 0, int endCol = 0); template - Derived& operator+=(const EigenBase& other); + Derived& operator+=(const EiObject& other); template - Derived& operator-=(const EigenBase& other); + Derived& operator-=(const EiObject& other); template - Derived& operator*=(const EigenBase& other); + Derived& operator*=(const EiObject& other); Derived& operator*=(const int& other); Derived& operator*=(const float& other); @@ -114,7 +114,7 @@ template class EigenBase template std::ostream & operator << ( std::ostream & s, - const EigenBase & m ) + const EiObject & m ) { for( int i = 0; i < m.rows(); i++ ) { diff --git a/src/internal/Matrix.h b/src/internal/Matrix.h index af397c2eb..00780ae43 100644 --- a/src/internal/Matrix.h +++ b/src/internal/Matrix.h @@ -27,17 +27,17 @@ #define EIGEN_MATRIX_H #include "Util.h" -#include "EigenBase.h" +#include "EiObject.h" #include "MatrixRef.h" #include "MatrixStorage.h" template -class Matrix : public EigenBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, +class EiMatrix : public EiObject<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, public MatrixStorage<_Scalar, _Rows, _Cols> { public: - friend class EigenBase<_Scalar, Matrix>; - typedef EigenBase<_Scalar, Matrix> Base; + friend class EiObject<_Scalar, Matrix>; + typedef EiObject<_Scalar, Matrix> Base; typedef MatrixStorage<_Scalar, _Rows, _Cols> Storage; typedef _Scalar Scalar; typedef MatrixRef Ref; @@ -70,7 +70,7 @@ class Matrix : public EigenBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, public: template - Matrix& operator=(const EigenBase& other) + Matrix& operator=(const EiObject& other) { resize(other.rows(), other.cols()); return Base::operator=(other); @@ -88,7 +88,7 @@ class Matrix : public EigenBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, explicit Matrix(int rows = 1, int cols = 1) : Storage(rows, cols) {} template - Matrix(const EigenBase& other) : Storage(other.rows(), other.cols()) + Matrix(const EiObject& other) : Storage(other.rows(), other.cols()) { *this = other; } @@ -101,7 +101,7 @@ class Matrix : public EigenBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, template Matrix -eval(const EigenBase& expression) +eval(const EiObject& expression) { return Matrix(expression); } @@ -114,7 +114,7 @@ typedef Matrix Vector##SizeSuffix##TypeSuffix; EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ -EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, DynamicSize, X) +EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, EiDynamic, X) EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int, i) EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float, f) diff --git a/src/internal/MatrixOps.h b/src/internal/MatrixOps.h index eda1b58b4..4f28c179a 100644 --- a/src/internal/MatrixOps.h +++ b/src/internal/MatrixOps.h @@ -26,15 +26,15 @@ #ifndef EIGEN_MATRIXOPS_H #define EIGEN_MATRIXOPS_H -template class MatrixSum - : public EigenBase > +template class EiSum + : public EiObject > { public: typedef typename Lhs::Scalar Scalar; typedef typename Lhs::Ref LhsRef; typedef typename Rhs::Ref RhsRef; - friend class EigenBase; - typedef MatrixSum Ref; + friend class EiObject; + typedef EiSum Ref; static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, ColsAtCompileTime = Rhs::ColsAtCompileTime; @@ -66,15 +66,15 @@ template class MatrixSum const RhsRef m_rhs; }; -template class MatrixDifference - : public EigenBase > +template class EiDifference + : public EiObject > { public: typedef typename Lhs::Scalar Scalar; typedef typename Lhs::Ref LhsRef; typedef typename Rhs::Ref RhsRef; - friend class EigenBase; - typedef MatrixDifference Ref; + friend class EiObject; + typedef EiDifference Ref; static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, ColsAtCompileTime = Rhs::ColsAtCompileTime; @@ -105,15 +105,15 @@ template class MatrixDifference const RhsRef m_rhs; }; -template class MatrixProduct - : public EigenBase > +template class EiMatrixProduct + : public EiObject > { public: typedef typename Lhs::Scalar Scalar; typedef typename Lhs::Ref LhsRef; typedef typename Rhs::Ref RhsRef; - friend class EigenBase; - typedef MatrixProduct Ref; + friend class EiObject; + typedef EiMatrixProduct Ref; static const int RowsAtCompileTime = Lhs::RowsAtCompileTime, ColsAtCompileTime = Rhs::ColsAtCompileTime; @@ -149,21 +149,21 @@ template class MatrixProduct template MatrixSum -operator+(const EigenBase &mat1, const EigenBase &mat2) +operator+(const EiObject &mat1, const EiObject &mat2) { return MatrixSum(mat1.ref(), mat2.ref()); } template MatrixDifference -operator-(const EigenBase &mat1, const EigenBase &mat2) +operator-(const EiObject &mat1, const EiObject &mat2) { return MatrixDifference(mat1.ref(), mat2.ref()); } template MatrixProduct -operator*(const EigenBase &mat1, const EigenBase &mat2) +operator*(const EiObject &mat1, const EiObject &mat2) { return MatrixProduct(mat1.ref(), mat2.ref()); } @@ -171,7 +171,7 @@ operator*(const EigenBase &mat1, const EigenBase template Derived & -EigenBase::operator+=(const EigenBase& other) +EiObject::operator+=(const EiObject& other) { *this = *this + other; return *static_cast(this); @@ -180,7 +180,7 @@ EigenBase::operator+=(const EigenBase& ot template template Derived & -EigenBase::operator-=(const EigenBase &other) +EiObject::operator-=(const EiObject &other) { *this = *this - other; return *static_cast(this); @@ -189,7 +189,7 @@ EigenBase::operator-=(const EigenBase &ot template template Derived & -EigenBase::operator*=(const EigenBase &other) +EiObject::operator*=(const EiObject &other) { *this = *this * other; return *static_cast(this); diff --git a/src/internal/MatrixRef.h b/src/internal/MatrixRef.h index 8ee569001..2e999d6d3 100644 --- a/src/internal/MatrixRef.h +++ b/src/internal/MatrixRef.h @@ -26,12 +26,12 @@ #ifndef EIGEN_MATRIXREF_H #define EIGEN_MATRIXREF_H -template class MatrixRef - : public EigenBase > +template class EiMatrixRef + : public EiObject > { public: typedef typename MatrixType::Scalar Scalar; - friend class EigenBase; + friend class EiObject; MatrixRef(MatrixType& matrix) : m_matrix(matrix) {} MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {} diff --git a/src/internal/MatrixStorage.h b/src/internal/MatrixStorage.h index 45afcbe6a..9554bf961 100644 --- a/src/internal/MatrixStorage.h +++ b/src/internal/MatrixStorage.h @@ -29,7 +29,7 @@ template -class MatrixStorage +class EiMatrixStorage { protected: Scalar m_array[RowsAtCompileTime * RowsAtCompileTime]; @@ -55,7 +55,7 @@ class MatrixStorage }; template -class MatrixStorage +class MatrixStorage { protected: int m_rows; @@ -88,7 +88,7 @@ class MatrixStorage }; template -class MatrixStorage +class MatrixStorage { protected: int m_rows, m_cols; diff --git a/src/internal/Minor.h b/src/internal/Minor.h index 20aa7060f..cc6fa0b18 100644 --- a/src/internal/Minor.h +++ b/src/internal/Minor.h @@ -26,14 +26,14 @@ #ifndef EIGEN_MINOR_H #define EIGEN_MINOR_H -template class MatrixMinor - : public EigenBase > +template class EiMinor + : public EiObject > { public: typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Ref MatRef; - friend class EigenBase >; - typedef MatrixMinor Ref; + friend class EiObject >; + typedef EiMinor Ref; static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime - 1, ColsAtCompileTime = MatrixType::ColsAtCompileTime - 1; @@ -71,10 +71,10 @@ template class MatrixMinor }; template -MatrixMinor > -EigenBase::minor(int row, int col) +MatrixMinor > +EiObject::minor(int row, int col) { - return MatrixMinor(ref(), row, col); + return MatrixMinor(ref(), row, col); } #endif // EIGEN_MINOR_H diff --git a/src/internal/RowAndCol.h b/src/internal/RowAndCol.h index 5b6e4ef07..03e25651f 100644 --- a/src/internal/RowAndCol.h +++ b/src/internal/RowAndCol.h @@ -26,14 +26,14 @@ #ifndef EIGEN_ROWANDCOL_H #define EIGEN_ROWANDCOL_H -template class MatrixRow - : public EigenBase > +template class EiRow + : public EiObject > { public: typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Ref MatRef; - friend class EigenBase >; - typedef MatrixRow Ref; + friend class EiObject >; + typedef EiRow Ref; static const int RowsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = 1; @@ -48,9 +48,9 @@ template class MatrixRow : m_matrix(other.m_matrix), m_row(other.m_row) {} template - MatrixRow& operator=(const EigenBase& other) + MatrixRow& operator=(const EiObject& other) { - return EigenBase >::operator=(other); + return EiObject >::operator=(other); } EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRow) @@ -81,12 +81,12 @@ template class MatrixRow }; template class MatrixCol - : public EigenBase > + : public EiObject > { public: typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Ref MatRef; - friend class EigenBase >; + friend class EiObject >; typedef MatrixCol Ref; static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, @@ -128,17 +128,17 @@ template class MatrixCol }; template -MatrixRow > -EigenBase::row(int i) +MatrixRow > +EiObject::row(int i) { - return MatrixRow(ref(), i); + return MatrixRow(ref(), i); } template -MatrixCol > -EigenBase::col(int i) +MatrixCol > +EiObject::col(int i) { - return MatrixCol(ref(), i); + return MatrixCol(ref(), i); } #endif // EIGEN_ROWANDCOL_H diff --git a/src/internal/ScalarOps.h b/src/internal/ScalarOps.h index a28b7e6cb..1dd072cb2 100644 --- a/src/internal/ScalarOps.h +++ b/src/internal/ScalarOps.h @@ -26,14 +26,14 @@ #ifndef EIGEN_SCALAROPS_H #define EIGEN_SCALAROPS_H -template class ScalarProduct - : public EigenBase > +template class EiScalarProduct + : public EiObject > { public: typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Ref MatRef; - typedef ScalarProduct Ref; - friend class EigenBase >; + typedef EiScalarProduct Ref; + friend class EiObject >; static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime; @@ -64,7 +64,7 @@ template class ScalarProduct #define EIGEN_MAKE_SCALAR_OPS(OtherScalar) \ template \ ScalarProduct \ -operator*(const EigenBase& matrix, \ +operator*(const EiObject& matrix, \ OtherScalar scalar) \ { \ return ScalarProduct(matrix.ref(), scalar); \ @@ -73,14 +73,14 @@ operator*(const EigenBase& matrix, \ template \ ScalarProduct \ operator*(OtherScalar scalar, \ - const EigenBase& matrix) \ + const EiObject& matrix) \ { \ return ScalarProduct(matrix.ref(), scalar); \ } \ \ template \ ScalarProduct \ -operator/(const EigenBase& matrix, \ +operator/(const EiObject& matrix, \ OtherScalar scalar) \ { \ return matrix * (static_cast(1) / scalar); \ @@ -88,7 +88,7 @@ operator/(const EigenBase& matrix, \ \ template \ Derived & \ -EigenBase::operator*=(const OtherScalar &other) \ +EiObject::operator*=(const OtherScalar &other) \ { \ *this = *this * other; \ return *static_cast(this); \ @@ -96,7 +96,7 @@ EigenBase::operator*=(const OtherScalar &other) \ \ template \ Derived & \ -EigenBase::operator/=(const OtherScalar &other) \ +EiObject::operator/=(const OtherScalar &other) \ { \ *this = *this / other; \ return *static_cast(this); \ diff --git a/src/internal/Util.h b/src/internal/Util.h index 179f70ffd..d4362383e 100644 --- a/src/internal/Util.h +++ b/src/internal/Util.h @@ -41,53 +41,48 @@ assert(col >= 0 && col < (matrix).cols()) //forward declarations -template class Matrix; -template class MatrixAlias; -template class MatrixRef; -template class MatrixRow; -template class MatrixCol; -template class MatrixMinor; -template class MatrixBlock; -template class MatrixSum; -template class MatrixDifference; -template class MatrixProduct; -template class ScalarProduct; +template class EiMatrix; +template class EiMatrixRef; +template class EiRow; +template class EiColumn; +template class EiMinor; +template class EiBlock; +template class EiSum; +template class EiDifference; +template class EiMatrixProduct; +template class EiScalarProduct; -template struct ForwardDecl +template struct EiForwardDecl { typedef T Ref; }; -template struct ForwardDecl > +template +struct EiForwardDecl > { - typedef MatrixRef > Ref; + typedef EiMatrixRef > Ref; }; -template struct ForwardDecl > -{ - typedef MatrixRef > Ref; -}; - -const int DynamicSize = -1; +const int EiDynamic = -1; #define EIGEN_UNUSED(x) (void)x #define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \ template \ -Derived& operator Op(const EigenBase& other) \ +Derived& operator Op(const EiObject& other) \ { \ - return EigenBase::operator Op(other); \ + return EiObject::operator Op(other); \ } \ Derived& operator Op(const Derived& other) \ { \ - return EigenBase::operator Op(other); \ + return EiObject::operator Op(other); \ } #define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \ template \ Derived& operator Op(const Other& scalar) \ { \ - return EigenBase::operator Op(scalar); \ + return EiObject::operator Op(scalar); \ } #define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \ diff --git a/test/matrixmanip.cpp b/test/matrixmanip.cpp index c95d33d1f..608dc1dad 100644 --- a/test/matrixmanip.cpp +++ b/test/matrixmanip.cpp @@ -47,7 +47,7 @@ void EigenTest::testMatrixManip() matrixManip(Matrix()); matrixManip(Matrix()); matrixManip(Matrix, 4,3>()); - matrixManip(MatrixXi(2, 2)); - matrixManip(MatrixXd(3, 5)); - matrixManip(MatrixXcf(4, 4)); + matrixManip(EiMatrixXi(2, 2)); + matrixManip(EiMatrixXd(3, 5)); + matrixManip(EiMatrixXcf(4, 4)); } diff --git a/test/matrixops.cpp b/test/matrixops.cpp index f148d8a82..059cb6126 100644 --- a/test/matrixops.cpp +++ b/test/matrixops.cpp @@ -62,10 +62,10 @@ void EigenTest::testMatrixOps() matrixOps(Matrix(), Matrix()); matrixOps(Matrix(), Matrix()); matrixOps(Matrix, 4,3>(), Matrix, 3,4>()); - matrixOps(MatrixXf(1, 1), MatrixXf(1, 3)); - matrixOps(MatrixXi(2, 2), MatrixXi(2, 2)); - matrixOps(MatrixXd(3, 5), MatrixXd(5, 1)); - matrixOps(MatrixXcf(4, 4), MatrixXcf(4, 4)); - matrixOps(MatrixXd(3, 5), Matrix()); - matrixOps(Matrix4cf(), MatrixXcf(4, 4)); + matrixOps(EiMatrixXf(1, 1), EiMatrixXf(1, 3)); + matrixOps(EiMatrixXi(2, 2), EiMatrixXi(2, 2)); + matrixOps(EiMatrixXd(3, 5), EiMatrixXd(5, 1)); + matrixOps(EiMatrixXcf(4, 4), EiMatrixXcf(4, 4)); + matrixOps(EiMatrixXd(3, 5), Matrix()); + matrixOps(EiMatrix4cf(), EiMatrixXcf(4, 4)); }