- improve and comment the "BasicStuff" test.

- adjust behavior of Matrix(int,int) constructor
- s/EI_/EIGEN_/
This commit is contained in:
Benoit Jacob 2007-11-26 08:47:07 +00:00
parent f14712a1a3
commit 5309ef5b5e
29 changed files with 246 additions and 212 deletions

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_BLOCK_H #ifndef EIGEN_BLOCK_H
#define EI_BLOCK_H #define EIGEN_BLOCK_H
template<typename MatrixType> class Block template<typename MatrixType> class Block
: public Object<typename MatrixType::Scalar, Block<MatrixType> > : public Object<typename MatrixType::Scalar, Block<MatrixType> >
@ -51,7 +51,7 @@ template<typename MatrixType> class Block
: m_matrix(other.m_matrix), m_startRow(other.m_startRow), m_endRow(other.m_endRow), : 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) {} m_startCol(other.m_startCol), m_endCol(other.m_endCol) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(Block) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
private: private:
const Block& _ref() const { return *this; } const Block& _ref() const { return *this; }
@ -81,4 +81,4 @@ Object<Scalar, Derived>::block(int startRow, int endRow, int startCol, int endCo
startRow, endRow, startCol, endCol); startRow, endRow, startCol, endCol);
} }
#endif // EI_BLOCK_H #endif // EIGEN_BLOCK_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_CAST_H #ifndef EIGEN_CAST_H
#define EI_CAST_H #define EIGEN_CAST_H
template<typename NewScalar, typename MatrixType> class Cast template<typename NewScalar, typename MatrixType> class Cast
: public Object<NewScalar, Cast<NewScalar, MatrixType> > : public Object<NewScalar, Cast<NewScalar, MatrixType> >
@ -43,7 +43,7 @@ template<typename NewScalar, typename MatrixType> class Cast
: m_matrix(other.m_matrix) {} : m_matrix(other.m_matrix) {}
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(Cast) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Cast)
private: private:
const Cast& _ref() const { return *this; } const Cast& _ref() const { return *this; }
@ -67,4 +67,4 @@ Object<Scalar, Derived>::cast() const
return Cast<NewScalar, Derived>(static_cast<const Derived*>(this)->ref()); return Cast<NewScalar, Derived>(static_cast<const Derived*>(this)->ref());
} }
#endif // EI_CAST_H #endif // EIGEN_CAST_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_COLUMN_H #ifndef EIGEN_COLUMN_H
#define EI_COLUMN_H #define EIGEN_COLUMN_H
template<typename MatrixType> class Column template<typename MatrixType> class Column
: public Object<typename MatrixType::Scalar, Column<MatrixType> > : public Object<typename MatrixType::Scalar, Column<MatrixType> >
@ -40,13 +40,13 @@ template<typename MatrixType> class Column
Column(const MatRef& matrix, int col) Column(const MatRef& matrix, int col)
: m_matrix(matrix), m_col(col) : m_matrix(matrix), m_col(col)
{ {
EI_CHECK_COL_RANGE(matrix, col); EIGEN_CHECK_COL_RANGE(matrix, col);
} }
Column(const Column& other) Column(const Column& other)
: m_matrix(other.m_matrix), m_col(other.m_col) {} : m_matrix(other.m_matrix), m_col(other.m_col) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(Column) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column)
private: private:
const Column& _ref() const { return *this; } const Column& _ref() const { return *this; }
@ -55,15 +55,15 @@ template<typename MatrixType> class Column
Scalar& _write(int row, int col=0) Scalar& _write(int row, int col=0)
{ {
EI_UNUSED(col); EIGEN_UNUSED(col);
EI_CHECK_ROW_RANGE(*this, row); EIGEN_CHECK_ROW_RANGE(*this, row);
return m_matrix.write(row, m_col); return m_matrix.write(row, m_col);
} }
Scalar _read(int row, int col=0) const Scalar _read(int row, int col=0) const
{ {
EI_UNUSED(col); EIGEN_UNUSED(col);
EI_CHECK_ROW_RANGE(*this, row); EIGEN_CHECK_ROW_RANGE(*this, row);
return m_matrix.read(row, m_col); return m_matrix.read(row, m_col);
} }
@ -79,4 +79,4 @@ Object<Scalar, Derived>::col(int i) const
return Column<Derived>(static_cast<Derived*>(const_cast<Object*>(this))->ref(), i); return Column<Derived>(static_cast<Derived*>(const_cast<Object*>(this))->ref(), i);
} }
#endif // EI_COLUMN_H #endif // EIGEN_COLUMN_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_CONJUGATE_H #ifndef EIGEN_CONJUGATE_H
#define EI_CONJUGATE_H #define EIGEN_CONJUGATE_H
template<typename MatrixType> class Conjugate template<typename MatrixType> class Conjugate
: public Object<typename MatrixType::Scalar, Conjugate<MatrixType> > : public Object<typename MatrixType::Scalar, Conjugate<MatrixType> >
@ -43,7 +43,7 @@ template<typename MatrixType> class Conjugate
: m_matrix(other.m_matrix) {} : m_matrix(other.m_matrix) {}
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(Conjugate) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Conjugate)
private: private:
const Conjugate& _ref() const { return *this; } const Conjugate& _ref() const { return *this; }
@ -66,4 +66,4 @@ Object<Scalar, Derived>::conjugate() const
return Conjugate<Derived>(static_cast<const Derived*>(this)->ref()); return Conjugate<Derived>(static_cast<const Derived*>(this)->ref());
} }
#endif // EI_CONJUGATE_H #endif // EIGEN_CONJUGATE_H

View File

