* introducte recursive Flags system for the expressions

-- currently 3 flags: RowMajor, Lazy and Large
 -- only RowMajor actually used for now
* many minor improvements
This commit is contained in:
Benoit Jacob 2008-03-30 18:43:22 +00:00
parent 758b26551a
commit f279162ec4
26 changed files with 153 additions and 115 deletions

View File

@ -49,7 +49,7 @@ struct ei_scalar_product_op EIGEN_EMPTY_STRUCT {
* \sa class CwiseBinaryOp, MatrixBase::cwiseMin, class PartialRedux, MatrixBase::minCoeff() * \sa class CwiseBinaryOp, MatrixBase::cwiseMin, class PartialRedux, MatrixBase::minCoeff()
*/ */
struct ei_scalar_min_op EIGEN_EMPTY_STRUCT { struct ei_scalar_min_op EIGEN_EMPTY_STRUCT {
template<typename Scalar> Scalar operator() (const Scalar& a, const Scalar& b) const { return ei_min(a, b); } template<typename Scalar> Scalar operator() (const Scalar& a, const Scalar& b) const { return std::min(a, b); }
}; };
/** \internal /** \internal
@ -58,7 +58,7 @@ struct ei_scalar_min_op EIGEN_EMPTY_STRUCT {
* \sa class CwiseBinaryOp, MatrixBase::cwiseMax, class PartialRedux, MatrixBase::maxCoeff() * \sa class CwiseBinaryOp, MatrixBase::cwiseMax, class PartialRedux, MatrixBase::maxCoeff()
*/ */
struct ei_scalar_max_op EIGEN_EMPTY_STRUCT { struct ei_scalar_max_op EIGEN_EMPTY_STRUCT {
template<typename Scalar> Scalar operator() (const Scalar& a, const Scalar& b) const { return ei_max(a, b); } template<typename Scalar> Scalar operator() (const Scalar& a, const Scalar& b) const { return std::max(a, b); }
}; };
#endif // EIGEN_ASSOCIATIVE_FUNCTORS_H #endif // EIGEN_ASSOCIATIVE_FUNCTORS_H

View File

@ -66,7 +66,10 @@ struct ei_traits<Block<MatrixType, BlockRows, BlockCols> >
MaxRowsAtCompileTime = RowsAtCompileTime == 1 ? 1 MaxRowsAtCompileTime = RowsAtCompileTime == 1 ? 1
: (BlockRows==Dynamic ? MatrixType::MaxRowsAtCompileTime : BlockRows), : (BlockRows==Dynamic ? MatrixType::MaxRowsAtCompileTime : BlockRows),
MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1 MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1
: (BlockCols==Dynamic ? MatrixType::MaxColsAtCompileTime : BlockCols) : (BlockCols==Dynamic ? MatrixType::MaxColsAtCompileTime : BlockCols),
Flags = RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic
? (unsigned int)MatrixType::Flags
: (unsigned int)MatrixType::Flags &~ Large
}; };
}; };
@ -132,7 +135,7 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
.coeffRef(row + m_startRow.value(), col + m_startCol.value()); .coeffRef(row + m_startRow.value(), col + m_startCol.value());
} }
Scalar _coeff(int row, int col) const const Scalar _coeff(int row, int col) const
{ {
return m_matrix.coeff(row + m_startRow.value(), col + m_startCol.value()); return m_matrix.coeff(row + m_startRow.value(), col + m_startCol.value());
} }

View File

