change derived classes methods from "private:_method()"

to "public:method()" i.e. reimplementing the generic method()
from MatrixBase.
improves compilation speed by 7%, reduces almost by half the call depth
of trivial functions, making gcc errors and application backtraces
nicer...
This commit is contained in:
Benoit Jacob 2008-06-26 20:08:16 +00:00
parent 25ba9f377c
commit c5bd1703cb
20 changed files with 137 additions and 168 deletions

View File

@ -79,10 +79,10 @@ class PartialRedux : ei_no_assignment_operator,
private: private:
int _rows() const { return (Direction==Vertical ? 1 : m_matrix.rows()); } int rows() const { return (Direction==Vertical ? 1 : m_matrix.rows()); }
int _cols() const { return (Direction==Horizontal ? 1 : m_matrix.cols()); } int cols() const { return (Direction==Horizontal ? 1 : m_matrix.cols()); }
const Scalar _coeff(int i, int j) const const Scalar coeff(int i, int j) const
{ {
if (Direction==Vertical) if (Direction==Vertical)
return m_matrix.col(j).redux(m_functor); return m_matrix.col(j).redux(m_functor);

View File

@ -134,25 +134,23 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Block)
private: inline int rows() const { return m_blockRows.value(); }
inline int cols() const { return m_blockCols.value(); }
inline int _rows() const { return m_blockRows.value(); } inline int stride(void) const { return m_matrix.stride(); }
inline int _cols() const { return m_blockCols.value(); }
inline int _stride(void) const { return m_matrix.stride(); } inline Scalar& coeffRef(int row, int col)
inline Scalar& _coeffRef(int row, int col)
{ {
return m_matrix.const_cast_derived() return m_matrix.const_cast_derived()
.coeffRef(row + m_startRow.value(), col + m_startCol.value()); .coeffRef(row + m_startRow.value(), col + m_startCol.value());
} }
inline const Scalar _coeff(int row, int col) const inline const Scalar coeff(int row, int col) const
{ {
return m_matrix.coeff(row + m_startRow.value(), col + m_startCol.value()); return m_matrix.coeff(row + m_startRow.value(), col + m_startCol.value());
} }
inline Scalar& _coeffRef(int index) inline Scalar& coeffRef(int index)
{ {
return m_matrix.const_cast_derived() return m_matrix.const_cast_derived()
.coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), .coeffRef(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
@ -160,7 +158,7 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
} }
inline const Scalar _coeff(int index) const inline const Scalar coeff(int index) const
{ {
return m_matrix return m_matrix
.coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), .coeff(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
@ -168,26 +166,26 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
} }
template<int LoadMode> template<int LoadMode>
inline PacketScalar _packet(int row, int col) const inline PacketScalar packet(int row, int col) const
{ {
return m_matrix.template packet<UnAligned>(row + m_startRow.value(), col + m_startCol.value()); return m_matrix.template packet<UnAligned>(row + m_startRow.value(), col + m_startCol.value());
} }
template<int LoadMode> template<int LoadMode>
inline void _writePacket(int row, int col, const PacketScalar& x) inline void writePacket(int row, int col, const PacketScalar& x)
{ {
m_matrix.const_cast_derived().template writePacket<UnAligned>(row + m_startRow.value(), col + m_startCol.value(), x); m_matrix.const_cast_derived().template writePacket<UnAligned>(row + m_startRow.value(), col + m_startCol.value(), x);
} }
template<int LoadMode> template<int LoadMode>
inline PacketScalar _packet(int index) const inline PacketScalar packet(int index) const
{ {
return m_matrix.template packet<UnAligned>(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), return m_matrix.template packet<UnAligned>(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),
m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0)); m_startCol.value() + (RowsAtCompileTime == 1 ? index : 0));
} }
template<int LoadMode> template<int LoadMode>
inline void _writePacket(int index, const PacketScalar& x) inline void writePacket(int index, const PacketScalar& x)
{ {
m_matrix.const_cast_derived().template writePacket<UnAligned> m_matrix.const_cast_derived().template writePacket<UnAligned>
(m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index), (m_startRow.value() + (RowsAtCompileTime == 1 ? 0 : index),

View File

@ -45,7 +45,7 @@ inline const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
{ {
ei_internal_assert(row >= 0 && row < rows() ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols()); && col >= 0 && col < cols());
return derived()._coeff(row, col); return derived().coeff(row, col);
} }
/** \returns the coefficient at given the given row and column. /** \returns the coefficient at given the given row and column.
@ -58,7 +58,7 @@ inline const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
{ {
ei_assert(row >= 0 && row < rows() ei_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols()); && col >= 0 && col < cols());
return derived()._coeff(row, col); return derived().coeff(row, col);
} }
/** Short version: don't use this function, use /** Short version: don't use this function, use
@ -81,7 +81,7 @@ inline typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
{ {
ei_internal_assert(row >= 0 && row < rows() ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols()); && col >= 0 && col < cols());
return derived()._coeffRef(row, col); return derived().coeffRef(row, col);
} }
/** \returns a reference to the coefficient at given the given row and column. /** \returns a reference to the coefficient at given the given row and column.
@ -94,7 +94,7 @@ inline typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
{ {
ei_assert(row >= 0 && row < rows() ei_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols()); && col >= 0 && col < cols());
return derived()._coeffRef(row, col); return derived().coeffRef(row, col);
} }
/** Short version: don't use this function, use /** Short version: don't use this function, use
@ -116,7 +116,7 @@ inline const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::coeff(int index) const ::coeff(int index) const
{ {
ei_internal_assert(index >= 0 && index < size()); ei_internal_assert(index >= 0 && index < size());
return derived()._coeff(index); return derived().coeff(index);
} }
/** \returns the coefficient at given index. /** \returns the coefficient at given index.
@ -131,7 +131,7 @@ inline const typename ei_traits<Derived>::Scalar MatrixBase<Derived>
::operator[](int index) const ::operator[](int index) const
{ {
ei_assert(index >= 0 && index < size()); ei_assert(index >= 0 && index < size());
return derived()._coeff(index); return derived().coeff(index);
} }
/** Short version: don't use this function, use /** Short version: don't use this function, use
@ -153,7 +153,7 @@ inline typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::coeffRef(int index) ::coeffRef(int index)
{ {
ei_internal_assert(index >= 0 && index < size()); ei_internal_assert(index >= 0 && index < size());
return derived()._coeffRef(index); return derived().coeffRef(index);
} }
/** \returns a reference to the coefficient at given index. /** \returns a reference to the coefficient at given index.
@ -167,7 +167,7 @@ inline typename ei_traits<Derived>::Scalar& MatrixBase<Derived>
::operator[](int index) ::operator[](int index)
{ {
ei_assert(index >= 0 && index < size()); ei_assert(index >= 0 && index < size());
return derived()._coeffRef(index); return derived().coeffRef(index);
} }
/** equivalent to operator[](0). */ /** equivalent to operator[](0). */
@ -225,7 +225,7 @@ MatrixBase<Derived>::packet(int row, int col) const
{ {
ei_internal_assert(row >= 0 && row < rows() ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols()); && col >= 0 && col < cols());
return derived().template _packet<LoadMode>(row,col); return derived().template packet<LoadMode>(row,col);
} }
/** Stores the given packet of coefficients, at the given row and column of this expression. It is your responsibility /** Stores the given packet of coefficients, at the given row and column of this expression. It is your responsibility
@ -243,7 +243,7 @@ inline void MatrixBase<Derived>::writePacket
{ {
ei_internal_assert(row >= 0 && row < rows() ei_internal_assert(row >= 0 && row < rows()
&& col >= 0 && col < cols()); && col >= 0 && col < cols());
derived().template _writePacket<StoreMode>(row,col,x); derived().template writePacket<StoreMode>(row,col,x);
} }
/** \returns the packet of coefficients starting at the given index. It is your responsibility /** \returns the packet of coefficients starting at the given index. It is your responsibility
@ -260,7 +260,7 @@ inline typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type
MatrixBase<Derived>::packet(int index) const MatrixBase<Derived>::packet(int index) const
{ {
ei_internal_assert(index >= 0 && index < size()); ei_internal_assert(index >= 0 && index < size());
return derived().template _packet<LoadMode>(index); return derived().template packet<LoadMode>(index);
} }
/** Stores the given packet of coefficients, at the given index in this expression. It is your responsibility /** Stores the given packet of coefficients, at the given index in this expression. It is your responsibility
@ -277,7 +277,7 @@ inline void MatrixBase<Derived>::writePacket
(int index, const typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type& x) (int index, const typename ei_packet_traits<typename ei_traits<Derived>::Scalar>::type& x)
{ {
ei_internal_assert(index >= 0 && index < size()); ei_internal_assert(index >= 0 && index < size());
derived().template _writePacket<StoreMode>(index,x); derived().template writePacket<StoreMode>(index,x);
} }

View File

@ -92,29 +92,27 @@ class CwiseBinaryOp : ei_no_assignment_operator,
ei_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols()); ei_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
} }
private: inline int rows() const { return m_lhs.rows(); }
inline int cols() const { return m_lhs.cols(); }
inline int _rows() const { return m_lhs.rows(); } inline const Scalar coeff(int row, int col) const
inline int _cols() const { return m_lhs.cols(); }
inline const Scalar _coeff(int row, int col) const
{ {
return m_functor(m_lhs.coeff(row, col), m_rhs.coeff(row, col)); return m_functor(m_lhs.coeff(row, col), m_rhs.coeff(row, col));
} }
template<int LoadMode> template<int LoadMode>
inline PacketScalar _packet(int row, int col) const inline PacketScalar packet(int row, int col) const
{ {
return m_functor.packetOp(m_lhs.template packet<LoadMode>(row, col), m_rhs.template packet<LoadMode>(row, col)); return m_functor.packetOp(m_lhs.template packet<LoadMode>(row, col), m_rhs.template packet<LoadMode>(row, col));
} }
inline const Scalar _coeff(int index) const inline const Scalar coeff(int index) const
{ {
return m_functor(m_lhs.coeff(index), m_rhs.coeff(index)); return m_functor(m_lhs.coeff(index), m_rhs.coeff(index));
} }
template<int LoadMode> template<int LoadMode>
inline PacketScalar _packet(int index) const inline PacketScalar packet(int index) const
{ {
return m_functor.packetOp(m_lhs.template packet<LoadMode>(index), m_rhs.template packet<LoadMode>(index)); return m_functor.packetOp(m_lhs.template packet<LoadMode>(index), m_rhs.template packet<LoadMode>(index));
} }

View File

@ -75,29 +75,27 @@ class CwiseNullaryOp : ei_no_assignment_operator,
&& (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
} }
private: int rows() const { return m_rows.value(); }
int cols() const { return m_cols.value(); }
int _rows() const { return m_rows.value(); } const Scalar coeff(int rows, int cols) const
int _cols() const { return m_cols.value(); }
const Scalar _coeff(int rows, int cols) const
{ {
return m_functor(rows, cols); return m_functor(rows, cols);
} }
template<int LoadMode> template<int LoadMode>
PacketScalar _packet(int, int) const PacketScalar packet(int, int) const
{ {
return m_functor.packetOp(); return m_functor.packetOp();
} }
const Scalar _coeff(int index) const const Scalar coeff(int index) const
{ {
return m_functor(index); return m_functor(index);
} }
template<int LoadMode> template<int LoadMode>
PacketScalar _packet(int) const PacketScalar packet(int) const
{ {
return m_functor.packetOp(); return m_functor.packetOp();
} }

View File

@ -74,29 +74,27 @@ class CwiseUnaryOp : ei_no_assignment_operator,
inline CwiseUnaryOp(const MatrixType& mat, const UnaryOp& func = UnaryOp()) inline CwiseUnaryOp(const MatrixType& mat, const UnaryOp& func = UnaryOp())
: m_matrix(mat), m_functor(func) {} : m_matrix(mat), m_functor(func) {}
private: inline int rows() const { return m_matrix.rows(); }
inline int cols() const { return m_matrix.cols(); }
inline int _rows() const { return m_matrix.rows(); } inline const Scalar coeff(int row, int col) const
inline int _cols() const { return m_matrix.cols(); }
inline const Scalar _coeff(int row, int col) const
{ {
return m_functor(m_matrix.coeff(row, col)); return m_functor(m_matrix.coeff(row, col));
} }
template<int LoadMode> template<int LoadMode>
inline PacketScalar _packet(int row, int col) const inline PacketScalar packet(int row, int col) const
{ {
return m_functor.packetOp(m_matrix.template packet<LoadMode>(row, col)); return m_functor.packetOp(m_matrix.template packet<LoadMode>(row, col));
} }
inline const Scalar _coeff(int index) const inline const Scalar coeff(int index) const
{ {
return m_functor(m_matrix.coeff(index)); return m_functor(m_matrix.coeff(index));
} }
template<int LoadMode> template<int LoadMode>
inline PacketScalar _packet(int index) const inline PacketScalar packet(int index) const
{ {
return m_functor.packetOp(m_matrix.template packet<LoadMode>(index)); return m_functor.packetOp(m_matrix.template packet<LoadMode>(index));
} }

View File

@ -73,27 +73,25 @@ template<typename MatrixType> class DiagonalCoeffs
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(DiagonalCoeffs)
private: inline int rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); }
inline int cols() const { return 1; }
inline int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); } inline Scalar& coeffRef(int row, int)
inline int _cols() const { return 1; }
inline Scalar& _coeffRef(int row, int)
{ {
return m_matrix.const_cast_derived().coeffRef(row, row); return m_matrix.const_cast_derived().coeffRef(row, row);
} }
inline const Scalar _coeff(int row, int) const inline const Scalar coeff(int row, int) const
{ {
return m_matrix.coeff(row, row); return m_matrix.coeff(row, row);
} }
inline Scalar& _coeffRef(int index) inline Scalar& coeffRef(int index)
{ {
return m_matrix.const_cast_derived().coeffRef(index, index); return m_matrix.const_cast_derived().coeffRef(index, index);
} }
inline const Scalar _coeff(int index) const inline const Scalar coeff(int index) const
{ {
return m_matrix.coeff(index, index); return m_matrix.coeff(index, index);
} }

View File

@ -68,12 +68,10 @@ class DiagonalMatrix : ei_no_assignment_operator,
&& coeffs.size() > 0); && coeffs.size() > 0);
} }
private: inline int rows() const { return m_coeffs.size(); }
inline int cols() const { return m_coeffs.size(); }
inline int _rows() const { return m_coeffs.size(); } inline const Scalar coeff(int row, int col) const
inline int _cols() const { return m_coeffs.size(); }
inline const Scalar _coeff(int row, int col) const
{ {
return row == col ? m_coeffs.coeff(row) : static_cast<Scalar>(0); return row == col ? m_coeffs.coeff(row) : static_cast<Scalar>(0);
} }

View File

@ -82,19 +82,17 @@ template<typename LhsNested, typename RhsNested> class Product<LhsNested, RhsNes
ei_assert(lhs.cols() == rhs.rows()); ei_assert(lhs.cols() == rhs.rows());
} }
private: inline int rows() const { return m_lhs.rows(); }
inline int cols() const { return m_rhs.cols(); }
inline int _rows() const { return m_lhs.rows(); } const Scalar coeff(int row, int col) const
inline int _cols() const { return m_rhs.cols(); }
const Scalar _coeff(int row, int col) const
{ {
const int unique = RhsIsDiagonal ? col : row; const int unique = RhsIsDiagonal ? col : row;
return m_lhs.coeff(row, unique) * m_rhs.coeff(unique, col); return m_lhs.coeff(row, unique) * m_rhs.coeff(unique, col);
} }
template<int LoadMode> template<int LoadMode>
const PacketScalar _packet(int row, int col) const const PacketScalar packet(int row, int col) const
{ {
if (RhsIsDiagonal) if (RhsIsDiagonal)
{ {

View File

@ -69,12 +69,10 @@ template<typename MatrixType, unsigned int Mode> class Extract
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Extract) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Extract)
private: inline int rows() const { return m_matrix.rows(); }
inline int cols() const { return m_matrix.cols(); }
inline int _rows() const { return m_matrix.rows(); } inline Scalar coeff(int row, int col) const
inline int _cols() const { return m_matrix.cols(); }
inline Scalar _coeff(int row, int col) const
{ {
if(Flags & LowerTriangularBit ? col>row : row>col) if(Flags & LowerTriangularBit ? col>row : row>col)
return (Flags & SelfAdjointBit) ? ei_conj(m_matrix.coeff(col, row)) : (Scalar)0; return (Flags & SelfAdjointBit) ? ei_conj(m_matrix.coeff(col, row)) : (Scalar)0;

View File

@ -68,52 +68,50 @@ template<typename ExpressionType, unsigned int Added, unsigned int Removed> clas
/** \internal */ /** \internal */
inline const ExpressionType& _expression() const { return m_matrix; } inline const ExpressionType& _expression() const { return m_matrix; }
private: inline int rows() const { return m_matrix.rows(); }
inline int cols() const { return m_matrix.cols(); }
inline int stride() const { return m_matrix.stride(); }
inline int _rows() const { return m_matrix.rows(); } inline const Scalar coeff(int row, int col) const
inline int _cols() const { return m_matrix.cols(); }
inline int _stride() const { return m_matrix.stride(); }
inline const Scalar _coeff(int row, int col) const
{ {
return m_matrix.coeff(row, col); return m_matrix.coeff(row, col);
} }
inline Scalar& _coeffRef(int row, int col) inline Scalar& coeffRef(int row, int col)
{ {
return m_matrix.const_cast_derived().coeffRef(row, col); return m_matrix.const_cast_derived().coeffRef(row, col);
} }
inline const Scalar _coeff(int index) const inline const Scalar coeff(int index) const
{ {
return m_matrix.coeff(index); return m_matrix.coeff(index);
} }
inline Scalar& _coeffRef(int index) inline Scalar& coeffRef(int index)
{ {
return m_matrix.const_cast_derived().coeffRef(index); return m_matrix.const_cast_derived().coeffRef(index);
} }
template<int LoadMode> template<int LoadMode>
inline const PacketScalar _packet(int row, int col) const inline const PacketScalar packet(int row, int col) const
{ {
return m_matrix.template packet<LoadMode>(row, col); return m_matrix.template packet<LoadMode>(row, col);
} }
template<int LoadMode> template<int LoadMode>
inline void _writePacket(int row, int col, const PacketScalar& x) inline void writePacket(int row, int col, const PacketScalar& x)
{ {
m_matrix.const_cast_derived().template writePacket<LoadMode>(row, col, x); m_matrix.const_cast_derived().template writePacket<LoadMode>(row, col, x);
} }
template<int LoadMode> template<int LoadMode>
inline const PacketScalar _packet(int index) const inline const PacketScalar packet(int index) const
{ {
return m_matrix.template packet<LoadMode>(index); return m_matrix.template packet<LoadMode>(index);
} }
template<int LoadMode> template<int LoadMode>
inline void _writePacket(int index, const PacketScalar& x) inline void writePacket(int index, const PacketScalar& x)
{ {
m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x); m_matrix.const_cast_derived().template writePacket<LoadMode>(index, x);
} }

