fix compilation when default to row major

This commit is contained in:
Gael Guennebaud 2010-06-24 15:13:41 +02:00
parent d44fce501b
commit 19f2f53e2c
7 changed files with 54 additions and 28 deletions

View File

@ -129,7 +129,7 @@ template<typename Derived> class MatrixBase
Transpose<Derived> Transpose<Derived>
>::ret AdjointReturnType; >::ret AdjointReturnType;
/** \internal Return type of eigenvalues() */ /** \internal Return type of eigenvalues() */
typedef Matrix<std::complex<RealScalar>, ei_traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType; typedef Matrix<std::complex<RealScalar>, ei_traits<Derived>::ColsAtCompileTime, 1, ColMajor> EigenvaluesReturnType;
/** \internal the return type of identity */ /** \internal the return type of identity */
typedef CwiseNullaryOp<ei_scalar_identity_op<Scalar>,Derived> IdentityReturnType; typedef CwiseNullaryOp<ei_scalar_identity_op<Scalar>,Derived> IdentityReturnType;
/** \internal the return type of unit vectors */ /** \internal the return type of unit vectors */

View File

@ -91,6 +91,26 @@ template<typename T> struct ei_unpacket_traits
enum {size=1}; enum {size=1};
}; };
template<typename _Scalar, int _Rows, int _Cols,
int _Options = AutoAlign |
( (_Rows==1 && _Cols!=1) ? RowMajor
: (_Cols==1 && _Rows!=1) ? ColMajor
: EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION ),
int _MaxRows = _Rows,
int _MaxCols = _Cols
> class ei_make_proper_matrix_type
{
enum {
IsColVector = _Cols==1 && _Rows!=1,
IsRowVector = _Rows==1 && _Cols!=1,
Options = IsColVector ? (_Options | ColMajor) & ~RowMajor
: IsRowVector ? (_Options | RowMajor) & ~ColMajor
: _Options
};
public:
typedef Matrix<_Scalar, _Rows, _Cols, Options, _MaxRows, _MaxCols> type;
};
template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols> template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
class ei_compute_matrix_flags class ei_compute_matrix_flags
{ {

View File

@ -89,7 +89,7 @@ template<typename _MatrixType> class ComplexEigenSolver
* This is a column vector with entries of type #ComplexScalar. * This is a column vector with entries of type #ComplexScalar.
* The length of the vector is the size of #MatrixType. * The length of the vector is the size of #MatrixType.
*/ */
typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options, MaxColsAtCompileTime, 1> EigenvalueType; typedef Matrix<ComplexScalar, ColsAtCompileTime, 1, Options&(~RowMajor), MaxColsAtCompileTime, 1> EigenvalueType;
/** \brief Type for matrix of eigenvectors as returned by eigenvectors(). /** \brief Type for matrix of eigenvectors as returned by eigenvectors().
* *

View File

@ -55,7 +55,10 @@ struct ei_traits<Homogeneous<MatrixType,Direction> >
ColsAtCompileTime = Direction==Horizontal ? ColsPlusOne : MatrixType::ColsAtCompileTime, ColsAtCompileTime = Direction==Horizontal ? ColsPlusOne : MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = RowsAtCompileTime, MaxRowsAtCompileTime = RowsAtCompileTime,
MaxColsAtCompileTime = ColsAtCompileTime, MaxColsAtCompileTime = ColsAtCompileTime,
Flags = _MatrixTypeNested::Flags & HereditaryBits, TmpFlags = _MatrixTypeNested::Flags & HereditaryBits,
Flags = ColsAtCompileTime==1 ? (TmpFlags & ~RowMajorBit)
: RowsAtCompileTime==1 ? (TmpFlags | RowMajorBit)
: TmpFlags,
CoeffReadCost = _MatrixTypeNested::CoeffReadCost CoeffReadCost = _MatrixTypeNested::CoeffReadCost
}; };
}; };
@ -210,12 +213,13 @@ VectorwiseOp<ExpressionType,Direction>::hnormalized() const
template<typename MatrixType,typename Lhs> template<typename MatrixType,typename Lhs>
struct ei_traits<ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> > struct ei_traits<ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> >
{ {
typedef Matrix<typename ei_traits<MatrixType>::Scalar, typedef typename ei_make_proper_matrix_type<
typename ei_traits<MatrixType>::Scalar,
Lhs::RowsAtCompileTime, Lhs::RowsAtCompileTime,
MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime,
MatrixType::PlainObject::Options, MatrixType::PlainObject::Options,
Lhs::MaxRowsAtCompileTime, Lhs::MaxRowsAtCompileTime,
MatrixType::MaxColsAtCompileTime> ReturnType; MatrixType::MaxColsAtCompileTime>::type ReturnType;
}; };
template<typename MatrixType,typename Lhs> template<typename MatrixType,typename Lhs>
@ -249,12 +253,12 @@ struct ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>
template<typename MatrixType,typename Rhs> template<typename MatrixType,typename Rhs>
struct ei_traits<ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> > struct ei_traits<ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> >
{ {
typedef Matrix<typename ei_traits<MatrixType>::Scalar, typedef typename ei_make_proper_matrix_type<typename ei_traits<MatrixType>::Scalar,
MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime,
Rhs::ColsAtCompileTime, Rhs::ColsAtCompileTime,
MatrixType::PlainObject::Options, MatrixType::PlainObject::Options,
MatrixType::MaxRowsAtCompileTime, MatrixType::MaxRowsAtCompileTime,
Rhs::MaxColsAtCompileTime> ReturnType; Rhs::MaxColsAtCompileTime>::type ReturnType;
}; };
template<typename MatrixType,typename Rhs> template<typename MatrixType,typename Rhs>

View File

@ -66,7 +66,8 @@ void ei_apply_block_householder_on_the_left(MatrixType& mat, const VectorsType&
const TriangularView<VectorsType, UnitLower>& V(vectors); const TriangularView<VectorsType, UnitLower>& V(vectors);
// A -= V T V^* A // A -= V T V^* A
Matrix<typename MatrixType::Scalar,Dynamic,Dynamic> tmp = V.adjoint() * mat; Matrix<typename MatrixType::Scalar,VectorsType::ColsAtCompileTime,MatrixType::ColsAtCompileTime,0,
VectorsType::MaxColsAtCompileTime,MatrixType::MaxColsAtCompileTime> tmp = V.adjoint() * mat;
// FIXME add .noalias() once the triangular product can work inplace // FIXME add .noalias() once the triangular product can work inplace
tmp = T.template triangularView<Upper>().adjoint() * tmp; tmp = T.template triangularView<Upper>().adjoint() * tmp;
mat.noalias() -= V * tmp; mat.noalias() -= V * tmp;

View File

@ -32,7 +32,7 @@ template<typename Scalar,int Size> void homogeneous(void)
*/ */
typedef Matrix<Scalar,Size,Size> MatrixType; typedef Matrix<Scalar,Size,Size> MatrixType;
typedef Matrix<Scalar,Size,1> VectorType; typedef Matrix<Scalar,Size,1, ColMajor> VectorType;
typedef Matrix<Scalar,Size+1,Size> HMatrixType; typedef Matrix<Scalar,Size+1,Size> HMatrixType;
typedef Matrix<Scalar,Size+1,1> HVectorType; typedef Matrix<Scalar,Size+1,1> HVectorType;
@ -80,6 +80,7 @@ template<typename Scalar,int Size> void homogeneous(void)
VERIFY_IS_APPROX((v0.transpose().rowwise().homogeneous().eval()) * t2, VERIFY_IS_APPROX((v0.transpose().rowwise().homogeneous().eval()) * t2,
v0.transpose().rowwise().homogeneous() * t2); v0.transpose().rowwise().homogeneous() * t2);
m0.transpose().rowwise().homogeneous().eval();
VERIFY_IS_APPROX((m0.transpose().rowwise().homogeneous().eval()) * t2, VERIFY_IS_APPROX((m0.transpose().rowwise().homogeneous().eval()) * t2,
m0.transpose().rowwise().homogeneous() * t2); m0.transpose().rowwise().homogeneous() * t2);

View File

@ -136,12 +136,12 @@ void mixingtypes_large(int size)
VERIFY_RAISES_ASSERT(mcf*vf); VERIFY_RAISES_ASSERT(mcf*vf);
// VERIFY_RAISES_ASSERT(mcf *= mf); // does not even compile // VERIFY_RAISES_ASSERT(mcf *= mf); // does not even compile
// VERIFY_RAISES_ASSERT(vcd = md*vcd); // does not even compile (cannot convert complex to double) // VERIFY_RAISES_ASSERT(vcd = md*vcd); // does not even compile (cannot convert complex to double)
VERIFY_RAISES_ASSERT(vcf = mcf*vf); // VERIFY_RAISES_ASSERT(vcf = mcf*vf);
// VERIFY_RAISES_ASSERT(mf*md); // does not even compile // VERIFY_RAISES_ASSERT(mf*md); // does not even compile
// VERIFY_RAISES_ASSERT(mcf*mcd); // does not even compile // VERIFY_RAISES_ASSERT(mcf*mcd); // does not even compile
// VERIFY_RAISES_ASSERT(mcf*vcd); // does not even compile // VERIFY_RAISES_ASSERT(mcf*vcd); // does not even compile
VERIFY_RAISES_ASSERT(vcf = mf*vf); // VERIFY_RAISES_ASSERT(vcf = mf*vf);
} }
template<int SizeAtCompileType> void mixingtypes_small() template<int SizeAtCompileType> void mixingtypes_small()