aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-01-06 13:17:07 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2008-01-06 13:17:07 +0000
commit495eb7053ab7101f714718332399d51b10645b8b (patch)
treec835f693522b380b53563e0c0fe870b27e5fb9a4
parentd1d55e67e967a9bd0d447a7ea105ac2771cde557 (diff)
Patch by Gael Guennebaud, making Eigen compatible with the Intel compiler (icc).
CCMAIL:eigen@lists.tuxfamily.org
-rw-r--r--Eigen/src/Core/Block.h8
-rw-r--r--Eigen/src/Core/Coeffs.h16
-rw-r--r--Eigen/src/Core/Column.h7
-rw-r--r--Eigen/src/Core/Conjugate.h8
-rw-r--r--Eigen/src/Core/DiagonalCoeffs.h8
-rw-r--r--Eigen/src/Core/DiagonalMatrix.h10
-rw-r--r--Eigen/src/Core/Difference.h8
-rw-r--r--Eigen/src/Core/Dot.h6
-rw-r--r--Eigen/src/Core/DynBlock.h8
-rw-r--r--Eigen/src/Core/Eval.h6
-rw-r--r--Eigen/src/Core/Fuzzy.h6
-rw-r--r--Eigen/src/Core/Identity.h4
-rw-r--r--Eigen/src/Core/Map.h17
-rw-r--r--Eigen/src/Core/Matrix.h49
-rw-r--r--Eigen/src/Core/MatrixBase.h61
-rw-r--r--Eigen/src/Core/MatrixRef.h8
-rw-r--r--Eigen/src/Core/Minor.h8
-rw-r--r--Eigen/src/Core/Ones.h19
-rw-r--r--Eigen/src/Core/OperatorEquals.h12
-rw-r--r--Eigen/src/Core/Opposite.h8
-rw-r--r--Eigen/src/Core/Product.h6
-rw-r--r--Eigen/src/Core/Random.h19
-rw-r--r--Eigen/src/Core/Row.h8
-rw-r--r--Eigen/src/Core/ScalarMultiple.h8
-rw-r--r--Eigen/src/Core/Sum.h8
-rw-r--r--Eigen/src/Core/Trace.h4
-rw-r--r--Eigen/src/Core/Transpose.h8
-rw-r--r--Eigen/src/Core/Zero.h18
28 files changed, 187 insertions, 169 deletions
diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h
index 19552308e..27ef2cb14 100644
--- a/Eigen/src/Core/Block.h
+++ b/Eigen/src/Core/Block.h
@@ -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; }
diff --git a/Eigen/src/Core/Coeffs.h b/Eigen/src/Core/Coeffs.h
index 6c48a40c5..a902fc9ba 100644
--- a/Eigen/src/Core/Coeffs.h
+++ b/Eigen/src/Core/Coeffs.h
@@ -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);
diff --git a/Eigen/src/Core/Column.h b/Eigen/src/Core/Column.h
index 1ee63423b..f32eb94e1 100644
--- a/Eigen/src/Core/Column.h
+++ b/Eigen/src/Core/Column.h
@@ -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; }
diff --git a/Eigen/src/Core/Conjugate.h b/Eigen/src/Core/Conjugate.h
index 2a900a8e9..b5450ef91 100644
--- a/Eigen/src/Core/Conjugate.h
+++ b/Eigen/src/Core/Conjugate.h
@@ -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(); }
diff --git a/Eigen/src/Core/DiagonalCoeffs.h b/Eigen/src/Core/DiagonalCoeffs.h
index 44904fbcd..0a570c9fc 100644
--- a/Eigen/src/Core/DiagonalCoeffs.h
+++ b/Eigen/src/Core/DiagonalCoeffs.h
@@ -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; }
diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h
index 67f10cfb7..99245b750 100644
--- a/Eigen/src/Core/DiagonalMatrix.h
+++ b/Eigen/src/Core/DiagonalMatrix.h
@@ -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(); }
diff --git a/Eigen/src/Core/Difference.h b/Eigen/src/Core/Difference.h
index b249e4e98..8d2e731ee 100644
--- a/Eigen/src/Core/Difference.h
+++ b/Eigen/src/Core/Difference.h
@@ -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(); }
diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h
index 322ff63a2..b22fbaac8 100644
--- a/Eigen/src/Core/Dot.h
+++ b/Eigen/src/Core/Dot.h
@@ -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
{
diff --git a/Eigen/src/Core/DynBlock.h b/Eigen/src/Core/DynBlock.h
index e47b09fb1..4f352293b 100644
--- a/Eigen/src/Core/DynBlock.h
+++ b/Eigen/src/Core/DynBlock.h
@@ -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; }
diff --git a/Eigen/src/Core/Eval.h b/Eigen/src/Core/Eval.h
index a4bf582f1..039b10b91 100644
--- a/Eigen/src/Core/Eval.h
+++ b/Eigen/src/Core/Eval.h
@@ -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>;
diff --git a/Eigen/src/Core/Fuzzy.h b/Eigen/src/Core/Fuzzy.h
index 6cf076cdc..3641157f7 100644
--- a/Eigen/src/Core/Fuzzy.h
+++ b/Eigen/src/Core/Fuzzy.h
@@ -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);
}
diff --git a/Eigen/src/Core/Identity.h b/Eigen/src/Core/Identity.h
index 068493125..21e70be5c 100644
--- a/Eigen/src/Core/Identity.h
+++ b/Eigen/src/Core/Identity.h
@@ -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,
diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h
index fa7a75a49..79a00b92b 100644
--- a/Eigen/src/Core/Map.h
+++ b/Eigen/src/Core/Map.h
@@ -46,19 +46,18 @@ template<typename MatrixType> class Map
typedef typename MatrixType::Scalar Scalar;
friend class MatrixBase<Scalar, Map<MatrixType> >;
- 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 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)
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 8148e2ac6..4fa997269 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -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;
diff --git a/Eigen/src/Core/MatrixBase.h b/Eigen/src/Core/MatrixBase.h
index 8f556388f..bfcea8cc5 100644
--- a/Eigen/src/Core/MatrixBase.h
+++ b/Eigen/src/Core/MatrixBase.h
@@ -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;
diff --git a/Eigen/src/Core/MatrixRef.h b/Eigen/src/Core/MatrixRef.h
index 57ae4a492..1660a2b01 100644
--- a/Eigen/src/Core/MatrixRef.h
+++ b/Eigen/src/Core/MatrixRef.h
@@ -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(); }
diff --git a/Eigen/src/Core/Minor.h b/Eigen/src/Core/Minor.h
index 11d47d4ac..5de41f169 100644
--- a/Eigen/src/Core/Minor.h
+++ b/Eigen/src/Core/Minor.h
@@ -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; }
diff --git a/Eigen/src/Core/Ones.h b/Eigen/src/Core/Ones.h
index cea830dc8..ede1c1d4f 100644
--- a/Eigen/src/Core/Ones.h
+++ b/Eigen/src/Core/Ones.h
@@ -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>
diff --git a/Eigen/src/Core/OperatorEquals.h b/Eigen/src/Core/OperatorEquals.h
index e2cc5d559..eaadb2478 100644
--- a/Eigen/src/Core/OperatorEquals.h
+++ b/Eigen/src/Core/OperatorEquals.h
@@ -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);
diff --git a/Eigen/src/Core/Opposite.h b/Eigen/src/Core/Opposite.h
index e0b6c1ac3..1b1139c9d 100644
--- a/Eigen/src/Core/Opposite.h
+++ b/Eigen/src/Core/Opposite.h
@@ -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(); }
diff --git a/Eigen/src/Core/Product.h b/Eigen/src/Core/Product.h
index db261491e..3c790bd84 100644
--- a/Eigen/src/Core/Product.h
+++ b/Eigen/src/Core/Product.h
@@ -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(); }
diff --git a/Eigen/src/Core/Random.h b/Eigen/src/Core/Random.h
index 1b870af74..164c24e30 100644
--- a/Eigen/src/Core/Random.h
+++ b/Eigen/src/Core/Random.h
@@ -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
diff --git a/Eigen/src/Core/Row.h b/Eigen/src/Core/Row.h
index 40f53de4c..7ba3a13a0 100644
--- a/Eigen/src/Core/Row.h
+++ b/Eigen/src/Core/Row.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; }
diff --git a/Eigen/src/Core/ScalarMultiple.h b/Eigen/src/Core/ScalarMultiple.h
index 76a4477cc..c60ef5f4a 100644
--- a/Eigen/src/Core/ScalarMultiple.h
+++ b/Eigen/src/Core/ScalarMultiple.h
@@ -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(); }
diff --git a/Eigen/src/Core/Sum.h b/Eigen/src/Core/Sum.h
index 453033673..a566077dd 100644
--- a/Eigen/src/Core/Sum.h
+++ b/Eigen/src/Core/Sum.h
@@ -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(); }
diff --git a/Eigen/src/Core/Trace.h b/Eigen/src/Core/Trace.h
index cfe7c7937..24a31a2f8 100644
--- a/Eigen/src/Core/Trace.h
+++ b/Eigen/src/Core/Trace.h
@@ -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
{
diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h
index dd0f8cc3e..b6a19c751 100644
--- a/Eigen/src/Core/Transpose.h
+++ b/Eigen/src/Core/Transpose.h
@@ -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(); }
diff --git a/Eigen/src/Core/Zero.h b/Eigen/src/Core/Zero.h
index 56ada635a..5dd6b7e7d 100644
--- a/Eigen/src/Core/Zero.h
+++ b/Eigen/src/Core/Zero.h
@@ -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>