@ -24,8 +24,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_COPYHELPER_H #ifndef EIGEN_COPYHELPER_H
#define EI_COPYHELPER_H #define EIGEN_COPYHELPER_H
template<int UnrollCount, int Rows> struct CopyHelperUnroller template<int UnrollCount, int Rows> struct CopyHelperUnroller
{ {
@ -54,8 +54,8 @@ template<int Rows> struct CopyHelperUnroller<Dynamic, Rows>
template <typename Derived1, typename Derived2> template <typename Derived1, typename Derived2>
static void run(Derived1 &dst, const Derived2 &src) static void run(Derived1 &dst, const Derived2 &src)
{ {
EI_UNUSED(dst); EIGEN_UNUSED(dst);
EI_UNUSED(src); EIGEN_UNUSED(src);
} }
}; };
@ -63,7 +63,7 @@ template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
void Object<Scalar, Derived>::_copy_helper(const Object<Scalar, OtherDerived>& other) void Object<Scalar, Derived>::_copy_helper(const Object<Scalar, OtherDerived>& other)
{ {
if(SizeAtCompileTime != Dynamic && SizeAtCompileTime <= EI_LOOP_UNROLLING_LIMIT) if(SizeAtCompileTime != Dynamic && SizeAtCompileTime <= EIGEN_LOOP_UNROLLING_LIMIT)
CopyHelperUnroller<SizeAtCompileTime, RowsAtCompileTime>::run(*this, other); CopyHelperUnroller<SizeAtCompileTime, RowsAtCompileTime>::run(*this, other);
else else
for(int i = 0; i < rows(); i++) for(int i = 0; i < rows(); i++)
@ -71,4 +71,4 @@ void Object<Scalar, Derived>::_copy_helper(const Object<Scalar, OtherDerived>& o
write(i, j) = other.read(i, j); write(i, j) = other.read(i, j);
} }
#endif // EI_COPYHELPER_H #endif // EIGEN_COPYHELPER_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_DIFFERENCE_H #ifndef EIGEN_DIFFERENCE_H
#define EI_DIFFERENCE_H #define EIGEN_DIFFERENCE_H
template<typename Lhs, typename Rhs> class Difference template<typename Lhs, typename Rhs> class Difference
: public Object<typename Lhs::Scalar, Difference<Lhs, Rhs> > : public Object<typename Lhs::Scalar, Difference<Lhs, Rhs> >
@ -48,7 +48,7 @@ template<typename Lhs, typename Rhs> class Difference
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {} : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(Difference) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Difference)
private: private:
const Difference& _ref() const { return *this; } const Difference& _ref() const { return *this; }
@ -80,4 +80,4 @@ Object<Scalar, Derived>::operator-=(const Object<Scalar, OtherDerived> &other)
return *this = *this - other; return *this = *this - other;
} }
#endif // EI_DIFFERENCE_H #endif // EIGEN_DIFFERENCE_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_DOT_H #ifndef EIGEN_DOT_H
#define EI_DOT_H #define EIGEN_DOT_H
template<int Index, int Size, typename Derived1, typename Derived2> template<int Index, int Size, typename Derived1, typename Derived2>
struct DotUnroller struct DotUnroller
@ -50,9 +50,9 @@ struct DotUnroller<Index, Dynamic, Derived1, Derived2>
{ {
static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot) static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot)
{ {
EI_UNUSED(v1); EIGEN_UNUSED(v1);
EI_UNUSED(v2); EIGEN_UNUSED(v2);
EI_UNUSED(dot); EIGEN_UNUSED(dot);
} }
}; };
@ -92,4 +92,4 @@ ScalarMultiple<Derived> Object<Scalar, Derived>::normalized() const
return (*this) / norm(); return (*this) / norm();
} }
#endif // EI_DOT_H #endif // EIGEN_DOT_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_EVAL_H #ifndef EIGEN_EVAL_H
#define EI_EVAL_H #define EIGEN_EVAL_H
template<typename Expression> class Eval template<typename Expression> class Eval
: public Matrix< typename Expression::Scalar, : public Matrix< typename Expression::Scalar,
@ -37,7 +37,7 @@ template<typename Expression> class Eval
typedef Expression Base; typedef Expression Base;
friend class Object<Scalar, Expression>; friend class Object<Scalar, Expression>;
EI_INHERIT_ASSIGNMENT_OPERATORS(Eval) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Eval)
Eval(const Expression& expression) : MatrixType(expression) {} Eval(const Expression& expression) : MatrixType(expression) {}
}; };
@ -48,4 +48,4 @@ Eval<Derived> Object<Scalar, Derived>::eval() const
return Eval<Derived>(*static_cast<const Derived*>(this)); return Eval<Derived>(*static_cast<const Derived*>(this));
} }
#endif // EI_EVAL_H #endif // EIGEN_EVAL_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_FROMARRAY_H #ifndef EIGEN_FROMARRAY_H
#define EI_FROMARRAY_H #define EIGEN_FROMARRAY_H
template<typename MatrixType> class FromArray template<typename MatrixType> class FromArray
: public Object<typename MatrixType::Scalar, FromArray<MatrixType> > : public Object<typename MatrixType::Scalar, FromArray<MatrixType> >
@ -41,7 +41,7 @@ template<typename MatrixType> class FromArray
assert(rows > 0 && cols > 0); assert(rows > 0 && cols > 0);
} }
EI_INHERIT_ASSIGNMENT_OPERATORS(FromArray) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(FromArray)
private: private:
FromArray& _ref() { return *this; } FromArray& _ref() { return *this; }
@ -70,4 +70,4 @@ FromArray<Derived> Object<Scalar, Derived>::fromArray(const Scalar* array, int r
return FromArray<Derived>(rows, cols, const_cast<Scalar*>(array)); return FromArray<Derived>(rows, cols, const_cast<Scalar*>(array));
} }
#endif // EI_FROMARRAY_H #endif // EIGEN_FROMARRAY_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_FUZZY_H #ifndef EIGEN_FUZZY_H
#define EI_FUZZY_H #define EIGEN_FUZZY_H
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
template<typename OtherDerived> template<typename OtherDerived>
@ -88,4 +88,4 @@ bool Object<Scalar, Derived>::isMuchSmallerThan(
} }
} }
#endif // EI_FUZZY_H #endif // EIGEN_FUZZY_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_IDENTITY_H #ifndef EIGEN_IDENTITY_H
#define EI_IDENTITY_H #define EIGEN_IDENTITY_H
template<typename MatrixType> class Identity template<typename MatrixType> class Identity
: public Object<typename MatrixType::Scalar, Identity<MatrixType> > : public Object<typename MatrixType::Scalar, Identity<MatrixType> >
@ -43,7 +43,7 @@ template<typename MatrixType> class Identity
} }
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(Identity) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Identity)
private: private:
Identity& _ref() { return *this; } Identity& _ref() { return *this; }
@ -66,4 +66,4 @@ Identity<Derived> Object<Scalar, Derived>::identity(int rows)
return Identity<Derived>(rows); return Identity<Derived>(rows);
} }
#endif // EI_IDENTITY_H #endif // EIGEN_IDENTITY_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_MATRIX_H #ifndef EIGEN_MATRIX_H
#define EI_MATRIX_H #define EIGEN_MATRIX_H
template<typename _Scalar, int _Rows, int _Cols> template<typename _Scalar, int _Rows, int _Cols>
class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >,
@ -51,13 +51,13 @@ class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >,
const Scalar& _read(int row, int col) const const Scalar& _read(int row, int col) const
{ {
EI_CHECK_RANGES(*this, row, col); EIGEN_CHECK_RANGES(*this, row, col);
return array()[row + col * Storage::_rows()]; return array()[row + col * Storage::_rows()];
} }
Scalar& _write(int row, int col) Scalar& _write(int row, int col)
{ {
EI_CHECK_RANGES(*this, row, col); EIGEN_CHECK_RANGES(*this, row, col);
return array()[row + col * Storage::_rows()]; return array()[row + col * Storage::_rows()];
} }
@ -75,14 +75,16 @@ class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >,
return Base::operator=(other); return Base::operator=(other);
} }
EI_INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=) EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=)
EI_INHERIT_ASSIGNMENT_OPERATOR(Matrix, -=) EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, -=)
EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, *=) EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, *=)
EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, /=) EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, /=)
explicit Matrix(int rows = 1, int cols = 1) : Storage(rows, cols) {} explicit Matrix(int rows = RowsAtCompileTime,
int cols = ColsAtCompileTime) : Storage(rows, cols) {}
template<typename OtherDerived> template<typename OtherDerived>
Matrix(const Object<Scalar, OtherDerived>& other) : Storage(other.rows(), other.cols()) Matrix(const Object<Scalar, OtherDerived>& other)
: Storage(other.rows(), other.cols())
{ {
*this = other; *this = other;
} }
@ -93,42 +95,42 @@ class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >,
~Matrix() {} ~Matrix() {}
}; };
#define EI_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ #define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \
typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \ typedef Matrix<Type, Size, Size> Matrix##SizeSuffix##TypeSuffix; \
typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \ typedef Matrix<Type, Size, 1> Vector##SizeSuffix##TypeSuffix; \
typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix; typedef Matrix<Type, 1, Size> RowVector##SizeSuffix##TypeSuffix;
#define EI_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ #define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \
EI_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \
EI_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \
EI_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \
EI_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X)
EI_MAKE_TYPEDEFS_ALL_SIZES(int, i) EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int, i)
EI_MAKE_TYPEDEFS_ALL_SIZES(float, f) EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float, f)
EI_MAKE_TYPEDEFS_ALL_SIZES(double, d) EIGEN_MAKE_TYPEDEFS_ALL_SIZES(double, d)
EI_MAKE_TYPEDEFS_ALL_SIZES(std::complex<float>, cf) EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<float>, cf)
EI_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd) EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex<double>, cd)
#undef EI_MAKE_TYPEDEFS_ALL_SIZES #undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES
#undef EI_MAKE_TYPEDEFS #undef EIGEN_MAKE_TYPEDEFS
#define EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \ #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, SizeSuffix) \
using Eigen::Matrix##SizeSuffix##TypeSuffix; \ using Eigen::Matrix##SizeSuffix##TypeSuffix; \
using Eigen::Vector##SizeSuffix##TypeSuffix; \ using Eigen::Vector##SizeSuffix##TypeSuffix; \
using Eigen::RowVector##SizeSuffix##TypeSuffix; using Eigen::RowVector##SizeSuffix##TypeSuffix;
#define EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \ #define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \ EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \ EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \ EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X)
#define EI_USING_MATRIX_TYPEDEFS \ #define EIGEN_USING_MATRIX_TYPEDEFS \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \ EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \ EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \ EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \ EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \
EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd) EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd)
#endif // EI_MATRIX_H #endif // EIGEN_MATRIX_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_MATRIXREF_H #ifndef EIGEN_MATRIXREF_H
#define EI_MATRIXREF_H #define EIGEN_MATRIXREF_H
template<typename MatrixType> class MatrixRef template<typename MatrixType> class MatrixRef
: public Object<typename MatrixType::Scalar, MatrixRef<MatrixType> > : public Object<typename MatrixType::Scalar, MatrixRef<MatrixType> >
@ -37,7 +37,7 @@ template<typename MatrixType> class MatrixRef
MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {} MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {}
~MatrixRef() {} ~MatrixRef() {}
EI_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef)
private: private:
int _rows() const { return m_matrix.rows(); } int _rows() const { return m_matrix.rows(); }
@ -57,4 +57,4 @@ template<typename MatrixType> class MatrixRef
MatrixType& m_matrix; MatrixType& m_matrix;
}; };
#endif // EI_MATRIXREF_H #endif // EIGEN_MATRIXREF_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_MATRIXSTORAGE_H #ifndef EIGEN_MATRIXSTORAGE_H
#define EI_MATRIXSTORAGE_H #define EIGEN_MATRIXSTORAGE_H
template<typename Scalar, template<typename Scalar,
int RowsAtCompileTime, int RowsAtCompileTime,
@ -46,9 +46,10 @@ class MatrixStorage
public: public:
MatrixStorage(int rows, int cols) MatrixStorage(int rows, int cols)
{ {
EI_UNUSED(rows); EIGEN_UNUSED(rows);
EI_UNUSED(cols); EIGEN_UNUSED(cols);
assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0); assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0
&& rows == RowsAtCompileTime && cols == ColsAtCompileTime);
} }
~MatrixStorage() {}; ~MatrixStorage() {};
@ -81,7 +82,7 @@ class MatrixStorage<Scalar, Dynamic, ColsAtCompileTime>
public: public:
MatrixStorage(int rows, int cols) : m_rows(rows) MatrixStorage(int rows, int cols) : m_rows(rows)
{ {
assert(m_rows > 0 && cols == ColsAtCompileTime); assert(m_rows > 0 && cols == ColsAtCompileTime && ColsAtCompileTime > 0);
m_array = new Scalar[m_rows * ColsAtCompileTime]; m_array = new Scalar[m_rows * ColsAtCompileTime];
} }
@ -116,7 +117,7 @@ class MatrixStorage<Scalar, RowsAtCompileTime, Dynamic>
public: public:
MatrixStorage(int rows, int cols) : m_cols(cols) MatrixStorage(int rows, int cols) : m_cols(cols)
{ {
assert(rows == RowsAtCompileTime && cols > 0); assert(rows == RowsAtCompileTime && RowsAtCompileTime > 0 && cols > 0);
m_array = new Scalar[m_cols * RowsAtCompileTime]; m_array = new Scalar[m_cols * RowsAtCompileTime];
} }
@ -160,4 +161,4 @@ class MatrixStorage<Scalar, Dynamic, Dynamic>
{ delete[] m_array; } { delete[] m_array; }
}; };
#endif // EI_MATRIXSTORAGE_H #endif // EIGEN_MATRIXSTORAGE_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_MINOR_H #ifndef EIGEN_MINOR_H
#define EI_MINOR_H #define EIGEN_MINOR_H
template<typename MatrixType> class Minor template<typename MatrixType> class Minor
: public Object<typename MatrixType::Scalar, Minor<MatrixType> > : public Object<typename MatrixType::Scalar, Minor<MatrixType> >
@ -44,13 +44,13 @@ template<typename MatrixType> class Minor
int row, int col = 0) int row, int col = 0)
: m_matrix(matrix), m_row(row), m_col(col) : m_matrix(matrix), m_row(row), m_col(col)
{ {
EI_CHECK_RANGES(matrix, row, col); EIGEN_CHECK_RANGES(matrix, row, col);
} }
Minor(const Minor& other) Minor(const Minor& other)
: m_matrix(other.m_matrix), m_row(other.m_row), m_col(other.m_col) {} : m_matrix(other.m_matrix), m_row(other.m_row), m_col(other.m_col) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(Minor) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
private: private:
Minor& _ref() { return *this; } Minor& _ref() { return *this; }
@ -80,4 +80,4 @@ Object<Scalar, Derived>::minor(int row, int col) const
return Minor<Derived>(static_cast<Derived*>(const_cast<Object*>(this))->ref(), row, col); return Minor<Derived>(static_cast<Derived*>(const_cast<Object*>(this))->ref(), row, col);
} }
#endif // EI_MINOR_H #endif // EIGEN_MINOR_H

