mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-22 04:44:25 +08:00
revert most of my previous commit. forcing the compiler to inline only increased
its memory usage.
This commit is contained in:
parent
936b0de9cc
commit
0cbdaf6bb8
@ -50,16 +50,16 @@ template<typename MatrixType> class Column
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const Column& _ref() const { return *this; }
|
const Column& _ref() const { return *this; }
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE { return 1; }
|
int _cols() const { return 1; }
|
||||||
|
|
||||||
Scalar& _write(int row, int col) EIGEN_ALWAYS_INLINE
|
Scalar& _write(int row, int col)
|
||||||
{
|
{
|
||||||
EIGEN_UNUSED(col);
|
EIGEN_UNUSED(col);
|
||||||
return m_matrix.write(row, m_col);
|
return m_matrix.write(row, m_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
Scalar _read(int row, int col) const
|
||||||
{
|
{
|
||||||
EIGEN_UNUSED(col);
|
EIGEN_UNUSED(col);
|
||||||
return m_matrix.read(row, m_col);
|
return m_matrix.read(row, m_col);
|
||||||
|
@ -47,10 +47,10 @@ template<typename MatrixType> class Conjugate
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const Conjugate& _ref() const { return *this; }
|
const Conjugate& _ref() const { return *this; }
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
Scalar _read(int row, int col) const
|
||||||
{
|
{
|
||||||
return conj(m_matrix.read(row, col));
|
return conj(m_matrix.read(row, col));
|
||||||
}
|
}
|
||||||
|
@ -52,10 +52,10 @@ template<typename Lhs, typename Rhs> class Difference
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const Difference& _ref() const { return *this; }
|
const Difference& _ref() const { return *this; }
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE { return m_lhs.rows(); }
|
int _rows() const { return m_lhs.rows(); }
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE { return m_lhs.cols(); }
|
int _cols() const { return m_lhs.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
Scalar _read(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_lhs.read(row, col) - m_rhs.read(row, col);
|
return m_lhs.read(row, col) - m_rhs.read(row, col);
|
||||||
}
|
}
|
||||||
|
@ -40,21 +40,21 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >,
|
|||||||
|
|
||||||
static const int RowsAtCompileTime = _Rows, ColsAtCompileTime = _Cols;
|
static const int RowsAtCompileTime = _Rows, ColsAtCompileTime = _Cols;
|
||||||
|
|
||||||
const Scalar* array() const EIGEN_ALWAYS_INLINE
|
const Scalar* array() const
|
||||||
{ return Storage::m_array; }
|
{ return Storage::m_array; }
|
||||||
|
|
||||||
Scalar* array() EIGEN_ALWAYS_INLINE
|
Scalar* array()
|
||||||
{ return Storage::m_array; }
|
{ return Storage::m_array; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ref _ref() const { return Ref(*this); }
|
Ref _ref() const { return Ref(*this); }
|
||||||
|
|
||||||
const Scalar& _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
const Scalar& _read(int row, int col) const
|
||||||
{
|
{
|
||||||
return array()[row + col * Storage::_rows()];
|
return array()[row + col * Storage::_rows()];
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar& _write(int row, int col) EIGEN_ALWAYS_INLINE
|
Scalar& _write(int row, int col)
|
||||||
{
|
{
|
||||||
return array()[row + col * Storage::_rows()];
|
return array()[row + col * Storage::_rows()];
|
||||||
}
|
}
|
||||||
|
@ -40,12 +40,9 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
typedef typename ForwardDecl<Derived>::Ref Ref;
|
typedef typename ForwardDecl<Derived>::Ref Ref;
|
||||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||||
|
|
||||||
int rows() const EIGEN_ALWAYS_INLINE
|
int rows() const { return static_cast<const Derived *>(this)->_rows(); }
|
||||||
{ return static_cast<const Derived *>(this)->_rows(); }
|
int cols() const { return static_cast<const Derived *>(this)->_cols(); }
|
||||||
int cols() const EIGEN_ALWAYS_INLINE
|
int size() const { return rows() * cols(); }
|
||||||
{ return static_cast<const Derived *>(this)->_cols(); }
|
|
||||||
int size() const EIGEN_ALWAYS_INLINE
|
|
||||||
{ return rows() * cols(); }
|
|
||||||
|
|
||||||
Ref ref() const
|
Ref ref() const
|
||||||
{ return static_cast<const Derived *>(this)->_ref(); }
|
{ return static_cast<const Derived *>(this)->_ref(); }
|
||||||
@ -132,7 +129,6 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
Derived& operator/=(const std::complex<double>& other);
|
Derived& operator/=(const std::complex<double>& other);
|
||||||
|
|
||||||
Scalar read(int row, int col, AssertLevel assertLevel = InternalDebugging) const
|
Scalar read(int row, int col, AssertLevel assertLevel = InternalDebugging) const
|
||||||
EIGEN_ALWAYS_INLINE
|
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, row >= 0 && row < rows()
|
eigen_assert(assertLevel, row >= 0 && row < rows()
|
||||||
&& col >= 0 && col < cols());
|
&& col >= 0 && col < cols());
|
||||||
@ -141,7 +137,6 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
Scalar operator()(int row, int col) const { return read(row, col, UserDebugging); }
|
Scalar operator()(int row, int col) const { return read(row, col, UserDebugging); }
|
||||||
|
|
||||||
Scalar& write(int row, int col, AssertLevel assertLevel = InternalDebugging)
|
Scalar& write(int row, int col, AssertLevel assertLevel = InternalDebugging)
|
||||||
EIGEN_ALWAYS_INLINE
|
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, row >= 0 && row < rows()
|
eigen_assert(assertLevel, row >= 0 && row < rows()
|
||||||
&& col >= 0 && col < cols());
|
&& col >= 0 && col < cols());
|
||||||
@ -150,7 +145,6 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
Scalar& operator()(int row, int col) { return write(row, col, UserDebugging); }
|
Scalar& operator()(int row, int col) { return write(row, col, UserDebugging); }
|
||||||
|
|
||||||
Scalar read(int index, AssertLevel assertLevel = InternalDebugging) const
|
Scalar read(int index, AssertLevel assertLevel = InternalDebugging) const
|
||||||
EIGEN_ALWAYS_INLINE
|
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, IsVector);
|
eigen_assert(assertLevel, IsVector);
|
||||||
if(RowsAtCompileTime == 1)
|
if(RowsAtCompileTime == 1)
|
||||||
@ -167,7 +161,6 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
Scalar operator[](int index) const { return read(index, UserDebugging); }
|
Scalar operator[](int index) const { return read(index, UserDebugging); }
|
||||||
|
|
||||||
Scalar& write(int index, AssertLevel assertLevel = InternalDebugging)
|
Scalar& write(int index, AssertLevel assertLevel = InternalDebugging)
|
||||||
EIGEN_ALWAYS_INLINE
|
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, IsVector);
|
eigen_assert(assertLevel, IsVector);
|
||||||
if(RowsAtCompileTime == 1)
|
if(RowsAtCompileTime == 1)
|
||||||
|
@ -40,15 +40,15 @@ template<typename MatrixType> class MatrixRef
|
|||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef)
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(MatrixRef)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
const Scalar& _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
const Scalar& _read(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix._read(row, col);
|
return m_matrix._read(row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar& _write(int row, int col) EIGEN_ALWAYS_INLINE
|
Scalar& _write(int row, int col)
|
||||||
{
|
{
|
||||||
return m_matrix.write(row, col);
|
return m_matrix.write(row, col);
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,10 @@ class MatrixStorage
|
|||||||
assert(rows == RowsAtCompileTime && cols == ColsAtCompileTime);
|
assert(rows == RowsAtCompileTime && cols == ColsAtCompileTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE
|
int _rows() const
|
||||||
{ return RowsAtCompileTime; }
|
{ return RowsAtCompileTime; }
|
||||||
|
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE
|
int _cols() const
|
||||||
{ return ColsAtCompileTime; }
|
{ return ColsAtCompileTime; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -80,10 +80,10 @@ class MatrixStorage<Scalar, Dynamic, ColsAtCompileTime>
|
|||||||
m_rows = rows;
|
m_rows = rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE
|
int _rows() const
|
||||||
{ return m_rows; }
|
{ return m_rows; }
|
||||||
|
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE
|
int _cols() const
|
||||||
{ return ColsAtCompileTime; }
|
{ return ColsAtCompileTime; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -124,10 +124,10 @@ class MatrixStorage<Scalar, RowsAtCompileTime, Dynamic>
|
|||||||
m_cols = cols;
|
m_cols = cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE
|
int _rows() const
|
||||||
{ return RowsAtCompileTime; }
|
{ return RowsAtCompileTime; }
|
||||||
|
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE
|
int _cols() const
|
||||||
{ return m_cols; }
|
{ return m_cols; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -168,10 +168,10 @@ class MatrixStorage<Scalar, Dynamic, Dynamic>
|
|||||||
m_cols = cols;
|
m_cols = cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE
|
int _rows() const
|
||||||
{ return m_rows; }
|
{ return m_rows; }
|
||||||
|
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE
|
int _cols() const
|
||||||
{ return m_cols; }
|
{ return m_cols; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -47,10 +47,10 @@ template<typename MatrixType> class Opposite
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const Opposite& _ref() const { return *this; }
|
const Opposite& _ref() const { return *this; }
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
Scalar _read(int row, int col) const
|
||||||
{
|
{
|
||||||
return -(m_matrix.read(row, col));
|
return -(m_matrix.read(row, col));
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ template<int Index, int Size, typename Lhs, typename Rhs>
|
|||||||
struct ProductUnroller
|
struct ProductUnroller
|
||||||
{
|
{
|
||||||
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
|
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
|
||||||
typename Lhs::Scalar &res)
|
typename Lhs::Scalar &res)
|
||||||
{
|
{
|
||||||
ProductUnroller<Index-1, Size, Lhs, Rhs>::run(row, col, lhs, rhs, res);
|
ProductUnroller<Index-1, Size, Lhs, Rhs>::run(row, col, lhs, rhs, res);
|
||||||
res += lhs.read(row, Index) * rhs.read(Index, col);
|
res += lhs.read(row, Index) * rhs.read(Index, col);
|
||||||
@ -41,7 +41,7 @@ template<int Size, typename Lhs, typename Rhs>
|
|||||||
struct ProductUnroller<0, Size, Lhs, Rhs>
|
struct ProductUnroller<0, Size, Lhs, Rhs>
|
||||||
{
|
{
|
||||||
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
|
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
|
||||||
typename Lhs::Scalar &res)
|
typename Lhs::Scalar &res)
|
||||||
{
|
{
|
||||||
res = lhs.read(row, 0) * rhs.read(0, col);
|
res = lhs.read(row, 0) * rhs.read(0, col);
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ template<int Index, typename Lhs, typename Rhs>
|
|||||||
struct ProductUnroller<Index, Dynamic, Lhs, Rhs>
|
struct ProductUnroller<Index, Dynamic, Lhs, Rhs>
|
||||||
{
|
{
|
||||||
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
|
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
|
||||||
typename Lhs::Scalar &res)
|
typename Lhs::Scalar &res)
|
||||||
{
|
{
|
||||||
EIGEN_UNUSED(row);
|
EIGEN_UNUSED(row);
|
||||||
EIGEN_UNUSED(col);
|
EIGEN_UNUSED(col);
|
||||||
@ -66,7 +66,7 @@ template<int Index, typename Lhs, typename Rhs>
|
|||||||
struct ProductUnroller<Index, 0, Lhs, Rhs>
|
struct ProductUnroller<Index, 0, Lhs, Rhs>
|
||||||
{
|
{
|
||||||
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
|
static void run(int row, int col, const Lhs& lhs, const Rhs& rhs,
|
||||||
typename Lhs::Scalar &res)
|
typename Lhs::Scalar &res)
|
||||||
{
|
{
|
||||||
EIGEN_UNUSED(row);
|
EIGEN_UNUSED(row);
|
||||||
EIGEN_UNUSED(col);
|
EIGEN_UNUSED(col);
|
||||||
|
@ -57,16 +57,16 @@ template<typename MatrixType> class Row
|
|||||||
private:
|
private:
|
||||||
const Row& _ref() const { return *this; }
|
const Row& _ref() const { return *this; }
|
||||||
|
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE { return 1; }
|
int _rows() const { return 1; }
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
Scalar& _write(int row, int col) EIGEN_ALWAYS_INLINE
|
Scalar& _write(int row, int col)
|
||||||
{
|
{
|
||||||
EIGEN_UNUSED(row);
|
EIGEN_UNUSED(row);
|
||||||
return m_matrix.write(m_row, col);
|
return m_matrix.write(m_row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
Scalar _read(int row, int col) const
|
||||||
{
|
{
|
||||||
EIGEN_UNUSED(row);
|
EIGEN_UNUSED(row);
|
||||||
return m_matrix.read(m_row, col);
|
return m_matrix.read(m_row, col);
|
||||||
|
@ -48,10 +48,10 @@ template<typename MatrixType> class ScalarMultiple
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const ScalarMultiple& _ref() const { return *this; }
|
const ScalarMultiple& _ref() const { return *this; }
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
Scalar _read(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(row, col) * m_scalar;
|
return m_matrix.read(row, col) * m_scalar;
|
||||||
}
|
}
|
||||||
|
@ -52,10 +52,10 @@ template<typename Lhs, typename Rhs> class Sum
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const Sum& _ref() const { return *this; }
|
const Sum& _ref() const { return *this; }
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE { return m_lhs.rows(); }
|
int _rows() const { return m_lhs.rows(); }
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE { return m_lhs.cols(); }
|
int _cols() const { return m_lhs.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
Scalar _read(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_lhs.read(row, col) + m_rhs.read(row, col);
|
return m_lhs.read(row, col) + m_rhs.read(row, col);
|
||||||
}
|
}
|
||||||
|
@ -46,15 +46,15 @@ template<typename MatrixType> class Transpose
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const Transpose& _ref() const { return *this; }
|
const Transpose& _ref() const { return *this; }
|
||||||
int _rows() const EIGEN_ALWAYS_INLINE { return m_matrix.cols(); }
|
int _rows() const { return m_matrix.cols(); }
|
||||||
int _cols() const EIGEN_ALWAYS_INLINE { return m_matrix.rows(); }
|
int _cols() const { return m_matrix.rows(); }
|
||||||
|
|
||||||
Scalar& _write(int row, int col) EIGEN_ALWAYS_INLINE
|
Scalar& _write(int row, int col)
|
||||||
{
|
{
|
||||||
return m_matrix.write(col, row);
|
return m_matrix.write(col, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int row, int col) const EIGEN_ALWAYS_INLINE
|
Scalar _read(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(col, row);
|
return m_matrix.read(col, row);
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@ int main(int argc, char *argv[])
|
|||||||
bool has_set_repeat = false;
|
bool has_set_repeat = false;
|
||||||
bool has_set_seed = false;
|
bool has_set_seed = false;
|
||||||
bool need_help = false;
|
bool need_help = false;
|
||||||
unsigned int seed = 0;
|
unsigned int seed;
|
||||||
int repeat = 0;
|
int repeat;
|
||||||
|
|
||||||
QStringList args = QCoreApplication::instance()->arguments();
|
QStringList args = QCoreApplication::instance()->arguments();
|
||||||
args.takeFirst(); // throw away the first argument (path to executable)
|
args.takeFirst(); // throw away the first argument (path to executable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user