View File

@ -59,12 +59,10 @@ template<typename MatrixType> class Map
EIGEN_GENERIC_PUBLIC_INTERFACE(Map) EIGEN_GENERIC_PUBLIC_INTERFACE(Map)
private: inline int rows() const { return m_rows; }
inline int cols() const { return m_cols; }
inline int _rows() const { return m_rows; } inline const Scalar& coeff(int row, int col) const
inline int _cols() const { return m_cols; }
inline const Scalar& _coeff(int row, int col) const
{ {
if(Flags & RowMajorBit) if(Flags & RowMajorBit)
return m_data[col + row * m_cols]; return m_data[col + row * m_cols];
@ -72,7 +70,7 @@ template<typename MatrixType> class Map
return m_data[row + col * m_rows]; return m_data[row + col * m_rows];
} }
inline Scalar& _coeffRef(int row, int col) inline Scalar& coeffRef(int row, int col)
{ {
if(Flags & RowMajorBit) if(Flags & RowMajorBit)
return const_cast<Scalar*>(m_data)[col + row * m_cols]; return const_cast<Scalar*>(m_data)[col + row * m_cols];
@ -80,12 +78,12 @@ template<typename MatrixType> class Map
return const_cast<Scalar*>(m_data)[row + col * m_rows]; return const_cast<Scalar*>(m_data)[row + col * m_rows];
} }
inline const Scalar& _coeff(int index) const inline const Scalar& coeff(int index) const
{ {
return m_data[index]; return m_data[index];
} }
inline Scalar& _coeffRef(int index) inline Scalar& coeffRef(int index)
{ {
return m_data[index]; return m_data[index];
} }

