diff options
-rw-r--r-- | Eigen/src/Core/DenseBase.h | 10 | ||||
-rw-r--r-- | Eigen/src/Core/Product.h | 5 | ||||
-rw-r--r-- | test/array.cpp | 10 | ||||
-rw-r--r-- | test/array_for_matrix.cpp | 4 | ||||
-rw-r--r-- | test/product.h | 9 |
5 files changed, 24 insertions, 14 deletions
diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index c4b4057a4..80db0f421 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -218,8 +218,8 @@ template<typename Derived> class DenseBase */ void resize(Index rows, Index cols) { - EIGEN_ONLY_USED_FOR_DEBUG(rows); - EIGEN_ONLY_USED_FOR_DEBUG(cols); + EIGEN_ONLY_USED_FOR_DEBUG(rows); + EIGEN_ONLY_USED_FOR_DEBUG(cols); ei_assert(rows == this->rows() && cols == this->cols() && "DenseBase::resize() does not actually allow to resize."); } @@ -247,7 +247,7 @@ template<typename Derived> class DenseBase /** \internal expression type of a block of whole rows */ template<int N> struct NRowsBlockXpr { typedef Block<Derived, N, ei_traits<Derived>::ColsAtCompileTime> Type; }; - + #endif // not EIGEN_PARSED_BY_DOXYGEN /** Copies \a other into *this. \returns a reference to *this. */ @@ -440,8 +440,8 @@ template<typename Derived> class DenseBase * a const reference, in order to avoid a useless copy. */ EIGEN_STRONG_INLINE const typename ei_eval<Derived>::type eval() const - { - // Even though MSVC does not honor strong inlining when the return type + { + // Even though MSVC does not honor strong inlining when the return type // is a dynamic matrix, we desperately need strong inlining for fixed // size types on MSVC. return typename ei_eval<Derived>::type(derived()); diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 93e978779..859545aa0 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -182,6 +182,11 @@ class GeneralProduct<Lhs, Rhs, InnerProduct> } typename Base::Scalar value() const { return Base::coeff(0,0); } + + /** Convertion to scalar */ + operator const typename Base::Scalar() const { + return Base::coeff(0,0); + } }; /*********************************************************************** diff --git a/test/array.cpp b/test/array.cpp index df1e1b49e..b1fa45b12 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -129,7 +129,7 @@ template<typename ArrayType> void comparisons(const ArrayType& m) VERIFY(((m1.abs()+1)>RealScalar(0.1)).count() == rows*cols); typedef Array<typename ArrayType::Index, Dynamic, 1> ArrayOfIndices; - + // TODO allows colwise/rowwise for array VERIFY_IS_APPROX(((m1.abs()+1)>RealScalar(0.1)).colwise().count(), ArrayOfIndices::Constant(cols,rows).transpose()); VERIFY_IS_APPROX(((m1.abs()+1)>RealScalar(0.1)).rowwise().count(), ArrayOfIndices::Constant(rows, cols)); @@ -151,10 +151,10 @@ template<typename ArrayType> void array_real(const ArrayType& m) VERIFY_IS_APPROX(m1.sin(), ei_sin(m1)); VERIFY_IS_APPROX(m1.cos(), std::cos(m1)); VERIFY_IS_APPROX(m1.cos(), ei_cos(m1)); - + VERIFY_IS_APPROX(ei_cos(m1+RealScalar(3)*m2), ei_cos((m1+RealScalar(3)*m2).eval())); VERIFY_IS_APPROX(std::cos(m1+RealScalar(3)*m2), std::cos((m1+RealScalar(3)*m2).eval())); - + VERIFY_IS_APPROX(m1.abs().sqrt(), std::sqrt(std::abs(m1))); VERIFY_IS_APPROX(m1.abs().sqrt(), ei_sqrt(ei_abs(m1))); VERIFY_IS_APPROX(m1.abs(), ei_sqrt(ei_abs2(m1))); @@ -163,10 +163,10 @@ template<typename ArrayType> void array_real(const ArrayType& m) VERIFY_IS_APPROX(ei_abs2(std::real(m1)) + ei_abs2(std::imag(m1)), ei_abs2(m1)); if(!NumTraits<Scalar>::IsComplex) VERIFY_IS_APPROX(ei_real(m1), m1); - + VERIFY_IS_APPROX(m1.abs().log(), std::log(std::abs(m1))); VERIFY_IS_APPROX(m1.abs().log(), ei_log(ei_abs(m1))); - + VERIFY_IS_APPROX(m1.exp(), std::exp(m1)); VERIFY_IS_APPROX(m1.exp() * m2.exp(), std::exp(m1+m2)); VERIFY_IS_APPROX(m1.exp(), ei_exp(m1)); diff --git a/test/array_for_matrix.cpp b/test/array_for_matrix.cpp index 477d1788d..5d0b9bbbd 100644 --- a/test/array_for_matrix.cpp +++ b/test/array_for_matrix.cpp @@ -37,10 +37,10 @@ template<typename MatrixType> void array_for_matrix(const MatrixType& m) MatrixType m1 = MatrixType::Random(rows, cols), m2 = MatrixType::Random(rows, cols), m3(rows, cols); - + ColVectorType cv1 = ColVectorType::Random(rows); RowVectorType rv1 = RowVectorType::Random(cols); - + Scalar s1 = ei_random<Scalar>(), s2 = ei_random<Scalar>(); diff --git a/test/product.h b/test/product.h index 277b73c45..71dc4bde2 100644 --- a/test/product.h +++ b/test/product.h @@ -71,8 +71,9 @@ template<typename MatrixType> void product(const MatrixType& m) Scalar s1 = ei_random<Scalar>(); - int r = ei_random<int>(0, rows-1), - c = ei_random<int>(0, cols-1); + int r = ei_random<int>(0, rows-1), + c = ei_random<int>(0, cols-1), + c2 = ei_random<int>(0, cols-1); // begin testing Product.h: only associativity for now // (we use Transpose.h but this doesn't count as a test for it) @@ -150,4 +151,8 @@ template<typename MatrixType> void product(const MatrixType& m) { VERIFY(areNotApprox(res2,square2 + m2.transpose() * m1)); } + + // inner product + Scalar x = square2.row(c) * square2.col(c2); + VERIFY_IS_APPROX(x, square2.row(c).transpose().cwiseProduct(square2.col(c2)).sum()); } |