@ -40,7 +40,7 @@
* \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const * \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const
*/ */
template<typename Derived> template<typename Derived>
typename ei_traits<Derived>::Scalar MatrixBase<Derived> const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::coeff(int row, int col) const ::coeff(int row, int col) const
{ {
ei_internal_assert(row >= 0 && row < rows() ei_internal_assert(row >= 0 && row < rows()
@ -53,7 +53,7 @@ typename ei_traits<Derived>::Scalar MatrixBase<Derived>
* \sa operator()(int,int), operator[](int) const * \sa operator()(int,int), operator[](int) const
*/ */
template<typename Derived> template<typename Derived>
typename ei_traits<Derived>::Scalar MatrixBase<Derived> const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::operator()(int row, int col) const ::operator()(int row, int col) const
{ {
ei_assert(row >= 0 && row < rows() ei_assert(row >= 0 && row < rows()
@ -112,7 +112,7 @@ typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
* \sa operator[](int) const, coeffRef(int), coeff(int,int) const * \sa operator[](int) const, coeffRef(int), coeff(int,int) const
*/ */
template<typename Derived> template<typename Derived>
typename ei_traits<Derived>::Scalar MatrixBase<Derived> const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::coeff(int index) const ::coeff(int index) const
{ {
ei_internal_assert(IsVectorAtCompileTime); ei_internal_assert(IsVectorAtCompileTime);
@ -136,7 +136,7 @@ typename ei_traits<Derived>::Scalar MatrixBase<Derived>
* z() const, w() const * z() const, w() const
*/ */
template<typename Derived> template<typename Derived>
typename ei_traits<Derived>::Scalar MatrixBase<Derived> const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::operator[](int index) const ::operator[](int index) const
{ {
ei_assert(IsVectorAtCompileTime); ei_assert(IsVectorAtCompileTime);
@ -208,22 +208,22 @@ typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
/** equivalent to operator[](0). \only_for_vectors */ /** equivalent to operator[](0). \only_for_vectors */
template<typename Derived> template<typename Derived>
typename ei_traits<Derived>::Scalar MatrixBase<Derived> const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::x() const { return (*this)[0]; } ::x() const { return (*this)[0]; }
/** equivalent to operator[](1). \only_for_vectors */ /** equivalent to operator[](1). \only_for_vectors */
template<typename Derived> template<typename Derived>
typename ei_traits<Derived>::Scalar MatrixBase<Derived> const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::y() const { return (*this)[1]; } ::y() const { return (*this)[1]; }
/** equivalent to operator[](2). \only_for_vectors */ /** equivalent to operator[](2). \only_for_vectors */
template<typename Derived> template<typename Derived>
typename ei_traits<Derived>::Scalar MatrixBase<Derived> const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::z() const { return (*this)[2]; } ::z() const { return (*this)[2]; }
/** equivalent to operator[](3). \only_for_vectors */ /** equivalent to operator[](3). \only_for_vectors */
template<typename Derived> template<typename Derived>
typename ei_traits<Derived>::Scalar MatrixBase<Derived> const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::w() const { return (*this)[3]; } ::w() const { return (*this)[3]; }
/** equivalent to operator[](0). \only_for_vectors */ /** equivalent to operator[](0). \only_for_vectors */

View File

@ -59,7 +59,8 @@ struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
RowsAtCompileTime = Lhs::RowsAtCompileTime, RowsAtCompileTime = Lhs::RowsAtCompileTime,
ColsAtCompileTime = Lhs::ColsAtCompileTime, ColsAtCompileTime = Lhs::ColsAtCompileTime,
MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime, MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime,
MaxColsAtCompileTime = Lhs::MaxColsAtCompileTime MaxColsAtCompileTime = Lhs::MaxColsAtCompileTime,
Flags = Lhs::Flags | Rhs::Flags
}; };
}; };
@ -82,7 +83,7 @@ class CwiseBinaryOp : ei_no_assignment_operator,
int _rows() const { return m_lhs.rows(); } int _rows() const { return m_lhs.rows(); }
int _cols() const { return m_lhs.cols(); } int _cols() const { return m_lhs.cols(); }
Scalar _coeff(int row, int col) const const Scalar _coeff(int row, int col) const
{ {
return m_functor(m_lhs.coeff(row, col), m_rhs.coeff(row, col)); return m_functor(m_lhs.coeff(row, col), m_rhs.coeff(row, col));
} }

View File

@ -49,7 +49,8 @@ struct ei_traits<CwiseUnaryOp<UnaryOp, MatrixType> >
RowsAtCompileTime = MatrixType::RowsAtCompileTime, RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
Flags = MatrixType::Flags
}; };
}; };
@ -69,7 +70,7 @@ class CwiseUnaryOp : ei_no_assignment_operator,
int _rows() const { return m_matrix.rows(); } int _rows() const { return m_matrix.rows(); }
int _cols() const { return m_matrix.cols(); } int _cols() const { return m_matrix.cols(); }
Scalar _coeff(int row, int col) const const Scalar _coeff(int row, int col) const
{ {
return m_functor(m_matrix.coeff(row, col)); return m_functor(m_matrix.coeff(row, col));
} }

View File

@ -51,7 +51,10 @@ struct ei_traits<DiagonalCoeffs<MatrixType> >
MaxRowsAtCompileTime = MatrixType::MaxSizeAtCompileTime == Dynamic ? Dynamic MaxRowsAtCompileTime = MatrixType::MaxSizeAtCompileTime == Dynamic ? Dynamic
: EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime, : EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime,
MatrixType::MaxColsAtCompileTime), MatrixType::MaxColsAtCompileTime),
MaxColsAtCompileTime = 1 MaxColsAtCompileTime = 1,
Flags = RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic
? (unsigned int)MatrixType::Flags
: (unsigned int)MatrixType::Flags &~ Large
}; };
}; };
@ -76,7 +79,7 @@ template<typename MatrixType> class DiagonalCoeffs
return m_matrix.const_cast_derived().coeffRef(row, row); return m_matrix.const_cast_derived().coeffRef(row, row);
} }
Scalar _coeff(int row, int) const const Scalar _coeff(int row, int) const
{ {
return m_matrix.coeff(row, row); return m_matrix.coeff(row, row);
} }

View File

