diff options
author | Gael Guennebaud <g.gael@free.fr> | 2008-04-25 23:10:37 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2008-04-25 23:10:37 +0000 |
commit | 6f2c72fb537c18e5b3a2ddc1f1ba2ff2f4a38785 (patch) | |
tree | 13554a164d91eeaa659976e66042ebf9e1276f66 | |
parent | a451835bce179a999cddedc3c9dab49e421968eb (diff) |
Various fixes in:
- vector to vector assign
- PartialRedux
- Vectorization criteria of Product
- returned type of normalized
- SSE integer mul
-rw-r--r-- | Eigen/src/Core/Assign.h | 3 | ||||
-rw-r--r-- | Eigen/src/Core/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Eigen/src/Core/CwiseNullaryOp.h | 22 | ||||
-rw-r--r-- | Eigen/src/Core/Dot.h | 2 | ||||
-rw-r--r-- | Eigen/src/Core/MatrixBase.h | 18 | ||||
-rw-r--r-- | Eigen/src/Core/PacketMath.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/Product.h | 6 | ||||
-rw-r--r-- | Eigen/src/Core/Redux.h | 8 |
8 files changed, 39 insertions, 32 deletions
diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index c9e2b6b4b..1590fef81 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -123,7 +123,8 @@ Derived& MatrixBase<Derived> { const bool need_to_transpose = Derived::IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime - && (int)Derived::RowsAtCompileTime != (int)OtherDerived::RowsAtCompileTime; + && (int)Derived::RowsAtCompileTime != (int)OtherDerived::RowsAtCompileTime + && (int)Derived::ColsAtCompileTime != (int)OtherDerived::ColsAtCompileTime; if(OtherDerived::Flags & EvalBeforeAssigningBit) { if(need_to_transpose) diff --git a/Eigen/src/Core/CMakeLists.txt b/Eigen/src/Core/CMakeLists.txt index a59a0fd67..9af605dd4 100644 --- a/Eigen/src/Core/CMakeLists.txt +++ b/Eigen/src/Core/CMakeLists.txt @@ -1,8 +1,8 @@ FILE(GLOB Eigen_Core_SRCS "*.h") -INSTALL(FILES +INSTALL(FILES ${Eigen_Core_SRCS} DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/src/Core ) -ADD_SUBDIRECTORY(util) +ADD_SUBDIRECTORY(util)
\ No newline at end of file diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h index 4f09bd8a9..6a0b6bc0c 100644 --- a/Eigen/src/Core/CwiseNullaryOp.h +++ b/Eigen/src/Core/CwiseNullaryOp.h @@ -110,7 +110,7 @@ class CwiseNullaryOp : ei_no_assignment_operator, template<typename Derived> template<typename CustomNullaryOp> const CwiseNullaryOp<CustomNullaryOp, Derived> -MatrixBase<Derived>::cwiseCreate(int rows, int cols, const CustomNullaryOp& func) +MatrixBase<Derived>::create(int rows, int cols, const CustomNullaryOp& func) { return CwiseNullaryOp<CustomNullaryOp, Derived>(rows, cols, func); } @@ -133,7 +133,7 @@ MatrixBase<Derived>::cwiseCreate(int rows, int cols, const CustomNullaryOp& func template<typename Derived> template<typename CustomNullaryOp> const CwiseNullaryOp<CustomNullaryOp, Derived> -MatrixBase<Derived>::cwiseCreate(int size, const CustomNullaryOp& func) +MatrixBase<Derived>::create(int size, const CustomNullaryOp& func) { ei_assert(IsVectorAtCompileTime); if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, Derived>(1, size, func); @@ -152,7 +152,7 @@ MatrixBase<Derived>::cwiseCreate(int size, const CustomNullaryOp& func) template<typename Derived> template<typename CustomNullaryOp> const CwiseNullaryOp<CustomNullaryOp, Derived> -MatrixBase<Derived>::cwiseCreate(const CustomNullaryOp& func) +MatrixBase<Derived>::create(const CustomNullaryOp& func) { return CwiseNullaryOp<CustomNullaryOp, Derived>(rows(), cols(), func); } @@ -174,7 +174,7 @@ template<typename Derived> const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::constant(int rows, int cols, const Scalar& value) { - return cwiseCreate(rows, cols, ei_scalar_constant_op<Scalar>(value)); + return create(rows, cols, ei_scalar_constant_op<Scalar>(value)); } /** \returns an expression of a constant matrix of value \a value @@ -196,7 +196,7 @@ template<typename Derived> const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::constant(int size, const Scalar& value) { - return cwiseCreate(size, ei_scalar_constant_op<Scalar>(value)); + return create(size, ei_scalar_constant_op<Scalar>(value)); } /** \returns an expression of a constant matrix of value \a value @@ -212,7 +212,7 @@ template<typename Derived> const CwiseNullaryOp<ei_scalar_constant_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::constant(const Scalar& value) { - return cwiseCreate(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_constant_op<Scalar>(value)); + return create(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_constant_op<Scalar>(value)); } template<typename Derived> @@ -442,7 +442,7 @@ template<typename Derived> const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::random(int rows, int cols) { - return cwiseCreate(rows, cols, ei_scalar_random_op<Scalar>()); + return create(rows, cols, ei_scalar_random_op<Scalar>()); } /** \returns a random vector (not an expression, the vector is immediately evaluated). @@ -465,7 +465,7 @@ template<typename Derived> const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::random(int size) { - return cwiseCreate(size, ei_scalar_random_op<Scalar>()); + return create(size, ei_scalar_random_op<Scalar>()); } /** \returns a fixed-size random matrix or vector @@ -483,7 +483,7 @@ template<typename Derived> const CwiseNullaryOp<ei_scalar_random_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::random() { - return cwiseCreate(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_random_op<Scalar>()); + return create(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_random_op<Scalar>()); } /** Sets all coefficients in this expression to random values. @@ -519,7 +519,7 @@ template<typename Derived> const CwiseNullaryOp<ei_scalar_identity_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::identity(int rows, int cols) { - return cwiseCreate(rows, cols, ei_scalar_identity_op<Scalar>()); + return create(rows, cols, ei_scalar_identity_op<Scalar>()); } /** \returns an expression of the identity matrix (not necessarily square). @@ -536,7 +536,7 @@ template<typename Derived> const CwiseNullaryOp<ei_scalar_identity_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::identity() { - return cwiseCreate(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_identity_op<Scalar>()); + return create(RowsAtCompileTime, ColsAtCompileTime, ei_scalar_identity_op<Scalar>()); } /** \returns true if *this is approximately equal to the identity matrix diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h index ae42bfa1b..c1c607639 100644 --- a/Eigen/src/Core/Dot.h +++ b/Eigen/src/Core/Dot.h @@ -135,7 +135,7 @@ template<typename Derived> const CwiseUnaryOp<ei_scalar_multiple_op<typename ei_traits<Derived>::Scalar>, Derived> MatrixBase<Derived>::normalized() const { - return (*this) / norm(); + return (*this) * (Scalar(1)/norm()); } /** \returns true if *this is approximately orthogonal to \a other, diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index b6a161bdd..bed6b2f93 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -340,15 +340,15 @@ template<typename Derived> class MatrixBase static const CwiseNullaryOp<ei_scalar_constant_op<Scalar>,Derived> constant(const Scalar& value); - template<typename CustomZeroaryOp> - static const CwiseNullaryOp<CustomZeroaryOp, Derived> - cwiseCreate(int rows, int cols, const CustomZeroaryOp& func); - template<typename CustomZeroaryOp> - static const CwiseNullaryOp<CustomZeroaryOp, Derived> - cwiseCreate(int size, const CustomZeroaryOp& func); - template<typename CustomZeroaryOp> - static const CwiseNullaryOp<CustomZeroaryOp, Derived> - cwiseCreate(const CustomZeroaryOp& func); + template<typename CustomNullaryOp> + static const CwiseNullaryOp<CustomNullaryOp, Derived> + create(int rows, int cols, const CustomNullaryOp& func); + template<typename CustomNullaryOp> + static const CwiseNullaryOp<CustomNullaryOp, Derived> + create(int size, const CustomNullaryOp& func); + template<typename CustomNullaryOp> + static const CwiseNullaryOp<CustomNullaryOp, Derived> + create(const CustomNullaryOp& func); static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> random(int rows, int cols); static const CwiseNullaryOp<ei_scalar_random_op<Scalar>,Derived> random(int size); diff --git a/Eigen/src/Core/PacketMath.h b/Eigen/src/Core/PacketMath.h index 8956c27b0..0f3a132a9 100644 --- a/Eigen/src/Core/PacketMath.h +++ b/Eigen/src/Core/PacketMath.h @@ -59,9 +59,13 @@ inline __m128d ei_pmul(const __m128d& a, const __m128d& b) { return _mm_mul_pd(a inline __m128i ei_pmul(const __m128i& a, const __m128i& b) { return _mm_or_si128( - _mm_mul_epu32(a,b), + _mm_and_si128( + _mm_mul_epu32(a,b), + _mm_setr_epi32(0xffffffff,0,0xffffffff,0)), _mm_slli_si128( - _mm_mul_epu32(_mm_srli_si128(a,32),_mm_srli_si128(b,32)), 32)); + _mm_and_si128( + _mm_mul_epu32(_mm_srli_si128(a,4),_mm_srli_si128(b,4)), + _mm_setr_epi32(0xffffffff,0,0xffffffff,0)), 4)); } inline __m128 ei_pmin(const __m128& a, const __m128& b) { return _mm_min_ps(a,b); } diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h index 895e19e0e..b77fd3eae 100644 --- a/Eigen/src/Core/Product.h +++ b/Eigen/src/Core/Product.h @@ -138,12 +138,14 @@ struct ei_traits<Product<Lhs, Rhs, EvalMode> > ~(RowMajorBit | VectorizableBit | Like1DArrayBit) | ( ( - !(Lhs::Flags & RowMajorBit) && (Lhs::Flags & VectorizableBit) + (!(Lhs::Flags & RowMajorBit)) && (Lhs::Flags & VectorizableBit) + && (Lhs::RowsAtCompileTime % ei_packet_traits<Scalar>::size == 0) ) ? VectorizableBit : ( ( (Rhs::Flags & RowMajorBit) && (Rhs::Flags & VectorizableBit) + && (Lhs::ColsAtCompileTime % ei_packet_traits<Scalar>::size == 0) ) ? RowMajorBit | VectorizableBit : 0 @@ -282,7 +284,7 @@ Derived& MatrixBase<Derived>::lazyAssign(const Product<Lhs,Rhs,CacheOptimalProdu && (Lhs::RowsAtCompileTime%ei_packet_traits<Scalar>::size==0) ), ei_meta_true,ei_meta_false>::ret() #else - ei_meta_false + ei_meta_false() #endif ); return derived(); diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 6e740fc7d..c9332c847 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -53,7 +53,7 @@ struct ei_redux_unroller<BinaryOp, Derived, Start, 1> typedef typename ei_result_of<BinaryOp(typename Derived::Scalar)>::type Scalar; - static Scalar run(const Derived &mat, const BinaryOp &func) + static Scalar run(const Derived &mat, const BinaryOp &) { return mat.coeff(row, col); } @@ -96,7 +96,7 @@ struct ei_traits<PartialRedux<Direction, BinaryOp, MatrixType> > MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime, Flags = ((RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic) ? (unsigned int)_MatrixTypeNested::Flags - : (unsigned int)_MatrixTypeNested::Flags & ~LargeBit) & ~VectorizableBit, + : (unsigned int)_MatrixTypeNested::Flags & ~LargeBit) & ~(VectorizableBit | Like1DArrayBit), TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime, CoeffReadCost = TraversalSize * _MatrixTypeNested::CoeffReadCost + (TraversalSize - 1) * ei_functor_traits<BinaryOp>::Cost @@ -124,9 +124,9 @@ class PartialRedux : ei_no_assignment_operator, const Scalar _coeff(int i, int j) const { if (Direction==Vertical) - return this->col(j).redux(m_functor); + return m_matrix.col(j).redux(m_functor); else - return this->row(i).redux(m_functor); + return m_matrix.row(i).redux(m_functor); } protected: |