View File

@ -100,19 +100,18 @@ template<typename _Scalar, int _Rows, int _Cols, int _MaxRows, int _MaxCols, uns
class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCols, _Flags> > class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCols, _Flags> >
{ {
public: public:
EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix) EIGEN_GENERIC_PUBLIC_INTERFACE(Matrix)
friend class Map<Matrix>; protected:
private:
ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime> m_storage; ei_matrix_storage<Scalar, MaxSizeAtCompileTime, RowsAtCompileTime, ColsAtCompileTime> m_storage;
inline int _rows() const { return m_storage.rows(); } public:
inline int _cols() const { return m_storage.cols(); } friend class Map<Matrix>;
inline int _stride(void) const inline int rows() const { return m_storage.rows(); }
inline int cols() const { return m_storage.cols(); }
inline int stride(void) const
{ {
if(Flags & RowMajorBit) if(Flags & RowMajorBit)
return m_storage.cols(); return m_storage.cols();
@ -120,7 +119,7 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCol
return m_storage.rows(); return m_storage.rows();
} }
inline const Scalar& _coeff(int row, int col) const inline const Scalar& coeff(int row, int col) const
{ {
if(Flags & RowMajorBit) if(Flags & RowMajorBit)
return m_storage.data()[col + row * m_storage.cols()]; return m_storage.data()[col + row * m_storage.cols()];
@ -128,12 +127,12 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCol
return m_storage.data()[row + col * m_storage.rows()]; return m_storage.data()[row + col * m_storage.rows()];
} }
inline const Scalar& _coeff(int index) const inline const Scalar& coeff(int index) const
{ {
return m_storage.data()[index]; return m_storage.data()[index];
} }
inline Scalar& _coeffRef(int row, int col) inline Scalar& coeffRef(int row, int col)
{ {
if(Flags & RowMajorBit) if(Flags & RowMajorBit)
return m_storage.data()[col + row * m_storage.cols()]; return m_storage.data()[col + row * m_storage.cols()];
@ -141,13 +140,13 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCol
return m_storage.data()[row + col * m_storage.rows()]; return m_storage.data()[row + col * m_storage.rows()];
} }
inline Scalar& _coeffRef(int index) inline Scalar& coeffRef(int index)
{ {
return m_storage.data()[index]; return m_storage.data()[index];
} }
template<int LoadMode> template<int LoadMode>
inline PacketScalar _packet(int row, int col) const inline PacketScalar packet(int row, int col) const
{ {
if(Flags & RowMajorBit) if(Flags & RowMajorBit)
if (LoadMode==Aligned) if (LoadMode==Aligned)
@ -162,7 +161,7 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCol
} }
template<int LoadMode> template<int LoadMode>
inline PacketScalar _packet(int index) const inline PacketScalar packet(int index) const
{ {
if (LoadMode==Aligned) if (LoadMode==Aligned)
return ei_pload(m_storage.data() + index); return ei_pload(m_storage.data() + index);
@ -171,7 +170,7 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCol
} }
template<int StoreMode> template<int StoreMode>
inline void _writePacket(int row, int col, const PacketScalar& x) inline void writePacket(int row, int col, const PacketScalar& x)
{ {
ei_internal_assert(Flags & PacketAccessBit); ei_internal_assert(Flags & PacketAccessBit);
if(Flags & RowMajorBit) if(Flags & RowMajorBit)
@ -187,7 +186,7 @@ class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols, _MaxRows, _MaxCol
} }
template<int StoreMode> template<int StoreMode>
inline void _writePacket(int index, const PacketScalar& x) inline void writePacket(int index, const PacketScalar& x)
{ {
if (StoreMode==Aligned) if (StoreMode==Aligned)
ei_pstore(m_storage.data() + index, x); ei_pstore(m_storage.data() + index, x);

View File

@ -148,9 +148,9 @@ template<typename Derived> class MatrixBase
typedef typename NumTraits<Scalar>::Real RealScalar; typedef typename NumTraits<Scalar>::Real RealScalar;
/** \returns the number of rows. \sa cols(), RowsAtCompileTime */ /** \returns the number of rows. \sa cols(), RowsAtCompileTime */
inline int rows() const { return derived()._rows(); } inline int rows() const { return derived().rows(); }
/** \returns the number of columns. \sa row(), ColsAtCompileTime*/ /** \returns the number of columns. \sa row(), ColsAtCompileTime*/
inline int cols() const { return derived()._cols(); } inline int cols() const { return derived().cols(); }
/** \returns the number of coefficients, which is \a rows()*cols(). /** \returns the number of coefficients, which is \a rows()*cols().
* \sa rows(), cols(), SizeAtCompileTime. */ * \sa rows(), cols(), SizeAtCompileTime. */
inline int size() const { return rows() * cols(); } inline int size() const { return rows() * cols(); }
@ -433,7 +433,7 @@ template<typename Derived> class MatrixBase
* Combined with coeffRef() and the \ref flags flags, it allows a direct access to the data * Combined with coeffRef() and the \ref flags flags, it allows a direct access to the data
* of the underlying matrix. * of the underlying matrix.
*/ */
inline int stride(void) const { return derived()._stride(); } inline int stride(void) const { return derived().stride(); }
inline const NestByValue<Derived> nestByValue() const; inline const NestByValue<Derived> nestByValue() const;

View File

@ -74,17 +74,15 @@ template<typename MatrixType> class Minor
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Minor)
private: inline int rows() const { return m_matrix.rows() - 1; }
inline int cols() const { return m_matrix.cols() - 1; }
inline int _rows() const { return m_matrix.rows() - 1; } inline Scalar& coeffRef(int row, int col)
inline int _cols() const { return m_matrix.cols() - 1; }
inline Scalar& _coeffRef(int row, int col)
{ {
return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col)); return m_matrix.const_cast_derived().coeffRef(row + (row >= m_row), col + (col >= m_col));
} }
inline const Scalar _coeff(int row, int col) const inline const Scalar coeff(int row, int col) const
{ {
return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col)); return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
} }