@ -46,7 +46,8 @@ struct ei_traits<DiagonalMatrix<CoeffsVectorType> >
RowsAtCompileTime = CoeffsVectorType::SizeAtCompileTime, RowsAtCompileTime = CoeffsVectorType::SizeAtCompileTime,
ColsAtCompileTime = CoeffsVectorType::SizeAtCompileTime, ColsAtCompileTime = CoeffsVectorType::SizeAtCompileTime,
MaxRowsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime, MaxRowsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime,
MaxColsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime MaxColsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime,
Flags = CoeffsVectorType::Flags
}; };
}; };
@ -69,7 +70,7 @@ class DiagonalMatrix : ei_no_assignment_operator,
int _rows() const { return m_coeffs.size(); } int _rows() const { return m_coeffs.size(); }
int _cols() const { return m_coeffs.size(); } int _cols() const { return m_coeffs.size(); }
Scalar _coeff(int row, int col) const const Scalar _coeff(int row, int col) const
{ {
return row == col ? m_coeffs.coeff(row) : static_cast<Scalar>(0); return row == col ? m_coeffs.coeff(row) : static_cast<Scalar>(0);
} }

View File

@ -52,7 +52,8 @@ struct ei_traits<Eval<ExpressionType> >
RowsAtCompileTime = ExpressionType::RowsAtCompileTime, RowsAtCompileTime = ExpressionType::RowsAtCompileTime,
ColsAtCompileTime = ExpressionType::ColsAtCompileTime, ColsAtCompileTime = ExpressionType::ColsAtCompileTime,
MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime,
Flags = ExpressionType::Flags & ~Lazy
}; };
}; };
@ -60,7 +61,7 @@ template<typename ExpressionType> class Eval : ei_no_assignment_operator,
public Matrix< typename ExpressionType::Scalar, public Matrix< typename ExpressionType::Scalar,
ExpressionType::RowsAtCompileTime, ExpressionType::RowsAtCompileTime,
ExpressionType::ColsAtCompileTime, ExpressionType::ColsAtCompileTime,
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER, ExpressionType::Flags,
ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxRowsAtCompileTime,
ExpressionType::MaxColsAtCompileTime> ExpressionType::MaxColsAtCompileTime>
{ {
@ -77,7 +78,7 @@ template<typename ExpressionType> class Eval : ei_no_assignment_operator,
typedef Matrix<typename ExpressionType::Scalar, typedef Matrix<typename ExpressionType::Scalar,
ExpressionType::RowsAtCompileTime, ExpressionType::RowsAtCompileTime,
ExpressionType::ColsAtCompileTime, ExpressionType::ColsAtCompileTime,
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER, ExpressionType::Flags,
ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxRowsAtCompileTime,
ExpressionType::MaxColsAtCompileTime> MatrixType; ExpressionType::MaxColsAtCompileTime> MatrixType;

View File

@ -47,7 +47,8 @@ struct ei_traits<EvalOMP<ExpressionType> >
RowsAtCompileTime = ExpressionType::RowsAtCompileTime, RowsAtCompileTime = ExpressionType::RowsAtCompileTime,
ColsAtCompileTime = ExpressionType::ColsAtCompileTime, ColsAtCompileTime = ExpressionType::ColsAtCompileTime,
MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime,
Flags = ExpressionType::Flags & ~Lazy
}; };
}; };
@ -55,7 +56,7 @@ template<typename ExpressionType> class EvalOMP : ei_no_assignment_operator,
public Matrix< typename ExpressionType::Scalar, public Matrix< typename ExpressionType::Scalar,
ExpressionType::RowsAtCompileTime, ExpressionType::RowsAtCompileTime,
ExpressionType::ColsAtCompileTime, ExpressionType::ColsAtCompileTime,
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER, ExpressionType::Flags,
ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxRowsAtCompileTime,
ExpressionType::MaxColsAtCompileTime> ExpressionType::MaxColsAtCompileTime>
{ {
@ -68,7 +69,7 @@ template<typename ExpressionType> class EvalOMP : ei_no_assignment_operator,
typedef Matrix<typename ExpressionType::Scalar, typedef Matrix<typename ExpressionType::Scalar,
ExpressionType::RowsAtCompileTime, ExpressionType::RowsAtCompileTime,
ExpressionType::ColsAtCompileTime, ExpressionType::ColsAtCompileTime,
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER, ExpressionType::Flags,
ExpressionType::MaxRowsAtCompileTime, ExpressionType::MaxRowsAtCompileTime,
ExpressionType::MaxColsAtCompileTime> MatrixType; ExpressionType::MaxColsAtCompileTime> MatrixType;

View File

@ -28,7 +28,7 @@
template<typename T> struct ei_traits; template<typename T> struct ei_traits;
template<typename Lhs, typename Rhs> struct ei_product_eval_mode; template<typename Lhs, typename Rhs> struct ei_product_eval_mode;
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> class Matrix; template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols> class Matrix;
template<typename MatrixType> class MatrixRef; template<typename MatrixType> class MatrixRef;
template<typename MatrixType> class Minor; template<typename MatrixType> class Minor;
template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic> class Block; template<typename MatrixType, int BlockRows=Dynamic, int BlockCols=Dynamic> class Block;
@ -73,10 +73,10 @@ template<typename T> struct ei_xpr_copy
typedef T Type; typedef T Type;
}; };
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
struct ei_xpr_copy<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> > struct ei_xpr_copy<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> >
{ {
typedef const Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> & Type; typedef const Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> & Type;
}; };
#endif // EIGEN_FORWARDDECLARATIONS_H #endif // EIGEN_FORWARDDECLARATIONS_H

