From 5309ef5b5ed3d21778eb0a89f96121e8e3333487 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 26 Nov 2007 08:47:07 +0000 Subject: [PATCH] - improve and comment the "BasicStuff" test. - adjust behavior of Matrix(int,int) constructor - s/EI_/EIGEN_/ --- src/Core/Block.h | 8 ++--- src/Core/Cast.h | 8 ++--- src/Core/Column.h | 18 +++++----- src/Core/Conjugate.h | 8 ++--- src/Core/CopyHelper.h | 12 +++---- src/Core/Difference.h | 8 ++--- src/Core/Dot.h | 12 +++---- src/Core/Eval.h | 8 ++--- src/Core/FromArray.h | 8 ++--- src/Core/Fuzzy.h | 6 ++-- src/Core/Identity.h | 8 ++--- src/Core/Matrix.h | 74 ++++++++++++++++++++------------------- src/Core/MatrixRef.h | 8 ++--- src/Core/MatrixStorage.h | 17 ++++----- src/Core/Minor.h | 10 +++--- src/Core/NumTraits.h | 21 ++++++----- src/Core/Object.h | 10 +++--- src/Core/Opposite.h | 8 ++--- src/Core/Product.h | 18 +++++----- src/Core/Random.h | 12 +++---- src/Core/Row.h | 14 ++++---- src/Core/ScalarMultiple.h | 22 ++++++------ src/Core/Sum.h | 8 ++--- src/Core/Trace.h | 10 +++--- src/Core/Transpose.h | 8 ++--- src/Core/Util.h | 44 +++++++++++------------ src/Core/Zero.h | 12 +++---- test/basicstuff.cpp | 52 +++++++++++++++++++++------ test/main.h | 6 ++-- 29 files changed, 246 insertions(+), 212 deletions(-) diff --git a/src/Core/Block.h b/src/Core/Block.h index d3a00f6c8..05b78644d 100644 --- a/src/Core/Block.h +++ b/src/Core/Block.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_BLOCK_H -#define EI_BLOCK_H +#ifndef EIGEN_BLOCK_H +#define EIGEN_BLOCK_H template class Block : public Object > @@ -51,7 +51,7 @@ template class Block : 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) {} - EI_INHERIT_ASSIGNMENT_OPERATORS(Block) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block) private: const Block& _ref() const { return *this; } @@ -81,4 +81,4 @@ Object::block(int startRow, int endRow, int startCol, int endCo startRow, endRow, startCol, endCol); } -#endif // EI_BLOCK_H +#endif // EIGEN_BLOCK_H diff --git a/src/Core/Cast.h b/src/Core/Cast.h index cc4e19f23..0b8bdd6c5 100644 --- a/src/Core/Cast.h +++ b/src/Core/Cast.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_CAST_H -#define EI_CAST_H +#ifndef EIGEN_CAST_H +#define EIGEN_CAST_H template class Cast : public Object > @@ -43,7 +43,7 @@ template class Cast : m_matrix(other.m_matrix) {} // 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: const Cast& _ref() const { return *this; } @@ -67,4 +67,4 @@ Object::cast() const return Cast(static_cast(this)->ref()); } -#endif // EI_CAST_H +#endif // EIGEN_CAST_H diff --git a/src/Core/Column.h b/src/Core/Column.h index d8ed8e0a7..f0309cd13 100644 --- a/src/Core/Column.h +++ b/src/Core/Column.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_COLUMN_H -#define EI_COLUMN_H +#ifndef EIGEN_COLUMN_H +#define EIGEN_COLUMN_H template class Column : public Object > @@ -40,13 +40,13 @@ template class Column Column(const MatRef& matrix, int col) : m_matrix(matrix), m_col(col) { - EI_CHECK_COL_RANGE(matrix, col); + EIGEN_CHECK_COL_RANGE(matrix, col); } Column(const Column& other) : m_matrix(other.m_matrix), m_col(other.m_col) {} - EI_INHERIT_ASSIGNMENT_OPERATORS(Column) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column) private: const Column& _ref() const { return *this; } @@ -55,15 +55,15 @@ template class Column Scalar& _write(int row, int col=0) { - EI_UNUSED(col); - EI_CHECK_ROW_RANGE(*this, row); + EIGEN_UNUSED(col); + EIGEN_CHECK_ROW_RANGE(*this, row); return m_matrix.write(row, m_col); } Scalar _read(int row, int col=0) const { - EI_UNUSED(col); - EI_CHECK_ROW_RANGE(*this, row); + EIGEN_UNUSED(col); + EIGEN_CHECK_ROW_RANGE(*this, row); return m_matrix.read(row, m_col); } @@ -79,4 +79,4 @@ Object::col(int i) const return Column(static_cast(const_cast(this))->ref(), i); } -#endif // EI_COLUMN_H +#endif // EIGEN_COLUMN_H diff --git a/src/Core/Conjugate.h b/src/Core/Conjugate.h index 127b0dee9..b185e2ee3 100644 --- a/src/Core/Conjugate.h +++ b/src/Core/Conjugate.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_CONJUGATE_H -#define EI_CONJUGATE_H +#ifndef EIGEN_CONJUGATE_H +#define EIGEN_CONJUGATE_H template class Conjugate : public Object > @@ -43,7 +43,7 @@ template class Conjugate : m_matrix(other.m_matrix) {} // 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: const Conjugate& _ref() const { return *this; } @@ -66,4 +66,4 @@ Object::conjugate() const return Conjugate(static_cast(this)->ref()); } -#endif // EI_CONJUGATE_H +#endif // EIGEN_CONJUGATE_H diff --git a/src/Core/CopyHelper.h b/src/Core/CopyHelper.h index b62f0aaf0..55bfdf2f9 100644 --- a/src/Core/CopyHelper.h +++ b/src/Core/CopyHelper.h @@ -24,8 +24,8 @@ // 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. -#ifndef EI_COPYHELPER_H -#define EI_COPYHELPER_H +#ifndef EIGEN_COPYHELPER_H +#define EIGEN_COPYHELPER_H template struct CopyHelperUnroller { @@ -54,8 +54,8 @@ template struct CopyHelperUnroller template static void run(Derived1 &dst, const Derived2 &src) { - EI_UNUSED(dst); - EI_UNUSED(src); + EIGEN_UNUSED(dst); + EIGEN_UNUSED(src); } }; @@ -63,7 +63,7 @@ template template void Object::_copy_helper(const Object& other) { - if(SizeAtCompileTime != Dynamic && SizeAtCompileTime <= EI_LOOP_UNROLLING_LIMIT) + if(SizeAtCompileTime != Dynamic && SizeAtCompileTime <= EIGEN_LOOP_UNROLLING_LIMIT) CopyHelperUnroller::run(*this, other); else for(int i = 0; i < rows(); i++) @@ -71,4 +71,4 @@ void Object::_copy_helper(const Object& o write(i, j) = other.read(i, j); } -#endif // EI_COPYHELPER_H +#endif // EIGEN_COPYHELPER_H diff --git a/src/Core/Difference.h b/src/Core/Difference.h index 9800bdcd6..2c93ed9ae 100644 --- a/src/Core/Difference.h +++ b/src/Core/Difference.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_DIFFERENCE_H -#define EI_DIFFERENCE_H +#ifndef EIGEN_DIFFERENCE_H +#define EIGEN_DIFFERENCE_H template class Difference : public Object > @@ -48,7 +48,7 @@ template class Difference : 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 - EI_INHERIT_ASSIGNMENT_OPERATORS(Difference) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Difference) private: const Difference& _ref() const { return *this; } @@ -80,4 +80,4 @@ Object::operator-=(const Object &other) return *this = *this - other; } -#endif // EI_DIFFERENCE_H +#endif // EIGEN_DIFFERENCE_H diff --git a/src/Core/Dot.h b/src/Core/Dot.h index 43df2766e..53342d572 100644 --- a/src/Core/Dot.h +++ b/src/Core/Dot.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_DOT_H -#define EI_DOT_H +#ifndef EIGEN_DOT_H +#define EIGEN_DOT_H template struct DotUnroller @@ -50,9 +50,9 @@ struct DotUnroller { static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot) { - EI_UNUSED(v1); - EI_UNUSED(v2); - EI_UNUSED(dot); + EIGEN_UNUSED(v1); + EIGEN_UNUSED(v2); + EIGEN_UNUSED(dot); } }; @@ -92,4 +92,4 @@ ScalarMultiple Object::normalized() const return (*this) / norm(); } -#endif // EI_DOT_H +#endif // EIGEN_DOT_H diff --git a/src/Core/Eval.h b/src/Core/Eval.h index 3dd22bf9f..d5bc8e457 100644 --- a/src/Core/Eval.h +++ b/src/Core/Eval.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_EVAL_H -#define EI_EVAL_H +#ifndef EIGEN_EVAL_H +#define EIGEN_EVAL_H template class Eval : public Matrix< typename Expression::Scalar, @@ -37,7 +37,7 @@ template class Eval typedef Expression Base; friend class Object; - EI_INHERIT_ASSIGNMENT_OPERATORS(Eval) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Eval) Eval(const Expression& expression) : MatrixType(expression) {} }; @@ -48,4 +48,4 @@ Eval Object::eval() const return Eval(*static_cast(this)); } -#endif // EI_EVAL_H +#endif // EIGEN_EVAL_H diff --git a/src/Core/FromArray.h b/src/Core/FromArray.h index ab144ed13..a8d0eda5b 100644 --- a/src/Core/FromArray.h +++ b/src/Core/FromArray.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_FROMARRAY_H -#define EI_FROMARRAY_H +#ifndef EIGEN_FROMARRAY_H +#define EIGEN_FROMARRAY_H template class FromArray : public Object > @@ -41,7 +41,7 @@ template class FromArray assert(rows > 0 && cols > 0); } - EI_INHERIT_ASSIGNMENT_OPERATORS(FromArray) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(FromArray) private: FromArray& _ref() { return *this; } @@ -70,4 +70,4 @@ FromArray Object::fromArray(const Scalar* array, int r return FromArray(rows, cols, const_cast(array)); } -#endif // EI_FROMARRAY_H +#endif // EIGEN_FROMARRAY_H diff --git a/src/Core/Fuzzy.h b/src/Core/Fuzzy.h index 0b007329f..823ea71f1 100644 --- a/src/Core/Fuzzy.h +++ b/src/Core/Fuzzy.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_FUZZY_H -#define EI_FUZZY_H +#ifndef EIGEN_FUZZY_H +#define EIGEN_FUZZY_H template template @@ -88,4 +88,4 @@ bool Object::isMuchSmallerThan( } } -#endif // EI_FUZZY_H +#endif // EIGEN_FUZZY_H diff --git a/src/Core/Identity.h b/src/Core/Identity.h index cdd38ada7..99186dc3a 100644 --- a/src/Core/Identity.h +++ b/src/Core/Identity.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_IDENTITY_H -#define EI_IDENTITY_H +#ifndef EIGEN_IDENTITY_H +#define EIGEN_IDENTITY_H template class Identity : public Object > @@ -43,7 +43,7 @@ template class Identity } // 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: Identity& _ref() { return *this; } @@ -66,4 +66,4 @@ Identity Object::identity(int rows) return Identity(rows); } -#endif // EI_IDENTITY_H +#endif // EIGEN_IDENTITY_H diff --git a/src/Core/Matrix.h b/src/Core/Matrix.h index 10b3dd1d2..b0a9e003c 100644 --- a/src/Core/Matrix.h +++ b/src/Core/Matrix.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_MATRIX_H -#define EI_MATRIX_H +#ifndef EIGEN_MATRIX_H +#define EIGEN_MATRIX_H template 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 { - EI_CHECK_RANGES(*this, row, col); + EIGEN_CHECK_RANGES(*this, row, col); return array()[row + col * Storage::_rows()]; } Scalar& _write(int row, int col) { - EI_CHECK_RANGES(*this, row, col); + EIGEN_CHECK_RANGES(*this, row, col); return array()[row + col * Storage::_rows()]; } @@ -75,14 +75,16 @@ class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, return Base::operator=(other); } - EI_INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=) - EI_INHERIT_ASSIGNMENT_OPERATOR(Matrix, -=) - EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, *=) - EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Matrix, /=) + EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=) + EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Matrix, -=) + EIGEN_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 - Matrix(const Object& other) : Storage(other.rows(), other.cols()) + Matrix(const Object& other) + : Storage(other.rows(), other.cols()) { *this = other; } @@ -93,42 +95,42 @@ class Matrix : public Object<_Scalar, Matrix<_Scalar, _Rows, _Cols> >, ~Matrix() {} }; -#define EI_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ +#define EIGEN_MAKE_TYPEDEFS(Type, TypeSuffix, Size, SizeSuffix) \ typedef Matrix Matrix##SizeSuffix##TypeSuffix; \ typedef Matrix Vector##SizeSuffix##TypeSuffix; \ typedef Matrix RowVector##SizeSuffix##TypeSuffix; -#define EI_MAKE_TYPEDEFS_ALL_SIZES(Type, TypeSuffix) \ -EI_MAKE_TYPEDEFS(Type, TypeSuffix, 2, 2) \ -EI_MAKE_TYPEDEFS(Type, TypeSuffix, 3, 3) \ -EI_MAKE_TYPEDEFS(Type, TypeSuffix, 4, 4) \ -EI_MAKE_TYPEDEFS(Type, TypeSuffix, Dynamic, X) +#define EIGEN_MAKE_TYPEDEFS_ALL_SIZES(Type, 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, Dynamic, X) -EI_MAKE_TYPEDEFS_ALL_SIZES(int, i) -EI_MAKE_TYPEDEFS_ALL_SIZES(float, f) -EI_MAKE_TYPEDEFS_ALL_SIZES(double, d) -EI_MAKE_TYPEDEFS_ALL_SIZES(std::complex, cf) -EI_MAKE_TYPEDEFS_ALL_SIZES(std::complex, cd) +EIGEN_MAKE_TYPEDEFS_ALL_SIZES(int, i) +EIGEN_MAKE_TYPEDEFS_ALL_SIZES(float, f) +EIGEN_MAKE_TYPEDEFS_ALL_SIZES(double, d) +EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex, cf) +EIGEN_MAKE_TYPEDEFS_ALL_SIZES(std::complex, cd) -#undef EI_MAKE_TYPEDEFS_ALL_SIZES -#undef EI_MAKE_TYPEDEFS +#undef EIGEN_MAKE_TYPEDEFS_ALL_SIZES +#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::Vector##SizeSuffix##TypeSuffix; \ using Eigen::RowVector##SizeSuffix##TypeSuffix; -#define EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \ -EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \ -EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \ -EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \ -EI_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) +#define EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(TypeSuffix) \ +EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 2) \ +EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 3) \ +EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, 4) \ +EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE_AND_SIZE(TypeSuffix, X) -#define EI_USING_MATRIX_TYPEDEFS \ -EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \ -EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \ -EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \ -EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \ -EI_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd) +#define EIGEN_USING_MATRIX_TYPEDEFS \ +EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(i) \ +EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(f) \ +EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(d) \ +EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cf) \ +EIGEN_USING_MATRIX_TYPEDEFS_FOR_TYPE(cd) -#endif // EI_MATRIX_H +#endif // EIGEN_MATRIX_H diff --git a/src/Core/MatrixRef.h b/src/Core/MatrixRef.h index 8fab9d06a..c2558cd49 100644 --- a/src/Core/MatrixRef.h +++ b/src/Core/MatrixRef.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_MATRIXREF_H -#define EI_MATRIXREF_H +#ifndef EIGEN_MATRIXREF_H +#define EIGEN_MATRIXREF_H template class MatrixRef : public Object > @@ -37,7 +37,7 @@ template class MatrixRef MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {} ~MatrixRef() {} - EI_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef) private: int _rows() const { return m_matrix.rows(); } @@ -57,4 +57,4 @@ template class MatrixRef MatrixType& m_matrix; }; -#endif // EI_MATRIXREF_H +#endif // EIGEN_MATRIXREF_H diff --git a/src/Core/MatrixStorage.h b/src/Core/MatrixStorage.h index 5d636dc21..e03397015 100644 --- a/src/Core/MatrixStorage.h +++ b/src/Core/MatrixStorage.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_MATRIXSTORAGE_H -#define EI_MATRIXSTORAGE_H +#ifndef EIGEN_MATRIXSTORAGE_H +#define EIGEN_MATRIXSTORAGE_H template 0 && ColsAtCompileTime > 0); + EIGEN_UNUSED(rows); + EIGEN_UNUSED(cols); + assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0 + && rows == RowsAtCompileTime && cols == ColsAtCompileTime); } ~MatrixStorage() {}; @@ -81,7 +82,7 @@ class MatrixStorage public: 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]; } @@ -116,7 +117,7 @@ class MatrixStorage public: 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]; } @@ -160,4 +161,4 @@ class MatrixStorage { delete[] m_array; } }; -#endif // EI_MATRIXSTORAGE_H +#endif // EIGEN_MATRIXSTORAGE_H diff --git a/src/Core/Minor.h b/src/Core/Minor.h index bc9025d3a..d52862968 100644 --- a/src/Core/Minor.h +++ b/src/Core/Minor.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_MINOR_H -#define EI_MINOR_H +#ifndef EIGEN_MINOR_H +#define EIGEN_MINOR_H template class Minor : public Object > @@ -44,13 +44,13 @@ template class Minor int row, int col = 0) : 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) : 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: Minor& _ref() { return *this; } @@ -80,4 +80,4 @@ Object::minor(int row, int col) const return Minor(static_cast(const_cast(this))->ref(), row, col); } -#endif // EI_MINOR_H +#endif // EIGEN_MINOR_H diff --git a/src/Core/NumTraits.h b/src/Core/NumTraits.h index 68fa1cc71..132c9205e 100644 --- a/src/Core/NumTraits.h +++ b/src/Core/NumTraits.h @@ -1,4 +1,3 @@ - // This file is part of Eigen, a lightweight C++ template library // 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 // based on this file might be covered by the GNU General Public License. -#ifndef EI_NUMERIC_H -#define EI_NUMERIC_H +#ifndef EIGEN_NUMERIC_H +#define EIGEN_NUMERIC_H template struct NumTraits; @@ -40,7 +39,7 @@ template<> struct NumTraits static int precision() { return 0; } 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 abs2(const int& x) { return x*x; } static int random() @@ -52,18 +51,18 @@ template<> struct NumTraits } static bool isMuchSmallerThan(const int& a, const int& b, const int& prec = precision()) { - EI_UNUSED(b); - EI_UNUSED(prec); + EIGEN_UNUSED(b); + EIGEN_UNUSED(prec); return a == 0; } static bool isApprox(const int& a, const int& b, const int& prec = precision()) { - EI_UNUSED(prec); + EIGEN_UNUSED(prec); return a == b; } static bool isApproxOrLessThan(const int& a, const int& b, const int& prec = precision()) { - EI_UNUSED(prec); + EIGEN_UNUSED(prec); return a <= b; } }; @@ -79,7 +78,7 @@ template<> struct NumTraits static float precision() { return 1e-5f; } 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 abs2(const float& x) { return x*x; } static float random() @@ -111,7 +110,7 @@ template<> struct NumTraits static double precision() { return 1e-11; } 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 abs2(const double& x) { return x*x; } static double random() @@ -164,4 +163,4 @@ template struct NumTraits > // isApproxOrLessThan wouldn't make sense for complex numbers }; -#endif // EI_NUMERIC_H +#endif // EIGEN_NUMERIC_H diff --git a/src/Core/Object.h b/src/Core/Object.h index ff412e789..9425f0050 100644 --- a/src/Core/Object.h +++ b/src/Core/Object.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_OBJECT_H -#define EI_OBJECT_H +#ifndef EIGEN_OBJECT_H +#define EIGEN_OBJECT_H template class Object { @@ -134,7 +134,7 @@ template class Object template Product - lazyProduct(const Object& other) const EI_ALWAYS_INLINE; + lazyProduct(const Object& other) const EIGEN_ALWAYS_INLINE; Opposite operator-() const; @@ -177,7 +177,7 @@ template class Object else return write(index, 0); } - Eval eval() const EI_ALWAYS_INLINE; + Eval eval() const EIGEN_ALWAYS_INLINE; }; template @@ -196,4 +196,4 @@ std::ostream & operator << return s; } -#endif // EI_OBJECT_H +#endif // EIGEN_OBJECT_H diff --git a/src/Core/Opposite.h b/src/Core/Opposite.h index ea7533dfd..744ccb840 100644 --- a/src/Core/Opposite.h +++ b/src/Core/Opposite.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_OPPOSITE_H -#define EI_OPPOSITE_H +#ifndef EIGEN_OPPOSITE_H +#define EIGEN_OPPOSITE_H template class Opposite : public Object > @@ -43,7 +43,7 @@ template class Opposite : m_matrix(other.m_matrix) {} // 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: const Opposite& _ref() const { return *this; } @@ -66,4 +66,4 @@ Object::operator-() const return Opposite(static_cast(this)->ref()); } -#endif // EI_OPPOSITE_H +#endif // EIGEN_OPPOSITE_H diff --git a/src/Core/Product.h b/src/Core/Product.h index 1937b5182..4705d347d 100644 --- a/src/Core/Product.h +++ b/src/Core/Product.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_PRODUCT_H -#define EI_PRODUCT_H +#ifndef EIGEN_PRODUCT_H +#define EIGEN_PRODUCT_H template struct ProductUnroller @@ -53,11 +53,11 @@ struct ProductUnroller static void run(int row, int col, const Lhs& lhs, const Rhs& rhs, typename Lhs::Scalar &res) { - EI_UNUSED(row); - EI_UNUSED(col); - EI_UNUSED(lhs); - EI_UNUSED(rhs); - EI_UNUSED(res); + EIGEN_UNUSED(row); + EIGEN_UNUSED(col); + EIGEN_UNUSED(lhs); + EIGEN_UNUSED(rhs); + EIGEN_UNUSED(res); } }; @@ -83,7 +83,7 @@ template class Product : 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 - EI_INHERIT_ASSIGNMENT_OPERATORS(Product) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Product) private: const Product& _ref() const { return *this; } @@ -133,4 +133,4 @@ Object::operator*=(const Object &other) return *this = *this * other; } -#endif // EI_PRODUCT_H +#endif // EIGEN_PRODUCT_H diff --git a/src/Core/Random.h b/src/Core/Random.h index 18c6d483b..c30749b95 100644 --- a/src/Core/Random.h +++ b/src/Core/Random.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_RANDOM_H -#define EI_RANDOM_H +#ifndef EIGEN_RANDOM_H +#define EIGEN_RANDOM_H template class Random : public Object > @@ -42,7 +42,7 @@ template class Random } // 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: const Random& _ref() const { return *this; } @@ -51,8 +51,8 @@ template class Random Scalar _read(int row, int col) const { - EI_UNUSED(row); - EI_UNUSED(col); + EIGEN_UNUSED(row); + EIGEN_UNUSED(col); return NumTraits::random(); } @@ -66,4 +66,4 @@ Eval > Object::random(int rows, int cols) return Random(rows, cols).eval(); } -#endif // EI_RANDOM_H +#endif // EIGEN_RANDOM_H diff --git a/src/Core/Row.h b/src/Core/Row.h index 00ec34d9a..92597cd96 100644 --- a/src/Core/Row.h +++ b/src/Core/Row.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_ROW_H -#define EI_ROW_H +#ifndef EIGEN_ROW_H +#define EIGEN_ROW_H template class Row : public Object > @@ -40,7 +40,7 @@ template class Row Row(const MatRef& matrix, int row) : m_matrix(matrix), m_row(row) { - EI_CHECK_ROW_RANGE(matrix, row); + EIGEN_CHECK_ROW_RANGE(matrix, row); } Row(const Row& other) @@ -52,7 +52,7 @@ template class Row return Object >::operator=(other); } - EI_INHERIT_ASSIGNMENT_OPERATORS(Row) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row) private: const Row& _ref() const { return *this; } @@ -62,13 +62,13 @@ template class Row Scalar& _write(int row, int col) { - EI_UNUSED(row); + EIGEN_UNUSED(row); return m_matrix.write(m_row, col); } Scalar _read(int row, int col) const { - EI_UNUSED(row); + EIGEN_UNUSED(row); return m_matrix.read(m_row, col); } @@ -84,4 +84,4 @@ Object::row(int i) const return Row(static_cast(const_cast(this))->ref(), i); } -#endif // EI_ROW_H +#endif // EIGEN_ROW_H diff --git a/src/Core/ScalarMultiple.h b/src/Core/ScalarMultiple.h index 760d15d67..f6a5ea6c5 100644 --- a/src/Core/ScalarMultiple.h +++ b/src/Core/ScalarMultiple.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_SCALARMULTIPLE_H -#define EI_SCALARMULTIPLE_H +#ifndef EIGEN_SCALARMULTIPLE_H +#define EIGEN_SCALARMULTIPLE_H template class ScalarMultiple : public Object > @@ -44,7 +44,7 @@ template class ScalarMultiple : 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 - EI_INHERIT_ASSIGNMENT_OPERATORS(ScalarMultiple) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(ScalarMultiple) private: const ScalarMultiple& _ref() const { return *this; } @@ -61,7 +61,7 @@ template class ScalarMultiple const Scalar m_scalar; }; -#define EI_MAKE_SCALAR_OPS(OtherScalar) \ +#define EIGEN_MAKE_SCALAR_OPS(OtherScalar) \ template \ ScalarMultiple \ operator*(const Object& matrix, \ @@ -101,12 +101,12 @@ Object::operator/=(const OtherScalar &other) \ return *this = *this / other; \ } -EI_MAKE_SCALAR_OPS(int) -EI_MAKE_SCALAR_OPS(float) -EI_MAKE_SCALAR_OPS(double) -EI_MAKE_SCALAR_OPS(std::complex) -EI_MAKE_SCALAR_OPS(std::complex) +EIGEN_MAKE_SCALAR_OPS(int) +EIGEN_MAKE_SCALAR_OPS(float) +EIGEN_MAKE_SCALAR_OPS(double) +EIGEN_MAKE_SCALAR_OPS(std::complex) +EIGEN_MAKE_SCALAR_OPS(std::complex) -#undef EI_MAKE_SCALAR_OPS +#undef EIGEN_MAKE_SCALAR_OPS -#endif // EI_SCALARMULTIPLE_H +#endif // EIGEN_SCALARMULTIPLE_H diff --git a/src/Core/Sum.h b/src/Core/Sum.h index d6cd15488..cfbf20ee3 100644 --- a/src/Core/Sum.h +++ b/src/Core/Sum.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_SUM_H -#define EI_SUM_H +#ifndef EIGEN_SUM_H +#define EIGEN_SUM_H template class Sum : public Object > @@ -48,7 +48,7 @@ template class Sum : 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 - EI_INHERIT_ASSIGNMENT_OPERATORS(Sum) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Sum) private: const Sum& _ref() const { return *this; } @@ -80,4 +80,4 @@ Object::operator+=(const Object& other) return *this = *this + other; } -#endif // EI_SUM_H +#endif // EIGEN_SUM_H diff --git a/src/Core/Trace.h b/src/Core/Trace.h index 5ea999dae..9990ec3c7 100644 --- a/src/Core/Trace.h +++ b/src/Core/Trace.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_TRACE_H -#define EI_TRACE_H +#ifndef EIGEN_TRACE_H +#define EIGEN_TRACE_H template struct TraceUnroller { @@ -47,8 +47,8 @@ template struct TraceUnroller::trace() const return res; } -#endif // EI_TRACE_H +#endif // EIGEN_TRACE_H diff --git a/src/Core/Transpose.h b/src/Core/Transpose.h index c9c4f669e..e1930f081 100644 --- a/src/Core/Transpose.h +++ b/src/Core/Transpose.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_TRANSPOSE_H -#define EI_TRANSPOSE_H +#ifndef EIGEN_TRANSPOSE_H +#define EIGEN_TRANSPOSE_H template class Transpose : public Object > @@ -42,7 +42,7 @@ template class Transpose Transpose(const Transpose& other) : m_matrix(other.m_matrix) {} - EI_INHERIT_ASSIGNMENT_OPERATORS(Transpose) + EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose) private: const Transpose& _ref() const { return *this; } @@ -70,4 +70,4 @@ Object::transpose() const return Transpose(static_cast(const_cast(this))->ref()); } -#endif // EI_TRANSPOSE_H +#endif // EIGEN_TRANSPOSE_H diff --git a/src/Core/Util.h b/src/Core/Util.h index 7ad38aa21..1eafe4514 100644 --- a/src/Core/Util.h +++ b/src/Core/Util.h @@ -23,21 +23,21 @@ // 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. -#ifndef EI_UTIL_H -#define EI_UTIL_H +#ifndef EIGEN_UTIL_H +#define EIGEN_UTIL_H #undef minor #define USING_EIGEN_DATA_TYPES \ -EI_USING_MATRIX_TYPEDEFS \ +EIGEN_USING_MATRIX_TYPEDEFS \ using Eigen::Matrix; -#define EI_UNUSED(x) (void)x -#define EI_CHECK_RANGES(matrix, row, col) \ +#define EIGEN_UNUSED(x) (void)x +#define EIGEN_CHECK_RANGES(matrix, row, col) \ 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()) -#define EI_CHECK_COL_RANGE(matrix, col) \ +#define EIGEN_CHECK_COL_RANGE(matrix, col) \ assert(col >= 0 && col < (matrix).cols()) //forward declarations @@ -74,19 +74,19 @@ struct ForwardDecl > 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__ -# define EI_ALWAYS_INLINE __attribute__((always_inline)) -# define EI_RESTRICT /*__restrict__*/ +# define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) +# define EIGEN_RESTRICT /*__restrict__*/ #else -# define EI_ALWAYS_INLINE -# define EI_RESTRICT +# define EIGEN_ALWAYS_INLINE +# define EIGEN_RESTRICT #endif -#define EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \ +#define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \ template \ Derived& operator Op(const Object& other) \ { \ @@ -97,18 +97,18 @@ Derived& operator Op(const Derived& other) \ return Object::operator Op(other); \ } -#define EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \ +#define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \ template \ Derived& operator Op(const Other& scalar) \ { \ return Object::operator Op(scalar); \ } -#define EI_INHERIT_ASSIGNMENT_OPERATORS(Derived) \ -EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \ -EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \ -EI_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \ -EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \ -EI_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=) +#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \ +EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, =) \ +EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, +=) \ +EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \ +EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \ +EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=) -#endif // EI_UTIL_H +#endif // EIGEN_UTIL_H diff --git a/src/Core/Zero.h b/src/Core/Zero.h index 9ee9776b9..1d64730da 100644 --- a/src/Core/Zero.h +++ b/src/Core/Zero.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_ZERO_H -#define EI_ZERO_H +#ifndef EIGEN_ZERO_H +#define EIGEN_ZERO_H template class Zero : public Object > @@ -42,7 +42,7 @@ template class Zero } // 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: const Zero& _ref() const { return *this; } @@ -51,8 +51,8 @@ template class Zero Scalar _read(int row, int col) const { - EI_UNUSED(row); - EI_UNUSED(col); + EIGEN_UNUSED(row); + EIGEN_UNUSED(col); return static_cast(0); } @@ -66,4 +66,4 @@ Zero Object::zero(int rows, int cols) return Zero(rows, cols); } -#endif // EI_ZERO_H +#endif // EIGEN_ZERO_H diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp index 02ebb2343..2bb939570 100644 --- a/test/basicstuff.cpp +++ b/test/basicstuff.cpp @@ -27,14 +27,26 @@ template 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 Matrix VectorType; int rows = m.rows(); 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), m2 = MatrixType::random(rows, cols), - m3, + m3(rows, cols), mzero = MatrixType::zero(rows, cols), identity = Matrix ::identity(rows), @@ -47,25 +59,31 @@ template void basicStuff(const MatrixType& m) Scalar s1 = NumTraits::random(), s2 = NumTraits::random(); + // test Fuzzy.h and Zero.h. QVERIFY(v1.isApprox(v1)); QVERIFY(!v1.isApprox(2*v1)); - QVERIFY(vzero.isMuchSmallerThan(v1)); QVERIFY(vzero.isMuchSmallerThan(v1.norm())); QVERIFY(!v1.isMuchSmallerThan(v1)); + QVERIFY(vzero.isApprox(v1-v1)); QVERIFY(m1.isApprox(m1)); QVERIFY(!m1.isApprox(2*m1)); QVERIFY(mzero.isMuchSmallerThan(m1)); QVERIFY(!m1.isMuchSmallerThan(m1)); - - QVERIFY(vzero.isApprox(v1-v1)); 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+m2-m1).isApprox(m2)); + QVERIFY((-m2+m1+m2).isApprox(m1)); QVERIFY((m1 * s1).isApprox(s1 * m1)); 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)); + QVERIFY(((-m1 + m2) * s1).isApprox(-s1 * m1 + s1 * m2)); + QVERIFY(((-s1 + s2) * m1).isApprox(-m1 * s1 + m1 * s2)); m3 = m2; QVERIFY((m3 += m1).isApprox(m1 + m2)); m3 = m2; @@ -77,23 +95,37 @@ template void basicStuff(const MatrixType& m) && s1 != static_cast(0)) 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))); m3 = m1; m3 *= (m1.transpose() * m2); QVERIFY(m3.isApprox(m1 * (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(v1.isApprox(identity * v1)); - QVERIFY((square * (m1 + m2)).isApprox(square * m1 + square * m2)); - + // test FromArray.h Scalar* array1 = new Scalar[rows]; Scalar* array2 = new Scalar[rows]; Matrix::fromArray(array1, rows) = Matrix::random(rows); - Matrix::fromArray(array2, rows) = Matrix::fromArray(array1, rows); - bool b = Matrix::fromArray(array1, rows).isApprox(Matrix::fromArray(array2, rows)); + Matrix::fromArray(array2, rows) + = Matrix::fromArray(array1, rows); + bool b = Matrix::fromArray(array1, rows) + .isApprox(Matrix::fromArray(array2, rows)); QVERIFY(b); + delete[] array1; + delete[] array2; } void EigenTest::testBasicStuff() diff --git a/test/main.h b/test/main.h index 3eecec210..013abf595 100644 --- a/test/main.h +++ b/test/main.h @@ -23,8 +23,8 @@ // 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. -#ifndef EI_TEST_MAIN_H -#define EI_TEST_MAIN_H +#ifndef EIGEN_TEST_MAIN_H +#define EIGEN_TEST_MAIN_H #include #include "../src/Core.h" @@ -47,4 +47,4 @@ class EigenTest : public QObject void testBasicStuff(); }; -#endif // EI_TEST_MAIN_H +#endif // EIGEN_TEST_MAIN_H