mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-24 02:29:33 +08:00
switch to enums everywhere
This commit is contained in:
parent
209cf7c91f
commit
45a4b61b5f
@ -67,8 +67,10 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = BlockRows,
|
||||
ColsAtCompileTime = BlockCols;
|
||||
enum{
|
||||
RowsAtCompileTime = BlockRows,
|
||||
ColsAtCompileTime = BlockCols
|
||||
};
|
||||
|
||||
const Block& _ref() const { return *this; }
|
||||
int _rows() const { return BlockRows; }
|
||||
|
@ -57,8 +57,10 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals,
|
||||
Cast(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
const Cast& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
int _cols() const { return m_matrix.cols(); }
|
||||
|
@ -63,8 +63,11 @@ template<typename MatrixType> class Column
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Column)
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = 1;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = 1
|
||||
};
|
||||
|
||||
const Column& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
int _cols() const { return 1; }
|
||||
|
@ -49,8 +49,10 @@ template<typename MatrixType> class Conjugate : NoOperatorEquals,
|
||||
Conjugate(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Conjugate& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
|
@ -51,8 +51,10 @@ template<typename MatrixType> class DiagonalCoeffs
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = 1;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = 1
|
||||
};
|
||||
|
||||
const DiagonalCoeffs& _ref() const { return *this; }
|
||||
int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); }
|
||||
|
@ -52,16 +52,18 @@ class DiagonalMatrix : NoOperatorEquals,
|
||||
DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs)
|
||||
{
|
||||
assert(CoeffsVectorType::Traits::IsVectorAtCompileTime
|
||||
&& coeffs.size() > 0);
|
||||
&& coeffs.coeffs() > 0);
|
||||
}
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime,
|
||||
ColsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime,
|
||||
ColsAtCompileTime = CoeffsVectorType::Traits::SizeAtCompileTime
|
||||
};
|
||||
|
||||
const DiagonalMatrix& _ref() const { return *this; }
|
||||
int _rows() const { return m_coeffs.size(); }
|
||||
int _cols() const { return m_coeffs.size(); }
|
||||
int _rows() const { return m_coeffs.coeffs(); }
|
||||
int _cols() const { return m_coeffs.coeffs(); }
|
||||
|
||||
Scalar _coeff(int row, int col) const
|
||||
{
|
||||
|
@ -55,8 +55,10 @@ template<typename Lhs, typename Rhs> class Difference : NoOperatorEquals,
|
||||
}
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Difference& _ref() const { return *this; }
|
||||
int _rows() const { return m_lhs.rows(); }
|
||||
|
@ -74,7 +74,7 @@ Scalar MatrixBase<Scalar, Derived>::dot(const OtherDerived& other) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime
|
||||
&& OtherDerived::Traits::IsVectorAtCompileTime
|
||||
&& size() == other.size());
|
||||
&& coeffs() == other.coeffs());
|
||||
Scalar res;
|
||||
if(EIGEN_UNROLLED_LOOPS
|
||||
&& Traits::SizeAtCompileTime != Dynamic
|
||||
@ -85,7 +85,7 @@ Scalar MatrixBase<Scalar, Derived>::dot(const OtherDerived& other) const
|
||||
else
|
||||
{
|
||||
res = (*this).coeff(0) * conj(other.coeff(0));
|
||||
for(int i = 1; i < size(); i++)
|
||||
for(int i = 1; i < coeffs(); i++)
|
||||
res += (*this).coeff(i)* conj(other.coeff(i));
|
||||
}
|
||||
return res;
|
||||
|
@ -67,9 +67,10 @@ template<typename MatrixType> class DynBlock
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DynBlock)
|
||||
|
||||
private:
|
||||
static const int
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime == 1 ? 1 : Dynamic,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime == 1 ? 1 : Dynamic;
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime == 1 ? 1 : Dynamic
|
||||
};
|
||||
|
||||
const DynBlock& _ref() const { return *this; }
|
||||
int _rows() const { return m_blockRows; }
|
||||
|
@ -45,8 +45,10 @@ template<typename MatrixType> class Identity : NoOperatorEquals,
|
||||
}
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Identity& _ref() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
|
@ -47,9 +47,11 @@ template<typename MatrixType> class Map
|
||||
friend class MatrixBase<Scalar, Map<MatrixType> >;
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
static const MatrixStorageOrder _Order = MatrixType::StorageOrder;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
Order = MatrixType::StorageOrder
|
||||
};
|
||||
|
||||
const Map& _ref() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
@ -57,7 +59,7 @@ template<typename MatrixType> class Map
|
||||
|
||||
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];
|
||||
@ -65,7 +67,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];
|
||||
@ -88,7 +90,7 @@ template<typename MatrixType> class Map
|
||||
};
|
||||
|
||||
/** This is the const version of map(Scalar*,int,int). */
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
|
||||
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int rows, int cols)
|
||||
{
|
||||
@ -96,7 +98,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int rows,
|
||||
}
|
||||
|
||||
/** This is the const version of map(Scalar*,int). */
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
|
||||
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int size)
|
||||
{
|
||||
@ -108,7 +110,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data, int size)
|
||||
}
|
||||
|
||||
/** This is the const version of map(Scalar*). */
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
const Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
|
||||
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data)
|
||||
{
|
||||
@ -126,7 +128,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(const Scalar* data)
|
||||
*
|
||||
* \sa map(const Scalar*, int, int), map(Scalar*, int), map(Scalar*), class Map
|
||||
*/
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
|
||||
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int rows, int cols)
|
||||
{
|
||||
@ -145,7 +147,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int rows, int co
|
||||
*
|
||||
* \sa map(const Scalar*, int), map(Scalar*, int, int), map(Scalar*), class Map
|
||||
*/
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
|
||||
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int size)
|
||||
{
|
||||
@ -165,7 +167,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data, int size)
|
||||
*
|
||||
* \sa map(const Scalar*), map(Scalar*, int), map(Scalar*, int, int), class Map
|
||||
*/
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
Map<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
|
||||
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data)
|
||||
{
|
||||
@ -180,7 +182,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>::map(Scalar* data)
|
||||
*
|
||||
* \sa Matrix(const Scalar *), Matrix::map(const Scalar *, int, int)
|
||||
*/
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>
|
||||
::Matrix(const Scalar *data, int rows, int cols)
|
||||
: Storage(rows, cols)
|
||||
@ -198,7 +200,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>
|
||||
*
|
||||
* \sa Matrix(const Scalar *), Matrix::map(const Scalar *, int)
|
||||
*/
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>
|
||||
::Matrix(const Scalar *data, int size)
|
||||
: Storage(size)
|
||||
@ -216,7 +218,7 @@ Matrix<_Scalar, _Rows, _Cols, _StorageOrder>
|
||||
* \sa Matrix(const Scalar *, int), Matrix(const Scalar *, int, int),
|
||||
* Matrix::map(const Scalar *)
|
||||
*/
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
Matrix<_Scalar, _Rows, _Cols, _StorageOrder>
|
||||
::Matrix(const Scalar *data)
|
||||
: Storage()
|
||||
|
@ -70,10 +70,10 @@
|
||||
* \c Matrix<double,3,5>.
|
||||
*
|
||||
* Note that most of the API is in the base class MatrixBase, and that the base class
|
||||
* MatrixStorage also provides the MatrixStorage::resize() public method.
|
||||
* MatrixStorage also provides the MatrixStorage::recoeffs() public method.
|
||||
*/
|
||||
template<typename _Scalar, int _Rows, int _Cols,
|
||||
MatrixStorageOrder _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER>
|
||||
int _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER>
|
||||
class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >,
|
||||
public MatrixStorage<_Scalar, _Rows, _Cols>
|
||||
{
|
||||
@ -96,8 +96,11 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
|
||||
{ return Storage::m_data; }
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = _Rows, ColsAtCompileTime = _Cols;
|
||||
static const MatrixStorageOrder StorageOrder = _StorageOrder;
|
||||
enum {
|
||||
RowsAtCompileTime = _Rows,
|
||||
ColsAtCompileTime = _Cols,
|
||||
StorageOrder = _StorageOrder
|
||||
};
|
||||
|
||||
Ref _ref() const { return Ref(*this); }
|
||||
|
||||
@ -132,12 +135,12 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols, _Storage
|
||||
if(RowsAtCompileTime == 1)
|
||||
{
|
||||
assert(other.isVector());
|
||||
resize(1, other.size());
|
||||
resize(1, other.coeffs());
|
||||
}
|
||||
else if(ColsAtCompileTime == 1)
|
||||
{
|
||||
assert(other.isVector());
|
||||
resize(other.size(), 1);
|
||||
resize(other.coeffs(), 1);
|
||||
}
|
||||
else resize(other.rows(), other.cols());
|
||||
return Base::operator=(other);
|
||||
|
@ -64,27 +64,29 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
* 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 */
|
||||
static const int RowsAtCompileTime = Derived::RowsAtCompileTime;
|
||||
enum { 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 MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
|
||||
static const int ColsAtCompileTime = Derived::ColsAtCompileTime;
|
||||
enum { 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
|
||||
enum { SizeAtCompileTime
|
||||
= Derived::RowsAtCompileTime == Dynamic || Derived::ColsAtCompileTime == Dynamic
|
||||
? Dynamic : Derived::RowsAtCompileTime * Derived::ColsAtCompileTime;
|
||||
? 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;
|
||||
enum { IsVectorAtCompileTime
|
||||
= Derived::RowsAtCompileTime == 1 || Derived::ColsAtCompileTime == 1
|
||||
};
|
||||
};
|
||||
|
||||
/** This is the "reference type" used to pass objects of type MatrixBase as arguments
|
||||
@ -113,7 +115,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
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. */
|
||||
int size() const { return rows() * cols(); }
|
||||
int coeffs() 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
|
||||
|
@ -39,8 +39,10 @@ template<typename MatrixType> class MatrixRef
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef)
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
int _cols() const { return m_matrix.cols(); }
|
||||
|
@ -57,11 +57,12 @@ template<typename MatrixType> class Minor
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
|
||||
|
||||
private:
|
||||
static const int
|
||||
enum {
|
||||
RowsAtCompileTime = (MatrixType::Traits::RowsAtCompileTime != Dynamic) ?
|
||||
MatrixType::Traits::RowsAtCompileTime - 1 : Dynamic,
|
||||
ColsAtCompileTime = (MatrixType::Traits::ColsAtCompileTime != Dynamic) ?
|
||||
MatrixType::Traits::ColsAtCompileTime - 1 : Dynamic;
|
||||
MatrixType::Traits::ColsAtCompileTime - 1 : Dynamic
|
||||
};
|
||||
|
||||
const Minor& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows() - 1; }
|
||||
|
@ -41,10 +41,10 @@
|
||||
* \li A typedef \a FloatingPoint, giving the "floating-point type" of \a T. If \a T is
|
||||
* \c int, then \a FloatingPoint is a typedef to \c double. Otherwise, \a FloatingPoint
|
||||
* is a typedef to \a T.
|
||||
* \li A static const bool \a IsComplex. It is equal to \c true if \a T is a \c std::complex
|
||||
* type, and to false otherwise.
|
||||
* \li A static const bool \a HasFloatingPoint. It is equal to \c false if \a T is \c int,
|
||||
* and to \c true otherwise.
|
||||
* \li An enum value \a IsComplex. It is equal to 1 if \a T is a \c std::complex
|
||||
* type, and to 0 otherwise.
|
||||
* \li An enum \a HasFloatingPoint. It is equal to \c 0 if \a T is \c int,
|
||||
* and to \c 1 otherwise.
|
||||
*/
|
||||
template<typename T> struct NumTraits;
|
||||
|
||||
@ -52,32 +52,40 @@ template<> struct NumTraits<int>
|
||||
{
|
||||
typedef int Real;
|
||||
typedef double FloatingPoint;
|
||||
static const bool IsComplex = false;
|
||||
static const bool HasFloatingPoint = false;
|
||||
enum {
|
||||
IsComplex = 0,
|
||||
HasFloatingPoint = 0
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct NumTraits<float>
|
||||
{
|
||||
typedef float Real;
|
||||
typedef float FloatingPoint;
|
||||
static const bool IsComplex = false;
|
||||
static const bool HasFloatingPoint = true;
|
||||
enum {
|
||||
IsComplex = 0,
|
||||
HasFloatingPoint = 1
|
||||
};
|
||||
};
|
||||
|
||||
template<> struct NumTraits<double>
|
||||
{
|
||||
typedef double Real;
|
||||
typedef double FloatingPoint;
|
||||
static const bool IsComplex = false;
|
||||
static const bool HasFloatingPoint = true;
|
||||
enum {
|
||||
IsComplex = 0,
|
||||
HasFloatingPoint = 1
|
||||
};
|
||||
};
|
||||
|
||||
template<typename _Real> struct NumTraits<std::complex<_Real> >
|
||||
{
|
||||
typedef _Real Real;
|
||||
typedef std::complex<_Real> FloatingPoint;
|
||||
static const bool IsComplex = true;
|
||||
static const bool HasFloatingPoint = NumTraits<Real>::HasFloatingPoint;
|
||||
enum {
|
||||
IsComplex = 1,
|
||||
HasFloatingPoint = 1 // anyway we don't allow std::complex<int>
|
||||
};
|
||||
};
|
||||
|
||||
#endif // EIGEN_NUMTRAITS_H
|
||||
|
@ -40,8 +40,10 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
|
||||
friend class MatrixBase<Scalar, Ones<MatrixType> >;
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Ones& _ref() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
|
@ -30,8 +30,10 @@
|
||||
template<typename Derived1, typename Derived2, int UnrollCount>
|
||||
struct MatrixOperatorEqualsUnroller
|
||||
{
|
||||
static const int col = (UnrollCount-1) / Derived1::Traits::RowsAtCompileTime;
|
||||
static const int row = (UnrollCount-1) % Derived1::Traits::RowsAtCompileTime;
|
||||
enum {
|
||||
col = (UnrollCount-1) / Derived1::Traits::RowsAtCompileTime,
|
||||
row = (UnrollCount-1) % Derived1::Traits::RowsAtCompileTime
|
||||
};
|
||||
|
||||
static void run(Derived1 &dst, const Derived2 &src)
|
||||
{
|
||||
@ -65,7 +67,7 @@ struct MatrixOperatorEqualsUnroller<Derived1, Derived2, Dynamic>
|
||||
template<typename Derived1, typename Derived2, int UnrollCount>
|
||||
struct VectorOperatorEqualsUnroller
|
||||
{
|
||||
static const int index = UnrollCount - 1;
|
||||
enum { index = UnrollCount - 1 };
|
||||
|
||||
static void run(Derived1 &dst, const Derived2 &src)
|
||||
{
|
||||
@ -104,13 +106,13 @@ Derived& MatrixBase<Scalar, Derived>
|
||||
if(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime)
|
||||
// copying a vector expression into a vector
|
||||
{
|
||||
assert(size() == other.size());
|
||||
assert(coeffs() == other.coeffs());
|
||||
if(EIGEN_UNROLLED_LOOPS && Traits::SizeAtCompileTime != Dynamic && Traits::SizeAtCompileTime <= 25)
|
||||
VectorOperatorEqualsUnroller
|
||||
<Derived, OtherDerived, Traits::SizeAtCompileTime>::run
|
||||
(*static_cast<Derived*>(this), *static_cast<const OtherDerived*>(&other));
|
||||
else
|
||||
for(int i = 0; i < size(); i++)
|
||||
for(int i = 0; i < coeffs(); i++)
|
||||
coeffRef(i) = other.coeff(i);
|
||||
return *static_cast<Derived*>(this);
|
||||
}
|
||||
|
@ -49,8 +49,10 @@ template<typename MatrixType> class Opposite : NoOperatorEquals,
|
||||
Opposite(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Opposite& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
|
@ -89,8 +89,10 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
||||
}
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Product& _ref() const { return *this; }
|
||||
int _rows() const { return m_lhs.rows(); }
|
||||
|
@ -40,8 +40,10 @@ template<typename MatrixType> class Random : NoOperatorEquals,
|
||||
friend class MatrixBase<Scalar, Random<MatrixType> >;
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Random& _ref() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
|
@ -69,8 +69,10 @@ template<typename MatrixType> class Row
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row)
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = 1,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = 1,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Row& _ref() const { return *this; }
|
||||
|
||||
|
@ -49,8 +49,10 @@ template<typename FactorType, typename MatrixType> class ScalarMultiple : NoOper
|
||||
: m_matrix(matrix), m_factor(factor) {}
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const ScalarMultiple& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.rows(); }
|
||||
|
@ -55,8 +55,10 @@ template<typename Lhs, typename Rhs> class Sum : NoOperatorEquals,
|
||||
}
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = Lhs::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Rhs::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Sum& _ref() const { return *this; }
|
||||
int _rows() const { return m_lhs.rows(); }
|
||||
|
@ -51,8 +51,10 @@ template<typename MatrixType> class Transpose
|
||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::RowsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::ColsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::RowsAtCompileTime
|
||||
};
|
||||
|
||||
const Transpose& _ref() const { return *this; }
|
||||
int _rows() const { return m_matrix.cols(); }
|
||||
|
@ -32,7 +32,9 @@
|
||||
#define EIGEN_UNROLLED_LOOPS (true)
|
||||
#endif
|
||||
|
||||
#ifndef EIGEN_DEFAULT_MATRIX_STORAGE_ORDER
|
||||
#ifdef EIGEN_DEFAULT_TO_ROW_MAJOR
|
||||
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER RowMajor
|
||||
#else
|
||||
#define EIGEN_DEFAULT_MATRIX_STORAGE_ORDER ColumnMajor
|
||||
#endif
|
||||
|
||||
@ -87,15 +89,12 @@ EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, *=) \
|
||||
EIGEN_INHERIT_SCALAR_ASSIGNMENT_OPERATOR(Derived, /=)
|
||||
|
||||
const int Dynamic = -1;
|
||||
|
||||
enum MatrixStorageOrder
|
||||
{
|
||||
ColumnMajor,
|
||||
RowMajor
|
||||
};
|
||||
const int Generic = -2;
|
||||
const int ColumnMajor = 0;
|
||||
const int RowMajor = 1;
|
||||
|
||||
//forward declarations
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
class Matrix;
|
||||
template<typename MatrixType> class MatrixRef;
|
||||
template<typename NewScalar, typename MatrixType> class Cast;
|
||||
@ -125,7 +124,7 @@ template<typename T> struct ForwardDecl
|
||||
typedef T Ref;
|
||||
};
|
||||
|
||||
template<typename _Scalar, int _Rows, int _Cols, MatrixStorageOrder _StorageOrder>
|
||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder>
|
||||
struct ForwardDecl<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> >
|
||||
{
|
||||
typedef MatrixRef<Matrix<_Scalar, _Rows, _Cols, _StorageOrder> > Ref;
|
||||
|
@ -40,8 +40,10 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||
friend class MatrixBase<Scalar, Zero<MatrixType> >;
|
||||
|
||||
private:
|
||||
static const int RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime;
|
||||
enum {
|
||||
RowsAtCompileTime = MatrixType::Traits::RowsAtCompileTime,
|
||||
ColsAtCompileTime = MatrixType::Traits::ColsAtCompileTime
|
||||
};
|
||||
|
||||
const Zero& _ref() const { return *this; }
|
||||
int _rows() const { return m_rows; }
|
||||
|
@ -1,16 +1,16 @@
|
||||
echo "Fixed size 3x3, ColumnMajor, -DNDEBUG"
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=ColumnMajor -DNDEBUG benchmark.cpp -o benchmark && time ./benchmark >/dev/null
|
||||
g++ -O3 -I .. -DNDEBUG benchmark.cpp -o benchmark && time ./benchmark >/dev/null
|
||||
echo "Fixed size 3x3, ColumnMajor, with asserts"
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=ColumnMajor benchmark.cpp -o benchmark && time ./benchmark >/dev/null
|
||||
g++ -O3 -I .. benchmark.cpp -o benchmark && time ./benchmark >/dev/null
|
||||
echo "Fixed size 3x3, RowMajor, -DNDEBUG"
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=RowMajor -DNDEBUG benchmark.cpp -o benchmark && time ./benchmark >/dev/null
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_TO_ROW_MAJOR -DNDEBUG benchmark.cpp -o benchmark && time ./benchmark >/dev/null
|
||||
echo "Fixed size 3x3, RowMajor, with asserts"
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=RowMajor benchmark.cpp -o benchmark && time ./benchmark >/dev/null
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_TO_ROW_MAJOR benchmark.cpp -o benchmark && time ./benchmark >/dev/null
|
||||
echo "Dynamic size 20x20, ColumnMajor, -DNDEBUG"
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=ColumnMajor -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null
|
||||
g++ -O3 -I .. -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null
|
||||
echo "Dynamic size 20x20, ColumnMajor, with asserts"
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=ColumnMajor benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null
|
||||
g++ -O3 -I .. benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null
|
||||
echo "Dynamic size 20x20, RowMajor, -DNDEBUG"
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=RowMajor -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_TO_ROW_MAJOR -DNDEBUG benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null
|
||||
echo "Dynamic size 20x20, RowMajor, with asserts"
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_MATRIX_STORAGE_ORDER=RowMajor benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null
|
||||
g++ -O3 -I .. -DEIGEN_DEFAULT_TO_ROW_MAJOR benchmarkX.cpp -o benchmarkX && time ./benchmarkX >/dev/null
|
||||
|
@ -31,7 +31,7 @@ template<typename VectorType> void tmap(const VectorType& m)
|
||||
{
|
||||
typedef typename VectorType::Scalar Scalar;
|
||||
|
||||
int size = m.size();
|
||||
int size = m.coeffs();
|
||||
|
||||
// test Map.h
|
||||
Scalar* array1 = new Scalar[size];
|
||||
|
Loading…
x
Reference in New Issue
Block a user