View File

@ -40,7 +40,7 @@ std::ostream & operator <<
for (int j = 1; j < m.cols(); j++ ) for (int j = 1; j < m.cols(); j++ )
s << " " << m( i, j ); s << " " << m( i, j );
if( i < m.rows() - 1) if( i < m.rows() - 1)
s << std::endl; s << "\n";
} }
return s; return s;
} }

View File

@ -39,7 +39,8 @@ struct ei_traits<Identity<MatrixType> >
RowsAtCompileTime = MatrixType::RowsAtCompileTime, RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
Flags = MatrixType::Flags
}; };
}; };
@ -63,7 +64,7 @@ template<typename MatrixType> class Identity : ei_no_assignment_operator,
int _rows() const { return m_rows.value(); } int _rows() const { return m_rows.value(); }
int _cols() const { return m_cols.value(); } int _cols() const { return m_cols.value(); }
Scalar _coeff(int row, int col) const const Scalar _coeff(int row, int col) const
{ {
return row == col ? static_cast<Scalar>(1) : static_cast<Scalar>(0); return row == col ? static_cast<Scalar>(1) : static_cast<Scalar>(0);
} }

View File

@ -46,7 +46,8 @@ struct ei_traits<Map<MatrixType> >
RowsAtCompileTime = MatrixType::RowsAtCompileTime, RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
Flags = MatrixType::Flags
}; };
}; };
@ -64,18 +65,18 @@ template<typename MatrixType> class Map
const Scalar& _coeff(int row, int col) const const Scalar& _coeff(int row, int col) const
{ {
if(MatrixType::StorageOrder == ColumnMajor) if(Flags & RowMajor)
return m_data[row + col * m_rows];
else // RowMajor
return m_data[col + row * m_cols]; return m_data[col + row * m_cols];
else // column-major
return m_data[row + col * m_rows];
} }
Scalar& _coeffRef(int row, int col) Scalar& _coeffRef(int row, int col)
{ {
if(MatrixType::StorageOrder == ColumnMajor) if(Flags & RowMajor)
return const_cast<Scalar*>(m_data)[row + col * m_rows];
else // RowMajor
return const_cast<Scalar*>(m_data)[col + row * m_cols]; return const_cast<Scalar*>(m_data)[col + row * m_cols];
else // column-major
return const_cast<Scalar*>(m_data)[row + col * m_rows];
} }
public: public:
@ -95,17 +96,17 @@ template<typename MatrixType> class Map
}; };
/** This is the const version of map(Scalar*,int,int). */ /** This is the const version of map(Scalar*,int,int). */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> > const Map<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> >
Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(const Scalar* data, int rows, int cols) Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols>::map(const Scalar* data, int rows, int cols)
{ {
return Map<Matrix>(data, rows, cols); return Map<Matrix>(data, rows, cols);
} }
/** This is the const version of map(Scalar*,int). */ /** This is the const version of map(Scalar*,int). */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> > const Map<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> >
Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(const Scalar* data, int size) Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols>::map(const Scalar* data, int size)
{ {
ei_assert(_Cols == 1 || _Rows ==1); ei_assert(_Cols == 1 || _Rows ==1);
if(_Cols == 1) if(_Cols == 1)
@ -115,9 +116,9 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(const Scal
} }
/** This is the const version of map(Scalar*). */ /** This is the const version of map(Scalar*). */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> > const Map<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> >
Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(const Scalar* data) Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols>::map(const Scalar* data)
{ {
return Map<Matrix>(data, _Rows, _Cols); return Map<Matrix>(data, _Rows, _Cols);
} }
@ -133,9 +134,9 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(const Scal
* *
* \sa map(const Scalar*, int, int), map(Scalar*, int), map(Scalar*), class Map * \sa map(const Scalar*, int, int), map(Scalar*, int), map(Scalar*), class Map
*/ */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> > Map<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> >
Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(Scalar* data, int rows, int cols) Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols>::map(Scalar* data, int rows, int cols)
{ {
return Map<Matrix>(data, rows, cols); return Map<Matrix>(data, rows, cols);
} }
@ -152,9 +153,9 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(Scalar* da
* *
* \sa map(const Scalar*, int), map(Scalar*, int, int), map(Scalar*), class Map * \sa map(const Scalar*, int), map(Scalar*, int, int), map(Scalar*), class Map
*/ */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> > Map<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> >
Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(Scalar* data, int size) Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols>::map(Scalar* data, int size)
{ {
ei_assert(_Cols == 1 || _Rows ==1); ei_assert(_Cols == 1 || _Rows ==1);
if(_Cols == 1) if(_Cols == 1)
@ -172,9 +173,9 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(Scalar* da
* *
* \sa map(const Scalar*), map(Scalar*, int), map(Scalar*, int, int), class Map * \sa map(const Scalar*), map(Scalar*, int), map(Scalar*, int, int), class Map
*/ */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> > Map<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> >
Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(Scalar* data) Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols>::map(Scalar* data)
{ {
return Map<Matrix>(data, _Rows, _Cols); return Map<Matrix>(data, _Rows, _Cols);
} }
@ -187,8 +188,8 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>::map(Scalar* da
* *
* \sa Matrix(const Scalar *), Matrix::map(const Scalar *, int, int) * \sa Matrix(const Scalar *), Matrix::map(const Scalar *, int, int)
*/ */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols>
::Matrix(const Scalar *data, int rows, int cols) ::Matrix(const Scalar *data, int rows, int cols)
: m_storage(rows*cols, rows, cols) : m_storage(rows*cols, rows, cols)
{ {
@ -205,8 +206,8 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>
* *
* \sa Matrix(const Scalar *), Matrix::map(const Scalar *, int) * \sa Matrix(const Scalar *), Matrix::map(const Scalar *, int)
*/ */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols>
::Matrix(const Scalar *data, int size) ::Matrix(const Scalar *data, int size)
: m_storage(size, RowsAtCompileTime == 1 ? 1 : size, ColsAtCompileTime == 1 ? 1 : size) : m_storage(size, RowsAtCompileTime == 1 ? 1 : size, ColsAtCompileTime == 1 ? 1 : size)
{ {
@ -223,8 +224,8 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols>
* \sa Matrix(const Scalar *, int), Matrix(const Scalar *, int, int), * \sa Matrix(const Scalar *, int), Matrix(const Scalar *, int, int),
* Matrix::map(const Scalar *) * Matrix::map(const Scalar *)
*/ */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols>
::Matrix(const Scalar *data) ::Matrix(const Scalar *data)
{ {
*this = map(data); *this = map(data);

View File

@ -40,6 +40,7 @@ inline int ei_exp(int) { ei_assert(false); return 0; }
inline int ei_log(int) { ei_assert(false); return 0; } inline int ei_log(int) { ei_assert(false); return 0; }
inline int ei_sin(int) { ei_assert(false); return 0; } inline int ei_sin(int) { ei_assert(false); return 0; }
inline int ei_cos(int) { ei_assert(false); return 0; } inline int ei_cos(int) { ei_assert(false); return 0; }
// FIXME naive GCC version test, e.g. 5.0 would not pass
#if (defined __ICC) || (defined __GNUC__ && (__GNUC__<4 || __GNUC_MINOR__<3)) #if (defined __ICC) || (defined __GNUC__ && (__GNUC__<4 || __GNUC_MINOR__<3))
inline int ei_pow(int x, int y) { return int(std::pow(double(x), y)); } inline int ei_pow(int x, int y) { return int(std::pow(double(x), y)); }
#else #else

View File

@ -31,12 +31,11 @@
* \brief The matrix class, also used for vectors and row-vectors * \brief The matrix class, also used for vectors and row-vectors
* *
* \param _Scalar the scalar type, i.e. the type of the coefficients * \param _Scalar the scalar type, i.e. the type of the coefficients
* \param _Rows the number of rows at compile-time. Use the special value \a Dynamic to specify that the number of rows is dynamic, i.e. is not fixed at compile-time. * \param _Rows the number of rows at compile-time. Use the special value \a Dynamic to
* \param _Cols the number of columns at compile-time. Use the special value \a Dynamic to specify that the number of columns is dynamic, i.e. is not fixed at compile-time. * specify that the number of rows is dynamic, i.e. is not fixed at compile-time.
* \param _StorageOrder can be either \a RowMajor or \a ColumnMajor. * \param _Cols the number of columns at compile-time. Use the special value \a Dynamic to
* This template parameter has a default value (EIGEN_DEFAULT_MATRIX_STORAGE_ORDER) * specify that the number of columns is dynamic, i.e. is not fixed at compile-time.
* which, if not predefined, is defined to \a ColumnMajor. You can override this behavior by * \param _Flags allows to control certain features such as storage order. See MatrixBase::Flags.
* predefining it before including Eigen headers.
* *
* This single class template covers all kinds of matrix and vectors that Eigen can handle. * This single class template covers all kinds of matrix and vectors that Eigen can handle.
* All matrix and vector types are just typedefs to specializations of this class template. * All matrix and vector types are just typedefs to specializations of this class template.
@ -71,8 +70,8 @@
* *
* Note that most of the API is in the base class MatrixBase. * Note that most of the API is in the base class MatrixBase.
*/ */
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> template<typename _Scalar, int _Rows, int _Cols, unsigned int _Flags, int _MaxRows, int _MaxCols>
struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> > struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _Flags, _MaxRows, _MaxCols> >
{ {
typedef _Scalar Scalar; typedef _Scalar Scalar;
enum { enum {
@ -80,21 +79,20 @@ struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols
ColsAtCompileTime = _Cols, ColsAtCompileTime = _Cols,
MaxRowsAtCompileTime = _MaxRows, MaxRowsAtCompileTime = _MaxRows,
MaxColsAtCompileTime = _MaxCols, MaxColsAtCompileTime = _MaxCols,
Flags = _Flags
}; };
}; };
template<typename _Scalar, int _Rows, int _Cols, template<typename _Scalar, int _Rows, int _Cols,
int _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER, unsigned int _Flags = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
int _MaxRows = _Rows, int _MaxCols = _Cols> int _MaxRows = _Rows, int _MaxCols = _Cols>
class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols,
_StorageOrder, _MaxRows, _MaxCols> > _Flags, _MaxRows, _MaxCols> >
{ {
public: public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix) EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix)
enum { StorageOrder = _StorageOrder };
friend class Map<Matrix>; friend class Map<Matrix>;
private: private:
@ -106,18 +104,18 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols,
const Scalar& _coeff(int row, int col) const const Scalar& _coeff(int row, int col) const
{ {
if(StorageOrder == ColumnMajor) if(Flags & RowMajor)
return m_storage.data()[row + col * m_storage.rows()];
else // RowMajor
return m_storage.data()[col + row * m_storage.cols()]; return m_storage.data()[col + row * m_storage.cols()];
else // column-major
return m_storage.data()[row + col * m_storage.rows()];
} }
Scalar& _coeffRef(int row, int col) Scalar& _coeffRef(int row, int col)
{ {
if(StorageOrder == ColumnMajor) if(Flags & RowMajor)
return m_storage.data()[row + col * m_storage.rows()];
else // RowMajor
return m_storage.data()[col + row * m_storage.cols()]; return m_storage.data()[col + row * m_storage.cols()];
else // column-major
return m_storage.data()[row + col * m_storage.rows()];
} }
public: public:

View File

@ -120,11 +120,22 @@ template<typename Derived> class MatrixBase
*/ */
IsVectorAtCompileTime IsVectorAtCompileTime
= ei_traits<Derived>::RowsAtCompileTime == 1 || ei_traits<Derived>::ColsAtCompileTime == 1 = ei_traits<Derived>::RowsAtCompileTime == 1 || ei_traits<Derived>::ColsAtCompileTime == 1,
/**< This is set to true if either the number of rows or the number of /**< This is set to true if either the number of rows or the number of
* columns is known at compile-time to be equal to 1. Indeed, in that case, * columns is known at compile-time to be equal to 1. Indeed, in that case,
* we are dealing with a column-vector (if there is only one column) or with * we are dealing with a column-vector (if there is only one column) or with
* a row-vector (if there is only one row). */ * a row-vector (if there is only one row). */
Flags = ei_traits<Derived>::Flags
/**< This stores expression metadata which typically is inherited by new expressions
* constructed from this one. The available flags are:
* \li \c RowMajor: if this bit is set, the preferred storage order for an evaluation
* of this expression is row-major. Otherwise, it is column-major.
* \li \c Lazy: if this bit is set, the next evaluation of this expression will be canceled.
* This can be used, with care, to achieve lazy evaluation.
* \li \c Large: if this bit is set, optimization will be tuned for large matrices (typically,
* at least 32x32).
*/
}; };
/** This is the "real scalar" type; if the \a Scalar type is already real numbers /** This is the "real scalar" type; if the \a Scalar type is already real numbers
@ -182,22 +193,22 @@ template<typename Derived> class MatrixBase
/// \name Coefficient accessors /// \name Coefficient accessors
//@{ //@{
Scalar coeff(int row, int col) const; const Scalar coeff(int row, int col) const;
Scalar operator()(int row, int col) const; const Scalar operator()(int row, int col) const;
Scalar& coeffRef(int row, int col); Scalar& coeffRef(int row, int col);
Scalar& operator()(int row, int col); Scalar& operator()(int row, int col);
Scalar coeff(int index) const; const Scalar coeff(int index) const;
Scalar operator[](int index) const; const Scalar operator[](int index) const;
Scalar& coeffRef(int index); Scalar& coeffRef(int index);
Scalar& operator[](int index); Scalar& operator[](int index);
Scalar x() const; const Scalar x() const;
Scalar y() const; const Scalar y() const;
Scalar z() const; const Scalar z() const;
Scalar w() const; const Scalar w() const;
Scalar& x(); Scalar& x();
Scalar& y(); Scalar& y();
Scalar& z(); Scalar& z();

View File

@ -49,7 +49,8 @@ struct ei_traits<Minor<MatrixType> >
MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ? MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ?
MatrixType::MaxRowsAtCompileTime - 1 : Dynamic, MatrixType::MaxRowsAtCompileTime - 1 : Dynamic,
MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ? MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
MatrixType::MaxColsAtCompileTime - 1 : Dynamic MatrixType::MaxColsAtCompileTime - 1 : Dynamic,
Flags = MatrixType::Flags
}; };
}; };
@ -80,7 +81,7 @@ template<typename MatrixType> class Minor
return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col)); return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col));
} }
Scalar _coeff(int row, int col) const const Scalar _coeff(int row, int col) const
{ {
return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col)); return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
} }

View File

@ -40,7 +40,8 @@ struct ei_traits<Ones<MatrixType> >
RowsAtCompileTime = MatrixType::RowsAtCompileTime, RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
Flags = MatrixType::Flags
}; };
}; };
@ -56,7 +57,7 @@ template<typename MatrixType> class Ones : ei_no_assignment_operator,
int _rows() const { return m_rows.value(); } int _rows() const { return m_rows.value(); }
int _cols() const { return m_cols.value(); } int _cols() const { return m_cols.value(); }
Scalar _coeff(int, int) const const Scalar _coeff(int, int) const
{ {
return static_cast<Scalar>(1); return static_cast<Scalar>(1);
} }

View File

@ -111,12 +111,12 @@ Derived& MatrixBase<Derived>
&& SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT) && SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT)
ei_vector_operator_equals_unroller ei_vector_operator_equals_unroller
<Derived, OtherDerived, <Derived, OtherDerived,
SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT ? SizeAtCompileTime : Dynamic>::run SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT ? SizeAtCompileTime : Dynamic
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other)); >::run(derived(), other.derived());
else else
for(int i = 0; i < size(); i++) for(int i = 0; i < size(); i++)
coeffRef(i) = other.coeff(i); coeffRef(i) = other.coeff(i);
return *static_cast<Derived*>(this); return derived();
} }
else // copying a matrix expression into a matrix else // copying a matrix expression into a matrix
{ {
@ -127,8 +127,8 @@ Derived& MatrixBase<Derived>
{ {
ei_matrix_operator_equals_unroller ei_matrix_operator_equals_unroller
<Derived, OtherDerived, <Derived, OtherDerived,
SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT ? SizeAtCompileTime : Dynamic>::run SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT ? SizeAtCompileTime : Dynamic
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other)); >::run(derived(), other.derived());
} }
else else
{ {

View File

@ -82,7 +82,10 @@ struct ei_traits<Product<Lhs, Rhs, EvalMode> >
RowsAtCompileTime = Lhs::RowsAtCompileTime, RowsAtCompileTime = Lhs::RowsAtCompileTime,
ColsAtCompileTime = Rhs::ColsAtCompileTime, ColsAtCompileTime = Rhs::ColsAtCompileTime,
MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime, MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime,
MaxColsAtCompileTime = Rhs::MaxColsAtCompileTime MaxColsAtCompileTime = Rhs::MaxColsAtCompileTime,
Flags = (RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic)
? (unsigned int)(Lhs::Flags | Rhs::Flags)
: (unsigned int)(Lhs::Flags | Rhs::Flags) & ~Large
}; };
}; };
@ -120,7 +123,7 @@ template<typename Lhs, typename Rhs, int EvalMode> class Product : ei_no_assignm
int _rows() const { return m_lhs.rows(); } int _rows() const { return m_lhs.rows(); }
int _cols() const { return m_rhs.cols(); } int _cols() const { return m_rhs.cols(); }
Scalar _coeff(int row, int col) const const Scalar _coeff(int row, int col) const
{ {
Scalar res; Scalar res;
if(EIGEN_UNROLLED_LOOPS if(EIGEN_UNROLLED_LOOPS

View File

@ -40,7 +40,8 @@ struct ei_traits<Random<MatrixType> >
RowsAtCompileTime = MatrixType::RowsAtCompileTime, RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
Flags = MatrixType::Flags
}; };
}; };
@ -56,7 +57,7 @@ template<typename MatrixType> class Random : ei_no_assignment_operator,
int _rows() const { return m_rows.value(); } int _rows() const { return m_rows.value(); }
int _cols() const { return m_cols.value(); } int _cols() const { return m_cols.value(); }
Scalar _coeff(int, int) const const Scalar _coeff(int, int) const
{ {
return ei_random<Scalar>(); return ei_random<Scalar>();
} }

View File

@ -92,7 +92,10 @@ struct ei_traits<PartialRedux<Direction, BinaryOp, MatrixType> >
RowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::RowsAtCompileTime, RowsAtCompileTime = Direction==Vertical ? 1 : MatrixType::RowsAtCompileTime,
ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime, ColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
Flags = (RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic)
? (unsigned int)MatrixType::Flags
: (unsigned int)MatrixType::Flags & ~Large
}; };
}; };
@ -112,7 +115,7 @@ class PartialRedux : ei_no_assignment_operator,
int _rows() const { return (Direction==Vertical ? 1 : m_matrix.rows()); } int _rows() const { return (Direction==Vertical ? 1 : m_matrix.rows()); }
int _cols() const { return (Direction==Horizontal ? 1 : m_matrix.cols()); } int _cols() const { return (Direction==Horizontal ? 1 : m_matrix.cols()); }
Scalar _coeff(int i, int j) const const Scalar _coeff(int i, int j) const
{ {
if (Direction==Vertical) if (Direction==Vertical)
return this->col(j).redux(m_functor); return this->col(j).redux(m_functor);

View File

@ -45,7 +45,8 @@ struct ei_traits<Transpose<MatrixType> >
RowsAtCompileTime = MatrixType::ColsAtCompileTime, RowsAtCompileTime = MatrixType::ColsAtCompileTime,
ColsAtCompileTime = MatrixType::RowsAtCompileTime, ColsAtCompileTime = MatrixType::RowsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
Flags = MatrixType::Flags ^ RowMajor
}; };
}; };
@ -70,7 +71,7 @@ template<typename MatrixType> class Transpose
return m_matrix.const_cast_derived().coeffRef(col, row); return m_matrix.const_cast_derived().coeffRef(col, row);
} }
Scalar _coeff(int row, int col) const const Scalar _coeff(int row, int col) const
{ {
return m_matrix.coeff(col, row); return m_matrix.coeff(col, row);
} }

View File

@ -39,7 +39,7 @@
#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR #ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor
#else #else
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER ColumnMajor #define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER 0
#endif #endif
#undef minor #undef minor
@ -116,7 +116,8 @@ enum { RowsAtCompileTime = Base::RowsAtCompileTime, \
MaxColsAtCompileTime = Base::MaxColsAtCompileTime, \ MaxColsAtCompileTime = Base::MaxColsAtCompileTime, \
SizeAtCompileTime = Base::SizeAtCompileTime, \ SizeAtCompileTime = Base::SizeAtCompileTime, \
MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \ MaxSizeAtCompileTime = Base::MaxSizeAtCompileTime, \
IsVectorAtCompileTime = Base::IsVectorAtCompileTime }; IsVectorAtCompileTime = Base::IsVectorAtCompileTime, \
Flags = Base::Flags };
#define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \ #define EIGEN_GENERIC_PUBLIC_INTERFACE(Derived) \
_EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase<Derived>) \ _EIGEN_GENERIC_PUBLIC_INTERFACE(Derived, Eigen::MatrixBase<Derived>) \
@ -125,8 +126,11 @@ friend class Eigen::MatrixBase<Derived>;
#define EIGEN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b) #define EIGEN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
const int Dynamic = -10; const int Dynamic = -10;
const int ColumnMajor = 0;
const int RowMajor = 1; // matrix/expression flags
const unsigned int RowMajor = 0x1;
const unsigned int Lazy = 0x2;
const unsigned int Large = 0x4;
enum CornerType { TopLeft, TopRight, BottomLeft, BottomRight }; enum CornerType { TopLeft, TopRight, BottomLeft, BottomRight };

View File

@ -40,7 +40,8 @@ struct ei_traits<Zero<MatrixType> >
RowsAtCompileTime = MatrixType::RowsAtCompileTime, RowsAtCompileTime = MatrixType::RowsAtCompileTime,
ColsAtCompileTime = MatrixType::ColsAtCompileTime, ColsAtCompileTime = MatrixType::ColsAtCompileTime,
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime,
Flags = MatrixType::Flags
}; };
}; };

View File

@ -76,8 +76,8 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
square.col(r) = square.row(r).eval(); square.col(r) = square.row(r).eval();
Matrix<Scalar, 1, MatrixType::RowsAtCompileTime> rv(rows); Matrix<Scalar, 1, MatrixType::RowsAtCompileTime> rv(rows);
Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> cv(rows); Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> cv(rows);
rv = square.col(r); rv = square.row(r);
cv = square.row(r); cv = square.col(r);
VERIFY_IS_APPROX(rv, cv.transpose()); VERIFY_IS_APPROX(rv, cv.transpose());
if(cols!=1 && rows!=1 && MatrixType::SizeAtCompileTime!=Dynamic) if(cols!=1 && rows!=1 && MatrixType::SizeAtCompileTime!=Dynamic)