View File

@ -1,4 +1,3 @@
// This file is part of Eigen, a lightweight C++ template library // This file is part of Eigen, a lightweight C++ template library
// for linear algebra. Eigen itself is part of the KDE project. // for linear algebra. Eigen itself is part of the KDE project.
// //
@ -24,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_NUMERIC_H #ifndef EIGEN_NUMERIC_H
#define EI_NUMERIC_H #define EIGEN_NUMERIC_H
template<typename T> struct NumTraits; template<typename T> struct NumTraits;
@ -40,7 +39,7 @@ template<> struct NumTraits<int>
static int precision() { return 0; } static int precision() { return 0; }
static int real(const int& x) { return x; } static int real(const int& x) { return x; }
static int imag(const int& x) { EI_UNUSED(x); return 0; } static int imag(const int& x) { EIGEN_UNUSED(x); return 0; }
static int conj(const int& x) { return x; } static int conj(const int& x) { return x; }
static int abs2(const int& x) { return x*x; } static int abs2(const int& x) { return x*x; }
static int random() static int random()
@ -52,18 +51,18 @@ template<> struct NumTraits<int>
} }
static bool isMuchSmallerThan(const int& a, const int& b, const int& prec = precision()) static bool isMuchSmallerThan(const int& a, const int& b, const int& prec = precision())
{ {
EI_UNUSED(b); EIGEN_UNUSED(b);
EI_UNUSED(prec); EIGEN_UNUSED(prec);
return a == 0; return a == 0;
} }
static bool isApprox(const int& a, const int& b, const int& prec = precision()) static bool isApprox(const int& a, const int& b, const int& prec = precision())
{ {
EI_UNUSED(prec); EIGEN_UNUSED(prec);
return a == b; return a == b;
} }
static bool isApproxOrLessThan(const int& a, const int& b, const int& prec = precision()) static bool isApproxOrLessThan(const int& a, const int& b, const int& prec = precision())
{ {
EI_UNUSED(prec); EIGEN_UNUSED(prec);
return a <= b; return a <= b;
} }
}; };
@ -79,7 +78,7 @@ template<> struct NumTraits<float>
static float precision() { return 1e-5f; } static float precision() { return 1e-5f; }
static float real(const float& x) { return x; } static float real(const float& x) { return x; }
static float imag(const float& x) { EI_UNUSED(x); return 0; } static float imag(const float& x) { EIGEN_UNUSED(x); return 0; }
static float conj(const float& x) { return x; } static float conj(const float& x) { return x; }
static float abs2(const float& x) { return x*x; } static float abs2(const float& x) { return x*x; }
static float random() static float random()
@ -111,7 +110,7 @@ template<> struct NumTraits<double>
static double precision() { return 1e-11; } static double precision() { return 1e-11; }
static double real(const double& x) { return x; } static double real(const double& x) { return x; }
static double imag(const double& x) { EI_UNUSED(x); return 0; } static double imag(const double& x) { EIGEN_UNUSED(x); return 0; }
static double conj(const double& x) { return x; } static double conj(const double& x) { return x; }
static double abs2(const double& x) { return x*x; } static double abs2(const double& x) { return x*x; }
static double random() static double random()
@ -164,4 +163,4 @@ template<typename _Real> struct NumTraits<std::complex<_Real> >
// isApproxOrLessThan wouldn't make sense for complex numbers // isApproxOrLessThan wouldn't make sense for complex numbers
}; };
#endif // EI_NUMERIC_H #endif // EIGEN_NUMERIC_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_OBJECT_H #ifndef EIGEN_OBJECT_H
#define EI_OBJECT_H #define EIGEN_OBJECT_H
template<typename Scalar, typename Derived> class Object template<typename Scalar, typename Derived> class Object
{ {
@ -134,7 +134,7 @@ template<typename Scalar, typename Derived> class Object
template<typename OtherDerived> template<typename OtherDerived>
Product<Derived, OtherDerived> Product<Derived, OtherDerived>
lazyProduct(const Object<Scalar, OtherDerived>& other) const EI_ALWAYS_INLINE; lazyProduct(const Object<Scalar, OtherDerived>& other) const EIGEN_ALWAYS_INLINE;
Opposite<Derived> operator-() const; Opposite<Derived> operator-() const;
@ -177,7 +177,7 @@ template<typename Scalar, typename Derived> class Object
else return write(index, 0); else return write(index, 0);
} }
Eval<Derived> eval() const EI_ALWAYS_INLINE; Eval<Derived> eval() const EIGEN_ALWAYS_INLINE;
}; };
template<typename Scalar, typename Derived> template<typename Scalar, typename Derived>
@ -196,4 +196,4 @@ std::ostream & operator <<
return s; return s;
} }
#endif // EI_OBJECT_H #endif // EIGEN_OBJECT_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_OPPOSITE_H #ifndef EIGEN_OPPOSITE_H
#define EI_OPPOSITE_H #define EIGEN_OPPOSITE_H
template<typename MatrixType> class Opposite template<typename MatrixType> class Opposite
: public Object<typename MatrixType::Scalar, Opposite<MatrixType> > : public Object<typename MatrixType::Scalar, Opposite<MatrixType> >
@ -43,7 +43,7 @@ template<typename MatrixType> class Opposite
: m_matrix(other.m_matrix) {} : m_matrix(other.m_matrix) {}
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(Opposite) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Opposite)
private: private:
const Opposite& _ref() const { return *this; } const Opposite& _ref() const { return *this; }
@ -66,4 +66,4 @@ Object<Scalar, Derived>::operator-() const
return Opposite<Derived>(static_cast<const Derived*>(this)->ref()); return Opposite<Derived>(static_cast<const Derived*>(this)->ref());
} }
#endif // EI_OPPOSITE_H #endif // EIGEN_OPPOSITE_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_PRODUCT_H #ifndef EIGEN_PRODUCT_H
#define EI_PRODUCT_H #define EIGEN_PRODUCT_H
template<int Index, int Size, typename Lhs, typename Rhs> template<int Index, int Size, typename Lhs, typename Rhs>
struct ProductUnroller struct ProductUnroller
@ -53,11 +53,11 @@ struct ProductUnroller<Index, Dynamic, Lhs, Rhs>
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
typename Lhs::Scalar &res) typename Lhs::Scalar &res)
{ {
EI_UNUSED(row); EIGEN_UNUSED(row);
EI_UNUSED(col); EIGEN_UNUSED(col);
EI_UNUSED(lhs); EIGEN_UNUSED(lhs);
EI_UNUSED(rhs); EIGEN_UNUSED(rhs);
EI_UNUSED(res); EIGEN_UNUSED(res);
} }
}; };
@ -83,7 +83,7 @@ template<typename Lhs, typename Rhs> class Product
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {} : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(Product) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Product)
private: private:
const Product& _ref() const { return *this; } const Product& _ref() const { return *this; }
@ -133,4 +133,4 @@ Object<Scalar, Derived>::operator*=(const Object<Scalar, OtherDerived> &other)
return *this = *this * other; return *this = *this * other;
} }
#endif // EI_PRODUCT_H #endif // EIGEN_PRODUCT_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_RANDOM_H #ifndef EIGEN_RANDOM_H
#define EI_RANDOM_H #define EIGEN_RANDOM_H
template<typename MatrixType> class Random template<typename MatrixType> class Random
: public Object<typename MatrixType::Scalar, Random<MatrixType> > : public Object<typename MatrixType::Scalar, Random<MatrixType> >
@ -42,7 +42,7 @@ template<typename MatrixType> class Random
} }
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(Random) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Random)
private: private:
const Random& _ref() const { return *this; } const Random& _ref() const { return *this; }
@ -51,8 +51,8 @@ template<typename MatrixType> class Random
Scalar _read(int row, int col) const Scalar _read(int row, int col) const
{ {
EI_UNUSED(row); EIGEN_UNUSED(row);
EI_UNUSED(col); EIGEN_UNUSED(col);
return NumTraits<Scalar>::random(); return NumTraits<Scalar>::random();
} }
@ -66,4 +66,4 @@ Eval<Random<Derived> > Object<Scalar, Derived>::random(int rows, int cols)
return Random<Derived>(rows, cols).eval(); return Random<Derived>(rows, cols).eval();
} }
#endif // EI_RANDOM_H #endif // EIGEN_RANDOM_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_ROW_H #ifndef EIGEN_ROW_H
#define EI_ROW_H #define EIGEN_ROW_H
template<typename MatrixType> class Row template<typename MatrixType> class Row
: public Object<typename MatrixType::Scalar, Row<MatrixType> > : public Object<typename MatrixType::Scalar, Row<MatrixType> >
@ -40,7 +40,7 @@ template<typename MatrixType> class Row
Row(const MatRef& matrix, int row) Row(const MatRef& matrix, int row)
: m_matrix(matrix), m_row(row) : m_matrix(matrix), m_row(row)
{ {
EI_CHECK_ROW_RANGE(matrix, row); EIGEN_CHECK_ROW_RANGE(matrix, row);
} }
Row(const Row& other) Row(const Row& other)
@ -52,7 +52,7 @@ template<typename MatrixType> class Row
return Object<Scalar, Row<MatrixType> >::operator=(other); return Object<Scalar, Row<MatrixType> >::operator=(other);
} }
EI_INHERIT_ASSIGNMENT_OPERATORS(Row) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row)
private: private:
const Row& _ref() const { return *this; } const Row& _ref() const { return *this; }
@ -62,13 +62,13 @@ template<typename MatrixType> class Row
Scalar& _write(int row, int col) Scalar& _write(int row, int col)
{ {
EI_UNUSED(row); EIGEN_UNUSED(row);
return m_matrix.write(m_row, col); return m_matrix.write(m_row, col);
} }
Scalar _read(int row, int col) const Scalar _read(int row, int col) const
{ {
EI_UNUSED(row); EIGEN_UNUSED(row);
return m_matrix.read(m_row, col); return m_matrix.read(m_row, col);
} }
@ -84,4 +84,4 @@ Object<Scalar, Derived>::row(int i) const
return Row<Derived>(static_cast<Derived*>(const_cast<Object*>(this))->ref(), i); return Row<Derived>(static_cast<Derived*>(const_cast<Object*>(this))->ref(), i);
} }
#endif // EI_ROW_H #endif // EIGEN_ROW_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_SCALARMULTIPLE_H #ifndef EIGEN_SCALARMULTIPLE_H
#define EI_SCALARMULTIPLE_H #define EIGEN_SCALARMULTIPLE_H
template<typename MatrixType> class ScalarMultiple template<typename MatrixType> class ScalarMultiple
: public Object<typename MatrixType::Scalar, ScalarMultiple<MatrixType> > : public Object<typename MatrixType::Scalar, ScalarMultiple<MatrixType> >
@ -44,7 +44,7 @@ template<typename MatrixType> class ScalarMultiple
: m_matrix(other.m_matrix), m_scalar(other.m_scalar) {} : m_matrix(other.m_matrix), m_scalar(other.m_scalar) {}
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(ScalarMultiple) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ScalarMultiple)
private: private:
const ScalarMultiple& _ref() const { return *this; } const ScalarMultiple& _ref() const { return *this; }
@ -61,7 +61,7 @@ template<typename MatrixType> class ScalarMultiple
const Scalar m_scalar; const Scalar m_scalar;
}; };
#define EI_MAKE_SCALAR_OPS(OtherScalar) \ #define EIGEN_MAKE_SCALAR_OPS(OtherScalar) \
template<typename Scalar, typename Derived> \ template<typename Scalar, typename Derived> \
ScalarMultiple<Derived> \ ScalarMultiple<Derived> \
operator*(const Object<Scalar, Derived>& matrix, \ operator*(const Object<Scalar, Derived>& matrix, \
@ -101,12 +101,12 @@ Object<Scalar, Derived>::operator/=(const OtherScalar &other) \
return *this = *this / other; \ return *this = *this / other; \
} }
EI_MAKE_SCALAR_OPS(int) EIGEN_MAKE_SCALAR_OPS(int)
EI_MAKE_SCALAR_OPS(float) EIGEN_MAKE_SCALAR_OPS(float)
EI_MAKE_SCALAR_OPS(double) EIGEN_MAKE_SCALAR_OPS(double)
EI_MAKE_SCALAR_OPS(std::complex<float>) EIGEN_MAKE_SCALAR_OPS(std::complex<float>)
EI_MAKE_SCALAR_OPS(std::complex<double>) EIGEN_MAKE_SCALAR_OPS(std::complex<double>)
#undef EI_MAKE_SCALAR_OPS #undef EIGEN_MAKE_SCALAR_OPS
#endif // EI_SCALARMULTIPLE_H #endif // EIGEN_SCALARMULTIPLE_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_SUM_H #ifndef EIGEN_SUM_H
#define EI_SUM_H #define EIGEN_SUM_H
template<typename Lhs, typename Rhs> class Sum template<typename Lhs, typename Rhs> class Sum
: public Object<typename Lhs::Scalar, Sum<Lhs, Rhs> > : public Object<typename Lhs::Scalar, Sum<Lhs, Rhs> >
@ -48,7 +48,7 @@ template<typename Lhs, typename Rhs> class Sum
: m_lhs(other.m_lhs), m_rhs(other.m_rhs) {} : m_lhs(other.m_lhs), m_rhs(other.m_rhs) {}
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(Sum) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Sum)
private: private:
const Sum& _ref() const { return *this; } const Sum& _ref() const { return *this; }
@ -80,4 +80,4 @@ Object<Scalar, Derived>::operator+=(const Object<Scalar, OtherDerived>& other)
return *this = *this + other; return *this = *this + other;
} }
#endif // EI_SUM_H #endif // EIGEN_SUM_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_TRACE_H #ifndef EIGEN_TRACE_H
#define EI_TRACE_H #define EIGEN_TRACE_H
template<int Index, int Rows, typename Derived> struct TraceUnroller template<int Index, int Rows, typename Derived> struct TraceUnroller
{ {
@ -47,8 +47,8 @@ template<int Index, typename Derived> struct TraceUnroller<Index, Dynamic, Deriv
{ {
static void run(const Derived &mat, typename Derived::Scalar &trace) static void run(const Derived &mat, typename Derived::Scalar &trace)
{ {
EI_UNUSED(mat); EIGEN_UNUSED(mat);
EI_UNUSED(trace); EIGEN_UNUSED(trace);
} }
}; };
@ -69,4 +69,4 @@ Scalar Object<Scalar, Derived>::trace() const
return res; return res;
} }
#endif // EI_TRACE_H #endif // EIGEN_TRACE_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_TRANSPOSE_H #ifndef EIGEN_TRANSPOSE_H
#define EI_TRANSPOSE_H #define EIGEN_TRANSPOSE_H
template<typename MatrixType> class Transpose template<typename MatrixType> class Transpose
: public Object<typename MatrixType::Scalar, Transpose<MatrixType> > : public Object<typename MatrixType::Scalar, Transpose<MatrixType> >
@ -42,7 +42,7 @@ template<typename MatrixType> class Transpose
Transpose(const Transpose& other) Transpose(const Transpose& other)
: m_matrix(other.m_matrix) {} : m_matrix(other.m_matrix) {}
EI_INHERIT_ASSIGNMENT_OPERATORS(Transpose) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
private: private:
const Transpose& _ref() const { return *this; } const Transpose& _ref() const { return *this; }
@ -70,4 +70,4 @@ Object<Scalar, Derived>::transpose() const
return Transpose<Derived>(static_cast<Derived*>(const_cast<Object*>(this))->ref()); return Transpose<Derived>(static_cast<Derived*>(const_cast<Object*>(this))->ref());
} }
#endif // EI_TRANSPOSE_H #endif // EIGEN_TRANSPOSE_H

