diff options
author | Gael Guennebaud <g.gael@free.fr> | 2010-01-05 13:07:32 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2010-01-05 13:07:32 +0100 |
commit | 9d9e00b6080153ddaa26ccfce922d7814811a1ae (patch) | |
tree | a18d77d660e3734a21daec2637c2066afab9021d /Eigen/src | |
parent | 90d2ae7fec1000c244472c94af24126c5f2ca2a2 (diff) | |
parent | 51b8f014f30d0f64fcd4f6dff4b1afa64f8ace48 (diff) |
merge and add start/end to Eigen2Support
Diffstat (limited to 'Eigen/src')
39 files changed, 346 insertions, 198 deletions
diff --git a/Eigen/src/Array/VectorwiseOp.h b/Eigen/src/Array/VectorwiseOp.h index 3aaaa1ec9..eef554d8a 100644 --- a/Eigen/src/Array/VectorwiseOp.h +++ b/Eigen/src/Array/VectorwiseOp.h @@ -384,7 +384,7 @@ template<typename ExpressionType, int Direction> class VectorwiseOp const Reverse<ExpressionType, Direction> reverse() const { return Reverse<ExpressionType, Direction>( _expression() ); } - const Replicate<ExpressionType,Direction==Vertical?Dynamic:1,Direction==Horizontal?Dynamic:1> + const Replicate<ExpressionType,(Direction==Vertical?Dynamic:1),(Direction==Horizontal?Dynamic:1)> replicate(int factor) const; /** \nonstableyet diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index c13be9ac2..4fb6d3d2c 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -194,7 +194,7 @@ LDLT<MatrixType>& LDLT<MatrixType>::compute(const MatrixType& a) { // Find largest diagonal element int index_of_biggest_in_corner; - biggest_in_corner = m_matrix.diagonal().end(size-j).cwiseAbs() + biggest_in_corner = m_matrix.diagonal().tail(size-j).cwiseAbs() .maxCoeff(&index_of_biggest_in_corner); index_of_biggest_in_corner += j; @@ -227,12 +227,12 @@ LDLT<MatrixType>& LDLT<MatrixType>::compute(const MatrixType& a) if (j == 0) { m_matrix.row(0) = m_matrix.row(0).conjugate(); - m_matrix.col(0).end(size-1) = m_matrix.row(0).end(size-1) / m_matrix.coeff(0,0); + m_matrix.col(0).tail(size-1) = m_matrix.row(0).tail(size-1) / m_matrix.coeff(0,0); continue; } - RealScalar Djj = ei_real(m_matrix.coeff(j,j) - m_matrix.row(j).start(j) - .dot(m_matrix.col(j).start(j))); + RealScalar Djj = ei_real(m_matrix.coeff(j,j) - m_matrix.row(j).head(j) + .dot(m_matrix.col(j).head(j))); m_matrix.coeffRef(j,j) = Djj; // Finish early if the matrix is not full rank. @@ -244,13 +244,13 @@ LDLT<MatrixType>& LDLT<MatrixType>::compute(const MatrixType& a) int endSize = size - j - 1; if (endSize > 0) { - _temporary.end(endSize).noalias() = m_matrix.block(j+1,0, endSize, j) - * m_matrix.col(j).start(j).conjugate(); + _temporary.tail(endSize).noalias() = m_matrix.block(j+1,0, endSize, j) + * m_matrix.col(j).head(j).conjugate(); - m_matrix.row(j).end(endSize) = m_matrix.row(j).end(endSize).conjugate() - - _temporary.end(endSize).transpose(); + m_matrix.row(j).tail(endSize) = m_matrix.row(j).tail(endSize).conjugate() + - _temporary.tail(endSize).transpose(); - m_matrix.col(j).end(endSize) = m_matrix.row(j).end(endSize) / Djj; + m_matrix.col(j).tail(endSize) = m_matrix.row(j).tail(endSize) / Djj; } } diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h index ad737aaeb..02645b23f 100644 --- a/Eigen/src/Cholesky/LLT.h +++ b/Eigen/src/Cholesky/LLT.h @@ -166,7 +166,7 @@ template<> struct ei_llt_inplace<LowerTriangular> Block<MatrixType,Dynamic,Dynamic> A20(mat,k+1,0,rs,k); RealScalar x = ei_real(mat.coeff(k,k)); - if (k>0) x -= mat.row(k).start(k).squaredNorm(); + if (k>0) x -= mat.row(k).head(k).squaredNorm(); if (x<=RealScalar(0)) return false; mat.coeffRef(k,k) = x = ei_sqrt(x); diff --git a/Eigen/src/Core/Assign.h b/Eigen/src/Core/Assign.h index d6bf37c6e..e5c17b3f4 100644 --- a/Eigen/src/Core/Assign.h +++ b/Eigen/src/Core/Assign.h @@ -49,6 +49,7 @@ private: InnerMaxSize = int(Derived::Flags)&RowMajorBit ? Derived::MaxColsAtCompileTime : Derived::MaxRowsAtCompileTime, + MaxSizeAtCompileTime = ei_size_at_compile_time<Derived::MaxColsAtCompileTime,Derived::MaxRowsAtCompileTime>::ret, PacketSize = ei_packet_traits<typename Derived::Scalar>::size }; @@ -60,9 +61,9 @@ private: && int(DstIsAligned) && int(SrcIsAligned), MayLinearize = StorageOrdersAgree && (int(Derived::Flags) & int(OtherDerived::Flags) & LinearAccessBit), MayLinearVectorize = MightVectorize && MayLinearize - && (DstIsAligned || InnerMaxSize == Dynamic), + && (DstIsAligned || MaxSizeAtCompileTime == Dynamic), /* If the destination isn't aligned, we have to do runtime checks and we don't unroll, - so it's only good for large enough sizes. See remark below about InnerMaxSize. */ + so it's only good for large enough sizes. */ MaySliceVectorize = MightVectorize && int(InnerMaxSize)>=3*PacketSize /* slice vectorization can be slow, so we only want it if the slices are big, which is indicated by InnerMaxSize rather than InnerSize, think of the case of a dynamic block @@ -385,7 +386,7 @@ struct ei_assign_impl<Derived1, Derived2, LinearVectorizedTraversal, NoUnrolling const int size = dst.size(); const int packetSize = ei_packet_traits<typename Derived1::Scalar>::size; const int alignedStart = ei_assign_traits<Derived1,Derived2>::DstIsAligned ? 0 - : ei_alignmentOffset(&dst.coeffRef(0), size); + : ei_first_aligned(&dst.coeffRef(0), size); const int alignedEnd = alignedStart + ((size-alignedStart)/packetSize)*packetSize; for(int index = 0; index < alignedStart; ++index) @@ -430,7 +431,7 @@ struct ei_assign_impl<Derived1, Derived2, SliceVectorizedTraversal, NoUnrolling> const int outerSize = dst.outerSize(); const int alignedStep = (packetSize - dst.stride() % packetSize) & packetAlignedMask; int alignedStart = ei_assign_traits<Derived1,Derived2>::DstIsAligned ? 0 - : ei_alignmentOffset(&dst.coeffRef(0,0), innerSize); + : ei_first_aligned(&dst.coeffRef(0,0), innerSize); for(int i = 0; i < outerSize; ++i) { @@ -480,11 +481,11 @@ EIGEN_STRONG_INLINE Derived& DenseBase<Derived> EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived) EIGEN_STATIC_ASSERT((ei_is_same_type<typename Derived::Scalar, typename OtherDerived::Scalar>::ret), YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY) - ei_assert(rows() == other.rows() && cols() == other.cols()); - ei_assign_impl<Derived, OtherDerived>::run(derived(),other.derived()); #ifdef EIGEN_DEBUG_ASSIGN ei_assign_traits<Derived, OtherDerived>::debug(); #endif + ei_assert(rows() == other.rows() && cols() == other.cols()); + ei_assign_impl<Derived, OtherDerived>::run(derived(),other.derived()); #ifndef EIGEN_NO_DEBUG checkTransposeAliasing(other.derived()); #endif diff --git a/Eigen/src/Core/Coeffs.h b/Eigen/src/Core/Coeffs.h index b8af2531e..ebfd0c80e 100644 --- a/Eigen/src/Core/Coeffs.h +++ b/Eigen/src/Core/Coeffs.h @@ -379,36 +379,33 @@ EIGEN_STRONG_INLINE void DenseBase<Derived>::copyPacket(int index, const DenseBa other.derived().template packet<LoadMode>(index)); } - -template<typename Derived, typename Integer, bool JustReturnZero> -struct ei_alignmentOffset_impl +template<typename Derived, bool JustReturnZero> +struct ei_first_aligned_impl { - inline static Integer run(const DenseBase<Derived>&, Integer) + inline static int run(const DenseBase<Derived>&) { return 0; } }; -template<typename Derived, typename Integer> -struct ei_alignmentOffset_impl<Derived, Integer, false> +template<typename Derived> +struct ei_first_aligned_impl<Derived, false> { - inline static Integer run(const DenseBase<Derived>& m, Integer maxOffset) + inline static int run(const DenseBase<Derived>& m) { - return ei_alignmentOffset(&m.const_cast_derived().coeffRef(0,0), maxOffset); + return ei_first_aligned(&m.const_cast_derived().coeffRef(0,0), m.size()); } }; -/** \internal \returns the number of elements which have to be skipped, starting - * from the address of coeffRef(0,0), to find the first 16-byte aligned element. +/** \internal \returns the index of the first element of the array that is well aligned for vectorization. * - * \note If the expression doesn't have the DirectAccessBit, this function returns 0. - * - * There is also the variant ei_alignmentOffset(const Scalar*, Integer) defined in Memory.h. + * There is also the variant ei_first_aligned(const Scalar*, Integer) defined in Memory.h. See it for more + * documentation. */ -template<typename Derived, typename Integer> -inline static Integer ei_alignmentOffset(const DenseBase<Derived>& m, Integer maxOffset) +template<typename Derived> +inline static int ei_first_aligned(const DenseBase<Derived>& m) { - return ei_alignmentOffset_impl<Derived, Integer, - (Derived::Flags & AlignedBit) || !(Derived::Flags & DirectAccessBit)> - ::run(m, maxOffset); + return ei_first_aligned_impl + <Derived, (Derived::Flags & AlignedBit) || !(Derived::Flags & DirectAccessBit)> + ::run(m); } #endif diff --git a/Eigen/src/Core/DenseBase.h b/Eigen/src/Core/DenseBase.h index d47cc8876..e07b02a51 100644 --- a/Eigen/src/Core/DenseBase.h +++ b/Eigen/src/Core/DenseBase.h @@ -290,11 +290,11 @@ template<typename Derived> class DenseBase VectorBlock<Derived> segment(int start, int size); const VectorBlock<Derived> segment(int start, int size) const; - VectorBlock<Derived> start(int size); - const VectorBlock<Derived> start(int size) const; + VectorBlock<Derived> head(int size); + const VectorBlock<Derived> head(int size) const; - VectorBlock<Derived> end(int size); - const VectorBlock<Derived> end(int size) const; + VectorBlock<Derived> tail(int size); + const VectorBlock<Derived> tail(int size) const; typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols); const typename BlockReturnType<Derived>::Type corner(CornerType type, int cRows, int cCols) const; @@ -309,11 +309,11 @@ template<typename Derived> class DenseBase template<int CRows, int CCols> const typename BlockReturnType<Derived, CRows, CCols>::Type corner(CornerType type) const; - template<int Size> VectorBlock<Derived,Size> start(void); - template<int Size> const VectorBlock<Derived,Size> start() const; + template<int Size> VectorBlock<Derived,Size> head(void); + template<int Size> const VectorBlock<Derived,Size> head() const; - template<int Size> VectorBlock<Derived,Size> end(); - template<int Size> const VectorBlock<Derived,Size> end() const; + template<int Size> VectorBlock<Derived,Size> tail(); + template<int Size> const VectorBlock<Derived,Size> tail() const; template<int Size> VectorBlock<Derived,Size> segment(int start); template<int Size> const VectorBlock<Derived,Size> segment(int start) const; diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h index 7ffddcbf8..eddabf4b9 100644 --- a/Eigen/src/Core/MathFunctions.h +++ b/Eigen/src/Core/MathFunctions.h @@ -218,7 +218,7 @@ inline float ei_norm1(const std::complex<float> &x) { return(ei_abs(x.real()) + inline std::complex<float> ei_exp(std::complex<float> x) { return std::exp(x); } inline std::complex<float> ei_sin(std::complex<float> x) { return std::sin(x); } inline std::complex<float> ei_cos(std::complex<float> x) { return std::cos(x); } -inline std::complex<float> ei_atan2(std::complex<float>, std::complex<float> ) { ei_assert(false); return 0; } +inline std::complex<float> ei_atan2(std::complex<float>, std::complex<float> ) { ei_assert(false); return 0.f; } template<> inline std::complex<float> ei_random() { @@ -255,7 +255,7 @@ inline double ei_norm1(const std::complex<double> &x) { return(ei_abs(x.real()) inline std::complex<double> ei_exp(std::complex<double> x) { return std::exp(x); } inline std::complex<double> ei_sin(std::complex<double> x) { return std::sin(x); } inline std::complex<double> ei_cos(std::complex<double> x) { return std::cos(x); } -inline std::complex<double> ei_atan2(std::complex<double>, std::complex<double>) { ei_assert(false); return 0; } +inline std::complex<double> ei_atan2(std::complex<double>, std::complex<double>) { ei_assert(false); return 0.; } template<> inline std::complex<double> ei_random() { diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h index 8f9949b43..4c30f30ad 100644 --- a/Eigen/src/Core/MatrixBase.h +++ b/Eigen/src/Core/MatrixBase.h @@ -397,6 +397,15 @@ template<typename Derived> class MatrixBase inline const Cwise<Derived> cwise() const; inline Cwise<Derived> cwise(); + VectorBlock<Derived> start(int size); + const VectorBlock<Derived> start(int size) const; + VectorBlock<Derived> end(int size); + const VectorBlock<Derived> end(int size) const; + template<int Size> VectorBlock<Derived,Size> start(); + template<int Size> const VectorBlock<Derived,Size> start() const; + template<int Size> VectorBlock<Derived,Size> end(); + template<int Size> const VectorBlock<Derived,Size> end() const; + template<typename OtherDerived> typename ei_plain_matrix_type_column_major<OtherDerived>::type solveTriangular(const MatrixBase<OtherDerived>& other) const; diff --git a/Eigen/src/Core/MatrixStorage.h b/Eigen/src/Core/MatrixStorage.h index 8bfa728b6..584ba8ca3 100644 --- a/Eigen/src/Core/MatrixStorage.h +++ b/Eigen/src/Core/MatrixStorage.h @@ -98,7 +98,7 @@ template<typename T, int _Rows, int _Cols, int _Options> class ei_matrix_storage inline explicit ei_matrix_storage() {} inline ei_matrix_storage(ei_constructor_without_unaligned_array_assert) {} inline ei_matrix_storage(int,int,int) {} - inline void swap(ei_matrix_storage& other) {} + inline void swap(ei_matrix_storage& ) {} inline static int rows(void) {return _Rows;} inline static int cols(void) {return _Cols;} inline void resize(int,int,int) {} diff --git a/Eigen/src/Core/Redux.h b/Eigen/src/Core/Redux.h index 92522f86c..1643f13b2 100644 --- a/Eigen/src/Core/Redux.h +++ b/Eigen/src/Core/Redux.h @@ -209,7 +209,7 @@ struct ei_redux_impl<Func, Derived, LinearVectorizedTraversal, NoUnrolling> { const int size = mat.size(); const int packetSize = ei_packet_traits<Scalar>::size; - const int alignedStart = ei_alignmentOffset(mat,size); + const int alignedStart = ei_first_aligned(mat); enum { alignment = (Derived::Flags & DirectAccessBit) || (Derived::Flags & AlignedBit) ? Aligned : Unaligned diff --git a/Eigen/src/Core/SolveTriangular.h b/Eigen/src/Core/SolveTriangular.h index 618e29828..9dc019d17 100644 --- a/Eigen/src/Core/SolveTriangular.h +++ b/Eigen/src/Core/SolveTriangular.h @@ -25,13 +25,27 @@ #ifndef EIGEN_SOLVETRIANGULAR_H #define EIGEN_SOLVETRIANGULAR_H +template<typename Lhs, typename Rhs, int Side> +class ei_trsolve_traits +{ + private: + enum { + RhsIsVectorAtCompileTime = (Side==OnTheLeft ? Rhs::ColsAtCompileTime : Rhs::RowsAtCompileTime)==1 + }; + public: + enum { + Unrolling = (RhsIsVectorAtCompileTime && Rhs::SizeAtCompileTime <= 8) + ? CompleteUnrolling : NoUnrolling, + RhsVectors = RhsIsVectorAtCompileTime ? 1 : Dynamic + }; +}; + template<typename Lhs, typename Rhs, - int Mode, // can be Upper/Lower | UnitDiag int Side, // can be OnTheLeft/OnTheRight - int Unrolling = Rhs::IsVectorAtCompileTime && Rhs::SizeAtCompileTime <= 8 // FIXME - ? CompleteUnrolling : NoUnrolling, + int Mode, // can be Upper/Lower | UnitDiag + int Unrolling = ei_trsolve_traits<Lhs,Rhs,Side>::Unrolling, int StorageOrder = (int(Lhs::Flags) & RowMajorBit) ? RowMajor : ColMajor, - int RhsCols = Rhs::ColsAtCompileTime + int RhsVectors = ei_trsolve_traits<Lhs,Rhs,Side>::RhsVectors > struct ei_triangular_solver_selector; @@ -142,12 +156,24 @@ struct ei_triangular_solver_selector<Lhs,Rhs,OnTheLeft,Mode,NoUnrolling,ColMajor } }; +// transpose OnTheRight cases for vectors +template<typename Lhs, typename Rhs, int Mode, int Unrolling, int StorageOrder> +struct ei_triangular_solver_selector<Lhs,Rhs,OnTheRight,Mode,Unrolling,StorageOrder,1> +{ + static void run(const Lhs& lhs, Rhs& rhs) + { + Transpose<Rhs> rhsTr(rhs); + Transpose<Lhs> lhsTr(lhs); + ei_triangular_solver_selector<Transpose<Lhs>,Transpose<Rhs>,OnTheLeft,TriangularView<Lhs,Mode>::TransposeMode>::run(lhsTr,rhsTr); + } +}; + template <typename Scalar, int Side, int Mode, bool Conjugate, int TriStorageOrder, int OtherStorageOrder> struct ei_triangular_solve_matrix; // the rhs is a matrix -template<typename Lhs, typename Rhs, int Side, int Mode, int StorageOrder, int RhsCols> -struct ei_triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,StorageOrder,RhsCols> +template<typename Lhs, typename Rhs, int Side, int Mode, int StorageOrder> +struct ei_triangular_solver_selector<Lhs,Rhs,Side,Mode,NoUnrolling,StorageOrder,Dynamic> { typedef typename Rhs::Scalar Scalar; typedef ei_blas_traits<Lhs> LhsProductTraits; diff --git a/Eigen/src/Core/StableNorm.h b/Eigen/src/Core/StableNorm.h index 2874f0fd8..b4d6aa353 100644 --- a/Eigen/src/Core/StableNorm.h +++ b/Eigen/src/Core/StableNorm.h @@ -65,9 +65,9 @@ MatrixBase<Derived>::stableNorm() const int bi=0; if ((int(Flags)&DirectAccessBit) && !(int(Flags)&AlignedBit)) { - bi = ei_alignmentOffset(&const_cast_derived().coeffRef(0), n); + bi = ei_first_aligned(&const_cast_derived().coeffRef(0), n); if (bi>0) - ei_stable_norm_kernel(this->start(bi), ssq, scale, invScale); + ei_stable_norm_kernel(this->head(bi), ssq, scale, invScale); } for (; bi<n; bi+=blockSize) ei_stable_norm_kernel(this->segment(bi,std::min(blockSize, n - bi)).template forceAlignedAccessIf<Alignment>(), ssq, scale, invScale); diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index e593a468d..62d800fef 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -95,12 +95,14 @@ template<typename Derived> class TriangularBase : public AnyMatrixBase<Derived> || ((Mode==StrictlyLowerTriangular || Mode==UnitLowerTriangular) && col<row)); } + #ifdef EIGEN_INTERNAL_DEBUGGING void check_coordinates_internal(int row, int col) { - #ifdef EIGEN_INTERNAL_DEBUGGING check_coordinates(row, col); - #endif } + #else + void check_coordinates_internal(int , int ) {} + #endif }; diff --git a/Eigen/src/Core/VectorBlock.h b/Eigen/src/Core/VectorBlock.h index 96af71b36..760c097ad 100644 --- a/Eigen/src/Core/VectorBlock.h +++ b/Eigen/src/Core/VectorBlock.h @@ -154,16 +154,16 @@ DenseBase<Derived>::segment(int start, int size) const */ template<typename Derived> inline VectorBlock<Derived> -DenseBase<Derived>::start(int size) +DenseBase<Derived>::head(int size) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return VectorBlock<Derived>(derived(), 0, size); } -/** This is the const version of start(int).*/ +/** This is the const version of head(int).*/ template<typename Derived> inline const VectorBlock<Derived> -DenseBase<Derived>::start(int size) const +DenseBase<Derived>::head(int size) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return VectorBlock<Derived>(derived(), 0, size); @@ -186,16 +186,16 @@ DenseBase<Derived>::start(int size) const */ template<typename Derived> inline VectorBlock<Derived> -DenseBase<Derived>::end(int size) +DenseBase<Derived>::tail(int size) { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return VectorBlock<Derived>(derived(), this->size() - size, size); } -/** This is the const version of end(int).*/ +/** This is the const version of tail(int).*/ template<typename Derived> inline const VectorBlock<Derived> -DenseBase<Derived>::end(int size) const +DenseBase<Derived>::tail(int size) const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return VectorBlock<Derived>(derived(), this->size() - size, size); @@ -247,17 +247,17 @@ DenseBase<Derived>::segment(int start) const template<typename Derived> template<int Size> inline VectorBlock<Derived,Size> -DenseBase<Derived>::start() +DenseBase<Derived>::head() { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return VectorBlock<Derived,Size>(derived(), 0); } -/** This is the const version of start<int>().*/ +/** This is the const version of head<int>().*/ template<typename Derived> template<int Size> inline const VectorBlock<Derived,Size> -DenseBase<Derived>::start() const +DenseBase<Derived>::head() const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return VectorBlock<Derived,Size>(derived(), 0); @@ -277,17 +277,17 @@ DenseBase<Derived>::start() const template<typename Derived> template<int Size> inline VectorBlock<Derived,Size> -DenseBase<Derived>::end() +DenseBase<Derived>::tail() { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return VectorBlock<Derived, Size>(derived(), size() - Size); } -/** This is the const version of end<int>.*/ +/** This is the const version of tail<int>.*/ template<typename Derived> template<int Size> inline const VectorBlock<Derived,Size> -DenseBase<Derived>::end() const +DenseBase<Derived>::tail() const { EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) return VectorBlock<Derived, Size>(derived(), size() - Size); diff --git a/Eigen/src/Core/products/GeneralMatrixVector.h b/Eigen/src/Core/products/GeneralMatrixVector.h index a18e5ef1d..3296f32ff 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector.h +++ b/Eigen/src/Core/products/GeneralMatrixVector.h @@ -69,7 +69,7 @@ void ei_cache_friendly_product_colmajor_times_vector( // How many coeffs of the result do we have to skip to be aligned. // Here we assume data are at least aligned on the base scalar type. - int alignedStart = ei_alignmentOffset(res,size); + int alignedStart = ei_first_aligned(res,size); int alignedSize = PacketSize>1 ? alignedStart + ((size-alignedStart) & ~PacketAlignedMask) : 0; const int peeledSize = peels>1 ? alignedStart + ((alignedSize-alignedStart) & ~PeelAlignedMask) : alignedStart; @@ -79,7 +79,7 @@ void ei_cache_friendly_product_colmajor_times_vector( : FirstAligned; // we cannot assume the first element is aligned because of sub-matrices - const int lhsAlignmentOffset = ei_alignmentOffset(lhs,size); + const int lhsAlignmentOffset = ei_first_aligned(lhs,size); // find how many columns do we have to skip to be aligned with the result (if possible) int skipColumns = 0; @@ -282,7 +282,7 @@ static EIGEN_DONT_INLINE void ei_cache_friendly_product_rowmajor_times_vector( // How many coeffs of the result do we have to skip to be aligned. // Here we assume data are at least aligned on the base scalar type // if that's not the case then vectorization is discarded, see below. - int alignedStart = ei_alignmentOffset(rhs, size); + int alignedStart = ei_first_aligned(rhs, size); int alignedSize = PacketSize>1 ? alignedStart + ((size-alignedStart) & ~PacketAlignedMask) : 0; const int peeledSize = peels>1 ? alignedStart + ((alignedSize-alignedStart) & ~PeelAlignedMask) : alignedStart; @@ -292,7 +292,7 @@ static EIGEN_DONT_INLINE void ei_cache_friendly_product_rowmajor_times_vector( : FirstAligned; // we cannot assume the first element is aligned because of sub-matrices - const int lhsAlignmentOffset = ei_alignmentOffset(lhs,size); + const int lhsAlignmentOffset = ei_first_aligned(lhs,size); // find how many rows do we have to skip to be aligned with rhs (if possible) int skipRows = 0; diff --git a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h index 5e025b90b..35efa752e 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixMatrix.h +++ b/Eigen/src/Core/products/SelfadjointMatrixMatrix.h @@ -313,7 +313,6 @@ struct ei_product_selfadjoint_matrix<Scalar,LhsStorageOrder,false,ConjugateLhs, int size = cols; ei_const_blas_data_mapper<Scalar, LhsStorageOrder> lhs(_lhs,lhsStride); - ei_const_blas_data_mapper<Scalar, RhsStorageOrder> rhs(_rhs,rhsStride); if (ConjugateRhs) alpha = ei_conj(alpha); diff --git a/Eigen/src/Core/products/SelfadjointMatrixVector.h b/Eigen/src/Core/products/SelfadjointMatrixVector.h index c27454bee..32b7f220e 100644 --- a/Eigen/src/Core/products/SelfadjointMatrixVector.h +++ b/Eigen/src/Core/products/SelfadjointMatrixVector.h @@ -86,7 +86,7 @@ static EIGEN_DONT_INLINE void ei_product_selfadjoint_vector( size_t starti = FirstTriangular ? 0 : j+2; size_t endi = FirstTriangular ? j : size; size_t alignedEnd = starti; - size_t alignedStart = (starti) + ei_alignmentOffset(&res[starti], endi-starti); + size_t alignedStart = (starti) + ei_first_aligned(&res[starti], endi-starti); alignedEnd = alignedStart + ((endi-alignedStart)/(PacketSize))*(PacketSize); res[j] += cj0.pmul(A0[j], t0); diff --git a/Eigen/src/Core/products/SelfadjointRank2Update.h b/Eigen/src/Core/products/SelfadjointRank2Update.h index 69cf1896c..1c0e503e6 100644 --- a/Eigen/src/Core/products/SelfadjointRank2Update.h +++ b/Eigen/src/Core/products/SelfadjointRank2Update.h @@ -41,8 +41,8 @@ struct ei_selfadjoint_rank2_update_selector<Scalar,UType,VType,LowerTriangular> for (int i=0; i<size; ++i) { Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i+i, size-i) += - (alpha * ei_conj(u.coeff(i))) * v.end(size-i) - + (alpha * ei_conj(v.coeff(i))) * u.end(size-i); + (alpha * ei_conj(u.coeff(i))) * v.tail(size-i) + + (alpha * ei_conj(v.coeff(i))) * u.tail(size-i); } } }; @@ -55,8 +55,8 @@ struct ei_selfadjoint_rank2_update_selector<Scalar,UType,VType,UpperTriangular> const int size = u.size(); for (int i=0; i<size; ++i) Map<Matrix<Scalar,Dynamic,1> >(mat+stride*i, i+1) += - (alpha * ei_conj(u.coeff(i))) * v.start(i+1) - + (alpha * ei_conj(v.coeff(i))) * u.start(i+1); + (alpha * ei_conj(u.coeff(i))) * v.head(i+1) + + (alpha * ei_conj(v.coeff(i))) * u.head(i+1); } }; diff --git a/Eigen/src/Core/util/BlasUtil.h b/Eigen/src/Core/util/BlasUtil.h index fa21ceebb..916a125e3 100644 --- a/Eigen/src/Core/util/BlasUtil.h +++ b/Eigen/src/Core/util/BlasUtil.h @@ -223,7 +223,8 @@ struct ei_blas_traits<Transpose<NestedXpr> > typedef typename NestedXpr::Scalar Scalar; typedef ei_blas_traits<NestedXpr> Base; typedef Transpose<NestedXpr> XprType; - typedef Transpose<typename Base::_ExtractType> ExtractType; + typedef Transpose<typename Base::_ExtractType> ExtractType; + typedef Transpose<typename Base::_ExtractType> _ExtractType; typedef typename ei_meta_if<int(Base::ActualAccess)==HasDirectAccess, ExtractType, typename ExtractType::PlainMatrixType diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 524bec2fc..bfc6ff686 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -209,27 +209,53 @@ template<typename T, bool Align> inline void ei_conditional_aligned_delete(T *pt ei_conditional_aligned_free<Align>(ptr); } -/** \internal \returns the number of elements which have to be skipped to - * find the first 16-byte aligned element +/** \internal \returns the index of the first element of the array that is well aligned for vectorization. * - * There is also the variant ei_alignmentOffset(const MatrixBase&, Integer) defined in Coeffs.h. + * \param array the address of the start of the array + * \param size the size of the array + * + * \note If no element of the array is well aligned, the size of the array is returned. Typically, + * for example with SSE, "well aligned" means 16-byte-aligned. If vectorization is disabled or if the + * packet size for the given scalar type is 1, then everything is considered well-aligned. + * + * \note If the scalar type is vectorizable, we rely on the following assumptions: sizeof(Scalar) is a + * power of 2, the packet size in bytes is also a power of 2, and is a multiple of sizeof(Scalar). On the + * other hand, we do not assume that the array address is a multiple of sizeof(Scalar), as that fails for + * example with Scalar=double on certain 32-bit platforms, see bug #79. + * + * There is also the variant ei_first_aligned(const MatrixBase&, Integer) defined in Coeffs.h. */ template<typename Scalar, typename Integer> -inline static Integer ei_alignmentOffset(const Scalar* ptr, Integer maxOffset) +inline static Integer ei_first_aligned(const Scalar* array, Integer size) { typedef typename ei_packet_traits<Scalar>::type Packet; - const Integer PacketSize = ei_packet_traits<Scalar>::size; - const Integer PacketAlignedMask = PacketSize-1; - const bool Vectorized = PacketSize>1; - return Vectorized - ? std::min<Integer>( (PacketSize - (Integer((size_t(ptr)/sizeof(Scalar))) & PacketAlignedMask)) - & PacketAlignedMask, maxOffset) - : 0; + enum { PacketSize = ei_packet_traits<Scalar>::size, + PacketAlignedMask = PacketSize-1 + }; + + if(PacketSize==1) + { + // Either there is no vectorization, or a packet consists of exactly 1 scalar so that all elements + // of the array have the same aligment. + return 0; + } + else if(size_t(array) & (sizeof(Scalar)-1)) + { + // There is vectorization for this scalar type, but the array is not aligned to the size of a single scalar. + // Consequently, no element of the array is well aligned. + return size; + } + else + { + return std::min<Integer>( (PacketSize - (Integer((size_t(array)/sizeof(Scalar))) & PacketAlignedMask)) + & PacketAlignedMask, size); + } } /** \internal * ei_aligned_stack_alloc(SIZE) allocates an aligned buffer of SIZE bytes - * on the stack if SIZE is smaller than EIGEN_STACK_ALLOCATION_LIMIT. + * on the stack if SIZE is smaller than EIGEN_STACK_ALLOCATION_LIMIT, and + * if stack allocation is supported by the platform (currently, this is linux only). * Otherwise the memory is allocated on the heap. * Data allocated with ei_aligned_stack_alloc \b must be freed by calling ei_aligned_stack_free(PTR,SIZE). * \code @@ -381,10 +407,10 @@ public: ei_aligned_free( p ); } - bool operator!=(const aligned_allocator<T>& other) const + bool operator!=(const aligned_allocator<T>& ) const { return false; } - bool operator==(const aligned_allocator<T>& other) const + bool operator==(const aligned_allocator<T>& ) const { return true; } }; diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 6d4a5c7bc..4bff09252 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -109,23 +109,6 @@ template<int _Rows, int _Cols> struct ei_size_at_compile_time * whereas ei_eval is a const reference in the case of a matrix */ -// template<typename Derived> class MatrixBase; -// template<typename Derived> class ArrayBase; -// template<typename Object> struct ei_is_matrix_or_array -// { -// struct is_matrix {int a[1];}; -// struct is_array {int a[2];}; -// struct is_none {int a[3];}; -// -// template<typename T> -// static is_matrix testBaseClass(const MatrixBase<T>*); -// template<typename T> -// static is_array testBaseClass(const ArrayBase<T>*); -// // static is_none testBaseClass(...); -// -// enum {BaseClassType = sizeof(testBaseClass(static_cast<const Object*>(0)))}; -// }; - template<typename T, typename StorageType = typename ei_traits<T>::StorageType> class ei_plain_matrix_type; template<typename T, typename BaseClassType> struct ei_plain_matrix_type_dense; template<typename T> struct ei_plain_matrix_type<T,Dense> diff --git a/Eigen/src/Eigen2Support/VectorBlock.h b/Eigen/src/Eigen2Support/VectorBlock.h new file mode 100644 index 000000000..c3be84c9b --- /dev/null +++ b/Eigen/src/Eigen2Support/VectorBlock.h @@ -0,0 +1,105 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. +// +// Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr> +// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com> +// +// Eigen is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 3 of the License, or (at your option) any later version. +// +// Alternatively, you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 2 of +// the License, or (at your option) any later version. +// +// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License and a copy of the GNU General Public License along with +// Eigen. If not, see <http://www.gnu.org/licenses/>. + +#ifndef EIGEN_VECTORBLOCK2_H +#define EIGEN_VECTORBLOCK2_H + +/** \deprecated use DenseMase::start(int) */ +template<typename Derived> +inline VectorBlock<Derived> +MatrixBase<Derived>::start(int size) +{ + EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) + return VectorBlock<Derived>(derived(), 0, size); +} + +/** \deprecated use DenseMase::start(int) */ +template<typename Derived> +inline const VectorBlock<Derived> +MatrixBase<Derived>::start(int size) const +{ + EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) + return VectorBlock<Derived>(derived(), 0, size); +} + +/** \deprecated use DenseMase::end(int) */ +template<typename Derived> +inline VectorBlock<Derived> +MatrixBase<Derived>::end(int size) +{ + EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) + return VectorBlock<Derived>(derived(), this->size() - size, size); +} + +/** \deprecated use DenseMase::end(int) */ +template<typename Derived> +inline const VectorBlock<Derived> +MatrixBase<Derived>::end(int size) const +{ + EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) + return VectorBlock<Derived>(derived(), this->size() - size, size); +} + +/** \deprecated use DenseMase::start() */ +template<typename Derived> +template<int Size> +inline VectorBlock<Derived,Size> +MatrixBase<Derived>::start() +{ + EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) + return VectorBlock<Derived,Size>(derived(), 0); +} + +/** \deprecated use DenseMase::start() */ +template<typename Derived> +template<int Size> +inline const VectorBlock<Derived,Size> +MatrixBase<Derived>::start() const +{ + EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) + return VectorBlock<Derived,Size>(derived(), 0); +} + +/** \deprecated use DenseMase::end() */ +template<typename Derived> +template<int Size> +inline VectorBlock<Derived,Size> +MatrixBase<Derived>::end() +{ + EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) + return VectorBlock<Derived, Size>(derived(), size() - Size); +} + +/** \deprecated use DenseMase::end() */ +template<typename Derived> +template<int Size> +inline const VectorBlock<Derived,Size> +MatrixBase<Derived>::end() const +{ + EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived) + return VectorBlock<Derived, Size>(derived(), size() - Size); +} + +#endif // EIGEN_VECTORBLOCK2_H diff --git a/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/Eigen/src/Eigenvalues/ComplexEigenSolver.h index 0441d4f02..d55dc2a96 100644 --- a/Eigen/src/Eigenvalues/ComplexEigenSolver.h +++ b/Eigen/src/Eigenvalues/ComplexEigenSolver.h @@ -133,7 +133,7 @@ void ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix) for (int i=0; i<n; i++) { int k; - m_eivalues.cwiseAbs().end(n-i).minCoeff(&k); + m_eivalues.cwiseAbs().tail(n-i).minCoeff(&k); if (k != 0) { k += i; diff --git a/Eigen/src/Eigenvalues/EigenSolver.h b/Eigen/src/Eigenvalues/EigenSolver.h index c9c239b98..3f9e30a6e 100644 --- a/Eigen/src/Eigenvalues/EigenSolver.h +++ b/Eigen/src/Eigenvalues/EigenSolver.h @@ -620,7 +620,7 @@ void EigenSolver<MatrixType>::hqr2(MatrixType& matH) // Overflow control t = ei_abs(matH.coeff(i,n)); if ((eps * t) * t > 1) - matH.col(n).end(nn-i) /= t; + matH.col(n).tail(nn-i) /= t; } } } @@ -708,7 +708,7 @@ void EigenSolver<MatrixType>::hqr2(MatrixType& matH) // in this algo low==0 and high==nn-1 !! if (i < low || i > high) { - m_eivec.row(i).end(nn-i) = matH.row(i).end(nn-i); + m_eivec.row(i).tail(nn-i) = matH.row(i).tail(nn-i); } } diff --git a/Eigen/src/Eigenvalues/HessenbergDecomposition.h b/Eigen/src/Eigenvalues/HessenbergDecomposition.h index 9f7df49bc..636b2f4f7 100644 --- a/Eigen/src/Eigenvalues/HessenbergDecomposition.h +++ b/Eigen/src/Eigenvalues/HessenbergDecomposition.h @@ -1,7 +1,7 @@ // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // -// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr> +// Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr> // // Eigen is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -55,25 +55,23 @@ template<typename _MatrixType> class HessenbergDecomposition }; typedef Matrix<Scalar, SizeMinusOne, 1> CoeffVectorType; - typedef Matrix<RealScalar, Size, 1> DiagonalType; - typedef Matrix<RealScalar, SizeMinusOne, 1> SubDiagonalType; - - typedef typename Diagonal<MatrixType,0>::RealReturnType DiagonalReturnType; - - typedef typename Diagonal< - Block<MatrixType,SizeMinusOne,SizeMinusOne>,0 >::RealReturnType SubDiagonalReturnType; /** This constructor initializes a HessenbergDecomposition object for * further use with HessenbergDecomposition::compute() */ HessenbergDecomposition(int size = Size==Dynamic ? 2 : Size) - : m_matrix(size,size), m_hCoeffs(size-1) - {} + : m_matrix(size,size) + { + if(size>1) + m_hCoeffs.resize(size-1); + } HessenbergDecomposition(const MatrixType& matrix) - : m_matrix(matrix), - m_hCoeffs(matrix.cols()-1) + : m_matrix(matrix) { + if(matrix.rows()<2) + return; + m_hCoeffs.resize(matrix.rows()-1,1); _compute(m_matrix, m_hCoeffs); } @@ -84,6 +82,8 @@ template<typename _MatrixType> class HessenbergDecomposition void compute(const MatrixType& matrix) { m_matrix = matrix; + if(matrix.rows()<2) + return; m_hCoeffs.resize(matrix.rows()-1,1); _compute(m_matrix, m_hCoeffs); } @@ -150,7 +150,7 @@ void HessenbergDecomposition<MatrixType>::_compute(MatrixType& matA, CoeffVector int remainingSize = n-i-1; RealScalar beta; Scalar h; - matA.col(i).end(remainingSize).makeHouseholderInPlace(h, beta); + matA.col(i).tail(remainingSize).makeHouseholderInPlace(h, beta); matA.col(i).coeffRef(i+1) = beta; hCoeffs.coeffRef(i) = h; @@ -159,11 +159,11 @@ void HessenbergDecomposition<MatrixType>::_compute(MatrixType& matA, CoeffVector // A = H A matA.corner(BottomRight, remainingSize, remainingSize) - .applyHouseholderOnTheLeft(matA.col(i).end(remainingSize-1), h, &temp.coeffRef(0)); + .applyHouseholderOnTheLeft(matA.col(i).tail(remainingSize-1), h, &temp.coeffRef(0)); // A = A H' matA.corner(BottomRight, n, remainingSize) - .applyHouseholderOnTheRight(matA.col(i).end(remainingSize-1).conjugate(), ei_conj(h), &temp.coeffRef(0)); + .applyHouseholderOnTheRight(matA.col(i).tail(remainingSize-1).conjugate(), ei_conj(h), &temp.coeffRef(0)); } } @@ -178,7 +178,7 @@ HessenbergDecomposition<MatrixType>::matrixQ() const for (int i = n-2; i>=0; i--) { matQ.corner(BottomRight,n-i-1,n-i-1) - .applyHouseholderOnTheLeft(m_matrix.col(i).end(n-i-2), ei_conj(m_hCoeffs.coeff(i)), &temp.coeffRef(0,0)); + .applyHouseholderOnTheLeft(m_matrix.col(i).tail(n-i-2), ei_conj(m_hCoeffs.coeff(i)), &temp.coeffRef(0,0)); } return matQ; } diff --git a/Eigen/src/Eigenvalues/Tridiagonalization.h b/Eigen/src/Eigenvalues/Tridiagonalization.h index d8dcfb047..e43605b0f 100644 --- a/Eigen/src/Eigenvalues/Tridiagonalization.h +++ b/Eigen/src/Eigenvalues/Tridiagonalization.h @@ -197,25 +197,24 @@ void Tridiagonalization<MatrixType>::_compute(MatrixType& matA, CoeffVectorType& { assert(matA.rows()==matA.cols()); int n = matA.rows(); - Matrix<Scalar,1,Dynamic> aux(n); for (int i = 0; i<n-1; ++i) { int remainingSize = n-i-1; RealScalar beta; Scalar h; - matA.col(i).end(remainingSize).makeHouseholderInPlace(h, beta); + matA.col(i).tail(remainingSize).makeHouseholderInPlace(h, beta); // Apply similarity transformation to remaining columns, - // i.e., A = H A H' where H = I - h v v' and v = matA.col(i).end(n-i-1) + // i.e., A = H A H' where H = I - h v v' and v = matA.col(i).tail(n-i-1) matA.col(i).coeffRef(i+1) = 1; - hCoeffs.end(n-i-1) = (matA.corner(BottomRight,remainingSize,remainingSize).template selfadjointView<LowerTriangular>() - * (ei_conj(h) * matA.col(i).end(remainingSize))); + hCoeffs.tail(n-i-1) = (matA.corner(BottomRight,remainingSize,remainingSize).template selfadjointView<LowerTriangular>() + * (ei_conj(h) * matA.col(i).tail(remainingSize))); - hCoeffs.end(n-i-1) += (ei_conj(h)*Scalar(-0.5)*(hCoeffs.end(remainingSize).dot(matA.col(i).end(remainingSize)))) * matA.col(i).end(n-i-1); + hCoeffs.tail(n-i-1) += (ei_conj(h)*Scalar(-0.5)*(hCoeffs.tail(remainingSize).dot(matA.col(i).tail(remainingSize)))) * matA.col(i).tail(n-i-1); matA.corner(BottomRight, remainingSize, remainingSize).template selfadjointView<LowerTriangular>() - .rankUpdate(matA.col(i).end(remainingSize), hCoeffs.end(remainingSize), -1); + .rankUpdate(matA.col(i).tail(remainingSize), hCoeffs.tail(remainingSize), -1); matA.col(i).coeffRef(i+1) = beta; hCoeffs.coeffRef(i) = h; @@ -243,7 +242,7 @@ void Tridiagonalization<MatrixType>::matrixQInPlace(MatrixBase<QDerived>* q) con for (int i = n-2; i>=0; i--) { matQ.corner(BottomRight,n-i-1,n-i-1) - .applyHouseholderOnTheLeft(m_matrix.col(i).end(n-i-2), ei_conj(m_hCoeffs.coeff(i)), &aux.coeffRef(0,0)); + .applyHouseholderOnTheLeft(m_matrix.col(i).tail(n-i-2), ei_conj(m_hCoeffs.coeff(i)), &aux.coeffRef(0,0)); } } diff --git a/Eigen/src/Geometry/OrthoMethods.h b/Eigen/src/Geometry/OrthoMethods.h index 79baeadd5..c10b6abf4 100644 --- a/Eigen/src/Geometry/OrthoMethods.h +++ b/Eigen/src/Geometry/OrthoMethods.h @@ -173,7 +173,7 @@ struct ei_unitOrthogonal_selector<Derived,3> if((!ei_isMuchSmallerThan(src.x(), src.z())) || (!ei_isMuchSmallerThan(src.y(), src.z()))) { - RealScalar invnm = RealScalar(1)/src.template start<2>().norm(); + RealScalar invnm = RealScalar(1)/src.template head<2>().norm(); perp.coeffRef(0) = -ei_conj(src.y())*invnm; perp.coeffRef(1) = ei_conj(src.x())*invnm; perp.coeffRef(2) = 0; @@ -184,7 +184,7 @@ struct ei_unitOrthogonal_selector<Derived,3> */ else { - RealScalar invnm = RealScalar(1)/src.template end<2>().norm(); + RealScalar invnm = RealScalar(1)/src.template tail<2>().norm(); perp.coeffRef(0) = 0; perp.coeffRef(1) = -ei_conj(src.z())*invnm; perp.coeffRef(2) = ei_conj(src.y())*invnm; diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 861eff19c..24772089e 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -77,10 +77,10 @@ public: inline Scalar& w() { return this->derived().coeffs().coeffRef(3); } /** \returns a read-only vector expression of the imaginary part (x,y,z) */ - inline const VectorBlock<Coefficients,3> vec() const { return coeffs().template start<3>(); } + inline const VectorBlock<Coefficients,3> vec() const { return coeffs().template head<3>(); } /** \returns a vector expression of the imaginary part (x,y,z) */ - inline VectorBlock<Coefficients,3> vec() { return coeffs().template start<3>(); } + inline VectorBlock<Coefficients,3> vec() { return coeffs().template head<3>(); } /** \returns a read-only vector expression of the coefficients (x,y,z,w) */ inline const typename ei_traits<Derived>::Coefficients& coeffs() const { return derived().coeffs(); } diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h index 89df73505..b945ea43f 100644 --- a/Eigen/src/Geometry/Transform.h +++ b/Eigen/src/Geometry/Transform.h @@ -1102,7 +1102,7 @@ struct ei_transform_right_product_impl<Other,AffineCompact, Dim,HDim, HDim,1> static ResultType run(const TransformType& tr, const Other& other) { ResultType res; - res.template start<HDim>() = tr.matrix() * other; + res.template head<HDim>() = tr.matrix() * other; res.coeffRef(Dim) = other.coeff(Dim); } }; @@ -1120,7 +1120,7 @@ struct ei_transform_right_product_impl<Other,Mode, Dim,HDim, Dim,Dim> res.matrix().col(Dim) = tr.matrix().col(Dim); res.linearExt().noalias() = (tr.linearExt() * other); if(Mode==Affine) - res.matrix().row(Dim).template start<Dim>() = tr.matrix().row(Dim).template start<Dim>(); + res.matrix().row(Dim).template head<Dim>() = tr.matrix().row(Dim).template head<Dim>(); return res; } }; diff --git a/Eigen/src/Geometry/Umeyama.h b/Eigen/src/Geometry/Umeyama.h index 551a69e5b..5be098d77 100644 --- a/Eigen/src/Geometry/Umeyama.h +++ b/Eigen/src/Geometry/Umeyama.h @@ -170,8 +170,8 @@ umeyama(const MatrixBase<Derived>& src, const MatrixBase<OtherDerived>& dst, boo // Eq. (41) // Note that we first assign dst_mean to the destination so that there no need // for a temporary. - Rt.col(m).start(m) = dst_mean; - Rt.col(m).start(m).noalias() -= c*Rt.corner(TopLeft,m,m)*src_mean; + Rt.col(m).head(m) = dst_mean; + Rt.col(m).head(m).noalias() -= c*Rt.corner(TopLeft,m,m)*src_mean; if (with_scaling) Rt.block(0,0,m,m) *= c; diff --git a/Eigen/src/Householder/HouseholderSequence.h b/Eigen/src/Householder/HouseholderSequence.h index 25e962001..26e0f6a88 100644 --- a/Eigen/src/Householder/HouseholderSequence.h +++ b/Eigen/src/Householder/HouseholderSequence.h @@ -105,10 +105,10 @@ template<typename VectorsType, typename CoeffsType> class HouseholderSequence { if(m_trans) dst.corner(BottomRight, length-k, length-k) - .applyHouseholderOnTheRight(m_vectors.col(k).end(length-k-1), m_coeffs.coeff(k), &temp.coeffRef(0)); + .applyHouseholderOnTheRight(m_vectors.col(k).tail(length-k-1), m_coeffs.coeff(k), &temp.coeffRef(0)); else dst.corner(BottomRight, length-k, length-k) - .applyHouseholderOnTheLeft(m_vectors.col(k).end(length-k-1), m_coeffs.coeff(k), &temp.coeffRef(k)); + .applyHouseholderOnTheLeft(m_vectors.col(k).tail(length-k-1), m_coeffs.coeff(k), &temp.coeffRef(k)); } } @@ -122,7 +122,7 @@ template<typename VectorsType, typename CoeffsType> class HouseholderSequence { int actual_k = m_trans ? vecs-k-1 : k; dst.corner(BottomRight, dst.rows(), length-actual_k) - .applyHouseholderOnTheRight(m_vectors.col(actual_k).end(length-actual_k-1), m_coeffs.coeff(actual_k), &temp.coeffRef(0)); + .applyHouseholderOnTheRight(m_vectors.col(actual_k).tail(length-actual_k-1), m_coeffs.coeff(actual_k), &temp.coeffRef(0)); } } @@ -136,7 +136,7 @@ template<typename VectorsType, typename CoeffsType> class HouseholderSequence { int actual_k = m_trans ? k : vecs-k-1; dst.corner(BottomRight, length-actual_k, dst.cols()) - .applyHouseholderOnTheLeft(m_vectors.col(actual_k).end(length-actual_k-1), m_coeffs.coeff(actual_k), &temp.coeffRef(0)); + .applyHouseholderOnTheLeft(m_vectors.col(actual_k).tail(length-actual_k-1), m_coeffs.coeff(actual_k), &temp.coeffRef(0)); } } diff --git a/Eigen/src/Jacobi/Jacobi.h b/Eigen/src/Jacobi/Jacobi.h index 727c97583..024a130f2 100644 --- a/Eigen/src/Jacobi/Jacobi.h +++ b/Eigen/src/Jacobi/Jacobi.h @@ -318,7 +318,7 @@ void /*EIGEN_DONT_INLINE*/ ei_apply_rotation_in_the_plane(VectorX& _x, VectorY& typedef typename ei_packet_traits<Scalar>::type Packet; enum { PacketSize = ei_packet_traits<Scalar>::size, Peeling = 2 }; - int alignedStart = ei_alignmentOffset(y, size); + int alignedStart = ei_first_aligned(y, size); int alignedEnd = alignedStart + ((size-alignedStart)/PacketSize)*PacketSize; const Packet pc = ei_pset1(Scalar(j.c())); @@ -336,7 +336,7 @@ void /*EIGEN_DONT_INLINE*/ ei_apply_rotation_in_the_plane(VectorX& _x, VectorY& Scalar* px = x + alignedStart; Scalar* py = y + alignedStart; - if(ei_alignmentOffset(x, size)==alignedStart) + if(ei_first_aligned(x, size)==alignedStart) { for(int i=alignedStart; i<alignedEnd; i+=PacketSize) { diff --git a/Eigen/src/LU/FullPivLU.h b/Eigen/src/LU/FullPivLU.h index 149af64bc..f62dcc1db 100644 --- a/Eigen/src/LU/FullPivLU.h +++ b/Eigen/src/LU/FullPivLU.h @@ -451,9 +451,9 @@ FullPivLU<MatrixType>& FullPivLU<MatrixType>::compute(const MatrixType& matrix) // bottom-right corner by Gaussian elimination. if(k<rows-1) - m_lu.col(k).end(rows-k-1) /= m_lu.coeff(k,k); + m_lu.col(k).tail(rows-k-1) /= m_lu.coeff(k,k); if(k<size-1) - m_lu.block(k+1,k+1,rows-k-1,cols-k-1).noalias() -= m_lu.col(k).end(rows-k-1) * m_lu.row(k).end(cols-k-1); + m_lu.block(k+1,k+1,rows-k-1,cols-k-1).noalias() -= m_lu.col(k).tail(rows-k-1) * m_lu.row(k).tail(cols-k-1); } // the main loop is over, we still have to accumulate the transpositions to find the @@ -537,8 +537,8 @@ struct ei_kernel_retval<FullPivLU<_MatrixType> > m(dec().matrixLU().block(0, 0, rank(), cols)); for(int i = 0; i < rank(); ++i) { - if(i) m.row(i).start(i).setZero(); - m.row(i).end(cols-i) = dec().matrixLU().row(pivots.coeff(i)).end(cols-i); + if(i) m.row(i).head(i).setZero(); + m.row(i).tail(cols-i) = dec().matrixLU().row(pivots.coeff(i)).tail(cols-i); } m.block(0, 0, rank(), rank()); m.block(0, 0, rank(), rank()).template triangularView<StrictlyLowerTriangular>().setZero(); @@ -558,7 +558,7 @@ struct ei_kernel_retval<FullPivLU<_MatrixType> > m.col(i).swap(m.col(pivots.coeff(i))); // see the negative sign in the next line, that's what we were talking about above. - for(int i = 0; i < rank(); ++i) dst.row(dec().permutationQ().indices().coeff(i)) = -m.row(i).end(dimker); + for(int i = 0; i < rank(); ++i) dst.row(dec().permutationQ().indices().coeff(i)) = -m.row(i).tail(dimker); for(int i = rank(); i < cols; ++i) dst.row(dec().permutationQ().indices().coeff(i)).setZero(); for(int k = 0; k < dimker; ++k) dst.coeffRef(dec().permutationQ().indices().coeff(rank()+k), k) = Scalar(1); } diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index deb29b5c6..6bb5c3ac7 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -229,7 +229,7 @@ struct ei_partial_lu_impl { int row_of_biggest_in_col; RealScalar biggest_in_corner - = lu.col(k).end(rows-k).cwiseAbs().maxCoeff(&row_of_biggest_in_col); + = lu.col(k).tail(rows-k).cwiseAbs().maxCoeff(&row_of_biggest_in_col); row_of_biggest_in_col += k; if(biggest_in_corner == 0) // the pivot is exactly zero: the matrix is singular @@ -256,8 +256,8 @@ struct ei_partial_lu_impl { int rrows = rows-k-1; int rsize = size-k-1; - lu.col(k).end(rrows) /= lu.coeff(k,k); - lu.corner(BottomRight,rrows,rsize).noalias() -= lu.col(k).end(rrows) * lu.row(k).end(rsize); + lu.col(k).tail(rrows) /= lu.coeff(k,k); + lu.corner(BottomRight,rrows,rsize).noalias() -= lu.col(k).tail(rrows) * lu.row(k).tail(rsize); } } return true; diff --git a/Eigen/src/QR/ColPivHouseholderQR.h b/Eigen/src/QR/ColPivHouseholderQR.h index b4c1a5fcc..8b705de3c 100644 --- a/Eigen/src/QR/ColPivHouseholderQR.h +++ b/Eigen/src/QR/ColPivHouseholderQR.h @@ -359,14 +359,14 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const { // first, we look up in our table colSqNorms which column has the biggest squared norm int biggest_col_index; - RealScalar biggest_col_sq_norm = colSqNorms.end(cols-k).maxCoeff(&biggest_col_index); + RealScalar biggest_col_sq_norm = colSqNorms.tail(cols-k).maxCoeff(&biggest_col_index); biggest_col_index += k; // since our table colSqNorms accumulates imprecision at every step, we must now recompute // the actual squared norm of the selected column. // Note that not doing so does result in solve() sometimes returning inf/nan values // when running the unit test with 1000 repetitions. - biggest_col_sq_norm = m_qr.col(biggest_col_index).end(rows-k).squaredNorm(); + biggest_col_sq_norm = m_qr.col(biggest_col_index).tail(rows-k).squaredNorm(); // we store that back into our table: it can't hurt to correct our table. colSqNorms.coeffRef(biggest_col_index) = biggest_col_sq_norm; @@ -379,7 +379,7 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const if(biggest_col_sq_norm < threshold_helper * (rows-k)) { m_nonzero_pivots = k; - m_hCoeffs.end(size-k).setZero(); + m_hCoeffs.tail(size-k).setZero(); m_qr.corner(BottomRight,rows-k,cols-k) .template triangularView<StrictlyLowerTriangular>() .setZero(); @@ -396,7 +396,7 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const // generate the householder vector, store it below the diagonal RealScalar beta; - m_qr.col(k).end(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta); + m_qr.col(k).tail(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta); // apply the householder transformation to the diagonal coefficient m_qr.coeffRef(k,k) = beta; @@ -406,10 +406,10 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const // apply the householder transformation m_qr.corner(BottomRight, rows-k, cols-k-1) - .applyHouseholderOnTheLeft(m_qr.col(k).end(rows-k-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1)); + .applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1)); // update our table of squared norms of the columns - colSqNorms.end(cols-k-1) -= m_qr.row(k).end(cols-k-1).cwiseAbs2(); + colSqNorms.tail(cols-k-1) -= m_qr.row(k).tail(cols-k-1).cwiseAbs2(); } m_cols_permutation.setIdentity(cols); @@ -427,7 +427,7 @@ struct ei_solve_retval<ColPivHouseholderQR<_MatrixType>, Rhs> : ei_solve_retval_base<ColPivHouseholderQR<_MatrixType>, Rhs> { EIGEN_MAKE_SOLVE_HELPERS(ColPivHouseholderQR<_MatrixType>,Rhs) - + template<typename Dest> void evalTo(Dest& dst) const { const int rows = dec().rows(), cols = dec().cols(), diff --git a/Eigen/src/QR/FullPivHouseholderQR.h b/Eigen/src/QR/FullPivHouseholderQR.h index 51609ca1a..598f44dc3 100644 --- a/Eigen/src/QR/FullPivHouseholderQR.h +++ b/Eigen/src/QR/FullPivHouseholderQR.h @@ -306,7 +306,7 @@ FullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(cons m_rows_transpositions.coeffRef(k) = row_of_biggest_in_corner; cols_transpositions.coeffRef(k) = col_of_biggest_in_corner; if(k != row_of_biggest_in_corner) { - m_qr.row(k).end(cols-k).swap(m_qr.row(row_of_biggest_in_corner).end(cols-k)); + m_qr.row(k).tail(cols-k).swap(m_qr.row(row_of_biggest_in_corner).tail(cols-k)); ++number_of_transpositions; } if(k != col_of_biggest_in_corner) { @@ -315,11 +315,11 @@ FullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(cons } RealScalar beta; - m_qr.col(k).end(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta); + m_qr.col(k).tail(rows-k).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta); m_qr.coeffRef(k,k) = beta; m_qr.corner(BottomRight, rows-k, cols-k-1) - .applyHouseholderOnTheLeft(m_qr.col(k).end(rows-k-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1)); + .applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1)); } m_cols_permutation.setIdentity(cols); @@ -360,7 +360,7 @@ struct ei_solve_retval<FullPivHouseholderQR<_MatrixType>, Rhs> int remainingSize = rows-k; c.row(k).swap(c.row(dec().rowsTranspositions().coeff(k))); c.corner(BottomRight, remainingSize, rhs().cols()) - .applyHouseholderOnTheLeft(dec().matrixQR().col(k).end(remainingSize-1), + .applyHouseholderOnTheLeft(dec().matrixQR().col(k).tail(remainingSize-1), dec().hCoeffs().coeff(k), &temp.coeffRef(0)); } @@ -400,7 +400,7 @@ typename FullPivHouseholderQR<MatrixType>::MatrixQType FullPivHouseholderQR<Matr for (int k = size-1; k >= 0; k--) { res.block(k, k, rows-k, rows-k) - .applyHouseholderOnTheLeft(m_qr.col(k).end(rows-k-1), ei_conj(m_hCoeffs.coeff(k)), &temp.coeffRef(k)); + .applyHouseholderOnTheLeft(m_qr.col(k).tail(rows-k-1), ei_conj(m_hCoeffs.coeff(k)), &temp.coeffRef(k)); res.row(k).swap(res.row(m_rows_transpositions.coeff(k))); } return res; diff --git a/Eigen/src/QR/HouseholderQR.h b/Eigen/src/QR/HouseholderQR.h index 895ae046a..24aa96e04 100644 --- a/Eigen/src/QR/HouseholderQR.h +++ b/Eigen/src/QR/HouseholderQR.h @@ -197,12 +197,12 @@ HouseholderQR<MatrixType>& HouseholderQR<MatrixType>::compute(const MatrixType& int remainingCols = cols - k - 1; RealScalar beta; - m_qr.col(k).end(remainingRows).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta); + m_qr.col(k).tail(remainingRows).makeHouseholderInPlace(m_hCoeffs.coeffRef(k), beta); m_qr.coeffRef(k,k) = beta; // apply H to remaining part of m_qr from the left m_qr.corner(BottomRight, remainingRows, remainingCols) - .applyHouseholderOnTheLeft(m_qr.col(k).end(remainingRows-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1)); + .applyHouseholderOnTheLeft(m_qr.col(k).tail(remainingRows-1), m_hCoeffs.coeffRef(k), &temp.coeffRef(k+1)); } m_isInitialized = true; return *this; @@ -226,7 +226,7 @@ struct ei_solve_retval<HouseholderQR<_MatrixType>, Rhs> // Note that the matrix Q = H_0^* H_1^*... so its inverse is Q^* = (H_0 H_1 ...)^T c.applyOnTheLeft(householderSequence( dec().matrixQR().corner(TopLeft,rows,rank), - dec().hCoeffs().start(rank)).transpose() + dec().hCoeffs().head(rank)).transpose() ); dec().matrixQR() diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index 5792c5767..d2cd8e478 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -342,7 +342,7 @@ JacobiSVD<MatrixType, Options>& JacobiSVD<MatrixType, Options>::compute(const Ma for(int i = 0; i < diagSize; i++) { int pos; - m_singularValues.end(diagSize-i).maxCoeff(&pos); + m_singularValues.tail(diagSize-i).maxCoeff(&pos); if(pos) { pos += i; diff --git a/Eigen/src/SVD/SVD.h b/Eigen/src/SVD/SVD.h index 7a8e4f312..cd8c11b8d 100644 --- a/Eigen/src/SVD/SVD.h +++ b/Eigen/src/SVD/SVD.h @@ -137,7 +137,7 @@ template<typename _MatrixType> class SVD ei_assert(m_isInitialized && "SVD is not initialized."); return m_cols; } - + protected: // Computes (a^2 + b^2)^(1/2) without destructive underflow or overflow. inline static Scalar pythag(Scalar a, Scalar b) @@ -205,7 +205,7 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix) g = s = scale = 0.0; if (i < m) { - scale = A.col(i).end(m-i).cwiseAbs().sum(); + scale = A.col(i).tail(m-i).cwiseAbs().sum(); if (scale != Scalar(0)) { for (k=i; k<m; k++) @@ -219,18 +219,18 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix) A(i, i)=f-g; for (j=l-1; j<n; j++) { - s = A.col(j).end(m-i).dot(A.col(i).end(m-i)); + s = A.col(j).tail(m-i).dot(A.col(i).tail(m-i)); f = s/h; - A.col(j).end(m-i) += f*A.col(i).end(m-i); + A.col(j).tail(m-i) += f*A.col(i).tail(m-i); } - A.col(i).end(m-i) *= scale; + A.col(i).tail(m-i) *= scale; } } W[i] = scale * g; g = s = scale = 0.0; if (i+1 <= m && i+1 != n) { - scale = A.row(i).end(n-l+1).cwiseAbs().sum(); + scale = A.row(i).tail(n-l+1).cwiseAbs().sum(); if (scale != Scalar(0)) { for (k=l-1; k<n; k++) @@ -242,13 +242,13 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix) g = -sign(ei_sqrt(s),f); h = f*g - s; A(i,l-1) = f-g; - rv1.end(n-l+1) = A.row(i).end(n-l+1)/h; + rv1.tail(n-l+1) = A.row(i).tail(n-l+1)/h; for (j=l-1; j<m; j++) { - s = A.row(i).end(n-l+1).dot(A.row(j).end(n-l+1)); - A.row(j).end(n-l+1) += s*rv1.end(n-l+1).transpose(); + s = A.row(i).tail(n-l+1).dot(A.row(j).tail(n-l+1)); + A.row(j).tail(n-l+1) += s*rv1.tail(n-l+1).transpose(); } - A.row(i).end(n-l+1) *= scale; + A.row(i).tail(n-l+1) *= scale; } } anorm = std::max( anorm, (ei_abs(W[i])+ei_abs(rv1[i])) ); @@ -265,12 +265,12 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix) V(j, i) = (A(i, j)/A(i, l))/g; for (j=l; j<n; j++) { - s = V.col(j).end(n-l).dot(A.row(i).end(n-l)); - V.col(j).end(n-l) += s * V.col(i).end(n-l); + s = V.col(j).tail(n-l).dot(A.row(i).tail(n-l)); + V.col(j).tail(n-l) += s * V.col(i).tail(n-l); } } - V.row(i).end(n-l).setZero(); - V.col(i).end(n-l).setZero(); + V.row(i).tail(n-l).setZero(); + V.col(i).tail(n-l).setZero(); } V(i, i) = 1.0; g = rv1[i]; @@ -282,7 +282,7 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix) l = i+1; g = W[i]; if (n-l>0) - A.row(i).end(n-l).setZero(); + A.row(i).tail(n-l).setZero(); if (g != Scalar(0.0)) { g = Scalar(1.0)/g; @@ -290,15 +290,15 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix) { for (j=l; j<n; j++) { - s = A.col(j).end(m-l).dot(A.col(i).end(m-l)); + s = A.col(j).tail(m-l).dot(A.col(i).tail(m-l)); f = (s/A(i,i))*g; - A.col(j).end(m-i) += f * A.col(i).end(m-i); + A.col(j).tail(m-i) += f * A.col(i).tail(m-i); } } - A.col(i).end(m-i) *= g; + A.col(i).tail(m-i) *= g; } else - A.col(i).end(m-i).setZero(); + A.col(i).tail(m-i).setZero(); ++A(i,i); } // Diagonalization of the bidiagonal form: Loop over @@ -408,7 +408,7 @@ SVD<MatrixType>& SVD<MatrixType>::compute(const MatrixType& matrix) for (int i=0; i<n; i++) { int k; - W.end(n-i).maxCoeff(&k); + W.tail(n-i).maxCoeff(&k); if (k != 0) { k += i; @@ -451,8 +451,8 @@ struct ei_solve_retval<SVD<_MatrixType>, Rhs> aux.coeffRef(i) /= si; } const int minsize = std::min(dec().rows(),dec().cols()); - dst.col(j).start(minsize) = aux.start(minsize); - if(dec().cols()>dec().rows()) dst.col(j).end(cols()-minsize).setZero(); + dst.col(j).head(minsize) = aux.head(minsize); + if(dec().cols()>dec().rows()) dst.col(j).tail(cols()-minsize).setZero(); dst.col(j) = dec().matrixV() * dst.col(j); } } |