diff options
Diffstat (limited to 'Eigen/src/Core/Diagonal.h')
-rw-r--r-- | Eigen/src/Core/Diagonal.h | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/Eigen/src/Core/Diagonal.h b/Eigen/src/Core/Diagonal.h index b160479ab..33b82f90f 100644 --- a/Eigen/src/Core/Diagonal.h +++ b/Eigen/src/Core/Diagonal.h @@ -52,8 +52,7 @@ struct traits<Diagonal<MatrixType,DiagIndex> > MatrixType::MaxColsAtCompileTime - EIGEN_PLAIN_ENUM_MAX( DiagIndex, 0))), MaxColsAtCompileTime = 1, MaskLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0, - Flags = (unsigned int)_MatrixTypeNested::Flags & (HereditaryBits | LinearAccessBit | MaskLvalueBit | DirectAccessBit) & ~RowMajorBit, - CoeffReadCost = _MatrixTypeNested::CoeffReadCost, + Flags = (unsigned int)_MatrixTypeNested::Flags & (RowMajorBit | MaskLvalueBit | DirectAccessBit) & ~RowMajorBit, // FIXME DirectAccessBit should not be handled by expressions MatrixTypeOuterStride = outer_stride_at_compile_time<MatrixType>::ret, InnerStrideAtCompileTime = MatrixTypeOuterStride == Dynamic ? Dynamic : MatrixTypeOuterStride+1, OuterStrideAtCompileTime = 0 @@ -71,17 +70,15 @@ template<typename MatrixType, int _DiagIndex> class Diagonal EIGEN_DENSE_PUBLIC_INTERFACE(Diagonal) EIGEN_DEVICE_FUNC - inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) : m_matrix(matrix), m_index(a_index) {} + explicit inline Diagonal(MatrixType& matrix, Index a_index = DiagIndex) : m_matrix(matrix), m_index(a_index) {} EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Diagonal) EIGEN_DEVICE_FUNC inline Index rows() const { - EIGEN_USING_STD_MATH(min); - return m_index.value()<0 ? (min)(Index(m_matrix.cols()),Index(m_matrix.rows()+m_index.value())) - : (min)(Index(m_matrix.rows()),Index(m_matrix.cols()-m_index.value())); - + return m_index.value()<0 ? numext::mini(Index(m_matrix.cols()),Index(m_matrix.rows()+m_index.value())) + : numext::mini(Index(m_matrix.rows()),Index(m_matrix.cols()-m_index.value())); } EIGEN_DEVICE_FUNC @@ -149,14 +146,14 @@ template<typename MatrixType, int _DiagIndex> class Diagonal } EIGEN_DEVICE_FUNC - const typename internal::remove_all<typename MatrixType::Nested>::type& + inline const typename internal::remove_all<typename MatrixType::Nested>::type& nestedExpression() const { return m_matrix; } EIGEN_DEVICE_FUNC - int index() const + inline Index index() const { return m_index.value(); } @@ -173,7 +170,7 @@ template<typename MatrixType, int _DiagIndex> class Diagonal EIGEN_STRONG_INLINE Index rowOffset() const { return m_index.value()>0 ? 0 : -m_index.value(); } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index colOffset() const { return m_index.value()>0 ? m_index.value() : 0; } - // triger a compile time error is someone try to call packet + // trigger a compile time error is someone try to call packet template<int LoadMode> typename MatrixType::PacketReturnType packet(Index) const; template<int LoadMode> typename MatrixType::PacketReturnType packet(Index,Index) const; }; @@ -190,7 +187,7 @@ template<typename Derived> inline typename MatrixBase<Derived>::DiagonalReturnType MatrixBase<Derived>::diagonal() { - return derived(); + return DiagonalReturnType(derived()); } /** This is the const version of diagonal(). */ @@ -213,18 +210,18 @@ MatrixBase<Derived>::diagonal() const * * \sa MatrixBase::diagonal(), class Diagonal */ template<typename Derived> -inline typename MatrixBase<Derived>::template DiagonalIndexReturnType<DynamicIndex>::Type +inline typename MatrixBase<Derived>::DiagonalDynamicIndexReturnType MatrixBase<Derived>::diagonal(Index index) { - return typename DiagonalIndexReturnType<DynamicIndex>::Type(derived(), index); + return DiagonalDynamicIndexReturnType(derived(), index); } /** This is the const version of diagonal(Index). */ template<typename Derived> -inline typename MatrixBase<Derived>::template ConstDiagonalIndexReturnType<DynamicIndex>::Type +inline typename MatrixBase<Derived>::ConstDiagonalDynamicIndexReturnType MatrixBase<Derived>::diagonal(Index index) const { - return typename ConstDiagonalIndexReturnType<DynamicIndex>::Type(derived(), index); + return ConstDiagonalDynamicIndexReturnType(derived(), index); } /** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this @@ -239,20 +236,20 @@ MatrixBase<Derived>::diagonal(Index index) const * * \sa MatrixBase::diagonal(), class Diagonal */ template<typename Derived> -template<int Index> -inline typename MatrixBase<Derived>::template DiagonalIndexReturnType<Index>::Type +template<int Index_> +inline typename MatrixBase<Derived>::template DiagonalIndexReturnType<Index_>::Type MatrixBase<Derived>::diagonal() { - return derived(); + return typename DiagonalIndexReturnType<Index_>::Type(derived()); } /** This is the const version of diagonal<int>(). */ template<typename Derived> -template<int Index> -inline typename MatrixBase<Derived>::template ConstDiagonalIndexReturnType<Index>::Type +template<int Index_> +inline typename MatrixBase<Derived>::template ConstDiagonalIndexReturnType<Index_>::Type MatrixBase<Derived>::diagonal() const { - return derived(); + return typename ConstDiagonalIndexReturnType<Index_>::Type(derived()); } } // end namespace Eigen |