View File

@ -60,52 +60,50 @@ template<typename ExpressionType> class NestByValue
inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {} inline NestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
private: inline int rows() const { return m_expression.rows(); }
inline int cols() const { return m_expression.cols(); }
inline int stride() const { return m_expression.stride(); }
inline int _rows() const { return m_expression.rows(); } inline const Scalar coeff(int row, int col) const
inline int _cols() const { return m_expression.cols(); }
inline int _stride() const { return m_expression.stride(); }
inline const Scalar _coeff(int row, int col) const
{ {
return m_expression.coeff(row, col); return m_expression.coeff(row, col);
} }
inline Scalar& _coeffRef(int row, int col) inline Scalar& coeffRef(int row, int col)
{ {
return m_expression.const_cast_derived().coeffRef(row, col); return m_expression.const_cast_derived().coeffRef(row, col);
} }
inline const Scalar _coeff(int index) const inline const Scalar coeff(int index) const
{ {
return m_expression.coeff(index); return m_expression.coeff(index);
} }
inline Scalar& _coeffRef(int index) inline Scalar& coeffRef(int index)
{ {
return m_expression.const_cast_derived().coeffRef(index); return m_expression.const_cast_derived().coeffRef(index);
} }
template<int LoadMode> template<int LoadMode>
inline const PacketScalar _packet(int row, int col) const inline const PacketScalar packet(int row, int col) const
{ {
return m_expression.template packet<LoadMode>(row, col); return m_expression.template packet<LoadMode>(row, col);
} }
template<int LoadMode> template<int LoadMode>
inline void _writePacket(int row, int col, const PacketScalar& x) inline void writePacket(int row, int col, const PacketScalar& x)
{ {
m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x); m_expression.const_cast_derived().template writePacket<LoadMode>(row, col, x);
} }
template<int LoadMode> template<int LoadMode>
inline const PacketScalar _packet(int index) const inline const PacketScalar packet(int index) const
{ {
return m_expression.template packet<LoadMode>(index); return m_expression.template packet<LoadMode>(index);
} }
template<int LoadMode> template<int LoadMode>
inline void _writePacket(int index, const PacketScalar& x) inline void writePacket(int index, const PacketScalar& x)
{ {
m_expression.const_cast_derived().template writePacket<LoadMode>(index, x); m_expression.const_cast_derived().template writePacket<LoadMode>(index, x);
} }

