mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-31 19:00:35 +08:00
generalized ei_traits<>.
Finally the importing macro is named EIGEN_BASIC_PUBLIC_INTERFACE because it does not only import the ei_traits, it also makes the base class a friend, etc.
This commit is contained in:
parent
01572b9f54
commit
2ee68a074e
@ -57,18 +57,27 @@
|
||||
* \sa MatrixBase::block(int,int,int,int), MatrixBase::block(int,int), class VectorBlock
|
||||
*/
|
||||
template<typename MatrixType, int BlockRows, int BlockCols>
|
||||
struct Scalar<Block<MatrixType, BlockRows, BlockCols> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Block<MatrixType, BlockRows, BlockCols> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum{
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime == 1 ? 1 : BlockRows,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime == 1 ? 1 : BlockCols,
|
||||
MaxRowsAtCompileTime = RowsAtCompileTime == 1 ? 1
|
||||
: (BlockRows==Dynamic ? MatrixType::MaxRowsAtCompileTime : BlockRows),
|
||||
MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1
|
||||
: (BlockCols==Dynamic ? MatrixType::MaxColsAtCompileTime : BlockCols)
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
||||
: public MatrixBase<Block<MatrixType, BlockRows, BlockCols> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Block)
|
||||
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Block>;
|
||||
friend class MatrixBase<Block>::Traits;
|
||||
typedef MatrixBase<Block> Base;
|
||||
|
||||
/** Fixed-size constructor
|
||||
*/
|
||||
@ -97,14 +106,6 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
|
||||
|
||||
private:
|
||||
enum{
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime == 1 ? 1 : BlockRows,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime == 1 ? 1 : BlockCols,
|
||||
MaxRowsAtCompileTime = RowsAtCompileTime == 1 ? 1
|
||||
: (BlockRows==Dynamic ? MatrixType::Traits::MaxRowsAtCompileTime : BlockRows),
|
||||
MaxColsAtCompileTime = ColsAtCompileTime == 1 ? 1
|
||||
: (BlockCols==Dynamic ? MatrixType::Traits::MaxColsAtCompileTime : BlockCols)
|
||||
};
|
||||
|
||||
const Block& _asArg() const { return *this; }
|
||||
int _rows() const { return m_blockRows.value(); }
|
||||
@ -123,8 +124,8 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
||||
protected:
|
||||
|
||||
MatRef m_matrix;
|
||||
IntAtRunTimeIfDynamic<MatrixType::Traits::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow;
|
||||
IntAtRunTimeIfDynamic<MatrixType::Traits::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol;
|
||||
IntAtRunTimeIfDynamic<MatrixType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow;
|
||||
IntAtRunTimeIfDynamic<MatrixType::ColsAtCompileTime == 1 ? 0 : Dynamic> m_startCol;
|
||||
IntAtRunTimeIfDynamic<RowsAtCompileTime> m_blockRows;
|
||||
IntAtRunTimeIfDynamic<ColsAtCompileTime> m_blockCols;
|
||||
};
|
||||
@ -180,11 +181,11 @@ template<typename Derived>
|
||||
Block<Derived> MatrixBase<Derived>
|
||||
::block(int start, int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
return Block<Derived>(asArg(), Traits::RowsAtCompileTime == 1 ? 0 : start,
|
||||
Traits::ColsAtCompileTime == 1 ? 0 : start,
|
||||
Traits::RowsAtCompileTime == 1 ? 1 : size,
|
||||
Traits::ColsAtCompileTime == 1 ? 1 : size);
|
||||
assert(IsVectorAtCompileTime);
|
||||
return Block<Derived>(asArg(), RowsAtCompileTime == 1 ? 0 : start,
|
||||
ColsAtCompileTime == 1 ? 0 : start,
|
||||
RowsAtCompileTime == 1 ? 1 : size,
|
||||
ColsAtCompileTime == 1 ? 1 : size);
|
||||
}
|
||||
|
||||
/** This is the const version of block(int,int).*/
|
||||
@ -192,11 +193,11 @@ template<typename Derived>
|
||||
const Block<Derived> MatrixBase<Derived>
|
||||
::block(int start, int size) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
return Block<Derived>(asArg(), Traits::RowsAtCompileTime == 1 ? 0 : start,
|
||||
Traits::ColsAtCompileTime == 1 ? 0 : start,
|
||||
Traits::RowsAtCompileTime == 1 ? 1 : size,
|
||||
Traits::ColsAtCompileTime == 1 ? 1 : size);
|
||||
assert(IsVectorAtCompileTime);
|
||||
return Block<Derived>(asArg(), RowsAtCompileTime == 1 ? 0 : start,
|
||||
ColsAtCompileTime == 1 ? 0 : start,
|
||||
RowsAtCompileTime == 1 ? 1 : size,
|
||||
ColsAtCompileTime == 1 ? 1 : size);
|
||||
}
|
||||
|
||||
/** \returns a dynamic-size expression of the first coefficients of *this.
|
||||
@ -218,10 +219,10 @@ template<typename Derived>
|
||||
Block<Derived> MatrixBase<Derived>
|
||||
::start(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
assert(IsVectorAtCompileTime);
|
||||
return Block<Derived>(asArg(), 0, 0,
|
||||
Traits::RowsAtCompileTime == 1 ? 1 : size,
|
||||
Traits::ColsAtCompileTime == 1 ? 1 : size);
|
||||
RowsAtCompileTime == 1 ? 1 : size,
|
||||
ColsAtCompileTime == 1 ? 1 : size);
|
||||
}
|
||||
|
||||
/** This is the const version of start(int).*/
|
||||
@ -229,10 +230,10 @@ template<typename Derived>
|
||||
const Block<Derived> MatrixBase<Derived>
|
||||
::start(int size) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
assert(IsVectorAtCompileTime);
|
||||
return Block<Derived>(asArg(), 0, 0,
|
||||
Traits::RowsAtCompileTime == 1 ? 1 : size,
|
||||
Traits::ColsAtCompileTime == 1 ? 1 : size);
|
||||
RowsAtCompileTime == 1 ? 1 : size,
|
||||
ColsAtCompileTime == 1 ? 1 : size);
|
||||
}
|
||||
|
||||
/** \returns a dynamic-size expression of the last coefficients of *this.
|
||||
@ -254,12 +255,12 @@ template<typename Derived>
|
||||
Block<Derived> MatrixBase<Derived>
|
||||
::end(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
assert(IsVectorAtCompileTime);
|
||||
return Block<Derived>(asArg(),
|
||||
Traits::RowsAtCompileTime == 1 ? 0 : rows() - size,
|
||||
Traits::ColsAtCompileTime == 1 ? 0 : cols() - size,
|
||||
Traits::RowsAtCompileTime == 1 ? 1 : size,
|
||||
Traits::ColsAtCompileTime == 1 ? 1 : size);
|
||||
RowsAtCompileTime == 1 ? 0 : rows() - size,
|
||||
ColsAtCompileTime == 1 ? 0 : cols() - size,
|
||||
RowsAtCompileTime == 1 ? 1 : size,
|
||||
ColsAtCompileTime == 1 ? 1 : size);
|
||||
}
|
||||
|
||||
/** This is the const version of end(int).*/
|
||||
@ -267,12 +268,12 @@ template<typename Derived>
|
||||
const Block<Derived> MatrixBase<Derived>
|
||||
::end(int size) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
assert(IsVectorAtCompileTime);
|
||||
return Block<Derived>(asArg(),
|
||||
Traits::RowsAtCompileTime == 1 ? 0 : rows() - size,
|
||||
Traits::ColsAtCompileTime == 1 ? 0 : cols() - size,
|
||||
Traits::RowsAtCompileTime == 1 ? 1 : size,
|
||||
Traits::ColsAtCompileTime == 1 ? 1 : size);
|
||||
RowsAtCompileTime == 1 ? 0 : rows() - size,
|
||||
ColsAtCompileTime == 1 ? 0 : cols() - size,
|
||||
RowsAtCompileTime == 1 ? 1 : size,
|
||||
ColsAtCompileTime == 1 ? 1 : size);
|
||||
}
|
||||
|
||||
/** \returns a dynamic-size expression of a corner of *this.
|
||||
|
@ -40,7 +40,7 @@
|
||||
* \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
||||
::coeff(int row, int col) const
|
||||
{
|
||||
eigen_internal_assert(row >= 0 && row < rows()
|
||||
@ -53,7 +53,7 @@ typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
* \sa operator()(int,int), operator[](int) const
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
||||
::operator()(int row, int col) const
|
||||
{
|
||||
assert(row >= 0 && row < rows()
|
||||
@ -76,7 +76,7 @@ typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
* \sa operator()(int,int), coeff(int, int) const, coeffRef(int)
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
||||
::coeffRef(int row, int col)
|
||||
{
|
||||
eigen_internal_assert(row >= 0 && row < rows()
|
||||
@ -89,7 +89,7 @@ typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
* \sa operator()(int,int) const, operator[](int)
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
||||
::operator()(int row, int col)
|
||||
{
|
||||
assert(row >= 0 && row < rows()
|
||||
@ -112,11 +112,11 @@ typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
* \sa operator[](int) const, coeffRef(int), coeff(int,int) const
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
||||
::coeff(int index) const
|
||||
{
|
||||
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1)
|
||||
eigen_internal_assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1)
|
||||
{
|
||||
eigen_internal_assert(index >= 0 && index < cols());
|
||||
return coeff(0, index);
|
||||
@ -136,11 +136,11 @@ typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
* z() const, w() const
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
||||
::operator[](int index) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1)
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1)
|
||||
{
|
||||
assert(index >= 0 && index < cols());
|
||||
return coeff(0, index);
|
||||
@ -167,11 +167,11 @@ typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
* \sa operator[](int), coeff(int) const, coeffRef(int,int)
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
||||
::coeffRef(int index)
|
||||
{
|
||||
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1)
|
||||
eigen_internal_assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1)
|
||||
{
|
||||
eigen_internal_assert(index >= 0 && index < cols());
|
||||
return coeffRef(0, index);
|
||||
@ -190,11 +190,11 @@ typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
* \sa operator[](int) const, operator()(int,int), x(), y(), z(), w()
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
||||
::operator[](int index)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1)
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1)
|
||||
{
|
||||
assert(index >= 0 && index < cols());
|
||||
return coeffRef(0, index);
|
||||
@ -208,42 +208,42 @@ typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
|
||||
/** equivalent to operator[](0). \only_for_vectors */
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
||||
::x() const { return (*this)[0]; }
|
||||
|
||||
/** equivalent to operator[](1). \only_for_vectors */
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
||||
::y() const { return (*this)[1]; }
|
||||
|
||||
/** equivalent to operator[](2). \only_for_vectors */
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
||||
::z() const { return (*this)[2]; }
|
||||
|
||||
/** equivalent to operator[](3). \only_for_vectors */
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar MatrixBase<Derived>
|
||||
::w() const { return (*this)[3]; }
|
||||
|
||||
/** equivalent to operator[](0). \only_for_vectors */
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
||||
::x() { return (*this)[0]; }
|
||||
|
||||
/** equivalent to operator[](1). \only_for_vectors */
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
||||
::y() { return (*this)[1]; }
|
||||
|
||||
/** equivalent to operator[](2). \only_for_vectors */
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
||||
::z() { return (*this)[2]; }
|
||||
|
||||
/** equivalent to operator[](3). \only_for_vectors */
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
|
||||
::w() { return (*this)[3]; }
|
||||
|
||||
#endif // EIGEN_COEFFS_H
|
||||
|
@ -46,18 +46,25 @@
|
||||
* \sa MatrixBase::col()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Column<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Column<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = 1,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = 1
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class Column
|
||||
: public MatrixBase<Column<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Column)
|
||||
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Column>;
|
||||
friend class MatrixBase<Column>::Traits;
|
||||
typedef MatrixBase<Column> Base;
|
||||
|
||||
Column(const MatRef& matrix, int col)
|
||||
: m_matrix(matrix), m_col(col)
|
||||
@ -68,12 +75,6 @@ template<typename MatrixType> class Column
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column)
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = 1,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = 1
|
||||
};
|
||||
|
||||
const Column& _asArg() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
|
@ -55,7 +55,7 @@ struct MatrixBase<Derived>::CommaInitializer
|
||||
}
|
||||
assert(m_col<m_matrix.cols() && "Too many coefficients passed to Matrix::operator<<");
|
||||
assert(m_currentBlockRows==1);
|
||||
m_matrix._coeffRef(m_row, m_col++) = s;
|
||||
m_matrix.coeffRef(m_row, m_col++) = s;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -77,7 +77,9 @@ struct MatrixBase<Derived>::CommaInitializer
|
||||
|
||||
~CommaInitializer(void)
|
||||
{
|
||||
assert((m_row+m_currentBlockRows)==m_matrix.rows() && m_col==m_matrix.cols() && "Too few coefficients passed to Matrix::operator<<");
|
||||
assert((m_row+m_currentBlockRows) == m_matrix.rows()
|
||||
&& m_col == m_matrix.cols()
|
||||
&& "Too few coefficients passed to Matrix::operator<<");
|
||||
}
|
||||
|
||||
Derived& m_matrix;
|
||||
|
@ -47,20 +47,32 @@
|
||||
* \sa class ScalarProductOp, class ScalarQuotientOp
|
||||
*/
|
||||
template<typename BinaryOp, typename Lhs, typename Rhs>
|
||||
struct Scalar<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
||||
{ typedef typename ei_result_of<BinaryOp(typename Lhs::Scalar,typename Rhs::Scalar)>::type Type; };
|
||||
struct ei_traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
||||
{
|
||||
typedef typename ei_result_of<
|
||||
BinaryOp(
|
||||
typename Lhs::Scalar,
|
||||
typename Rhs::Scalar
|
||||
)
|
||||
>::type Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Lhs::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = Lhs::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename BinaryOp, typename Lhs, typename Rhs>
|
||||
class CwiseBinaryOp : NoOperatorEquals,
|
||||
public MatrixBase<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<CwiseBinaryOp>::Type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(CwiseBinaryOp)
|
||||
|
||||
typedef typename Lhs::AsArg LhsRef;
|
||||
typedef typename Rhs::AsArg RhsRef;
|
||||
friend class MatrixBase<CwiseBinaryOp>;
|
||||
friend class MatrixBase<CwiseBinaryOp>::Traits;
|
||||
typedef MatrixBase<CwiseBinaryOp> Base;
|
||||
|
||||
CwiseBinaryOp(const LhsRef& lhs, const RhsRef& rhs, const BinaryOp& func = BinaryOp())
|
||||
: m_lhs(lhs), m_rhs(rhs), m_functor(func)
|
||||
@ -69,12 +81,6 @@ class CwiseBinaryOp : NoOperatorEquals,
|
||||
}
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Lhs::Traits::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = Lhs::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = Lhs::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
const CwiseBinaryOp& _asArg() const { return *this; }
|
||||
int _rows() const { return m_lhs.rows(); }
|
||||
|
@ -40,29 +40,32 @@
|
||||
* \sa class CwiseBinaryOp
|
||||
*/
|
||||
template<typename UnaryOp, typename MatrixType>
|
||||
struct Scalar<CwiseUnaryOp<UnaryOp, MatrixType> >
|
||||
{ typedef typename ei_result_of<UnaryOp(typename MatrixType::Scalar)>::type Type; };
|
||||
struct ei_traits<CwiseUnaryOp<UnaryOp, MatrixType> >
|
||||
{
|
||||
typedef typename ei_result_of<
|
||||
UnaryOp(typename MatrixType::Scalar)
|
||||
>::type Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename UnaryOp, typename MatrixType>
|
||||
class CwiseUnaryOp : NoOperatorEquals,
|
||||
public MatrixBase<CwiseUnaryOp<UnaryOp, MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename ei_result_of<UnaryOp(typename MatrixType::Scalar)>::type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(CwiseUnaryOp)
|
||||
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<CwiseUnaryOp>;
|
||||
friend class MatrixBase<CwiseUnaryOp>::Traits;
|
||||
typedef MatrixBase<CwiseUnaryOp> Base;
|
||||
|
||||
CwiseUnaryOp(const MatRef& mat, const UnaryOp& func = UnaryOp()) : m_matrix(mat), m_functor(func) {}
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
const CwiseUnaryOp& _asArg() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
@ -155,7 +158,7 @@ MatrixBase<Derived>::conjugate() const
|
||||
}
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to cast a scalar to another
|
||||
* \brief Template functor to cast a scalar to another type
|
||||
*
|
||||
* \sa class CwiseUnaryOp, MatrixBase::cast()
|
||||
*/
|
||||
@ -183,9 +186,8 @@ MatrixBase<Derived>::cast() const
|
||||
return CwiseUnaryOp<ScalarCastOp<NewType>, Derived>(asArg());
|
||||
}
|
||||
|
||||
|
||||
/** \internal
|
||||
* \brief Template functor to multiply a scalar by a fixed another one
|
||||
* \brief Template functor to multiply a scalar by a fixed other one
|
||||
*
|
||||
* \sa class CwiseUnaryOp, MatrixBase::operator*, MatrixBase::operator/
|
||||
*/
|
||||
@ -198,7 +200,7 @@ struct ScalarMultipleOp {
|
||||
|
||||
/** \relates MatrixBase \sa class ScalarMultipleOp */
|
||||
template<typename Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<typename Scalar<Derived>::Type>, Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
MatrixBase<Derived>::operator*(const Scalar& scalar) const
|
||||
{
|
||||
return CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>(asArg(), ScalarMultipleOp<Scalar>(scalar));
|
||||
@ -206,7 +208,7 @@ MatrixBase<Derived>::operator*(const Scalar& scalar) const
|
||||
|
||||
/** \relates MatrixBase \sa class ScalarMultipleOp */
|
||||
template<typename Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<typename Scalar<Derived>::Type>, Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
MatrixBase<Derived>::operator/(const Scalar& scalar) const
|
||||
{
|
||||
assert(NumTraits<Scalar>::HasFloatingPoint);
|
||||
|
@ -38,34 +38,35 @@
|
||||
* \sa MatrixBase::diagonal()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<DiagonalCoeffs<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<DiagonalCoeffs<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::SizeAtCompileTime == Dynamic ? Dynamic
|
||||
: EIGEN_ENUM_MIN(MatrixType::RowsAtCompileTime,
|
||||
MatrixType::ColsAtCompileTime),
|
||||
ColsAtCompileTime = 1,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxSizeAtCompileTime == Dynamic ? Dynamic
|
||||
: EIGEN_ENUM_MIN(MatrixType::MaxRowsAtCompileTime,
|
||||
MatrixType::MaxColsAtCompileTime),
|
||||
MaxColsAtCompileTime = 1
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class DiagonalCoeffs
|
||||
: public MatrixBase<DiagonalCoeffs<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(DiagonalCoeffs)
|
||||
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<DiagonalCoeffs>;
|
||||
friend class MatrixBase<DiagonalCoeffs>::Traits;
|
||||
typedef MatrixBase<DiagonalCoeffs> Base;
|
||||
|
||||
DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::SizeAtCompileTime == Dynamic ? Dynamic
|
||||
: EIGEN_ENUM_MIN(MatrixType::Traits::RowsAtCompileTime,
|
||||
MatrixType::Traits::ColsAtCompileTime),
|
||||
ColsAtCompileTime = 1,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxSizeAtCompileTime == Dynamic ? Dynamic
|
||||
: EIGEN_ENUM_MIN(MatrixType::Traits::MaxRowsAtCompileTime,
|
||||
MatrixType::Traits::MaxColsAtCompileTime),
|
||||
MaxColsAtCompileTime = 1
|
||||
};
|
||||
|
||||
const DiagonalCoeffs& _asArg() const { return *this; }
|
||||
int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); }
|
||||
|
@ -39,33 +39,34 @@
|
||||
* \sa MatrixBase::diagonal(const OtherDerived&)
|
||||
*/
|
||||
template<typename CoeffsVectorType>
|
||||
struct Scalar<DiagonalMatrix<CoeffsVectorType> >
|
||||
{ typedef typename Scalar<CoeffsVectorType>::Type Type; };
|
||||
struct ei_traits<DiagonalMatrix<CoeffsVectorType> >
|
||||
{
|
||||
typedef typename CoeffsVectorType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = CoeffsVectorType::SizeAtCompileTime,
|
||||
ColsAtCompileTime = CoeffsVectorType::SizeAtCompileTime,
|
||||
MaxRowsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime,
|
||||
MaxColsAtCompileTime = CoeffsVectorType::MaxSizeAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename CoeffsVectorType>
|
||||
class DiagonalMatrix : NoOperatorEquals,
|
||||
public MatrixBase<DiagonalMatrix<CoeffsVectorType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<CoeffsVectorType>::Type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(DiagonalMatrix)
|
||||
|
||||
typedef typename CoeffsVectorType::AsArg CoeffsVecRef;
|
||||
friend class MatrixBase<DiagonalMatrix>;
|
||||
friend class MatrixBase<DiagonalMatrix>::Traits;
|
||||
typedef MatrixBase<DiagonalMatrix> Base;
|
||||
|
||||
DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs)
|
||||
{
|
||||
assert(CoeffsVectorType::Traits::IsVectorAtCompileTime
|
||||
assert(CoeffsVectorType::IsVectorAtCompileTime
|
||||
&& coeffs.size() > 0);
|
||||
}
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime,
|
||||
ColsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime,
|
||||
MaxRowsAtCompileTime = CoeffsVectorType::Traits::MaxSizeAtCompileTime,
|
||||
MaxColsAtCompileTime = CoeffsVectorType::Traits::MaxSizeAtCompileTime
|
||||
};
|
||||
|
||||
const DiagonalMatrix& _asArg() const { return *this; }
|
||||
int _rows() const { return m_coeffs.size(); }
|
||||
|
@ -69,18 +69,18 @@ struct DotUnroller<Index, 0, Derived1, Derived2>
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
typename Scalar<Derived>::Type
|
||||
typename ei_traits<Derived>::Scalar
|
||||
MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime
|
||||
&& OtherDerived::Traits::IsVectorAtCompileTime
|
||||
assert(IsVectorAtCompileTime
|
||||
&& OtherDerived::IsVectorAtCompileTime
|
||||
&& size() == other.size());
|
||||
Scalar res;
|
||||
if(EIGEN_UNROLLED_LOOPS
|
||||
&& Traits::SizeAtCompileTime != Dynamic
|
||||
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||
DotUnroller<Traits::SizeAtCompileTime-1,
|
||||
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::SizeAtCompileTime : Dynamic,
|
||||
&& SizeAtCompileTime != Dynamic
|
||||
&& SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||
DotUnroller<SizeAtCompileTime-1,
|
||||
SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? SizeAtCompileTime : Dynamic,
|
||||
Derived, MatrixBase<OtherDerived> >
|
||||
::run(*static_cast<const Derived*>(this), other, res);
|
||||
else
|
||||
@ -99,7 +99,7 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
|
||||
* \sa dot(), norm()
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename NumTraits<typename Scalar<Derived>::Type>::Real MatrixBase<Derived>::norm2() const
|
||||
typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm2() const
|
||||
{
|
||||
return ei_real(dot(*this));
|
||||
}
|
||||
@ -111,7 +111,7 @@ typename NumTraits<typename Scalar<Derived>::Type>::Real MatrixBase<Derived>::no
|
||||
* \sa dot(), norm2()
|
||||
*/
|
||||
template<typename Derived>
|
||||
typename NumTraits<typename Scalar<Derived>::Type>::Real MatrixBase<Derived>::norm() const
|
||||
typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const
|
||||
{
|
||||
return ei_sqrt(norm2());
|
||||
}
|
||||
@ -123,7 +123,7 @@ typename NumTraits<typename Scalar<Derived>::Type>::Real MatrixBase<Derived>::no
|
||||
* \sa norm()
|
||||
*/
|
||||
template<typename Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<typename Scalar<Derived>::Type>, Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<typename ei_traits<Derived>::Scalar>, Derived>
|
||||
MatrixBase<Derived>::normalized() const
|
||||
{
|
||||
return (*this) / norm();
|
||||
|
@ -45,19 +45,26 @@
|
||||
* \sa MatrixBase::eval()
|
||||
*/
|
||||
template<typename ExpressionType>
|
||||
struct Scalar<Eval<ExpressionType> >
|
||||
{ typedef typename Scalar<ExpressionType>::Type Type; };
|
||||
struct ei_traits<Eval<ExpressionType> >
|
||||
{
|
||||
typedef typename ExpressionType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = ExpressionType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = ExpressionType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename ExpressionType> class Eval : NoOperatorEquals,
|
||||
public Matrix< typename ExpressionType::Scalar,
|
||||
ExpressionType::Traits::RowsAtCompileTime,
|
||||
ExpressionType::Traits::ColsAtCompileTime,
|
||||
ExpressionType::RowsAtCompileTime,
|
||||
ExpressionType::ColsAtCompileTime,
|
||||
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
|
||||
ExpressionType::Traits::MaxRowsAtCompileTime,
|
||||
ExpressionType::Traits::MaxColsAtCompileTime>
|
||||
ExpressionType::MaxRowsAtCompileTime,
|
||||
ExpressionType::MaxColsAtCompileTime>
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<ExpressionType>::Type Scalar;
|
||||
|
||||
/** The actual matrix type to evaluate to. This type can be used independently
|
||||
* of the rest of this class to get the actual matrix type to evaluate and store
|
||||
@ -67,12 +74,14 @@ template<typename ExpressionType> class Eval : NoOperatorEquals,
|
||||
* \include Eval_MatrixType.cpp
|
||||
* Output: \verbinclude Eval_MatrixType.out
|
||||
*/
|
||||
typedef Matrix<Scalar,
|
||||
ExpressionType::Traits::RowsAtCompileTime,
|
||||
ExpressionType::Traits::ColsAtCompileTime,
|
||||
typedef Matrix<typename ExpressionType::Scalar,
|
||||
ExpressionType::RowsAtCompileTime,
|
||||
ExpressionType::ColsAtCompileTime,
|
||||
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
|
||||
ExpressionType::Traits::MaxRowsAtCompileTime,
|
||||
ExpressionType::Traits::MaxColsAtCompileTime> MatrixType;
|
||||
ExpressionType::MaxRowsAtCompileTime,
|
||||
ExpressionType::MaxColsAtCompileTime> MatrixType;
|
||||
|
||||
_EIGEN_BASIC_PUBLIC_INTERFACE(Eval, MatrixType)
|
||||
|
||||
explicit Eval(const ExpressionType& expr) : MatrixType(expr) {}
|
||||
};
|
||||
|
@ -39,27 +39,40 @@
|
||||
*
|
||||
* \sa MatrixBase::evalOMP(), class Eval, MatrixBase::eval()
|
||||
*/
|
||||
template<typename ExpressionType>
|
||||
struct ei_traits<EvalOMP<ExpressionType> >
|
||||
{
|
||||
typedef typename ExpressionType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = ExpressionType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = ExpressionType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = ExpressionType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = ExpressionType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename ExpressionType> class EvalOMP : NoOperatorEquals,
|
||||
public Matrix< typename ExpressionType::Scalar,
|
||||
ExpressionType::Traits::RowsAtCompileTime,
|
||||
ExpressionType::Traits::ColsAtCompileTime,
|
||||
ExpressionType::RowsAtCompileTime,
|
||||
ExpressionType::ColsAtCompileTime,
|
||||
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
|
||||
ExpressionType::Traits::MaxRowsAtCompileTime,
|
||||
ExpressionType::Traits::MaxColsAtCompileTime>
|
||||
ExpressionType::MaxRowsAtCompileTime,
|
||||
ExpressionType::MaxColsAtCompileTime>
|
||||
{
|
||||
public:
|
||||
typedef typename ExpressionType::Scalar Scalar;
|
||||
|
||||
/** The actual matrix type to evaluate to. This type can be used independently
|
||||
* of the rest of this class to get the actual matrix type to evaluate and store
|
||||
* the value of an expression.
|
||||
*/
|
||||
typedef Matrix<Scalar,
|
||||
ExpressionType::Traits::RowsAtCompileTime,
|
||||
ExpressionType::Traits::ColsAtCompileTime,
|
||||
typedef Matrix<typename ExpressionType::Scalar,
|
||||
ExpressionType::RowsAtCompileTime,
|
||||
ExpressionType::ColsAtCompileTime,
|
||||
EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
|
||||
ExpressionType::Traits::MaxRowsAtCompileTime,
|
||||
ExpressionType::Traits::MaxColsAtCompileTime> MatrixType;
|
||||
ExpressionType::MaxRowsAtCompileTime,
|
||||
ExpressionType::MaxColsAtCompileTime> MatrixType;
|
||||
|
||||
_EIGEN_BASIC_PUBLIC_INTERFACE(EvalOMP, MatrixType)
|
||||
|
||||
#ifdef _OPENMP
|
||||
explicit EvalOMP(const ExpressionType& other)
|
||||
|
@ -25,7 +25,7 @@
|
||||
#ifndef EIGEN_FORWARDDECLARATIONS_H
|
||||
#define EIGEN_FORWARDDECLARATIONS_H
|
||||
|
||||
template<typename T> struct Scalar;
|
||||
template<typename T> struct ei_traits;
|
||||
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> class Matrix;
|
||||
template<typename MatrixType> class MatrixRef;
|
||||
|
@ -49,7 +49,7 @@ bool MatrixBase<Derived>::isApprox(
|
||||
) const
|
||||
{
|
||||
assert(rows() == other.rows() && cols() == other.cols());
|
||||
if(Traits::IsVectorAtCompileTime)
|
||||
if(IsVectorAtCompileTime)
|
||||
{
|
||||
return((*this - other).norm2() <= std::min(norm2(), other.norm2()) * prec * prec);
|
||||
}
|
||||
@ -79,7 +79,7 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
|
||||
typename NumTraits<Scalar>::Real prec
|
||||
) const
|
||||
{
|
||||
if(Traits::IsVectorAtCompileTime)
|
||||
if(IsVectorAtCompileTime)
|
||||
{
|
||||
return(norm2() <= ei_abs2(other * prec));
|
||||
}
|
||||
@ -110,7 +110,7 @@ bool MatrixBase<Derived>::isMuchSmallerThan(
|
||||
) const
|
||||
{
|
||||
assert(rows() == other.rows() && cols() == other.cols());
|
||||
if(Traits::IsVectorAtCompileTime)
|
||||
if(IsVectorAtCompileTime)
|
||||
{
|
||||
return(norm2() <= other.norm2() * prec * prec);
|
||||
}
|
||||
|
@ -32,17 +32,23 @@
|
||||
* \sa MatrixBase::identity(), MatrixBase::identity(int,int), MatrixBase::setIdentity()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Identity<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Identity<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class Identity : NoOperatorEquals,
|
||||
public MatrixBase<Identity<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
friend class MatrixBase<Identity>;
|
||||
friend class MatrixBase<Identity>::Traits;
|
||||
typedef MatrixBase<Identity> Base;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Identity)
|
||||
|
||||
Identity(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
@ -53,12 +59,6 @@ template<typename MatrixType> class Identity : NoOperatorEquals,
|
||||
}
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
const Identity& _asArg() const { return *this; }
|
||||
int _rows() const { return m_rows.value(); }
|
||||
@ -107,7 +107,7 @@ const Identity<Derived> MatrixBase<Derived>::identity(int rows, int cols)
|
||||
template<typename Derived>
|
||||
const Identity<Derived> MatrixBase<Derived>::identity()
|
||||
{
|
||||
return Identity<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||
return Identity<Derived>(RowsAtCompileTime, ColsAtCompileTime);
|
||||
}
|
||||
|
||||
/** \returns true if *this is approximately equal to the identity matrix
|
||||
|
@ -39,26 +39,25 @@
|
||||
* \sa Matrix::map()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Map<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Map<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class Map
|
||||
: public MatrixBase<Map<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
friend class MatrixBase<Map>;
|
||||
friend class MatrixBase<Map>::Traits;
|
||||
typedef MatrixBase<Map> Base;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Map)
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
Order = MatrixType::StorageOrder,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
const Map& _asArg() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
@ -66,7 +65,7 @@ template<typename MatrixType> class Map
|
||||
|
||||
const Scalar& _coeff(int row, int col) const
|
||||
{
|
||||
if(Order == ColumnMajor)
|
||||
if(MatrixType::StorageOrder == ColumnMajor)
|
||||
return m_data[row + col * m_rows];
|
||||
else // RowMajor
|
||||
return m_data[col + row * m_cols];
|
||||
@ -74,7 +73,7 @@ template<typename MatrixType> class Map
|
||||
|
||||
Scalar& _coeffRef(int row, int col)
|
||||
{
|
||||
if(Order == ColumnMajor)
|
||||
if(MatrixType::StorageOrder == ColumnMajor)
|
||||
return const_cast<Scalar*>(m_data)[row + col * m_rows];
|
||||
else // RowMajor
|
||||
return const_cast<Scalar*>(m_data)[col + row * m_cols];
|
||||
|
@ -72,8 +72,16 @@
|
||||
* 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>
|
||||
struct Scalar<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> >
|
||||
{ typedef _Scalar Type; };
|
||||
struct ei_traits<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> >
|
||||
{
|
||||
typedef _Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = _Rows,
|
||||
ColsAtCompileTime = _Cols,
|
||||
MaxRowsAtCompileTime = _MaxRows,
|
||||
MaxColsAtCompileTime = _MaxCols,
|
||||
};
|
||||
};
|
||||
|
||||
template<typename _Scalar, int _Rows, int _Cols,
|
||||
int _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
|
||||
@ -82,26 +90,17 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols,
|
||||
_StorageOrder, _MaxRows, _MaxCols> >
|
||||
{
|
||||
public:
|
||||
friend class MatrixBase<Matrix>;
|
||||
friend class MatrixBase<Matrix>::Traits;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Matrix)
|
||||
|
||||
enum { StorageOrder = _StorageOrder };
|
||||
|
||||
friend class Map<Matrix>;
|
||||
|
||||
typedef MatrixBase<Matrix> Base;
|
||||
typedef typename Scalar<Matrix>::Type Scalar;
|
||||
typedef MatrixRef<Matrix> AsArg;
|
||||
friend class MatrixRef<Matrix>;
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = _Rows,
|
||||
ColsAtCompileTime = _Cols,
|
||||
StorageOrder = _StorageOrder,
|
||||
MaxRowsAtCompileTime = _MaxRows,
|
||||
MaxColsAtCompileTime = _MaxCols,
|
||||
MaxSizeAtCompileTime = _MaxRows == Dynamic || _MaxCols == Dynamic
|
||||
? Dynamic
|
||||
: _MaxRows * _MaxCols
|
||||
};
|
||||
|
||||
MatrixStorage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime> m_storage;
|
||||
|
||||
@ -167,7 +166,7 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols,
|
||||
resize(other.size(), 1);
|
||||
}
|
||||
else resize(other.rows(), other.cols());
|
||||
return Base::operator=(other);
|
||||
return MatrixBase<Matrix>::operator=(other);
|
||||
}
|
||||
|
||||
/** This is a special case of the templated operator=. Its purpose is to
|
||||
|
@ -55,76 +55,74 @@ template<typename Derived> class MatrixBase
|
||||
|
||||
public:
|
||||
|
||||
typedef typename Scalar<Derived>::Type Scalar;
|
||||
typedef typename ei_traits<Derived>::Scalar Scalar;
|
||||
|
||||
/** \brief Some traits provided by the Derived type.
|
||||
/** The number of rows at compile-time. This is just a copy of the value provided
|
||||
* by the \a Derived type. If a value is not known at compile-time,
|
||||
* it is set to the \a Dynamic constant.
|
||||
* \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */
|
||||
enum { RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime };
|
||||
|
||||
/** The number of columns at compile-time. This is just a copy of the value provided
|
||||
* by the \a Derived type. If a value is not known at compile-time,
|
||||
* it is set to the \a Dynamic constant.
|
||||
* \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
|
||||
enum { ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime };
|
||||
|
||||
/** This is equal to the number of coefficients, i.e. the number of
|
||||
* rows times the number of columns, or to \a Dynamic if this is not
|
||||
* known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
|
||||
enum { SizeAtCompileTime
|
||||
= ei_traits<Derived>::RowsAtCompileTime == Dynamic
|
||||
|| ei_traits<Derived>::ColsAtCompileTime == Dynamic
|
||||
? Dynamic
|
||||
: ei_traits<Derived>::RowsAtCompileTime * ei_traits<Derived>::ColsAtCompileTime
|
||||
};
|
||||
|
||||
/** This value is equal to the maximum possible number of rows that this expression
|
||||
* might have. If this expression might have an arbitrarily high number of rows,
|
||||
* this value is set to \a Dynamic.
|
||||
*
|
||||
* Grouping these in a nested subclass is what was needed for ICC compatibility. */
|
||||
struct Traits
|
||||
{
|
||||
/** The number of rows at compile-time. This is just a copy of the value provided
|
||||
* by the \a Derived type. If a value is not known at compile-time,
|
||||
* it is set to the \a Dynamic constant.
|
||||
* \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */
|
||||
enum { RowsAtCompileTime = Derived::RowsAtCompileTime };
|
||||
* This value is useful to know when evaluating an expression, in order to determine
|
||||
* whether it is possible to avoid doing a dynamic memory allocation.
|
||||
*
|
||||
* \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
|
||||
*/
|
||||
enum { MaxRowsAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime };
|
||||
|
||||
/** The number of columns at compile-time. This is just a copy of the value provided
|
||||
* by the \a Derived type. If a value is not known at compile-time,
|
||||
* it is set to the \a Dynamic constant.
|
||||
* \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
|
||||
enum { ColsAtCompileTime = Derived::ColsAtCompileTime };
|
||||
/** This value is equal to the maximum possible number of columns that this expression
|
||||
* might have. If this expression might have an arbitrarily high number of columns,
|
||||
* this value is set to \a Dynamic.
|
||||
*
|
||||
* This value is useful to know when evaluating an expression, in order to determine
|
||||
* whether it is possible to avoid doing a dynamic memory allocation.
|
||||
*
|
||||
* \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
|
||||
*/
|
||||
enum { MaxColsAtCompileTime = ei_traits<Derived>::MaxColsAtCompileTime };
|
||||
|
||||
/** This is equal to the number of coefficients, i.e. the number of
|
||||
* rows times the number of columns, or to \a Dynamic if this is not
|
||||
* known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
|
||||
enum { SizeAtCompileTime
|
||||
= Derived::RowsAtCompileTime == Dynamic || Derived::ColsAtCompileTime == Dynamic
|
||||
? Dynamic : Derived::RowsAtCompileTime * Derived::ColsAtCompileTime
|
||||
};
|
||||
/** This value is equal to the maximum possible number of coefficients that this expression
|
||||
* might have. If this expression might have an arbitrarily high number of coefficients,
|
||||
* this value is set to \a Dynamic.
|
||||
*
|
||||
* This value is useful to know when evaluating an expression, in order to determine
|
||||
* whether it is possible to avoid doing a dynamic memory allocation.
|
||||
*
|
||||
* \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
|
||||
*/
|
||||
enum { MaxSizeAtCompileTime
|
||||
= ei_traits<Derived>::MaxRowsAtCompileTime == Dynamic
|
||||
|| ei_traits<Derived>::MaxColsAtCompileTime == Dynamic
|
||||
? Dynamic
|
||||
: ei_traits<Derived>::MaxRowsAtCompileTime * ei_traits<Derived>::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
/** This value is equal to the maximum possible number of rows that this expression
|
||||
* might have. If this expression might have an arbitrarily high number of rows,
|
||||
* this value is set to \a Dynamic.
|
||||
*
|
||||
* This value is useful to know when evaluating an expression, in order to determine
|
||||
* whether it is possible to avoid doing a dynamic memory allocation.
|
||||
*
|
||||
* \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
|
||||
*/
|
||||
enum { MaxRowsAtCompileTime = Derived::MaxRowsAtCompileTime };
|
||||
|
||||
/** This value is equal to the maximum possible number of columns that this expression
|
||||
* might have. If this expression might have an arbitrarily high number of columns,
|
||||
* this value is set to \a Dynamic.
|
||||
*
|
||||
* This value is useful to know when evaluating an expression, in order to determine
|
||||
* whether it is possible to avoid doing a dynamic memory allocation.
|
||||
*
|
||||
* \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
|
||||
*/
|
||||
enum { MaxColsAtCompileTime = Derived::MaxColsAtCompileTime };
|
||||
|
||||
/** This value is equal to the maximum possible number of coefficients that this expression
|
||||
* might have. If this expression might have an arbitrarily high number of coefficients,
|
||||
* this value is set to \a Dynamic.
|
||||
*
|
||||
* This value is useful to know when evaluating an expression, in order to determine
|
||||
* whether it is possible to avoid doing a dynamic memory allocation.
|
||||
*
|
||||
* \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
|
||||
*/
|
||||
enum { MaxSizeAtCompileTime
|
||||
= Derived::MaxRowsAtCompileTime == Dynamic || Derived::MaxColsAtCompileTime == Dynamic
|
||||
? Dynamic : Derived::MaxRowsAtCompileTime * Derived::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
/** 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,
|
||||
* we are dealing with a column-vector (if there is only one column) or with
|
||||
* a row-vector (if there is only one row). */
|
||||
enum { IsVectorAtCompileTime
|
||||
= Derived::RowsAtCompileTime == 1 || Derived::ColsAtCompileTime == 1
|
||||
};
|
||||
/** 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,
|
||||
* we are dealing with a column-vector (if there is only one column) or with
|
||||
* a row-vector (if there is only one row). */
|
||||
enum { IsVectorAtCompileTime
|
||||
= ei_traits<Derived>::RowsAtCompileTime == 1 || ei_traits<Derived>::ColsAtCompileTime == 1
|
||||
};
|
||||
|
||||
/** This is the "reference type" used to pass objects of type MatrixBase as arguments
|
||||
@ -149,17 +147,17 @@ template<typename Derived> class MatrixBase
|
||||
|
||||
/// \name matrix properties
|
||||
//@{
|
||||
/** \returns the number of rows. \sa cols(), Traits::RowsAtCompileTime */
|
||||
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */
|
||||
int rows() const { return static_cast<const Derived *>(this)->_rows(); }
|
||||
/** \returns the number of columns. \sa row(), Traits::ColsAtCompileTime*/
|
||||
/** \returns the number of columns. \sa row(), ColsAtCompileTime*/
|
||||
int cols() const { return static_cast<const Derived *>(this)->_cols(); }
|
||||
/** \returns the number of coefficients, which is \a rows()*cols().
|
||||
* \sa rows(), cols(), Traits::SizeAtCompileTime. */
|
||||
* \sa rows(), cols(), SizeAtCompileTime. */
|
||||
int size() const { return rows() * cols(); }
|
||||
/** \returns true if either the number of rows or the number of columns is equal to 1.
|
||||
* In other words, this function returns
|
||||
* \code rows()==1 || cols()==1 \endcode
|
||||
* \sa rows(), cols(), Traits::IsVectorAtCompileTime. */
|
||||
* \sa rows(), cols(), IsVectorAtCompileTime. */
|
||||
bool isVector() const { return rows()==1 || cols()==1; }
|
||||
//@}
|
||||
|
||||
|
@ -26,17 +26,23 @@
|
||||
#define EIGEN_MATRIXREF_H
|
||||
|
||||
template<typename MatrixType>
|
||||
struct Scalar<MatrixRef<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<MatrixRef<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class MatrixRef
|
||||
: public MatrixBase<MatrixRef<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixRef>::Type Scalar;
|
||||
friend class MatrixBase<MatrixRef>;
|
||||
friend class MatrixBase<MatrixRef>::Traits;
|
||||
typedef MatrixBase<MatrixRef> Base;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(MatrixRef)
|
||||
|
||||
MatrixRef(const MatrixType& matrix) : m_matrix(matrix) {}
|
||||
~MatrixRef() {}
|
||||
@ -44,12 +50,6 @@ template<typename MatrixType> class MatrixRef
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef)
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
MatrixRef _asArg() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
|
@ -38,18 +38,29 @@
|
||||
* \sa MatrixBase::minor()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Minor<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Minor<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
|
||||
MatrixType::RowsAtCompileTime - 1 : Dynamic,
|
||||
ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
|
||||
MatrixType::ColsAtCompileTime - 1 : Dynamic,
|
||||
MaxRowsAtCompileTime = (MatrixType::MaxRowsAtCompileTime != Dynamic) ?
|
||||
MatrixType::MaxRowsAtCompileTime - 1 : Dynamic,
|
||||
MaxColsAtCompileTime = (MatrixType::MaxColsAtCompileTime != Dynamic) ?
|
||||
MatrixType::MaxColsAtCompileTime - 1 : Dynamic
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class Minor
|
||||
: public MatrixBase<Minor<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Minor)
|
||||
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Minor>;
|
||||
friend class MatrixBase<Minor>::Traits;
|
||||
typedef MatrixBase<Minor> Base;
|
||||
|
||||
Minor(const MatRef& matrix,
|
||||
int row, int col)
|
||||
@ -62,16 +73,6 @@ template<typename MatrixType> class Minor
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = (MatrixType::Traits::RowsAtCompileTime != Dynamic) ?
|
||||
MatrixType::Traits::RowsAtCompileTime - 1 : Dynamic,
|
||||
ColsAtCompileTime = (MatrixType::Traits::ColsAtCompileTime != Dynamic) ?
|
||||
MatrixType::Traits::ColsAtCompileTime - 1 : Dynamic,
|
||||
MaxRowsAtCompileTime = (MatrixType::Traits::MaxRowsAtCompileTime != Dynamic) ?
|
||||
MatrixType::Traits::MaxRowsAtCompileTime - 1 : Dynamic,
|
||||
MaxColsAtCompileTime = (MatrixType::Traits::MaxColsAtCompileTime != Dynamic) ?
|
||||
MatrixType::Traits::MaxColsAtCompileTime - 1 : Dynamic
|
||||
};
|
||||
|
||||
const Minor& _asArg() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows() - 1; }
|
||||
|
@ -33,25 +33,25 @@
|
||||
* MatrixBase::setOnes(), MatrixBase::isOnes()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Ones<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Ones<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class Ones : NoOperatorEquals,
|
||||
public MatrixBase<Ones<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
friend class MatrixBase<Ones>;
|
||||
friend class MatrixBase<Ones>::Traits;
|
||||
typedef MatrixBase<Ones> Base;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Ones)
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
const Ones& _asArg() const { return *this; }
|
||||
int _rows() const { return m_rows.value(); }
|
||||
@ -115,8 +115,8 @@ const Ones<Derived> MatrixBase<Derived>::ones(int rows, int cols)
|
||||
template<typename Derived>
|
||||
const Ones<Derived> MatrixBase<Derived>::ones(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1) return Ones<Derived>(1, size);
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1) return Ones<Derived>(1, size);
|
||||
else return Ones<Derived>(size, 1);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ const Ones<Derived> MatrixBase<Derived>::ones(int size)
|
||||
template<typename Derived>
|
||||
const Ones<Derived> MatrixBase<Derived>::ones()
|
||||
{
|
||||
return Ones<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||
return Ones<Derived>(RowsAtCompileTime, ColsAtCompileTime);
|
||||
}
|
||||
|
||||
/** \returns true if *this is approximately equal to the matrix where all coefficients
|
||||
|
@ -30,8 +30,8 @@ template<typename Derived1, typename Derived2, int UnrollCount>
|
||||
struct MatrixOperatorEqualsUnroller
|
||||
{
|
||||
enum {
|
||||
col = (UnrollCount-1) / Derived1::Traits::RowsAtCompileTime,
|
||||
row = (UnrollCount-1) % Derived1::Traits::RowsAtCompileTime
|
||||
col = (UnrollCount-1) / Derived1::RowsAtCompileTime,
|
||||
row = (UnrollCount-1) % Derived1::RowsAtCompileTime
|
||||
};
|
||||
|
||||
static void run(Derived1 &dst, const Derived2 &src)
|
||||
@ -102,16 +102,16 @@ template<typename OtherDerived>
|
||||
Derived& MatrixBase<Derived>
|
||||
::operator=(const MatrixBase<OtherDerived>& other)
|
||||
{
|
||||
if(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime)
|
||||
if(IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime)
|
||||
// copying a vector expression into a vector
|
||||
{
|
||||
assert(size() == other.size());
|
||||
if(EIGEN_UNROLLED_LOOPS
|
||||
&& Traits::SizeAtCompileTime != Dynamic
|
||||
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL)
|
||||
&& SizeAtCompileTime != Dynamic
|
||||
&& SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL)
|
||||
VectorOperatorEqualsUnroller
|
||||
<Derived, OtherDerived,
|
||||
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? Traits::SizeAtCompileTime : Dynamic>::run
|
||||
SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? SizeAtCompileTime : Dynamic>::run
|
||||
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
||||
else
|
||||
for(int i = 0; i < size(); i++)
|
||||
@ -122,17 +122,17 @@ Derived& MatrixBase<Derived>
|
||||
{
|
||||
assert(rows() == other.rows() && cols() == other.cols());
|
||||
if(EIGEN_UNROLLED_LOOPS
|
||||
&& Traits::SizeAtCompileTime != Dynamic
|
||||
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL)
|
||||
&& SizeAtCompileTime != Dynamic
|
||||
&& SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL)
|
||||
{
|
||||
MatrixOperatorEqualsUnroller
|
||||
<Derived, OtherDerived,
|
||||
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? Traits::SizeAtCompileTime : Dynamic>::run
|
||||
SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_OPEQUAL ? SizeAtCompileTime : Dynamic>::run
|
||||
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Traits::ColsAtCompileTime == Dynamic || Traits::RowsAtCompileTime != Dynamic)
|
||||
if(ColsAtCompileTime == Dynamic || RowsAtCompileTime != Dynamic)
|
||||
{
|
||||
// traverse in column-major order
|
||||
for(int j = 0; j < cols(); j++)
|
||||
|
@ -1,4 +1,4 @@
|
||||
// // This file is part of Eigen, a lightweight C++ template library
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra. Eigen itself is part of the KDE project.
|
||||
//
|
||||
// Copyright (C) 2006-2008 Benoit Jacob <jacob@math.jussieu.fr>
|
||||
@ -73,19 +73,26 @@ struct ProductUnroller<Index, 0, Lhs, Rhs>
|
||||
* \sa class Sum, class Difference
|
||||
*/
|
||||
template<typename Lhs, typename Rhs>
|
||||
struct Scalar<Product<Lhs, Rhs> >
|
||||
{ typedef typename Scalar<Lhs>::Type Type; };
|
||||
struct ei_traits<Product<Lhs, Rhs> >
|
||||
{
|
||||
typedef typename Lhs::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = Lhs::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = Rhs::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
||||
public MatrixBase<Product<Lhs, Rhs> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<Lhs>::Type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Product)
|
||||
|
||||
typedef typename Lhs::AsArg LhsRef;
|
||||
typedef typename Rhs::AsArg RhsRef;
|
||||
friend class MatrixBase<Product>;
|
||||
friend class MatrixBase<Product>::Traits;
|
||||
typedef MatrixBase<Product> Base;
|
||||
|
||||
Product(const LhsRef& lhs, const RhsRef& rhs)
|
||||
: m_lhs(lhs), m_rhs(rhs)
|
||||
@ -94,12 +101,6 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
||||
}
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = Lhs::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = Rhs::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
const Product& _asArg() const { return *this; }
|
||||
int _rows() const { return m_lhs.rows(); }
|
||||
@ -109,10 +110,10 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
||||
{
|
||||
Scalar res;
|
||||
if(EIGEN_UNROLLED_LOOPS
|
||||
&& Lhs::Traits::ColsAtCompileTime != Dynamic
|
||||
&& Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||
ProductUnroller<Lhs::Traits::ColsAtCompileTime-1,
|
||||
Lhs::Traits::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Lhs::Traits::ColsAtCompileTime : Dynamic,
|
||||
&& Lhs::ColsAtCompileTime != Dynamic
|
||||
&& Lhs::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||
ProductUnroller<Lhs::ColsAtCompileTime-1,
|
||||
Lhs::ColsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Lhs::ColsAtCompileTime : Dynamic,
|
||||
LhsRef, RhsRef>
|
||||
::run(row, col, m_lhs, m_rhs, res);
|
||||
else
|
||||
|
@ -33,25 +33,23 @@
|
||||
* MatrixBase::setRandom()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Random<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Random<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class Random : NoOperatorEquals,
|
||||
public MatrixBase<Random<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Random>;
|
||||
friend class MatrixBase<Random>::Traits;
|
||||
typedef MatrixBase<Random> Base;
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Random)
|
||||
|
||||
const Random& _asArg() const { return *this; }
|
||||
int _rows() const { return m_rows.value(); }
|
||||
@ -117,8 +115,8 @@ template<typename Derived>
|
||||
const Eval<Random<Derived> >
|
||||
MatrixBase<Derived>::random(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1) return Random<Derived>(1, size).eval();
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1) return Random<Derived>(1, size).eval();
|
||||
else return Random<Derived>(size, 1).eval();
|
||||
}
|
||||
|
||||
@ -137,7 +135,7 @@ template<typename Derived>
|
||||
const Eval<Random<Derived> >
|
||||
MatrixBase<Derived>::random()
|
||||
{
|
||||
return Random<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime).eval();
|
||||
return Random<Derived>(RowsAtCompileTime, ColsAtCompileTime).eval();
|
||||
}
|
||||
|
||||
/** Sets all coefficients in this expression to random values.
|
||||
|
@ -46,18 +46,25 @@
|
||||
* \sa MatrixBase::row()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Row<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Row<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = 1,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = 1,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class Row
|
||||
: public MatrixBase<Row<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Row)
|
||||
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Row>;
|
||||
friend class MatrixBase<Row>::Traits;
|
||||
typedef MatrixBase<Row> Base;
|
||||
|
||||
Row(const MatRef& matrix, int row)
|
||||
: m_matrix(matrix), m_row(row)
|
||||
@ -68,12 +75,6 @@ template<typename MatrixType> class Row
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row)
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = 1,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = 1,
|
||||
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
const Row& _asArg() const { return *this; }
|
||||
|
||||
|
@ -30,12 +30,12 @@ template<typename OtherDerived>
|
||||
void MatrixBase<Derived>::swap(const MatrixBase<OtherDerived>& other)
|
||||
{
|
||||
MatrixBase<OtherDerived> *_other = const_cast<MatrixBase<OtherDerived>*>(&other);
|
||||
if(Traits::SizeAtCompileTime == Dynamic)
|
||||
if(SizeAtCompileTime == Dynamic)
|
||||
{
|
||||
Scalar tmp;
|
||||
if(Traits::IsVectorAtCompileTime)
|
||||
if(IsVectorAtCompileTime)
|
||||
{
|
||||
assert(OtherDerived::Traits::IsVectorAtCompileTime && size() == _other->size());
|
||||
assert(OtherDerived::IsVectorAtCompileTime && size() == _other->size());
|
||||
for(int i = 0; i < size(); i++)
|
||||
{
|
||||
tmp = coeff(i);
|
||||
|
@ -57,16 +57,16 @@ template<int Index, typename Derived> struct TraceUnroller<Index, 0, Derived>
|
||||
*
|
||||
* \sa diagonal() */
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type
|
||||
typename ei_traits<Derived>::Scalar
|
||||
MatrixBase<Derived>::trace() const
|
||||
{
|
||||
assert(rows() == cols());
|
||||
Scalar res;
|
||||
if(EIGEN_UNROLLED_LOOPS
|
||||
&& Traits::RowsAtCompileTime != Dynamic
|
||||
&& Traits::RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||
TraceUnroller<Traits::RowsAtCompileTime-1,
|
||||
Traits::RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::RowsAtCompileTime : Dynamic, Derived>
|
||||
&& RowsAtCompileTime != Dynamic
|
||||
&& RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||
TraceUnroller<RowsAtCompileTime-1,
|
||||
RowsAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? RowsAtCompileTime : Dynamic, Derived>
|
||||
::run(*static_cast<const Derived*>(this), res);
|
||||
else
|
||||
{
|
||||
|
@ -38,30 +38,31 @@
|
||||
* \sa MatrixBase::transpose(), MatrixBase::adjoint()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Transpose<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Transpose<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxColsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxRowsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class Transpose
|
||||
: public MatrixBase<Transpose<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Transpose)
|
||||
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Transpose>;
|
||||
friend class MatrixBase<Transpose>::Traits;
|
||||
typedef MatrixBase<Transpose> Base;
|
||||
|
||||
Transpose(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime
|
||||
};
|
||||
|
||||
const Transpose& _asArg() const { return *this; }
|
||||
int _rows() const { return m_matrix.cols(); }
|
||||
|
@ -84,18 +84,18 @@ using Eigen::MatrixBase;
|
||||
template<typename OtherDerived> \
|
||||
Derived& operator Op(const MatrixBase<OtherDerived>& other) \
|
||||
{ \
|
||||
return Base::operator Op(other); \
|
||||
return MatrixBase<Derived>::operator Op(other); \
|
||||
} \
|
||||
Derived& operator Op(const Derived& other) \
|
||||
{ \
|
||||
return Base::operator Op(other); \
|
||||
return MatrixBase<Derived>::operator Op(other); \
|
||||
}
|
||||
|
||||
#define EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, Op) \
|
||||
template<typename Other> \
|
||||
Derived& operator Op(const Other& scalar) \
|
||||
{ \
|
||||
return Base::operator Op(scalar); \
|
||||
return MatrixBase<Derived>::operator Op(scalar); \
|
||||
}
|
||||
|
||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
|
||||
@ -105,6 +105,21 @@ EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, -=) \
|
||||
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
|
||||
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
|
||||
|
||||
#define _EIGEN_BASIC_PUBLIC_INTERFACE(Derived, BaseClass) \
|
||||
friend class MatrixBase<Derived>; \
|
||||
typedef BaseClass Base; \
|
||||
typedef typename ei_traits<Derived>::Scalar Scalar; \
|
||||
enum { RowsAtCompileTime = ei_traits<Derived>::RowsAtCompileTime, \
|
||||
ColsAtCompileTime = ei_traits<Derived>::ColsAtCompileTime, \
|
||||
MaxRowsAtCompileTime = ei_traits<Derived>::MaxRowsAtCompileTime, \
|
||||
MaxColsAtCompileTime = ei_traits<Derived>::MaxColsAtCompileTime }; \
|
||||
using Base::SizeAtCompileTime; \
|
||||
using Base::MaxSizeAtCompileTime; \
|
||||
using Base::IsVectorAtCompileTime;
|
||||
|
||||
#define EIGEN_BASIC_PUBLIC_INTERFACE(Derived) \
|
||||
_EIGEN_BASIC_PUBLIC_INTERFACE(Derived, MatrixBase<Derived>)
|
||||
|
||||
#define EIGEN_ENUM_MIN(a,b) (((int)a <= (int)b) ? (int)a : (int)b)
|
||||
|
||||
const int Dynamic = -10;
|
||||
|
@ -33,25 +33,25 @@
|
||||
* MatrixBase::setZero(), MatrixBase::isZero()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Zero<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
struct ei_traits<Zero<MatrixType> >
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||
public MatrixBase<Zero<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
friend class MatrixBase<Zero>;
|
||||
friend class MatrixBase<Zero>::Traits;
|
||||
typedef MatrixBase<Zero> Base;
|
||||
|
||||
EIGEN_BASIC_PUBLIC_INTERFACE(Zero)
|
||||
|
||||
private:
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
MaxRowsAtCompileTime = MatrixType::Traits::MaxRowsAtCompileTime,
|
||||
MaxColsAtCompileTime = MatrixType::Traits::MaxColsAtCompileTime
|
||||
};
|
||||
|
||||
const Zero& _asArg() const { return *this; }
|
||||
int _rows() const { return m_rows.value(); }
|
||||
@ -63,6 +63,7 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Zero(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0
|
||||
@ -115,8 +116,8 @@ const Zero<Derived> MatrixBase<Derived>::zero(int rows, int cols)
|
||||
template<typename Derived>
|
||||
const Zero<Derived> MatrixBase<Derived>::zero(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1) return Zero<Derived>(1, size);
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1) return Zero<Derived>(1, size);
|
||||
else return Zero<Derived>(size, 1);
|
||||
}
|
||||
|
||||
@ -133,7 +134,7 @@ const Zero<Derived> MatrixBase<Derived>::zero(int size)
|
||||
template<typename Derived>
|
||||
const Zero<Derived> MatrixBase<Derived>::zero()
|
||||
{
|
||||
return Zero<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||
return Zero<Derived>(RowsAtCompileTime, ColsAtCompileTime);
|
||||
}
|
||||
|
||||
/** \returns true if *this is approximately equal to the zero matrix,
|
||||
|
@ -12,19 +12,19 @@ void benchBasic_loop(const MatrixType& I, MatrixType& m, int iterations)
|
||||
if (Mode==LazyEval)
|
||||
{
|
||||
asm("#begin_bench_loop LazyEval");
|
||||
if (MatrixType::Traits::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
|
||||
if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
|
||||
m = (I + 0.00005 * (m + m.lazyProduct(m))).eval();
|
||||
}
|
||||
else if (Mode==OmpEval)
|
||||
{
|
||||
asm("#begin_bench_loop OmpEval");
|
||||
if (MatrixType::Traits::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
|
||||
if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
|
||||
m = (I + 0.00005 * (m + m.lazyProduct(m))).evalOMP();
|
||||
}
|
||||
else
|
||||
{
|
||||
asm("#begin_bench_loop EarlyEval");
|
||||
if (MatrixType::Traits::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
|
||||
if (MatrixType::SizeAtCompileTime!=Eigen::Dynamic) asm("#fixedsize");
|
||||
m = I + 0.00005 * (m + m * m);
|
||||
}
|
||||
asm("#end_bench_loop");
|
||||
|
@ -33,7 +33,7 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
||||
*/
|
||||
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
|
||||
@ -41,9 +41,9 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
|
@ -29,7 +29,7 @@ namespace Eigen {
|
||||
template<typename MatrixType> void basicStuff(const MatrixType& m)
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
|
||||
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
@ -40,9 +40,9 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
@ -74,13 +74,13 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
|
||||
|
||||
// now test copying a row-vector into a (column-)vector and conversely.
|
||||
square.col(r) = square.row(r).eval();
|
||||
Matrix<Scalar, 1, MatrixType::Traits::RowsAtCompileTime> rv(rows);
|
||||
Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> cv(rows);
|
||||
Matrix<Scalar, 1, MatrixType::RowsAtCompileTime> rv(rows);
|
||||
Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> cv(rows);
|
||||
rv = square.col(r);
|
||||
cv = square.row(r);
|
||||
VERIFY_IS_APPROX(rv, cv.transpose());
|
||||
|
||||
if(cols!=1 && rows!=1 && MatrixType::Traits::SizeAtCompileTime!=Dynamic)
|
||||
if(cols!=1 && rows!=1 && MatrixType::SizeAtCompileTime!=Dynamic)
|
||||
{
|
||||
VERIFY_RAISES_ASSERT(m1 = (m2.block(0,0, rows-1, cols-1)));
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ struct AddIfNull {
|
||||
template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
{
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
|
||||
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
@ -47,9 +47,9 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
mones = MatrixType::ones(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
|
@ -33,7 +33,7 @@ template<typename MatrixType> void linearStructure(const MatrixType& m)
|
||||
*/
|
||||
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
|
||||
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
@ -44,9 +44,9 @@ template<typename MatrixType> void linearStructure(const MatrixType& m)
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
|
@ -153,21 +153,21 @@ template<typename Derived1, typename Derived2>
|
||||
inline bool test_ei_isApprox(const MatrixBase<Derived1>& m1,
|
||||
const MatrixBase<Derived2>& m2)
|
||||
{
|
||||
return m1.isApprox(m2, test_precision<typename Scalar<Derived1>::Type>());
|
||||
return m1.isApprox(m2, test_precision<typename ei_traits<Derived1>::Scalar>());
|
||||
}
|
||||
|
||||
template<typename Derived1, typename Derived2>
|
||||
inline bool test_ei_isMuchSmallerThan(const MatrixBase<Derived1>& m1,
|
||||
const MatrixBase<Derived2>& m2)
|
||||
{
|
||||
return m1.isMuchSmallerThan(m2, test_precision<typename Scalar<Derived1>::Type>());
|
||||
return m1.isMuchSmallerThan(m2, test_precision<typename ei_traits<Derived1>::Scalar>());
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
inline bool test_ei_isMuchSmallerThan(const MatrixBase<Derived>& m,
|
||||
const typename NumTraits<typename Scalar<Derived>::Type>::Real& s)
|
||||
const typename NumTraits<typename ei_traits<Derived>::Scalar>::Real& s)
|
||||
{
|
||||
return m.isMuchSmallerThan(s, test_precision<typename Scalar<Derived>::Type>());
|
||||
return m.isMuchSmallerThan(s, test_precision<typename ei_traits<Derived>::Scalar>());
|
||||
}
|
||||
|
||||
class EigenTest : public QObject
|
||||
|
@ -33,8 +33,8 @@ template<typename MatrixType> void miscMatrices(const MatrixType& m)
|
||||
*/
|
||||
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
||||
typedef Matrix<Scalar, 1, MatrixType::Traits::ColsAtCompileTime> RowVectorType;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
|
||||
typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime> RowVectorType;
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
|
||||
@ -44,7 +44,7 @@ template<typename MatrixType> void miscMatrices(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m1(r,c), static_cast<Scalar>(1));
|
||||
VectorType v1 = VectorType::random(rows);
|
||||
v1[0];
|
||||
Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
square = v1.asDiagonal();
|
||||
if(r==r2) VERIFY_IS_APPROX(square(r,r2), v1[r]);
|
||||
else VERIFY_IS_MUCH_SMALLER_THAN(square(r,r2), static_cast<Scalar>(1));
|
||||
|
@ -33,7 +33,7 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
*/
|
||||
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
|
||||
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
@ -44,9 +44,9 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
|
@ -59,8 +59,8 @@ template<typename MatrixType> void submatrices(const MatrixType& m)
|
||||
Row.h Column.h Block.h Minor.h DiagonalCoeffs.h
|
||||
*/
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, 1> VectorType;
|
||||
typedef Matrix<Scalar, 1, MatrixType::Traits::ColsAtCompileTime> RowVectorType;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> VectorType;
|
||||
typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime> RowVectorType;
|
||||
int rows = m.rows();
|
||||
int cols = m.cols();
|
||||
|
||||
@ -68,9 +68,9 @@ template<typename MatrixType> void submatrices(const MatrixType& m)
|
||||
m2 = MatrixType::random(rows, cols),
|
||||
m3(rows, cols),
|
||||
mzero = MatrixType::zero(rows, cols),
|
||||
identity = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
identity = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::identity(rows, rows),
|
||||
square = Matrix<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::RowsAtCompileTime>
|
||||
square = Matrix<Scalar, MatrixType::RowsAtCompileTime, MatrixType::RowsAtCompileTime>
|
||||
::random(rows, rows);
|
||||
VectorType v1 = VectorType::random(rows),
|
||||
v2 = VectorType::random(rows),
|
||||
@ -103,7 +103,7 @@ template<typename MatrixType> void submatrices(const MatrixType& m)
|
||||
m1.block(r1,c1,r2-r1+1,c2-c1+1)(r2-r1,c2-c1) = m2.block(0, 0, r2-r1+1,c2-c1+1)(0,0);
|
||||
|
||||
//check minor()
|
||||
CheckMinor<Scalar, MatrixType::Traits::RowsAtCompileTime, MatrixType::Traits::ColsAtCompileTime> checkminor(m1,r1,c1);
|
||||
CheckMinor<Scalar, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime> checkminor(m1,r1,c1);
|
||||
|
||||
//check diagonal()
|
||||
VERIFY_IS_APPROX(m1.diagonal(), m1.transpose().diagonal());
|
||||
|
Loading…
x
Reference in New Issue
Block a user