mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 19:29:02 +08:00
Patch by Gael Guennebaud, making Eigen compatible with the Intel compiler (icc).
CCMAIL:eigen@lists.tuxfamily.org
This commit is contained in:
parent
d1d55e67e9
commit
495eb7053a
@ -66,11 +66,11 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
|
||||
|
||||
static const TraversalOrder Order = MatrixType::Order;
|
||||
static const int RowsAtCompileTime = BlockRows,
|
||||
ColsAtCompileTime = BlockCols;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = MatrixType::Order;
|
||||
static const int _RowsAtCompileTime = BlockRows,
|
||||
_ColsAtCompileTime = BlockCols;
|
||||
|
||||
const Block& _ref() const { return *this; }
|
||||
int _rows() const { return BlockRows; }
|
||||
int _cols() const { return BlockCols; }
|
||||
|
@ -116,8 +116,8 @@ template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
::coeff(int index) const
|
||||
{
|
||||
eigen_internal_assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1)
|
||||
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1)
|
||||
{
|
||||
eigen_internal_assert(index >= 0 && index < cols());
|
||||
return coeff(0, index);
|
||||
@ -140,8 +140,8 @@ template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
::operator[](int index) const
|
||||
{
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1)
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1)
|
||||
{
|
||||
assert(index >= 0 && index < cols());
|
||||
return coeff(0, index);
|
||||
@ -171,8 +171,8 @@ template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
::coeffRef(int index)
|
||||
{
|
||||
eigen_internal_assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1)
|
||||
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1)
|
||||
{
|
||||
eigen_internal_assert(index >= 0 && index < cols());
|
||||
return coeffRef(0, index);
|
||||
@ -194,8 +194,8 @@ template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
::operator[](int index)
|
||||
{
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1)
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1)
|
||||
{
|
||||
assert(index >= 0 && index < cols());
|
||||
return coeffRef(0, index);
|
||||
|
@ -62,10 +62,11 @@ template<typename MatrixType> class Column
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column)
|
||||
|
||||
static const TraversalOrder Order = ColumnMajor;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = 1;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = ColumnMajor;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = 1;
|
||||
const Column& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
int _cols() const { return 1; }
|
||||
|
@ -48,11 +48,11 @@ template<typename MatrixType> class Conjugate : NoOperatorEquals,
|
||||
|
||||
Conjugate(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = MatrixType::Order;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
static const TraversalOrder Order = MatrixType::Order;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
const Conjugate& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
int _cols() const { return m_matrix.cols(); }
|
||||
|
@ -50,11 +50,11 @@ template<typename MatrixType> class DiagonalCoeffs
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
|
||||
|
||||
static const TraversalOrder Order = ColumnMajor;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = 1;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = ColumnMajor;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = 1;
|
||||
|
||||
const DiagonalCoeffs& _ref() const { return *this; }
|
||||
int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); }
|
||||
int _cols() const { return 1; }
|
||||
|
@ -51,15 +51,15 @@ class DiagonalMatrix : NoOperatorEquals,
|
||||
|
||||
DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs)
|
||||
{
|
||||
assert(CoeffsVectorType::IsVectorAtCompileTime
|
||||
assert(CoeffsVectorType::Traits::IsVectorAtCompileTime
|
||||
&& coeffs.size() > 0);
|
||||
}
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = Indifferent;
|
||||
static const int _RowsAtCompileTime = CoeffsVectorType::SizeAtCompileTime,
|
||||
_ColsAtCompileTime = CoeffsVectorType::SizeAtCompileTime;
|
||||
static const TraversalOrder Order = Indifferent;
|
||||
static const int RowsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime,
|
||||
ColsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime;
|
||||
|
||||
private:
|
||||
const DiagonalMatrix& _ref() const { return *this; }
|
||||
int _rows() const { return m_coeffs.size(); }
|
||||
int _cols() const { return m_coeffs.size(); }
|
||||
|
@ -41,11 +41,11 @@ template<typename Lhs, typename Rhs> class Difference : NoOperatorEquals,
|
||||
assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
|
||||
}
|
||||
|
||||
static const TraversalOrder Order = Lhs::Order;
|
||||
static const int RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = Lhs::Order;
|
||||
static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = Rhs::ColsAtCompileTime;
|
||||
|
||||
const Difference& _ref() const { return *this; }
|
||||
int _rows() const { return m_lhs.rows(); }
|
||||
int _cols() const { return m_lhs.cols(); }
|
||||
|
@ -72,10 +72,10 @@ template<typename Scalar, typename Derived>
|
||||
template<typename OtherDerived>
|
||||
Scalar MatrixBase<Scalar, Derived>::dot(const OtherDerived& other) const
|
||||
{
|
||||
assert(IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime && size() == other.size());
|
||||
assert(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime && size() == other.size());
|
||||
Scalar res;
|
||||
if(EIGEN_UNROLLED_LOOPS && SizeAtCompileTime != Dynamic && SizeAtCompileTime <= 16)
|
||||
DotUnroller<SizeAtCompileTime-1, SizeAtCompileTime, Derived, OtherDerived>
|
||||
if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 16)
|
||||
DotUnroller<Traits::SizeAtCompileTime-1, Traits::SizeAtCompileTime, Derived, OtherDerived>
|
||||
::run(*static_cast<const Derived*>(this), other, res);
|
||||
else
|
||||
{
|
||||
|
@ -66,12 +66,12 @@ template<typename MatrixType> class DynBlock
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DynBlock)
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = MatrixType::Order;
|
||||
static const TraversalOrder Order = MatrixType::Order;
|
||||
static const int
|
||||
_RowsAtCompileTime = MatrixType::RowsAtCompileTime == 1 ? 1 : Dynamic,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime == 1 ? 1 : Dynamic;
|
||||
RowsAtCompileTime = MatrixType::RowsAtCompileTime == 1 ? 1 : Dynamic,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime == 1 ? 1 : Dynamic;
|
||||
|
||||
private:
|
||||
const DynBlock& _ref() const { return *this; }
|
||||
int _rows() const { return m_blockRows; }
|
||||
int _cols() const { return m_blockCols; }
|
||||
|
@ -47,12 +47,12 @@
|
||||
*/
|
||||
template<typename Expression> class Eval : NoOperatorEquals,
|
||||
public Matrix< typename Expression::Scalar,
|
||||
Expression::RowsAtCompileTime,
|
||||
Expression::ColsAtCompileTime >
|
||||
Expression::Traits::RowsAtCompileTime,
|
||||
Expression::Traits::ColsAtCompileTime >
|
||||
{
|
||||
public:
|
||||
typedef typename Expression::Scalar Scalar;
|
||||
typedef Matrix<Scalar, Expression::RowsAtCompileTime, Expression::ColsAtCompileTime> MatrixType;
|
||||
typedef Matrix<Scalar, Expression::Traits::RowsAtCompileTime, Expression::Traits::ColsAtCompileTime> MatrixType;
|
||||
typedef Expression Base;
|
||||
friend class MatrixBase<Scalar, Expression>;
|
||||
|
||||
|
@ -34,7 +34,7 @@ bool MatrixBase<Scalar, Derived>::isApprox(
|
||||
) const
|
||||
{
|
||||
assert(rows() == other.rows() && cols() == other.cols());
|
||||
if(IsVectorAtCompileTime)
|
||||
if(Traits::IsVectorAtCompileTime)
|
||||
{
|
||||
return((*this - other).norm2() <= std::min(norm2(), other.norm2()) * prec * prec);
|
||||
}
|
||||
@ -54,7 +54,7 @@ bool MatrixBase<Scalar, Derived>::isMuchSmallerThan(
|
||||
const typename NumTraits<Scalar>::Real& prec = precision<Scalar>()
|
||||
) const
|
||||
{
|
||||
if(IsVectorAtCompileTime)
|
||||
if(Traits::IsVectorAtCompileTime)
|
||||
{
|
||||
return(norm2() <= abs2(other * prec));
|
||||
}
|
||||
@ -75,7 +75,7 @@ bool MatrixBase<Scalar, Derived>::isMuchSmallerThan(
|
||||
) const
|
||||
{
|
||||
assert(rows() == other.rows() && cols() == other.cols());
|
||||
if(IsVectorAtCompileTime)
|
||||
if(Traits::IsVectorAtCompileTime)
|
||||
{
|
||||
return(norm2() <= other.norm2() * prec * prec);
|
||||
}
|
||||
|
@ -38,6 +38,10 @@ template<typename MatrixType> class Identity : NoOperatorEquals,
|
||||
assert(rows > 0 && _RowsAtCompileTime == _ColsAtCompileTime);
|
||||
}
|
||||
|
||||
static const TraversalOrder Order = Indifferent;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = Indifferent;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
|
@ -46,19 +46,18 @@ template<typename MatrixType> class Map
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Map<MatrixType> >;
|
||||
|
||||
static const TraversalOrder Order = MatrixType::Order;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = MatrixType::Order;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
|
||||
const Map& _ref() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
int _cols() const { return m_cols; }
|
||||
|
||||
const Scalar& _coeff(int row, int col) const
|
||||
{
|
||||
if(_Order == ColumnMajor)
|
||||
if(Order == ColumnMajor)
|
||||
return m_data[row + col * m_rows];
|
||||
else // RowMajor
|
||||
return m_data[col + row * m_cols];
|
||||
@ -66,7 +65,7 @@ template<typename MatrixType> class Map
|
||||
|
||||
Scalar& _coeffRef(int row, int col)
|
||||
{
|
||||
if(_Order == ColumnMajor)
|
||||
if(Order == ColumnMajor)
|
||||
return const_cast<Scalar*>(m_data)[row + col * m_rows];
|
||||
else // RowMajor
|
||||
return const_cast<Scalar*>(m_data)[col + row * m_cols];
|
||||
@ -76,9 +75,9 @@ template<typename MatrixType> class Map
|
||||
Map(const Scalar* data, int rows, int cols) : m_data(data), m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0
|
||||
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
|
||||
&& (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
|
||||
&& cols > 0
|
||||
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
|
||||
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
|
||||
}
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
|
||||
|
@ -91,15 +91,16 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
|
||||
Scalar* data()
|
||||
{ return Storage::m_data; }
|
||||
|
||||
static const TraversalOrder Order = _StorageOrder;
|
||||
static const int RowsAtCompileTime = _Rows, ColsAtCompileTime = _Cols;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = _StorageOrder;
|
||||
static const int _RowsAtCompileTime = _Rows, _ColsAtCompileTime = _Cols;
|
||||
|
||||
|
||||
Ref _ref() const { return Ref(*this); }
|
||||
|
||||
const Scalar& _coeff(int row, int col) const
|
||||
{
|
||||
if(_Order == ColumnMajor)
|
||||
if(Order == ColumnMajor)
|
||||
return (Storage::m_data)[row + col * Storage::_rows()];
|
||||
else // RowMajor
|
||||
return (Storage::m_data)[col + row * Storage::_cols()];
|
||||
@ -107,7 +108,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
|
||||
|
||||
Scalar& _coeffRef(int row, int col)
|
||||
{
|
||||
if(_Order == ColumnMajor)
|
||||
if(Order == ColumnMajor)
|
||||
return (Storage::m_data)[row + col * Storage::_rows()];
|
||||
else // RowMajor
|
||||
return (Storage::m_data)[col + row * Storage::_cols()];
|
||||
@ -125,12 +126,12 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
|
||||
template<typename OtherDerived>
|
||||
Matrix& operator=(const MatrixBase<Scalar, OtherDerived>& other)
|
||||
{
|
||||
if(_RowsAtCompileTime == 1)
|
||||
if(RowsAtCompileTime == 1)
|
||||
{
|
||||
assert(other.isVector());
|
||||
resize(1, other.size());
|
||||
}
|
||||
else if(_ColsAtCompileTime == 1)
|
||||
else if(ColsAtCompileTime == 1)
|
||||
{
|
||||
assert(other.isVector());
|
||||
resize(other.size(), 1);
|
||||
@ -165,7 +166,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
|
||||
*/
|
||||
explicit Matrix() : Storage()
|
||||
{
|
||||
assert(_RowsAtCompileTime > 0 && _ColsAtCompileTime > 0);
|
||||
assert(RowsAtCompileTime > 0 && ColsAtCompileTime > 0);
|
||||
}
|
||||
|
||||
/** Constructs a vector or row-vector with given dimension. \only_for_vectors
|
||||
@ -177,10 +178,10 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
|
||||
explicit Matrix(int dim) : Storage(dim)
|
||||
{
|
||||
assert(dim > 0);
|
||||
assert((_RowsAtCompileTime == 1
|
||||
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == dim))
|
||||
|| (_ColsAtCompileTime == 1
|
||||
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == dim)));
|
||||
assert((RowsAtCompileTime == 1
|
||||
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == dim))
|
||||
|| (ColsAtCompileTime == 1
|
||||
&& (RowsAtCompileTime == Dynamic || RowsAtCompileTime == dim)));
|
||||
}
|
||||
|
||||
/** This constructor has two very different behaviors, depending on the type of *this.
|
||||
@ -195,39 +196,39 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
|
||||
*/
|
||||
Matrix(int x, int y) : Storage(x, y)
|
||||
{
|
||||
if((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 2)
|
||||
|| (_RowsAtCompileTime == 2 && _ColsAtCompileTime == 1))
|
||||
if((RowsAtCompileTime == 1 && ColsAtCompileTime == 2)
|
||||
|| (RowsAtCompileTime == 2 && ColsAtCompileTime == 1))
|
||||
{
|
||||
(Storage::m_data)[0] = x;
|
||||
(Storage::m_data)[1] = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(x > 0 && (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == x)
|
||||
&& y > 0 && (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == y));
|
||||
assert(x > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == x)
|
||||
&& y > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == y));
|
||||
}
|
||||
}
|
||||
/** constructs an initialized 2D vector with given coefficients */
|
||||
Matrix(const float& x, const float& y)
|
||||
{
|
||||
assert((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 2)
|
||||
|| (_RowsAtCompileTime == 2 && _ColsAtCompileTime == 1));
|
||||
assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 2)
|
||||
|| (RowsAtCompileTime == 2 && ColsAtCompileTime == 1));
|
||||
(Storage::m_data)[0] = x;
|
||||
(Storage::m_data)[1] = y;
|
||||
}
|
||||
/** constructs an initialized 2D vector with given coefficients */
|
||||
Matrix(const double& x, const double& y)
|
||||
{
|
||||
assert((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 2)
|
||||
|| (_RowsAtCompileTime == 2 && _ColsAtCompileTime == 1));
|
||||
assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 2)
|
||||
|| (RowsAtCompileTime == 2 && ColsAtCompileTime == 1));
|
||||
(Storage::m_data)[0] = x;
|
||||
(Storage::m_data)[1] = y;
|
||||
}
|
||||
/** constructs an initialized 3D vector with given coefficients */
|
||||
Matrix(const Scalar& x, const Scalar& y, const Scalar& z)
|
||||
{
|
||||
assert((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 3)
|
||||
|| (_RowsAtCompileTime == 3 && _ColsAtCompileTime == 1));
|
||||
assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 3)
|
||||
|| (RowsAtCompileTime == 3 && ColsAtCompileTime == 1));
|
||||
(Storage::m_data)[0] = x;
|
||||
(Storage::m_data)[1] = y;
|
||||
(Storage::m_data)[2] = z;
|
||||
@ -235,8 +236,8 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
|
||||
/** constructs an initialized 4D vector with given coefficients */
|
||||
Matrix(const Scalar& x, const Scalar& y, const Scalar& z, const Scalar& w)
|
||||
{
|
||||
assert((_RowsAtCompileTime == 1 && _ColsAtCompileTime == 4)
|
||||
|| (_RowsAtCompileTime == 4 && _ColsAtCompileTime == 1));
|
||||
assert((RowsAtCompileTime == 1 && ColsAtCompileTime == 4)
|
||||
|| (RowsAtCompileTime == 4 && ColsAtCompileTime == 1));
|
||||
(Storage::m_data)[0] = x;
|
||||
(Storage::m_data)[1] = y;
|
||||
(Storage::m_data)[2] = z;
|
||||
|
@ -26,6 +26,39 @@
|
||||
#ifndef EIGEN_MATRIXBASE_H
|
||||
#define EIGEN_MATRIXBASE_H
|
||||
|
||||
#include "Util.h"
|
||||
|
||||
template <typename Derived>
|
||||
struct DerivedTraits
|
||||
{
|
||||
static const TraversalOrder Order = Derived::Order;
|
||||
|
||||
/** 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 rows(), cols(), ColsAtCompileTime, SizeAtCompileTime */
|
||||
static const int RowsAtCompileTime = 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 rows(), cols(), RowsAtCompileTime, SizeAtCompileTime */
|
||||
static const int ColsAtCompileTime = 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 */
|
||||
static const int SizeAtCompileTime
|
||||
= Derived::RowsAtCompileTime == Dynamic || Derived::ColsAtCompileTime == Dynamic
|
||||
? Dynamic : Derived::RowsAtCompileTime * Derived::ColsAtCompileTime;
|
||||
|
||||
/** 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). */
|
||||
static const bool IsVectorAtCompileTime = Derived::RowsAtCompileTime == 1 || Derived::ColsAtCompileTime == 1;
|
||||
};
|
||||
|
||||
/** \class MatrixBase
|
||||
*
|
||||
* \brief Base class for all matrices, vectors, and expressions
|
||||
@ -57,31 +90,7 @@
|
||||
template<typename Scalar, typename Derived> class MatrixBase
|
||||
{
|
||||
public:
|
||||
static const TraversalOrder Order = Derived::_Order;
|
||||
|
||||
/** 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 rows(), cols(), ColsAtCompileTime, SizeAtCompileTime */
|
||||
static const int RowsAtCompileTime = 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 rows(), cols(), RowsAtCompileTime, SizeAtCompileTime */
|
||||
static const int ColsAtCompileTime = 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 */
|
||||
static const int SizeAtCompileTime
|
||||
= RowsAtCompileTime == Dynamic || ColsAtCompileTime == Dynamic
|
||||
? Dynamic : RowsAtCompileTime * ColsAtCompileTime;
|
||||
/** 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). */
|
||||
static const bool IsVectorAtCompileTime = RowsAtCompileTime == 1 || ColsAtCompileTime == 1;
|
||||
typedef DerivedTraits<Derived> Traits;
|
||||
|
||||
/** This is the "reference type" used to pass objects of type MatrixBase as arguments
|
||||
* to functions. If this MatrixBase type represents an expression, then \a Ref
|
||||
@ -170,7 +179,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
static const Ones<Derived> ones(int rows, int cols);
|
||||
static const Ones<Derived> ones(int size);
|
||||
static const Ones<Derived> ones();
|
||||
static const Identity<Derived> identity(int rows = RowsAtCompileTime);
|
||||
static const Identity<Derived> identity(int rows = Derived::RowsAtCompileTime);
|
||||
|
||||
bool isZero(const typename NumTraits<Scalar>::Real& prec) const;
|
||||
bool isOnes(const typename NumTraits<Scalar>::Real& prec) const;
|
||||
|
@ -38,11 +38,11 @@ template<typename MatrixType> class MatrixRef
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef)
|
||||
|
||||
static const TraversalOrder Order = MatrixType::Order;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = MatrixType::Order;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
int _cols() const { return m_matrix.cols(); }
|
||||
|
||||
|
@ -56,14 +56,14 @@ template<typename MatrixType> class Minor
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = MatrixType::Order;
|
||||
static const TraversalOrder Order = MatrixType::Order;
|
||||
static const int
|
||||
_RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
|
||||
RowsAtCompileTime = (MatrixType::RowsAtCompileTime != Dynamic) ?
|
||||
MatrixType::RowsAtCompileTime - 1 : Dynamic,
|
||||
_ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
|
||||
ColsAtCompileTime = (MatrixType::ColsAtCompileTime != Dynamic) ?
|
||||
MatrixType::ColsAtCompileTime - 1 : Dynamic;
|
||||
|
||||
private:
|
||||
const Minor& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows() - 1; }
|
||||
int _cols() const { return m_matrix.cols() - 1; }
|
||||
|
@ -39,11 +39,12 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Ones<MatrixType> >;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = Indifferent;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
static const TraversalOrder Order = Indifferent;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
|
||||
const Ones& _ref() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
int _cols() const { return m_cols; }
|
||||
@ -57,9 +58,9 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
|
||||
Ones(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0
|
||||
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
|
||||
&& (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
|
||||
&& cols > 0
|
||||
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
|
||||
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -105,8 +106,8 @@ const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int rows, int cols)
|
||||
template<typename Scalar, typename Derived>
|
||||
const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int size)
|
||||
{
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1) return Ones<Derived>(1, size);
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1) return Ones<Derived>(1, size);
|
||||
else return Ones<Derived>(size, 1);
|
||||
}
|
||||
|
||||
@ -123,7 +124,7 @@ const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int size)
|
||||
template<typename Scalar, typename Derived>
|
||||
const Ones<Derived> MatrixBase<Scalar, Derived>::ones()
|
||||
{
|
||||
return Ones<Derived>(RowsAtCompileTime, ColsAtCompileTime);
|
||||
return Ones<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||
}
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
|
@ -105,13 +105,13 @@ template<typename OtherDerived>
|
||||
Derived& MatrixBase<Scalar, Derived>
|
||||
::operator=(const MatrixBase<Scalar, OtherDerived>& other)
|
||||
{
|
||||
if(IsVectorAtCompileTime && OtherDerived::IsVectorAtCompileTime)
|
||||
if(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime)
|
||||
// copying a vector expression into a vector
|
||||
{
|
||||
assert(size() == other.size());
|
||||
if(EIGEN_UNROLLED_LOOPS && SizeAtCompileTime != Dynamic && SizeAtCompileTime <= 25)
|
||||
if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25)
|
||||
VectorOperatorEqualsUnroller
|
||||
<Derived, OtherDerived, SizeAtCompileTime>::run
|
||||
<Derived, OtherDerived, Traits::SizeAtCompileTime>::run
|
||||
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
||||
else
|
||||
for(int i = 0; i < size(); i++)
|
||||
@ -121,13 +121,13 @@ Derived& MatrixBase<Scalar, Derived>
|
||||
else // copying a matrix expression into a matrix
|
||||
{
|
||||
assert(rows() == other.rows() && cols() == other.cols());
|
||||
if(EIGEN_UNROLLED_LOOPS && SizeAtCompileTime != Dynamic && SizeAtCompileTime <= 25)
|
||||
if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25)
|
||||
MatrixOperatorEqualsUnroller
|
||||
<Derived, OtherDerived, SizeAtCompileTime, Order>::run
|
||||
<Derived, OtherDerived, Traits::SizeAtCompileTime, Traits::Order>::run
|
||||
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
||||
else
|
||||
{
|
||||
if(Order == ColumnMajor)
|
||||
if(Traits::Order == ColumnMajor)
|
||||
for(int j = 0; j < cols(); j++)
|
||||
for(int i = 0; i < rows(); i++)
|
||||
coeffRef(i, j) = other.coeff(i, j);
|
||||
|
@ -36,11 +36,11 @@ template<typename MatrixType> class Opposite : NoOperatorEquals,
|
||||
|
||||
Opposite(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = MatrixType::Order;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
static const TraversalOrder Order = MatrixType::Order;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
const Opposite& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
int _cols() const { return m_matrix.cols(); }
|
||||
|
@ -75,9 +75,11 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
||||
assert(lhs.cols() == rhs.rows());
|
||||
}
|
||||
|
||||
static const TraversalOrder Order = Lhs::Order;
|
||||
static const int RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = Rhs::ColsAtCompileTime;
|
||||
|
||||
const Product& _ref() const { return *this; }
|
||||
int _rows() const { return m_lhs.rows(); }
|
||||
|
@ -39,11 +39,12 @@ template<typename MatrixType> class Random : NoOperatorEquals,
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Random<MatrixType> >;
|
||||
|
||||
static const TraversalOrder Order = Indifferent;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = Indifferent;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
|
||||
const Random& _ref() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
int _cols() const { return m_cols; }
|
||||
@ -57,9 +58,9 @@ template<typename MatrixType> class Random : NoOperatorEquals,
|
||||
Random(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0
|
||||
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
|
||||
&& (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
|
||||
&& cols > 0
|
||||
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
|
||||
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -105,8 +106,8 @@ const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int rows, int c
|
||||
template<typename Scalar, typename Derived>
|
||||
const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int size)
|
||||
{
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1) return Random<Derived>(1, size).eval();
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1) return Random<Derived>(1, size).eval();
|
||||
else return Random<Derived>(size, 1).eval();
|
||||
}
|
||||
|
||||
@ -124,7 +125,7 @@ const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random(int size)
|
||||
template<typename Scalar, typename Derived>
|
||||
const Eval<Random<Derived> > MatrixBase<Scalar, Derived>::random()
|
||||
{
|
||||
return Random<Derived>(RowsAtCompileTime, ColsAtCompileTime).eval();
|
||||
return Random<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime).eval();
|
||||
}
|
||||
|
||||
#endif // EIGEN_RANDOM_H
|
||||
|
@ -68,11 +68,11 @@ template<typename MatrixType> class Row
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row)
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = RowMajor;
|
||||
static const int _RowsAtCompileTime = 1,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
static const TraversalOrder Order = RowMajor;
|
||||
static const int RowsAtCompileTime = 1,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
const Row& _ref() const { return *this; }
|
||||
|
||||
int _rows() const { return 1; }
|
||||
|
@ -37,11 +37,11 @@ template<typename FactorType, typename MatrixType> class ScalarMultiple : NoOper
|
||||
ScalarMultiple(const MatRef& matrix, FactorType factor)
|
||||
: m_matrix(matrix), m_factor(factor) {}
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = MatrixType::Order;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
static const TraversalOrder Order = MatrixType::Order;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
const ScalarMultiple& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
int _cols() const { return m_matrix.cols(); }
|
||||
|
@ -41,11 +41,11 @@ template<typename Lhs, typename Rhs> class Sum : NoOperatorEquals,
|
||||
assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
|
||||
}
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = Lhs::Order;
|
||||
static const int _RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = Rhs::ColsAtCompileTime;
|
||||
static const TraversalOrder Order = Lhs::Order;
|
||||
static const int RowsAtCompileTime = Lhs::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
const Sum& _ref() const { return *this; }
|
||||
int _rows() const { return m_lhs.rows(); }
|
||||
int _cols() const { return m_lhs.cols(); }
|
||||
|
@ -62,8 +62,8 @@ Scalar MatrixBase<Scalar, Derived>::trace() const
|
||||
{
|
||||
assert(rows() == cols());
|
||||
Scalar res;
|
||||
if(EIGEN_UNROLLED_LOOPS && RowsAtCompileTime != Dynamic && RowsAtCompileTime <= 16)
|
||||
TraceUnroller<RowsAtCompileTime-1, RowsAtCompileTime, Derived>
|
||||
if(EIGEN_UNROLLED_LOOPS && Traits::RowsAtCompileTime != Dynamic && Traits::RowsAtCompileTime <= 16)
|
||||
TraceUnroller<Traits::RowsAtCompileTime-1, Traits::RowsAtCompileTime, Derived>
|
||||
::run(*static_cast<const Derived*>(this), res);
|
||||
else
|
||||
{
|
||||
|
@ -50,12 +50,12 @@ template<typename MatrixType> class Transpose
|
||||
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = (MatrixType::Order == ColumnMajor)
|
||||
static const TraversalOrder Order = (MatrixType::Order == ColumnMajor)
|
||||
? RowMajor : ColumnMajor;
|
||||
static const int _RowsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::RowsAtCompileTime;
|
||||
static const int RowsAtCompileTime = MatrixType::ColsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::RowsAtCompileTime;
|
||||
|
||||
private:
|
||||
const Transpose& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.cols(); }
|
||||
int _cols() const { return m_matrix.rows(); }
|
||||
|
@ -39,11 +39,11 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Zero<MatrixType> >;
|
||||
|
||||
private:
|
||||
static const TraversalOrder _Order = Indifferent;
|
||||
static const int _RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
_ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
static const TraversalOrder Order = Indifferent;
|
||||
static const int RowsAtCompileTime = MatrixType::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::ColsAtCompileTime;
|
||||
|
||||
private:
|
||||
const Zero& _ref() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
int _cols() const { return m_cols; }
|
||||
@ -57,9 +57,9 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||
Zero(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||
{
|
||||
assert(rows > 0
|
||||
&& (_RowsAtCompileTime == Dynamic || _RowsAtCompileTime == rows)
|
||||
&& (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
|
||||
&& cols > 0
|
||||
&& (_ColsAtCompileTime == Dynamic || _ColsAtCompileTime == cols));
|
||||
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -105,8 +105,8 @@ const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int rows, int cols)
|
||||
template<typename Scalar, typename Derived>
|
||||
const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int size)
|
||||
{
|
||||
assert(IsVectorAtCompileTime);
|
||||
if(RowsAtCompileTime == 1) return Zero<Derived>(1, size);
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
if(Traits::RowsAtCompileTime == 1) return Zero<Derived>(1, size);
|
||||
else return Zero<Derived>(size, 1);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int size)
|
||||
template<typename Scalar, typename Derived>
|
||||
const Zero<Derived> MatrixBase<Scalar, Derived>::zero()
|
||||
{
|
||||
return Zero<Derived>(RowsAtCompileTime, ColsAtCompileTime);
|
||||
return Zero<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||
}
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
|
Loading…
x
Reference in New Issue
Block a user