View File

@ -23,21 +23,21 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_UTIL_H #ifndef EIGEN_UTIL_H
#define EI_UTIL_H #define EIGEN_UTIL_H
#undef minor #undef minor
#define USING_EIGEN_DATA_TYPES \ #define USING_EIGEN_DATA_TYPES \
EI_USING_MATRIX_TYPEDEFS \ EIGEN_USING_MATRIX_TYPEDEFS \
using Eigen::Matrix; using Eigen::Matrix;
#define EI_UNUSED(x) (void)x #define EIGEN_UNUSED(x) (void)x
#define EI_CHECK_RANGES(matrix, row, col) \ #define EIGEN_CHECK_RANGES(matrix, row, col) \
assert(row >= 0 && row < (matrix).rows() && col >= 0 && col < (matrix).cols()) assert(row >= 0 && row < (matrix).rows() && col >= 0 && col < (matrix).cols())
#define EI_CHECK_ROW_RANGE(matrix, row) \ #define EIGEN_CHECK_ROW_RANGE(matrix, row) \
assert(row >= 0 && row < (matrix).rows()) assert(row >= 0 && row < (matrix).rows())
#define EI_CHECK_COL_RANGE(matrix, col) \ #define EIGEN_CHECK_COL_RANGE(matrix, col) \
assert(col >= 0 && col < (matrix).cols()) assert(col >= 0 && col < (matrix).cols())
//forward declarations //forward declarations
@ -74,19 +74,19 @@ struct ForwardDecl<Matrix<_Scalar, _Rows, _Cols> >
const int Dynamic = -1; const int Dynamic = -1;
#define EI_LOOP_UNROLLING_LIMIT 25 #define EIGEN_LOOP_UNROLLING_LIMIT 25
#define EI_UNUSED(x) (void)x #define EIGEN_UNUSED(x) (void)x
#ifdef __GNUC__ #ifdef __GNUC__
# define EI_ALWAYS_INLINE __attribute__((always_inline)) # define EIGEN_ALWAYS_INLINE __attribute__((always_inline))
# define EI_RESTRICT /*__restrict__*/ # define EIGEN_RESTRICT /*__restrict__*/
#else #else
# define EI_ALWAYS_INLINE # define EIGEN_ALWAYS_INLINE
# define EI_RESTRICT # define EIGEN_RESTRICT
#endif #endif
#define EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \ #define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
template<typename OtherScalar, typename OtherDerived> \ template<typename OtherScalar, typename OtherDerived> \
Derived& operator Op(const Object<OtherScalar, OtherDerived>& other) \ Derived& operator Op(const Object<OtherScalar, OtherDerived>& other) \
{ \ { \
@ -97,18 +97,18 @@ Derived& operator Op(const Derived& other) \
return Object<Scalar, Derived>::operator Op(other); \ return Object<Scalar, Derived>::operator Op(other); \
} }
#define EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \ #define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
template<typename Other> \ template<typename Other> \
Derived& operator Op(const Other& scalar) \ Derived& operator Op(const Other& scalar) \
{ \ { \
return Object<Scalar, Derived>::operator Op(scalar); \ return Object<Scalar, Derived>::operator Op(scalar); \
} }
#define EI_INHERIT_ASSIGNMENT_OPERATORS(Derived) \ #define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \ EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \
EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \ EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \
EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \ EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \ EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=) EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
#endif // EI_UTIL_H #endif // EIGEN_UTIL_H

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_ZERO_H #ifndef EIGEN_ZERO_H
#define EI_ZERO_H #define EIGEN_ZERO_H
template<typename MatrixType> class Zero template<typename MatrixType> class Zero
: public Object<typename MatrixType::Scalar, Zero<MatrixType> > : public Object<typename MatrixType::Scalar, Zero<MatrixType> >
@ -42,7 +42,7 @@ template<typename MatrixType> class Zero
} }
// assignments are illegal but we still want to intercept them and get clean compile errors // assignments are illegal but we still want to intercept them and get clean compile errors
EI_INHERIT_ASSIGNMENT_OPERATORS(Zero) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Zero)
private: private:
const Zero& _ref() const { return *this; } const Zero& _ref() const { return *this; }
@ -51,8 +51,8 @@ template<typename MatrixType> class Zero
Scalar _read(int row, int col) const Scalar _read(int row, int col) const
{ {
EI_UNUSED(row); EIGEN_UNUSED(row);
EI_UNUSED(col); EIGEN_UNUSED(col);
return static_cast<Scalar>(0); return static_cast<Scalar>(0);
} }
@ -66,4 +66,4 @@ Zero<Derived> Object<Scalar, Derived>::zero(int rows, int cols)
return Zero<Derived>(rows, cols); return Zero<Derived>(rows, cols);
} }
#endif // EI_ZERO_H #endif // EIGEN_ZERO_H

