From 547269da3560518807efe902bce07d22db03e039 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Fri, 19 Mar 2010 02:12:23 -0400 Subject: [PATCH] fix the flags and matrix options, to always have the right RowMajor bit in the vector case --- Eigen/src/Array/VectorwiseOp.h | 3 +- Eigen/src/Cholesky/LDLT.h | 4 +- Eigen/src/Cholesky/LLT.h | 1 - Eigen/src/Core/Map.h | 4 +- Eigen/src/Core/ProductBase.h | 6 ++- Eigen/src/Core/util/ForwardDeclarations.h | 5 ++- Eigen/src/Core/util/XprHelper.h | 38 ++++++++++++++++--- Eigen/src/Eigenvalues/ComplexEigenSolver.h | 2 +- Eigen/src/Eigenvalues/EigenSolver.h | 4 +- .../src/Eigenvalues/HessenbergDecomposition.h | 4 +- .../src/Eigenvalues/SelfAdjointEigenSolver.h | 2 +- Eigen/src/Eigenvalues/Tridiagonalization.h | 8 ++-- Eigen/src/Householder/Householder.h | 4 +- Eigen/src/LU/FullPivLU.h | 4 +- Eigen/src/LU/PartialPivLU.h | 2 +- Eigen/src/QR/ColPivHouseholderQR.h | 12 +++--- Eigen/src/QR/FullPivHouseholderQR.h | 14 +++---- Eigen/src/QR/HouseholderQR.h | 8 ++-- Eigen/src/SVD/JacobiSVD.h | 7 ++-- Eigen/src/SVD/SVD.h | 6 +-- 20 files changed, 80 insertions(+), 58 deletions(-) diff --git a/Eigen/src/Array/VectorwiseOp.h b/Eigen/src/Array/VectorwiseOp.h index 50cfa7a5e..44fb138f7 100644 --- a/Eigen/src/Array/VectorwiseOp.h +++ b/Eigen/src/Array/VectorwiseOp.h @@ -60,7 +60,8 @@ struct ei_traits > ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime, MaxRowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::MaxRowsAtCompileTime, MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime, - Flags = (unsigned int)_MatrixTypeNested::Flags & HereditaryBits, + Flags0 = (unsigned int)_MatrixTypeNested::Flags & HereditaryBits, + Flags = (Flags0 & ~RowMajorBit) | (RowsAtCompileTime == 1 ? RowMajorBit : 0), TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime }; #if EIGEN_GNUC_AT_LEAST(3,4) diff --git a/Eigen/src/Cholesky/LDLT.h b/Eigen/src/Cholesky/LDLT.h index 1a4a4a8eb..f92a72c7b 100644 --- a/Eigen/src/Cholesky/LDLT.h +++ b/Eigen/src/Cholesky/LDLT.h @@ -65,9 +65,7 @@ template class LDLT }; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Matrix VectorType; - typedef Matrix IntColVectorType; - typedef Matrix IntRowVectorType; + typedef typename ei_plain_col_type::type IntColVectorType; /** \brief Default Constructor. * diff --git a/Eigen/src/Cholesky/LLT.h b/Eigen/src/Cholesky/LLT.h index d552e4e8a..51a0e44ae 100644 --- a/Eigen/src/Cholesky/LLT.h +++ b/Eigen/src/Cholesky/LLT.h @@ -65,7 +65,6 @@ template class LLT }; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Matrix VectorType; enum { PacketSize = ei_packet_traits::size, diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index 0608c784f..04d750a80 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -165,8 +165,8 @@ template class Map StrideType m_stride; }; -template -inline Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> +template +inline Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> ::Matrix(const Scalar *data) { _set_noalias(Eigen::Map(data)); diff --git a/Eigen/src/Core/ProductBase.h b/Eigen/src/Core/ProductBase.h index 789aecfb6..be32189e1 100644 --- a/Eigen/src/Core/ProductBase.h +++ b/Eigen/src/Core/ProductBase.h @@ -42,8 +42,10 @@ struct ei_traits > //: ei_traits::ColsAtCompileTime, MaxRowsAtCompileTime = ei_traits::MaxRowsAtCompileTime, MaxColsAtCompileTime = ei_traits::MaxColsAtCompileTime, - Flags = EvalBeforeNestingBit | EvalBeforeAssigningBit | NestByRefBit, // Note that EvalBeforeNestingBit and NestByRefBit - // are not used in practice because ei_nested is overloaded for products + Flags = (RowsAtCompileTime==1 ? RowMajorBit : 0) + | EvalBeforeNestingBit | EvalBeforeAssigningBit | NestByRefBit, + // Note that EvalBeforeNestingBit and NestByRefBit + // are not used in practice because ei_nested is overloaded for products CoeffReadCost = 0 // FIXME why is it needed ? }; }; diff --git a/Eigen/src/Core/util/ForwardDeclarations.h b/Eigen/src/Core/util/ForwardDeclarations.h index eb7e93b91..3218f1e49 100644 --- a/Eigen/src/Core/util/ForwardDeclarations.h +++ b/Eigen/src/Core/util/ForwardDeclarations.h @@ -137,7 +137,10 @@ struct IOFormat; // Array module template class Array; template class Select; template class PartialReduxExpr; diff --git a/Eigen/src/Core/util/XprHelper.h b/Eigen/src/Core/util/XprHelper.h index 4259ebb92..83104551f 100644 --- a/Eigen/src/Core/util/XprHelper.h +++ b/Eigen/src/Core/util/XprHelper.h @@ -185,16 +185,16 @@ template struct ei_eval }; // for matrices, no need to evaluate, just use a const reference to avoid a useless copy -template -struct ei_eval, Dense> +template +struct ei_eval, Dense> { - typedef const Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type; + typedef const Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& type; }; -template -struct ei_eval, Dense> +template +struct ei_eval, Dense> { - typedef const Array<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>& type; + typedef const Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>& type; }; @@ -355,4 +355,30 @@ template struct ei_promote_storage_type typedef A ret; }; +/** \internal gives the plain matrix type to store a row/column/diagonal of a matrix type. + * \param Scalar optional parameter allowing to pass a different scalar type than the one of the MatrixType. + */ +template +struct ei_plain_row_type +{ + typedef Matrix type; +}; + +template +struct ei_plain_col_type +{ + typedef Matrix type; +}; + +template +struct ei_plain_diag_type +{ + enum { diag_size = EIGEN_SIZE_MIN(MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime), + max_diag_size = EIGEN_SIZE_MIN(MatrixType::MaxRowsAtCompileTime, MatrixType::MaxColsAtCompileTime) + }; + typedef Matrix type; +}; + #endif // EIGEN_XPRHELPER_H diff --git a/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/Eigen/src/Eigenvalues/ComplexEigenSolver.h index dae6091fe..fe320c3a0 100644 --- a/Eigen/src/Eigenvalues/ComplexEigenSolver.h +++ b/Eigen/src/Eigenvalues/ComplexEigenSolver.h @@ -51,7 +51,7 @@ template class ComplexEigenSolver typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef std::complex Complex; - typedef Matrix EigenvalueType; + typedef typename ei_plain_col_type::type EigenvalueType; typedef Matrix EigenvectorType; /** diff --git a/Eigen/src/Eigenvalues/EigenSolver.h b/Eigen/src/Eigenvalues/EigenSolver.h index 579585618..3fcd8295c 100644 --- a/Eigen/src/Eigenvalues/EigenSolver.h +++ b/Eigen/src/Eigenvalues/EigenSolver.h @@ -55,9 +55,9 @@ template class EigenSolver typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef std::complex Complex; - typedef Matrix EigenvalueType; + typedef typename ei_plain_col_type::type EigenvalueType; typedef Matrix EigenvectorType; - typedef Matrix RealVectorType; + typedef typename ei_plain_col_type::type RealVectorType; /** * \brief Default Constructor. diff --git a/Eigen/src/Eigenvalues/HessenbergDecomposition.h b/Eigen/src/Eigenvalues/HessenbergDecomposition.h index f87c0b842..de833528d 100644 --- a/Eigen/src/Eigenvalues/HessenbergDecomposition.h +++ b/Eigen/src/Eigenvalues/HessenbergDecomposition.h @@ -53,8 +53,8 @@ template class HessenbergDecomposition }; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Matrix CoeffVectorType; - typedef Matrix VectorType; + typedef Matrix CoeffVectorType; + typedef typename ei_plain_col_type::type VectorType; /** This constructor initializes a HessenbergDecomposition object for * further use with HessenbergDecomposition::compute() diff --git a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index 209624c0a..b31f77e9b 100644 --- a/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -52,7 +52,7 @@ template class SelfAdjointEigenSolver typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; typedef std::complex Complex; - typedef Matrix RealVectorType; + typedef typename ei_plain_col_type::type RealVectorType; typedef Tridiagonalization TridiagonalizationType; // typedef typename TridiagonalizationType::TridiagonalMatrixType TridiagonalMatrixType; diff --git a/Eigen/src/Eigenvalues/Tridiagonalization.h b/Eigen/src/Eigenvalues/Tridiagonalization.h index 3ef493fa7..9549e2c97 100644 --- a/Eigen/src/Eigenvalues/Tridiagonalization.h +++ b/Eigen/src/Eigenvalues/Tridiagonalization.h @@ -57,10 +57,10 @@ template class Tridiagonalization PacketSize = ei_packet_traits::size }; - typedef Matrix CoeffVectorType; - typedef Matrix DiagonalType; - typedef Matrix SubDiagonalType; - typedef Matrix RowVectorType; + typedef Matrix CoeffVectorType; + typedef typename ei_plain_col_type::type DiagonalType; + typedef Matrix SubDiagonalType; + typedef typename ei_plain_row_type::type RowVectorType; typedef typename ei_meta_if::IsComplex, typename Diagonal::RealReturnType, diff --git a/Eigen/src/Householder/Householder.h b/Eigen/src/Householder/Householder.h index 3c55e9e9c..12093b78d 100644 --- a/Eigen/src/Householder/Householder.h +++ b/Eigen/src/Householder/Householder.h @@ -96,7 +96,7 @@ void MatrixBase::applyHouseholderOnTheLeft( } else { - Map > tmp(workspace,cols()); + Map::type> tmp(workspace,cols()); Block bottom(derived(), 1, 0, rows()-1, cols()); tmp.noalias() = essential.adjoint() * bottom; tmp += this->row(0); @@ -118,7 +118,7 @@ void MatrixBase::applyHouseholderOnTheRight( } else { - Map > tmp(workspace,rows()); + Map::type> tmp(workspace,rows()); Block right(derived(), 0, 1, rows(), cols()-1); tmp.noalias() = right * essential.conjugate(); tmp += this->col(0); diff --git a/Eigen/src/LU/FullPivLU.h b/Eigen/src/LU/FullPivLU.h index 4092567a6..1fe15bfd2 100644 --- a/Eigen/src/LU/FullPivLU.h +++ b/Eigen/src/LU/FullPivLU.h @@ -68,8 +68,8 @@ template class FullPivLU }; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Matrix IntRowVectorType; - typedef Matrix IntColVectorType; + typedef typename ei_plain_row_type::type IntRowVectorType; + typedef typename ei_plain_col_type::type IntColVectorType; typedef PermutationMatrix PermutationQType; typedef PermutationMatrix PermutationPType; diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index 8ff9c5b03..63b924926 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -71,7 +71,7 @@ template class PartialPivLU }; typedef typename MatrixType::Scalar Scalar; typedef typename NumTraits::Real RealScalar; - typedef Matrix PermutationVectorType; + typedef typename ei_plain_col_type::type PermutationVectorType; typedef PermutationMatrix PermutationType; diff --git a/Eigen/src/QR/ColPivHouseholderQR.h b/Eigen/src/QR/ColPivHouseholderQR.h index 7ec477153..27f80e046 100644 --- a/Eigen/src/QR/ColPivHouseholderQR.h +++ b/Eigen/src/QR/ColPivHouseholderQR.h @@ -52,18 +52,16 @@ template class ColPivHouseholderQR ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - DiagSizeAtCompileTime = EIGEN_SIZE_MIN(ColsAtCompileTime,RowsAtCompileTime), - MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN(MaxColsAtCompileTime,MaxRowsAtCompileTime) + MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; typedef Matrix MatrixQType; - typedef Matrix HCoeffsType; + typedef typename ei_plain_diag_type::type HCoeffsType; typedef PermutationMatrix PermutationType; - typedef Matrix IntRowVectorType; - typedef Matrix RowVectorType; - typedef Matrix RealRowVectorType; + typedef typename ei_plain_row_type::type IntRowVectorType; + typedef typename ei_plain_row_type::type RowVectorType; + typedef typename ei_plain_row_type::type RealRowVectorType; typedef typename HouseholderSequence::ConjugateReturnType HouseholderSequenceType; /** diff --git a/Eigen/src/QR/FullPivHouseholderQR.h b/Eigen/src/QR/FullPivHouseholderQR.h index cc0b6e4ed..7f3e0915e 100644 --- a/Eigen/src/QR/FullPivHouseholderQR.h +++ b/Eigen/src/QR/FullPivHouseholderQR.h @@ -52,19 +52,17 @@ template class FullPivHouseholderQR ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - DiagSizeAtCompileTime = EIGEN_SIZE_MIN(ColsAtCompileTime,RowsAtCompileTime), - MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN(MaxColsAtCompileTime,MaxRowsAtCompileTime) + MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; typedef Matrix MatrixQType; - typedef Matrix HCoeffsType; - typedef Matrix IntRowVectorType; + typedef typename ei_plain_diag_type::type HCoeffsType; + typedef Matrix IntRowVectorType; typedef PermutationMatrix PermutationType; - typedef Matrix IntColVectorType; - typedef Matrix RowVectorType; - typedef Matrix ColVectorType; + typedef typename ei_plain_row_type::type IntColVectorType; + typedef typename ei_plain_row_type::type RowVectorType; + typedef typename ei_plain_col_type::type ColVectorType; /** \brief Default Constructor. * diff --git a/Eigen/src/QR/HouseholderQR.h b/Eigen/src/QR/HouseholderQR.h index 42ad94030..c4abc16ff 100644 --- a/Eigen/src/QR/HouseholderQR.h +++ b/Eigen/src/QR/HouseholderQR.h @@ -56,15 +56,13 @@ template class HouseholderQR ColsAtCompileTime = MatrixType::ColsAtCompileTime, Options = MatrixType::Options, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, - MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime, - DiagSizeAtCompileTime = EIGEN_SIZE_MIN(ColsAtCompileTime,RowsAtCompileTime), - MaxDiagSizeAtCompileTime = EIGEN_SIZE_MIN(MaxColsAtCompileTime,MaxRowsAtCompileTime) + MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime }; typedef typename MatrixType::Scalar Scalar; typedef typename MatrixType::RealScalar RealScalar; typedef Matrix::Flags&RowMajorBit ? RowMajor : ColMajor, MaxRowsAtCompileTime, MaxRowsAtCompileTime> MatrixQType; - typedef Matrix HCoeffsType; - typedef Matrix RowVectorType; + typedef typename ei_plain_diag_type::type HCoeffsType; + typedef typename ei_plain_row_type::type RowVectorType; typedef typename HouseholderSequence::ConjugateReturnType HouseholderSequenceType; /** diff --git a/Eigen/src/SVD/JacobiSVD.h b/Eigen/src/SVD/JacobiSVD.h index 94375725f..b7cab023b 100644 --- a/Eigen/src/SVD/JacobiSVD.h +++ b/Eigen/src/SVD/JacobiSVD.h @@ -84,10 +84,9 @@ template class JacobiSVD Matrix, DummyMatrixType>::ret MatrixVType; - typedef Matrix SingularValuesType; - typedef Matrix RowType; - typedef Matrix ColType; + typedef typename ei_plain_diag_type::type SingularValuesType; + typedef typename ei_plain_row_type::type RowType; + typedef typename ei_plain_col_type::type ColType; typedef Matrix WorkMatrixType; diff --git a/Eigen/src/SVD/SVD.h b/Eigen/src/SVD/SVD.h index bd1ba3cf3..ed0e69f91 100644 --- a/Eigen/src/SVD/SVD.h +++ b/Eigen/src/SVD/SVD.h @@ -58,12 +58,12 @@ template class SVD MatrixOptions = MatrixType::Options }; - typedef Matrix ColVector; - typedef Matrix RowVector; + typedef typename ei_plain_col_type::type ColVector; + typedef typename ei_plain_row_type::type RowVector; typedef Matrix MatrixUType; typedef Matrix MatrixVType; - typedef Matrix SingularValuesType; + typedef ColVector SingularValuesType; /** * \brief Default Constructor.