mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-23 01:59:38 +08:00
some more cleanup and reorganisation
This commit is contained in:
parent
9314b8e024
commit
f75a0c5179
@ -36,5 +36,6 @@ namespace Eigen {
|
|||||||
#include "Core/Identity.h"
|
#include "Core/Identity.h"
|
||||||
#include "Core/Fuzzy.h"
|
#include "Core/Fuzzy.h"
|
||||||
#include "Core/Map.h"
|
#include "Core/Map.h"
|
||||||
|
#include "Core/IO.h"
|
||||||
|
|
||||||
} // namespace Eigen
|
} // namespace Eigen
|
||||||
|
@ -56,14 +56,14 @@ template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
|||||||
int _rows() const { return BlockRows; }
|
int _rows() const { return BlockRows; }
|
||||||
int _cols() const { return BlockCols; }
|
int _cols() const { return BlockCols; }
|
||||||
|
|
||||||
Scalar& _write(int row, int col)
|
Scalar& _coeffRef(int row, int col)
|
||||||
{
|
{
|
||||||
return m_matrix.write(row + m_startRow, col + m_startCol);
|
return m_matrix.coeffRef(row + m_startRow, col + m_startCol);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(row + m_startRow, col + m_startCol);
|
return m_matrix.coeff(row + m_startRow, col + m_startCol);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -47,9 +47,9 @@ template<typename NewScalar, typename MatrixType> class Cast : NoOperatorEquals,
|
|||||||
int _rows() const { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return static_cast<Scalar>(m_matrix.read(row, col));
|
return static_cast<Scalar>(m_matrix.coeff(row, col));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -53,14 +53,14 @@ template<typename MatrixType> class Column
|
|||||||
int _rows() const { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const { return 1; }
|
int _cols() const { return 1; }
|
||||||
|
|
||||||
Scalar& _write(int row, int)
|
Scalar& _coeffRef(int row, int)
|
||||||
{
|
{
|
||||||
return m_matrix.write(row, m_col);
|
return m_matrix.coeffRef(row, m_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int row, int) const
|
Scalar _coeff(int row, int) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(row, m_col);
|
return m_matrix.coeff(row, m_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -47,9 +47,9 @@ template<typename MatrixType> class Conjugate : NoOperatorEquals,
|
|||||||
int _rows() const { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return conj(m_matrix.read(row, col));
|
return conj(m_matrix.coeff(row, col));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -63,4 +63,11 @@ MatrixBase<Scalar, Derived>::conjugate() const
|
|||||||
return Conjugate<Derived>(static_cast<const Derived*>(this)->ref());
|
return Conjugate<Derived>(static_cast<const Derived*>(this)->ref());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename Scalar, typename Derived>
|
||||||
|
const Transpose<Conjugate<Derived> >
|
||||||
|
MatrixBase<Scalar, Derived>::adjoint() const
|
||||||
|
{
|
||||||
|
return conjugate().transpose();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EIGEN_CONJUGATE_H
|
#endif // EIGEN_CONJUGATE_H
|
||||||
|
@ -48,14 +48,14 @@ template<typename MatrixType> class DiagonalCoeffs
|
|||||||
int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); }
|
int _rows() const { return std::min(m_matrix.rows(), m_matrix.cols()); }
|
||||||
int _cols() const { return 1; }
|
int _cols() const { return 1; }
|
||||||
|
|
||||||
Scalar& _write(int row, int)
|
Scalar& _coeffRef(int row, int)
|
||||||
{
|
{
|
||||||
return m_matrix.write(row, row);
|
return m_matrix.coeffRef(row, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int row, int) const
|
Scalar _coeff(int row, int) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(row, row);
|
return m_matrix.coeff(row, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -52,9 +52,9 @@ class DiagonalMatrix : NoOperatorEquals,
|
|||||||
int _rows() const { return m_coeffs.size(); }
|
int _rows() const { return m_coeffs.size(); }
|
||||||
int _cols() const { return m_coeffs.size(); }
|
int _cols() const { return m_coeffs.size(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return row == col ? m_coeffs.read(row) : static_cast<Scalar>(0);
|
return row == col ? m_coeffs.coeff(row) : static_cast<Scalar>(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -52,9 +52,9 @@ template<typename Lhs, typename Rhs> class Difference : NoOperatorEquals,
|
|||||||
int _rows() const { return m_lhs.rows(); }
|
int _rows() const { return m_lhs.rows(); }
|
||||||
int _cols() const { return m_lhs.cols(); }
|
int _cols() const { return m_lhs.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_lhs.read(row, col) - m_rhs.read(row, col);
|
return m_lhs.coeff(row, col) - m_rhs.coeff(row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -32,7 +32,7 @@ struct DotUnroller
|
|||||||
static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot)
|
static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot)
|
||||||
{
|
{
|
||||||
DotUnroller<Index-1, Size, Derived1, Derived2>::run(v1, v2, dot);
|
DotUnroller<Index-1, Size, Derived1, Derived2>::run(v1, v2, dot);
|
||||||
dot += v1.read(Index) * conj(v2.read(Index));
|
dot += v1.coeff(Index) * conj(v2.coeff(Index));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ struct DotUnroller<0, Size, Derived1, Derived2>
|
|||||||
{
|
{
|
||||||
static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot)
|
static void run(const Derived1 &v1, const Derived2& v2, typename Derived1::Scalar &dot)
|
||||||
{
|
{
|
||||||
dot = v1.read(0) * conj(v2.read(0));
|
dot = v1.coeff(0) * conj(v2.coeff(0));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,9 +69,9 @@ Scalar MatrixBase<Scalar, Derived>::dot(const OtherDerived& other) const
|
|||||||
::run(*static_cast<const Derived*>(this), other, res);
|
::run(*static_cast<const Derived*>(this), other, res);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = (*this).read(0) * conj(other.read(0));
|
res = (*this).coeff(0) * conj(other.coeff(0));
|
||||||
for(int i = 1; i < size(); i++)
|
for(int i = 1; i < size(); i++)
|
||||||
res += (*this).read(i)* conj(other.read(i));
|
res += (*this).coeff(i)* conj(other.coeff(i));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -60,14 +60,14 @@ template<typename MatrixType> class DynBlock
|
|||||||
int _rows() const { return m_blockRows; }
|
int _rows() const { return m_blockRows; }
|
||||||
int _cols() const { return m_blockCols; }
|
int _cols() const { return m_blockCols; }
|
||||||
|
|
||||||
Scalar& _write(int row, int col)
|
Scalar& _coeffRef(int row, int col)
|
||||||
{
|
{
|
||||||
return m_matrix.write(row + m_startRow, col + m_startCol);
|
return m_matrix.coeffRef(row + m_startRow, col + m_startCol);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(row + m_startRow, col + m_startCol);
|
return m_matrix.coeff(row + m_startRow, col + m_startCol);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
45
src/Core/IO.h
Normal file
45
src/Core/IO.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// This file is part of Eigen, a lightweight C++ template library
|
||||||
|
// for linear algebra. Eigen itself is part of the KDE project.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2006-2007 Benoit Jacob <jacob@math.jussieu.fr>
|
||||||
|
//
|
||||||
|
// Eigen is free software; you can redistribute it and/or modify it under the
|
||||||
|
// terms of the GNU General Public License as published by the Free Software
|
||||||
|
// Foundation; either version 2 or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
// details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along
|
||||||
|
// with Eigen; if not, write to the Free Software Foundation, Inc., 51
|
||||||
|
// Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
//
|
||||||
|
// As a special exception, if other files instantiate templates or use macros
|
||||||
|
// or functions from this file, or you compile this file and link it
|
||||||
|
// with other works to produce a work based on this file, this file does not
|
||||||
|
// by itself cause the resulting work to be covered by the GNU General Public
|
||||||
|
// License. This exception does not invalidate any other reasons why a work
|
||||||
|
// based on this file might be covered by the GNU General Public License.
|
||||||
|
|
||||||
|
#ifndef EIGEN_IO_H
|
||||||
|
#define EIGEN_IO_H
|
||||||
|
|
||||||
|
template<typename Scalar, typename Derived>
|
||||||
|
std::ostream & operator <<
|
||||||
|
( std::ostream & s,
|
||||||
|
const MatrixBase<Scalar, Derived> & m )
|
||||||
|
{
|
||||||
|
for( int i = 0; i < m.rows(); i++ )
|
||||||
|
{
|
||||||
|
s << m( i, 0 );
|
||||||
|
for (int j = 1; j < m.cols(); j++ )
|
||||||
|
s << " " << m( i, j );
|
||||||
|
if( i < m.rows() - 1)
|
||||||
|
s << std::endl;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // EIGEN_IO_H
|
@ -46,7 +46,7 @@ template<typename MatrixType> class Identity : NoOperatorEquals,
|
|||||||
int _rows() const { return m_rows; }
|
int _rows() const { return m_rows; }
|
||||||
int _cols() const { return m_rows; }
|
int _cols() const { return m_rows; }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return row == col ? static_cast<Scalar>(1) : static_cast<Scalar>(0);
|
return row == col ? static_cast<Scalar>(1) : static_cast<Scalar>(0);
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,12 @@ template<typename MatrixType> class Map
|
|||||||
int _rows() const { return m_rows; }
|
int _rows() const { return m_rows; }
|
||||||
int _cols() const { return m_cols; }
|
int _cols() const { return m_cols; }
|
||||||
|
|
||||||
const Scalar& _read(int row, int col) const
|
const Scalar& _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_data[row + col * m_rows];
|
return m_data[row + col * m_rows];
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar& _write(int row, int col)
|
Scalar& _coeffRef(int row, int col)
|
||||||
{
|
{
|
||||||
return m_data[row + col * m_rows];
|
return m_data[row + col * m_rows];
|
||||||
}
|
}
|
||||||
|
@ -49,12 +49,12 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >,
|
|||||||
private:
|
private:
|
||||||
Ref _ref() const { return Ref(*this); }
|
Ref _ref() const { return Ref(*this); }
|
||||||
|
|
||||||
const Scalar& _read(int row, int col) const
|
const Scalar& _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return data()[row + col * Storage::_rows()];
|
return data()[row + col * Storage::_rows()];
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar& _write(int row, int col)
|
Scalar& _coeffRef(int row, int col)
|
||||||
{
|
{
|
||||||
return data()[row + col * Storage::_rows()];
|
return data()[row + col * Storage::_rows()];
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
|
|
||||||
Transpose<Derived> transpose() const;
|
Transpose<Derived> transpose() const;
|
||||||
const Conjugate<Derived> conjugate() const;
|
const Conjugate<Derived> conjugate() const;
|
||||||
const Transpose<Conjugate<Derived> > adjoint() const
|
const Transpose<Conjugate<Derived> > adjoint() const;
|
||||||
{ return conjugate().transpose(); }
|
|
||||||
Scalar trace() const;
|
Scalar trace() const;
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
@ -139,71 +138,55 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
Derived& operator/=(const std::complex<float>& other);
|
Derived& operator/=(const std::complex<float>& other);
|
||||||
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 coeff(int row, int col, AssertLevel assertLevel = InternalDebugging) const
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, row >= 0 && row < rows()
|
eigen_assert(assertLevel, row >= 0 && row < rows()
|
||||||
&& col >= 0 && col < cols());
|
&& col >= 0 && col < cols());
|
||||||
return static_cast<const Derived *>(this)->_read(row, col);
|
return static_cast<const Derived *>(this)->_coeff(row, col);
|
||||||
}
|
}
|
||||||
Scalar operator()(int row, int col) const { return read(row, col, UserDebugging); }
|
Scalar operator()(int row, int col) const { return coeff(row, col, UserDebugging); }
|
||||||
|
|
||||||
Scalar& write(int row, int col, AssertLevel assertLevel = InternalDebugging)
|
Scalar& coeffRef(int row, int col, AssertLevel assertLevel = InternalDebugging)
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, row >= 0 && row < rows()
|
eigen_assert(assertLevel, row >= 0 && row < rows()
|
||||||
&& col >= 0 && col < cols());
|
&& col >= 0 && col < cols());
|
||||||
return static_cast<Derived *>(this)->_write(row, col);
|
return static_cast<Derived *>(this)->_coeffRef(row, col);
|
||||||
}
|
}
|
||||||
Scalar& operator()(int row, int col) { return write(row, col, UserDebugging); }
|
Scalar& operator()(int row, int col) { return coeffRef(row, col, UserDebugging); }
|
||||||
|
|
||||||
Scalar read(int index, AssertLevel assertLevel = InternalDebugging) const
|
Scalar coeff(int index, AssertLevel assertLevel = InternalDebugging) const
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, IsVector);
|
eigen_assert(assertLevel, IsVector);
|
||||||
if(RowsAtCompileTime == 1)
|
if(RowsAtCompileTime == 1)
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, index >= 0 && index < cols());
|
eigen_assert(assertLevel, index >= 0 && index < cols());
|
||||||
return read(0, index);
|
return coeff(0, index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, index >= 0 && index < rows());
|
eigen_assert(assertLevel, index >= 0 && index < rows());
|
||||||
return read(index, 0);
|
return coeff(index, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Scalar operator[](int index) const { return read(index, UserDebugging); }
|
Scalar operator[](int index) const { return coeff(index, UserDebugging); }
|
||||||
|
|
||||||
Scalar& write(int index, AssertLevel assertLevel = InternalDebugging)
|
Scalar& coeffRef(int index, AssertLevel assertLevel = InternalDebugging)
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, IsVector);
|
eigen_assert(assertLevel, IsVector);
|
||||||
if(RowsAtCompileTime == 1)
|
if(RowsAtCompileTime == 1)
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, index >= 0 && index < cols());
|
eigen_assert(assertLevel, index >= 0 && index < cols());
|
||||||
return write(0, index);
|
return coeffRef(0, index);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
eigen_assert(assertLevel, index >= 0 && index < rows());
|
eigen_assert(assertLevel, index >= 0 && index < rows());
|
||||||
return write(index, 0);
|
return coeffRef(index, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Scalar& operator[](int index) { return write(index, UserDebugging); }
|
Scalar& operator[](int index) { return coeffRef(index, UserDebugging); }
|
||||||
|
|
||||||
Eval<Derived> eval() const EIGEN_ALWAYS_INLINE;
|
Eval<Derived> eval() const EIGEN_ALWAYS_INLINE;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
|
||||||
std::ostream & operator <<
|
|
||||||
( std::ostream & s,
|
|
||||||
const MatrixBase<Scalar, Derived> & m )
|
|
||||||
{
|
|
||||||
for( int i = 0; i < m.rows(); i++ )
|
|
||||||
{
|
|
||||||
s << m( i, 0 );
|
|
||||||
for (int j = 1; j < m.cols(); j++ )
|
|
||||||
s << " " << m( i, j );
|
|
||||||
if( i < m.rows() - 1)
|
|
||||||
s << std::endl;
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // EIGEN_MATRIXBASE_H
|
#endif // EIGEN_MATRIXBASE_H
|
||||||
|
@ -46,14 +46,14 @@ template<typename MatrixType> class MatrixRef
|
|||||||
int _rows() const { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
const Scalar& _read(int row, int col) const
|
const Scalar& _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix._read(row, col);
|
return m_matrix._coeff(row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar& _write(int row, int col)
|
Scalar& _coeffRef(int row, int col)
|
||||||
{
|
{
|
||||||
return m_matrix.write(row, col);
|
return m_matrix.coeffRef(row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -58,14 +58,14 @@ template<typename MatrixType> class Minor
|
|||||||
int _rows() const { return m_matrix.rows() - 1; }
|
int _rows() const { return m_matrix.rows() - 1; }
|
||||||
int _cols() const { return m_matrix.cols() - 1; }
|
int _cols() const { return m_matrix.cols() - 1; }
|
||||||
|
|
||||||
Scalar& _write(int row, int col)
|
Scalar& _coeffRef(int row, int col)
|
||||||
{
|
{
|
||||||
return m_matrix.write(row + (row >= m_row), col + (col >= m_col));
|
return m_matrix.coeffRef(row + (row >= m_row), col + (col >= m_col));
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(row + (row >= m_row), col + (col >= m_col));
|
return m_matrix.coeff(row + (row >= m_row), col + (col >= m_col));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -46,7 +46,7 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
|
|||||||
int _rows() const { return m_rows; }
|
int _rows() const { return m_rows; }
|
||||||
int _cols() const { return m_cols; }
|
int _cols() const { return m_cols; }
|
||||||
|
|
||||||
Scalar _read(int, int) const
|
Scalar _coeff(int, int) const
|
||||||
{
|
{
|
||||||
return static_cast<Scalar>(1);
|
return static_cast<Scalar>(1);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ struct OperatorEqualsUnroller
|
|||||||
static void run(Derived1 &dst, const Derived2 &src)
|
static void run(Derived1 &dst, const Derived2 &src)
|
||||||
{
|
{
|
||||||
OperatorEqualsUnroller<Derived1, Derived2, UnrollCount-1, Rows>::run(dst, src);
|
OperatorEqualsUnroller<Derived1, Derived2, UnrollCount-1, Rows>::run(dst, src);
|
||||||
dst.write(row, col) = src.read(row, col);
|
dst.coeffRef(row, col) = src.coeff(row, col);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ struct OperatorEqualsUnroller<Derived1, Derived2, 1, Rows>
|
|||||||
{
|
{
|
||||||
static void run(Derived1 &dst, const Derived2 &src)
|
static void run(Derived1 &dst, const Derived2 &src)
|
||||||
{
|
{
|
||||||
dst.write(0, 0) = src.read(0, 0);
|
dst.coeffRef(0, 0) = src.coeff(0, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ Derived& MatrixBase<Scalar, Derived>
|
|||||||
else
|
else
|
||||||
for(int j = 0; j < cols(); j++) //traverse in column-dominant order
|
for(int j = 0; j < cols(); j++) //traverse in column-dominant order
|
||||||
for(int i = 0; i < rows(); i++)
|
for(int i = 0; i < rows(); i++)
|
||||||
write(i, j) = other.read(i, j);
|
coeffRef(i, j) = other.coeff(i, j);
|
||||||
return *static_cast<Derived*>(this);
|
return *static_cast<Derived*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ template<typename MatrixType> class Opposite : NoOperatorEquals,
|
|||||||
int _rows() const { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return -(m_matrix.read(row, col));
|
return -(m_matrix.coeff(row, col));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -33,7 +33,7 @@ struct ProductUnroller
|
|||||||
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.coeff(row, Index) * rhs.coeff(Index, col);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ 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.coeff(row, 0) * rhs.coeff(0, col);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
|||||||
int _rows() const { return m_lhs.rows(); }
|
int _rows() const { return m_lhs.rows(); }
|
||||||
int _cols() const { return m_rhs.cols(); }
|
int _cols() const { return m_rhs.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
Scalar res;
|
Scalar res;
|
||||||
if(EIGEN_UNROLLED_LOOPS
|
if(EIGEN_UNROLLED_LOOPS
|
||||||
@ -95,9 +95,9 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
|||||||
::run(row, col, m_lhs, m_rhs, res);
|
::run(row, col, m_lhs, m_rhs, res);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = m_lhs.read(row, 0) * m_rhs.read(0, col);
|
res = m_lhs.coeff(row, 0) * m_rhs.coeff(0, col);
|
||||||
for(int i = 1; i < m_lhs.cols(); i++)
|
for(int i = 1; i < m_lhs.cols(); i++)
|
||||||
res += m_lhs.read(row, i) * m_rhs.read(i, col);
|
res += m_lhs.coeff(row, i) * m_rhs.coeff(i, col);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ template<typename MatrixType> class Random : NoOperatorEquals,
|
|||||||
int _rows() const { return m_rows; }
|
int _rows() const { return m_rows; }
|
||||||
int _cols() const { return m_cols; }
|
int _cols() const { return m_cols; }
|
||||||
|
|
||||||
Scalar _read(int, int) const
|
Scalar _coeff(int, int) const
|
||||||
{
|
{
|
||||||
return random<Scalar>();
|
return random<Scalar>();
|
||||||
}
|
}
|
||||||
|
@ -60,14 +60,14 @@ template<typename MatrixType> class Row
|
|||||||
int _rows() const { return 1; }
|
int _rows() const { return 1; }
|
||||||
int _cols() const { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
Scalar& _write(int, int col)
|
Scalar& _coeffRef(int, int col)
|
||||||
{
|
{
|
||||||
return m_matrix.write(m_row, col);
|
return m_matrix.coeffRef(m_row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int, int col) const
|
Scalar _coeff(int, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(m_row, col);
|
return m_matrix.coeff(m_row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -48,9 +48,9 @@ template<typename MatrixType> class ScalarMultiple : NoOperatorEquals,
|
|||||||
int _rows() const { return m_matrix.rows(); }
|
int _rows() const { return m_matrix.rows(); }
|
||||||
int _cols() const { return m_matrix.cols(); }
|
int _cols() const { return m_matrix.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(row, col) * m_scalar;
|
return m_matrix.coeff(row, col) * m_scalar;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -51,9 +51,9 @@ template<typename Lhs, typename Rhs> class Sum : NoOperatorEquals,
|
|||||||
int _rows() const { return m_lhs.rows(); }
|
int _rows() const { return m_lhs.rows(); }
|
||||||
int _cols() const { return m_lhs.cols(); }
|
int _cols() const { return m_lhs.cols(); }
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_lhs.read(row, col) + m_rhs.read(row, col);
|
return m_lhs.coeff(row, col) + m_rhs.coeff(row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -31,7 +31,7 @@ template<int Index, int Rows, typename Derived> struct TraceUnroller
|
|||||||
static void run(const Derived &mat, typename Derived::Scalar &trace)
|
static void run(const Derived &mat, typename Derived::Scalar &trace)
|
||||||
{
|
{
|
||||||
TraceUnroller<Index-1, Rows, Derived>::run(mat, trace);
|
TraceUnroller<Index-1, Rows, Derived>::run(mat, trace);
|
||||||
trace += mat.read(Index, Index);
|
trace += mat.coeff(Index, Index);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ template<int Rows, typename Derived> struct TraceUnroller<0, Rows, Derived>
|
|||||||
{
|
{
|
||||||
static void run(const Derived &mat, typename Derived::Scalar &trace)
|
static void run(const Derived &mat, typename Derived::Scalar &trace)
|
||||||
{
|
{
|
||||||
trace = mat.read(0, 0);
|
trace = mat.coeff(0, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,9 +64,9 @@ Scalar MatrixBase<Scalar, Derived>::trace() const
|
|||||||
::run(*static_cast<const Derived*>(this), res);
|
::run(*static_cast<const Derived*>(this), res);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = read(0, 0);
|
res = coeff(0, 0);
|
||||||
for(int i = 1; i < rows(); i++)
|
for(int i = 1; i < rows(); i++)
|
||||||
res += read(i, i);
|
res += coeff(i, i);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -49,14 +49,14 @@ template<typename MatrixType> class Transpose
|
|||||||
int _rows() const { return m_matrix.cols(); }
|
int _rows() const { return m_matrix.cols(); }
|
||||||
int _cols() const { return m_matrix.rows(); }
|
int _cols() const { return m_matrix.rows(); }
|
||||||
|
|
||||||
Scalar& _write(int row, int col)
|
Scalar& _coeffRef(int row, int col)
|
||||||
{
|
{
|
||||||
return m_matrix.write(col, row);
|
return m_matrix.coeffRef(col, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar _read(int row, int col) const
|
Scalar _coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
return m_matrix.read(col, row);
|
return m_matrix.coeff(col, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -46,7 +46,7 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
|
|||||||
int _rows() const { return m_rows; }
|
int _rows() const { return m_rows; }
|
||||||
int _cols() const { return m_cols; }
|
int _cols() const { return m_cols; }
|
||||||
|
|
||||||
Scalar _read(int, int) const
|
Scalar _coeff(int, int) const
|
||||||
{
|
{
|
||||||
return static_cast<Scalar>(0);
|
return static_cast<Scalar>(0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user