View File

@ -27,14 +27,26 @@
template<typename MatrixType> void basicStuff(const MatrixType& m) template<typename MatrixType> void basicStuff(const MatrixType& m)
{ {
/* this test covers the following files:
1) Explicitly (see comments below):
Random.h Zero.h Identity.h Fuzzy.h Sum.h Difference.h
Opposite.h Product.h ScalarMultiple.h FromArray.h
2) Implicitly (the core stuff):
Object.h Matrix.h MatrixStorage.h CopyHelper.h MatrixRef.h
NumTraits.h Util.h
*/
typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::Scalar Scalar;
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType; typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
int rows = m.rows(); int rows = m.rows();
int cols = m.cols(); int cols = m.cols();
// this test relies a lot on Random.h, and there's not much more that we can do
// to test it, hence I consider that we will have tested Random.h
MatrixType m1 = MatrixType::random(rows, cols), MatrixType m1 = MatrixType::random(rows, cols),
m2 = MatrixType::random(rows, cols), m2 = MatrixType::random(rows, cols),
m3, m3(rows, cols),
mzero = MatrixType::zero(rows, cols), mzero = MatrixType::zero(rows, cols),
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime> identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
::identity(rows), ::identity(rows),
@ -47,25 +59,31 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
Scalar s1 = NumTraits<Scalar>::random(), Scalar s1 = NumTraits<Scalar>::random(),
s2 = NumTraits<Scalar>::random(); s2 = NumTraits<Scalar>::random();
// test Fuzzy.h and Zero.h.
QVERIFY(v1.isApprox(v1)); QVERIFY(v1.isApprox(v1));
QVERIFY(!v1.isApprox(2*v1)); QVERIFY(!v1.isApprox(2*v1));
QVERIFY(vzero.isMuchSmallerThan(v1)); QVERIFY(vzero.isMuchSmallerThan(v1));
QVERIFY(vzero.isMuchSmallerThan(v1.norm())); QVERIFY(vzero.isMuchSmallerThan(v1.norm()));
QVERIFY(!v1.isMuchSmallerThan(v1)); QVERIFY(!v1.isMuchSmallerThan(v1));
QVERIFY(vzero.isApprox(v1-v1));
QVERIFY(m1.isApprox(m1)); QVERIFY(m1.isApprox(m1));
QVERIFY(!m1.isApprox(2*m1)); QVERIFY(!m1.isApprox(2*m1));
QVERIFY(mzero.isMuchSmallerThan(m1)); QVERIFY(mzero.isMuchSmallerThan(m1));
QVERIFY(!m1.isMuchSmallerThan(m1)); QVERIFY(!m1.isMuchSmallerThan(m1));
QVERIFY(vzero.isApprox(v1-v1));
QVERIFY(mzero.isApprox(m1-m1)); QVERIFY(mzero.isApprox(m1-m1));
// test the linear structure, i.e. the following files:
// Sum.h Difference.h Opposite.h ScalarMultiple.h
QVERIFY((m1+m1).isApprox(2 * m1)); QVERIFY((m1+m1).isApprox(2 * m1));
QVERIFY((m1+m2-m1).isApprox(m2));
QVERIFY((-m2+m1+m2).isApprox(m1));
QVERIFY((m1 * s1).isApprox(s1 * m1)); QVERIFY((m1 * s1).isApprox(s1 * m1));
QVERIFY(((m1 + m2) * s1).isApprox(s1 * m1 + s1 * m2)); QVERIFY(((m1 + m2) * s1).isApprox(s1 * m1 + s1 * m2));
QVERIFY(((s1 + s2) * m1).isApprox(m1 * s1 + m1 * s2)); QVERIFY(((s1 + s2) * m1).isApprox(m1 * s1 + m1 * s2));
QVERIFY(((m1 - m2) * s1).isApprox(s1 * m1 - s1 * m2));
QVERIFY(((s1 - s2) * m1).isApprox(m1 * s1 - m1 * s2));
QVERIFY(((-m1 + m2) * s1).isApprox(-s1 * m1 + s1 * m2));
QVERIFY(((-s1 + s2) * m1).isApprox(-m1 * s1 + m1 * s2));
m3 = m2; m3 = m2;
QVERIFY((m3 += m1).isApprox(m1 + m2)); QVERIFY((m3 += m1).isApprox(m1 + m2));
m3 = m2; m3 = m2;
@ -77,23 +95,37 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
&& s1 != static_cast<Scalar>(0)) && s1 != static_cast<Scalar>(0))
QVERIFY((m3 /= s1).isApprox(m2 / s1)); QVERIFY((m3 /= s1).isApprox(m2 / s1));
// begin testing Product.h: only associativity for now
// (we use Transpose.h but this doesn't count as a test for it)
QVERIFY(((m1 * m1.transpose()) * m2).isApprox(m1 * (m1.transpose() * m2))); QVERIFY(((m1 * m1.transpose()) * m2).isApprox(m1 * (m1.transpose() * m2)));
m3 = m1; m3 = m1;
m3 *= (m1.transpose() * m2); m3 *= (m1.transpose() * m2);
QVERIFY(m3.isApprox(m1 * (m1.transpose() * m2))); QVERIFY(m3.isApprox(m1 * (m1.transpose() * m2)));
QVERIFY(m3.isApprox(m1.lazyProduct(m1.transpose() * m2))); QVERIFY(m3.isApprox(m1.lazyProduct(m1.transpose() * m2)));
// continue testing Product.h: distributivity
QVERIFY((square * (m1 + m2)).isApprox(square * m1 + square * m2));
QVERIFY((square * (m1 - m2)).isApprox(square * m1 - square * m2));
// continue testing Product.h: compatibility with ScalarMultiple.h
QVERIFY((s1 * (square * m1)).isApprox((s1 * square) * m1));
QVERIFY((s1 * (square * m1)).isApprox(square * (m1 * s1)));
// test Product.h together with Identity.h. This does test Identity.h.
QVERIFY(m1.isApprox(identity * m1)); QVERIFY(m1.isApprox(identity * m1));
QVERIFY(v1.isApprox(identity * v1)); QVERIFY(v1.isApprox(identity * v1));
QVERIFY((square * (m1 + m2)).isApprox(square * m1 + square * m2)); // test FromArray.h
Scalar* array1 = new Scalar[rows]; Scalar* array1 = new Scalar[rows];
Scalar* array2 = new Scalar[rows]; Scalar* array2 = new Scalar[rows];
Matrix<Scalar, Dynamic, 1>::fromArray(array1, rows) = Matrix<Scalar, Dynamic, 1>::random(rows); Matrix<Scalar, Dynamic, 1>::fromArray(array1, rows) = Matrix<Scalar, Dynamic, 1>::random(rows);
Matrix<Scalar, Dynamic, 1>::fromArray(array2, rows) = Matrix<Scalar, Dynamic, 1>::fromArray(array1, rows); Matrix<Scalar, Dynamic, 1>::fromArray(array2, rows)
bool b = Matrix<Scalar, Dynamic, 1>::fromArray(array1, rows).isApprox(Matrix<Scalar, Dynamic, 1>::fromArray(array2, rows)); = Matrix<Scalar, Dynamic, 1>::fromArray(array1, rows);
bool b = Matrix<Scalar, Dynamic, 1>::fromArray(array1, rows)
.isApprox(Matrix<Scalar, Dynamic, 1>::fromArray(array2, rows));
QVERIFY(b); QVERIFY(b);
delete[] array1;
delete[] array2;
} }
void EigenTest::testBasicStuff() void EigenTest::testBasicStuff()

View File

@ -23,8 +23,8 @@
// License. This exception does not invalidate any other reasons why a work // License. This exception does not invalidate any other reasons why a work
// based on this file might be covered by the GNU General Public License. // based on this file might be covered by the GNU General Public License.
#ifndef EI_TEST_MAIN_H #ifndef EIGEN_TEST_MAIN_H
#define EI_TEST_MAIN_H #define EIGEN_TEST_MAIN_H
#include <QtTest/QtTest> #include <QtTest/QtTest>
#include "../src/Core.h" #include "../src/Core.h"
@ -47,4 +47,4 @@ class EigenTest : public QObject
void testBasicStuff(); void testBasicStuff();
}; };
#endif // EI_TEST_MAIN_H #endif // EIGEN_TEST_MAIN_H