View File

@ -206,17 +206,15 @@ template<typename LhsNested, typename RhsNested, int ProductMode> class Product
* \returns whether it is worth it to use the cache friendly product. * \returns whether it is worth it to use the cache friendly product.
*/ */
inline bool _useCacheFriendlyProduct() const { inline bool _useCacheFriendlyProduct() const {
return _rows()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD return rows()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
&& _cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD && cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
&& m_lhs.cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD; && m_lhs.cols()>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD;
} }
private: inline int rows() const { return m_lhs.rows(); }
inline int cols() const { return m_rhs.cols(); }
inline int _rows() const { return m_lhs.rows(); } const Scalar coeff(int row, int col) const
inline int _cols() const { return m_rhs.cols(); }
const Scalar _coeff(int row, int col) const
{ {
Scalar res; Scalar res;
ScalarCoeffImpl::run(row, col, m_lhs, m_rhs, res); ScalarCoeffImpl::run(row, col, m_lhs, m_rhs, res);
@ -226,7 +224,7 @@ template<typename LhsNested, typename RhsNested, int ProductMode> class Product
/* Allow index-based non-packet access. It is impossible though to allow index-based packed access, /* Allow index-based non-packet access. It is impossible though to allow index-based packed access,
* which is why we don't set the LinearAccessBit. * which is why we don't set the LinearAccessBit.
*/ */
const Scalar _coeff(int index) const const Scalar coeff(int index) const
{ {
Scalar res; Scalar res;
const int row = RowsAtCompileTime == 1 ? 0 : index; const int row = RowsAtCompileTime == 1 ? 0 : index;
@ -236,7 +234,7 @@ template<typename LhsNested, typename RhsNested, int ProductMode> class Product
} }
template<int LoadMode> template<int LoadMode>
const PacketScalar _packet(int row, int col) const const PacketScalar packet(int row, int col) const
{ {
PacketScalar res; PacketScalar res;
ei_product_packet_impl<Flags&RowMajorBit ? RowMajorProduct : ColMajorProduct, ei_product_packet_impl<Flags&RowMajorBit ? RowMajorProduct : ColMajorProduct,
@ -508,7 +506,7 @@ inline void Product<Lhs,Rhs,ProductMode>::_cacheFriendlyEvalAndAdd(DestDerived&
LhsCopy lhs(m_lhs); LhsCopy lhs(m_lhs);
RhsCopy rhs(m_rhs); RhsCopy rhs(m_rhs);
ei_cache_friendly_product<Scalar>( ei_cache_friendly_product<Scalar>(
_rows(), _cols(), lhs.cols(), rows(), cols(), lhs.cols(),
_LhsCopy::Flags&RowMajorBit, &(lhs.const_cast_derived().coeffRef(0,0)), lhs.stride(), _LhsCopy::Flags&RowMajorBit, &(lhs.const_cast_derived().coeffRef(0,0)), lhs.stride(),
_RhsCopy::Flags&RowMajorBit, &(rhs.const_cast_derived().coeffRef(0,0)), rhs.stride(), _RhsCopy::Flags&RowMajorBit, &(rhs.const_cast_derived().coeffRef(0,0)), rhs.stride(),
Flags&RowMajorBit, &(res.coeffRef(0,0)), res.stride() Flags&RowMajorBit, &(res.coeffRef(0,0)), res.stride()

View File

@ -67,31 +67,29 @@ template<typename MatrixType> class Transpose
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose) EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Transpose)
private: inline int rows() const { return m_matrix.cols(); }
inline int cols() const { return m_matrix.rows(); }
inline int _rows() const { return m_matrix.cols(); } inline int stride(void) const { return m_matrix.stride(); }
inline int _cols() const { return m_matrix.rows(); }
inline int _stride(void) const { return m_matrix.stride(); } inline Scalar& coeffRef(int row, int col)
inline Scalar& _coeffRef(int row, int col)
{ {
return m_matrix.const_cast_derived().coeffRef(col, row); return m_matrix.const_cast_derived().coeffRef(col, row);
} }
inline const Scalar _coeff(int row, int col) const inline const Scalar coeff(int row, int col) const
{ {
return m_matrix.coeff(col, row); return m_matrix.coeff(col, row);
} }
template<int LoadMode> template<int LoadMode>
inline const PacketScalar _packet(int row, int col) const inline const PacketScalar packet(int row, int col) const
{ {
return m_matrix.template packet<LoadMode>(col, row); return m_matrix.template packet<LoadMode>(col, row);
} }
template<int LoadMode> template<int LoadMode>
inline void _writePacket(int row, int col, const PacketScalar& x) inline void writePacket(int row, int col, const PacketScalar& x)
{ {
m_matrix.const_cast_derived().template writePacket<LoadMode>(col, row, x); m_matrix.const_cast_derived().template writePacket<LoadMode>(col, row, x);
} }

View File

@ -76,18 +76,16 @@ template<typename MatrixType, bool CheckExistence> class Inverse : ei_no_assignm
*/ */
bool exists() const { assert(CheckExistence); return m_exists; } bool exists() const { assert(CheckExistence); return m_exists; }
private: int rows() const { return m_inverse.rows(); }
int cols() const { return m_inverse.cols(); }
int _rows() const { return m_inverse.rows(); } const Scalar coeff(int row, int col) const
int _cols() const { return m_inverse.cols(); }
const Scalar _coeff(int row, int col) const
{ {
return m_inverse.coeff(row, col); return m_inverse.coeff(row, col);
} }
template<int LoadMode> template<int LoadMode>
PacketScalar _packet(int row, int col) const PacketScalar packet(int row, int col) const
{ {
return m_inverse.template packet<LoadMode>(row, col); return m_inverse.template packet<LoadMode>(row, col);
} }

View File

@ -63,10 +63,10 @@ class SparseMatrix : public MatrixBase<SparseMatrix<_Scalar> >
int m_rows; int m_rows;
int m_cols; int m_cols;
inline int _rows() const { return m_rows; } inline int rows() const { return m_rows; }
inline int _cols() const { return m_cols; } inline int cols() const { return m_cols; }
inline const Scalar& _coeff(int row, int col) const inline const Scalar& coeff(int row, int col) const
{ {
int id = m_colPtrs[col]; int id = m_colPtrs[col];
int end = m_colPtrs[col+1]; int end = m_colPtrs[col+1];
@ -79,7 +79,7 @@ class SparseMatrix : public MatrixBase<SparseMatrix<_Scalar> >
return m_data.value(id); return m_data.value(id);
} }
inline Scalar& _coeffRef(int row, int col) inline Scalar& coeffRef(int row, int col)
{ {
int id = m_colPtrs[cols]; int id = m_colPtrs[cols];
int end = m_colPtrs[cols+1]; int end = m_colPtrs[cols+1];
@ -95,19 +95,19 @@ class SparseMatrix : public MatrixBase<SparseMatrix<_Scalar> >
class InnerIterator; class InnerIterator;
inline int rows() const { return _rows(); } inline int rows() const { return rows(); }
inline int cols() const { return _cols(); } inline int cols() const { return cols(); }
/** \returns the number of non zero coefficients */ /** \returns the number of non zero coefficients */
inline int nonZeros() const { return m_data.size(); } inline int nonZeros() const { return m_data.size(); }
inline const Scalar& operator() (int row, int col) const inline const Scalar& operator() (int row, int col) const
{ {
return _coeff(row, col); return coeff(row, col);
} }
inline Scalar& operator() (int row, int col) inline Scalar& operator() (int row, int col)
{ {
return _coeffRef(row, col); return coeffRef(row, col);
} }
inline void startFill(int reserveSize = 1000) inline void startFill(int reserveSize = 1000)