mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
big change: MatrixBase only takes one template parameter "Derived", the
template parameter "Scalar" is removed. This is achieved by introducting a template <typename Derived> struct Scalar to achieve a forward-declaration of the Scalar typedefs.
This commit is contained in:
parent
9d9d81ad71
commit
01572b9f54
@ -56,17 +56,19 @@
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::block(int,int,int,int), MatrixBase::block(int,int), class VectorBlock
|
* \sa MatrixBase::block(int,int,int,int), MatrixBase::block(int,int), class VectorBlock
|
||||||
*/
|
*/
|
||||||
template<typename MatrixType,
|
template<typename MatrixType, int BlockRows, int BlockCols>
|
||||||
int BlockRows/*=Dynamic*/, int BlockCols/*=Dynamic*/> class Block
|
struct Scalar<Block<MatrixType, BlockRows, BlockCols> >
|
||||||
: public MatrixBase<typename MatrixType::Scalar,
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
Block<MatrixType, BlockRows, BlockCols> >
|
|
||||||
|
template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
||||||
|
: public MatrixBase<Block<MatrixType, BlockRows, BlockCols> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
typedef typename MatrixType::AsArg MatRef;
|
typedef typename MatrixType::AsArg MatRef;
|
||||||
friend class MatrixBase<Scalar, Block>;
|
friend class MatrixBase<Block>;
|
||||||
friend class MatrixBase<Scalar, Block>::Traits;
|
friend class MatrixBase<Block>::Traits;
|
||||||
typedef MatrixBase<Scalar, Block> Base;
|
typedef MatrixBase<Block> Base;
|
||||||
|
|
||||||
/** Fixed-size constructor
|
/** Fixed-size constructor
|
||||||
*/
|
*/
|
||||||
@ -143,16 +145,16 @@ template<typename MatrixType,
|
|||||||
*
|
*
|
||||||
* \sa class Block, block(int,int)
|
* \sa class Block, block(int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Block<Derived> MatrixBase<Scalar, Derived>
|
Block<Derived> MatrixBase<Derived>
|
||||||
::block(int startRow, int startCol, int blockRows, int blockCols)
|
::block(int startRow, int startCol, int blockRows, int blockCols)
|
||||||
{
|
{
|
||||||
return Block<Derived>(asArg(), startRow, startCol, blockRows, blockCols);
|
return Block<Derived>(asArg(), startRow, startCol, blockRows, blockCols);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of block(int,int,int,int). */
|
/** This is the const version of block(int,int,int,int). */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
const Block<Derived> MatrixBase<Derived>
|
||||||
::block(int startRow, int startCol, int blockRows, int blockCols) const
|
::block(int startRow, int startCol, int blockRows, int blockCols) const
|
||||||
{
|
{
|
||||||
return Block<Derived>(asArg(), startRow, startCol, blockRows, blockCols);
|
return Block<Derived>(asArg(), startRow, startCol, blockRows, blockCols);
|
||||||
@ -174,8 +176,8 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa class Block, block(int)
|
* \sa class Block, block(int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Block<Derived> MatrixBase<Scalar, Derived>
|
Block<Derived> MatrixBase<Derived>
|
||||||
::block(int start, int size)
|
::block(int start, int size)
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -186,8 +188,8 @@ Block<Derived> MatrixBase<Scalar, Derived>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of block(int,int).*/
|
/** This is the const version of block(int,int).*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
const Block<Derived> MatrixBase<Derived>
|
||||||
::block(int start, int size) const
|
::block(int start, int size) const
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -212,8 +214,8 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa class Block, block(int,int)
|
* \sa class Block, block(int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Block<Derived> MatrixBase<Scalar, Derived>
|
Block<Derived> MatrixBase<Derived>
|
||||||
::start(int size)
|
::start(int size)
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -223,8 +225,8 @@ Block<Derived> MatrixBase<Scalar, Derived>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of start(int).*/
|
/** This is the const version of start(int).*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
const Block<Derived> MatrixBase<Derived>
|
||||||
::start(int size) const
|
::start(int size) const
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -248,8 +250,8 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa class Block, block(int,int)
|
* \sa class Block, block(int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Block<Derived> MatrixBase<Scalar, Derived>
|
Block<Derived> MatrixBase<Derived>
|
||||||
::end(int size)
|
::end(int size)
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -261,8 +263,8 @@ Block<Derived> MatrixBase<Scalar, Derived>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of end(int).*/
|
/** This is the const version of end(int).*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
const Block<Derived> MatrixBase<Derived>
|
||||||
::end(int size) const
|
::end(int size) const
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -289,8 +291,8 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa class Block, block(int,int,int,int)
|
* \sa class Block, block(int,int,int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Block<Derived> MatrixBase<Scalar, Derived>
|
Block<Derived> MatrixBase<Derived>
|
||||||
::corner(CornerType type, int cRows, int cCols)
|
::corner(CornerType type, int cRows, int cCols)
|
||||||
{
|
{
|
||||||
if(type == TopLeft)
|
if(type == TopLeft)
|
||||||
@ -304,8 +306,8 @@ Block<Derived> MatrixBase<Scalar, Derived>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of corner(CornerType, int, int).*/
|
/** This is the const version of corner(CornerType, int, int).*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
const Block<Derived> MatrixBase<Derived>
|
||||||
::corner(CornerType type, int cRows, int cCols) const
|
::corner(CornerType type, int cRows, int cCols) const
|
||||||
{
|
{
|
||||||
if(type == TopLeft)
|
if(type == TopLeft)
|
||||||
@ -334,18 +336,18 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa class Block, block(int,int,int,int)
|
* \sa class Block, block(int,int,int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<int BlockRows, int BlockCols>
|
template<int BlockRows, int BlockCols>
|
||||||
Block<Derived, BlockRows, BlockCols> MatrixBase<Scalar, Derived>
|
Block<Derived, BlockRows, BlockCols> MatrixBase<Derived>
|
||||||
::block(int startRow, int startCol)
|
::block(int startRow, int startCol)
|
||||||
{
|
{
|
||||||
return Block<Derived, BlockRows, BlockCols>(asArg(), startRow, startCol);
|
return Block<Derived, BlockRows, BlockCols>(asArg(), startRow, startCol);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of block<>(int, int). */
|
/** This is the const version of block<>(int, int). */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<int BlockRows, int BlockCols>
|
template<int BlockRows, int BlockCols>
|
||||||
const Block<Derived, BlockRows, BlockCols> MatrixBase<Scalar, Derived>
|
const Block<Derived, BlockRows, BlockCols> MatrixBase<Derived>
|
||||||
::block(int startRow, int startCol) const
|
::block(int startRow, int startCol) const
|
||||||
{
|
{
|
||||||
return Block<Derived, BlockRows, BlockCols>(asArg(), startRow, startCol);
|
return Block<Derived, BlockRows, BlockCols>(asArg(), startRow, startCol);
|
||||||
|
@ -39,8 +39,8 @@
|
|||||||
*
|
*
|
||||||
* \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const
|
* \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||||
::coeff(int row, int col) const
|
::coeff(int row, int col) const
|
||||||
{
|
{
|
||||||
eigen_internal_assert(row >= 0 && row < rows()
|
eigen_internal_assert(row >= 0 && row < rows()
|
||||||
@ -52,8 +52,8 @@ Scalar MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa operator()(int,int), operator[](int) const
|
* \sa operator()(int,int), operator[](int) const
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||||
::operator()(int row, int col) const
|
::operator()(int row, int col) const
|
||||||
{
|
{
|
||||||
assert(row >= 0 && row < rows()
|
assert(row >= 0 && row < rows()
|
||||||
@ -75,8 +75,8 @@ Scalar MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa operator()(int,int), coeff(int, int) const, coeffRef(int)
|
* \sa operator()(int,int), coeff(int, int) const, coeffRef(int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar& MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||||
::coeffRef(int row, int col)
|
::coeffRef(int row, int col)
|
||||||
{
|
{
|
||||||
eigen_internal_assert(row >= 0 && row < rows()
|
eigen_internal_assert(row >= 0 && row < rows()
|
||||||
@ -88,8 +88,8 @@ Scalar& MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa operator()(int,int) const, operator[](int)
|
* \sa operator()(int,int) const, operator[](int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar& MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||||
::operator()(int row, int col)
|
::operator()(int row, int col)
|
||||||
{
|
{
|
||||||
assert(row >= 0 && row < rows()
|
assert(row >= 0 && row < rows()
|
||||||
@ -111,8 +111,8 @@ Scalar& MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa operator[](int) const, coeffRef(int), coeff(int,int) const
|
* \sa operator[](int) const, coeffRef(int), coeff(int,int) const
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||||
::coeff(int index) const
|
::coeff(int index) const
|
||||||
{
|
{
|
||||||
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -135,8 +135,8 @@ Scalar MatrixBase<Scalar, Derived>
|
|||||||
* \sa operator[](int), operator()(int,int) const, x() const, y() const,
|
* \sa operator[](int), operator()(int,int) const, x() const, y() const,
|
||||||
* z() const, w() const
|
* z() const, w() const
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||||
::operator[](int index) const
|
::operator[](int index) const
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -166,8 +166,8 @@ Scalar MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa operator[](int), coeff(int) const, coeffRef(int,int)
|
* \sa operator[](int), coeff(int) const, coeffRef(int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar& MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||||
::coeffRef(int index)
|
::coeffRef(int index)
|
||||||
{
|
{
|
||||||
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -189,8 +189,8 @@ Scalar& MatrixBase<Scalar, Derived>
|
|||||||
*
|
*
|
||||||
* \sa operator[](int) const, operator()(int,int), x(), y(), z(), w()
|
* \sa operator[](int) const, operator()(int,int), x(), y(), z(), w()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar& MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||||
::operator[](int index)
|
::operator[](int index)
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
@ -207,43 +207,43 @@ Scalar& MatrixBase<Scalar, Derived>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** equivalent to operator[](0). \only_for_vectors */
|
/** equivalent to operator[](0). \only_for_vectors */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||||
::x() const { return (*this)[0]; }
|
::x() const { return (*this)[0]; }
|
||||||
|
|
||||||
/** equivalent to operator[](1). \only_for_vectors */
|
/** equivalent to operator[](1). \only_for_vectors */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||||
::y() const { return (*this)[1]; }
|
::y() const { return (*this)[1]; }
|
||||||
|
|
||||||
/** equivalent to operator[](2). \only_for_vectors */
|
/** equivalent to operator[](2). \only_for_vectors */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||||
::z() const { return (*this)[2]; }
|
::z() const { return (*this)[2]; }
|
||||||
|
|
||||||
/** equivalent to operator[](3). \only_for_vectors */
|
/** equivalent to operator[](3). \only_for_vectors */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||||
::w() const { return (*this)[3]; }
|
::w() const { return (*this)[3]; }
|
||||||
|
|
||||||
/** equivalent to operator[](0). \only_for_vectors */
|
/** equivalent to operator[](0). \only_for_vectors */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar& MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||||
::x() { return (*this)[0]; }
|
::x() { return (*this)[0]; }
|
||||||
|
|
||||||
/** equivalent to operator[](1). \only_for_vectors */
|
/** equivalent to operator[](1). \only_for_vectors */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar& MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||||
::y() { return (*this)[1]; }
|
::y() { return (*this)[1]; }
|
||||||
|
|
||||||
/** equivalent to operator[](2). \only_for_vectors */
|
/** equivalent to operator[](2). \only_for_vectors */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar& MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||||
::z() { return (*this)[2]; }
|
::z() { return (*this)[2]; }
|
||||||
|
|
||||||
/** equivalent to operator[](3). \only_for_vectors */
|
/** equivalent to operator[](3). \only_for_vectors */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar& MatrixBase<Scalar, Derived>
|
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||||
::w() { return (*this)[3]; }
|
::w() { return (*this)[3]; }
|
||||||
|
|
||||||
#endif // EIGEN_COEFFS_H
|
#endif // EIGEN_COEFFS_H
|
||||||
|
@ -45,15 +45,19 @@
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::col()
|
* \sa MatrixBase::col()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<Column<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class Column
|
template<typename MatrixType> class Column
|
||||||
: public MatrixBase<typename MatrixType::Scalar, Column<MatrixType> >
|
: public MatrixBase<Column<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
typedef typename MatrixType::AsArg MatRef;
|
typedef typename MatrixType::AsArg MatRef;
|
||||||
friend class MatrixBase<Scalar, Column>;
|
friend class MatrixBase<Column>;
|
||||||
friend class MatrixBase<Scalar, Column>::Traits;
|
friend class MatrixBase<Column>::Traits;
|
||||||
typedef MatrixBase<Scalar, Column> Base;
|
typedef MatrixBase<Column> Base;
|
||||||
|
|
||||||
Column(const MatRef& matrix, int col)
|
Column(const MatRef& matrix, int col)
|
||||||
: m_matrix(matrix), m_col(col)
|
: m_matrix(matrix), m_col(col)
|
||||||
@ -96,17 +100,17 @@ template<typename MatrixType> class Column
|
|||||||
* Output: \verbinclude MatrixBase_col.out
|
* Output: \verbinclude MatrixBase_col.out
|
||||||
*
|
*
|
||||||
* \sa row(), class Column */
|
* \sa row(), class Column */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Column<Derived>
|
Column<Derived>
|
||||||
MatrixBase<Scalar, Derived>::col(int i)
|
MatrixBase<Derived>::col(int i)
|
||||||
{
|
{
|
||||||
return Column<Derived>(asArg(), i);
|
return Column<Derived>(asArg(), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of col(). */
|
/** This is the const version of col(). */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Column<Derived>
|
const Column<Derived>
|
||||||
MatrixBase<Scalar, Derived>::col(int i) const
|
MatrixBase<Derived>::col(int i) const
|
||||||
{
|
{
|
||||||
return Column<Derived>(asArg(), i);
|
return Column<Derived>(asArg(), i);
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
/** \internal
|
/** \internal
|
||||||
* Helper class to define the MatrixBase::operator<<
|
* Helper class to define the MatrixBase::operator<<
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
struct MatrixBase<Scalar, Derived>::CommaInitializer
|
struct MatrixBase<Derived>::CommaInitializer
|
||||||
{
|
{
|
||||||
CommaInitializer(Derived& mat, const Scalar& s)
|
CommaInitializer(Derived& mat, const Scalar& s)
|
||||||
: m_matrix(mat), m_row(0), m_col(1), m_currentBlockRows(1)
|
: m_matrix(mat), m_row(0), m_col(1), m_currentBlockRows(1)
|
||||||
@ -39,7 +39,7 @@ struct MatrixBase<Scalar, Derived>::CommaInitializer
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
CommaInitializer(Derived& mat, const MatrixBase<Scalar, OtherDerived>& other)
|
CommaInitializer(Derived& mat, const MatrixBase<OtherDerived>& other)
|
||||||
: m_matrix(mat), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())
|
: m_matrix(mat), m_row(0), m_col(other.cols()), m_currentBlockRows(other.rows())
|
||||||
{
|
{
|
||||||
m_matrix.block(0, 0, other.rows(), other.cols()) = other;
|
m_matrix.block(0, 0, other.rows(), other.cols()) = other;
|
||||||
@ -60,7 +60,7 @@ struct MatrixBase<Scalar, Derived>::CommaInitializer
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
CommaInitializer& operator,(const MatrixBase<Scalar, OtherDerived>& other)
|
CommaInitializer& operator,(const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
if (m_col==m_matrix.cols())
|
if (m_col==m_matrix.cols())
|
||||||
{
|
{
|
||||||
@ -94,15 +94,16 @@ struct MatrixBase<Scalar, Derived>::CommaInitializer
|
|||||||
* Example: \include MatrixBase_set.cpp
|
* Example: \include MatrixBase_set.cpp
|
||||||
* Output: \verbinclude MatrixBase_set.out
|
* Output: \verbinclude MatrixBase_set.out
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
typename MatrixBase<Scalar, Derived>::CommaInitializer MatrixBase<Scalar, Derived>::operator<< (const Scalar& s)
|
typename MatrixBase<Derived>::CommaInitializer MatrixBase<Derived>::operator<< (const Scalar& s)
|
||||||
{
|
{
|
||||||
return CommaInitializer(*static_cast<Derived *>(this), s);
|
return CommaInitializer(*static_cast<Derived*>(this), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
typename MatrixBase<Scalar, Derived>::CommaInitializer MatrixBase<Scalar, Derived>::operator<< (const MatrixBase<Scalar, OtherDerived>& other)
|
typename MatrixBase<Derived>::CommaInitializer
|
||||||
|
MatrixBase<Derived>::operator<<(const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
return CommaInitializer(*static_cast<Derived *>(this), other);
|
return CommaInitializer(*static_cast<Derived *>(this), other);
|
||||||
}
|
}
|
||||||
|
@ -46,19 +46,21 @@
|
|||||||
*
|
*
|
||||||
* \sa class ScalarProductOp, class ScalarQuotientOp
|
* \sa class ScalarProductOp, class ScalarQuotientOp
|
||||||
*/
|
*/
|
||||||
|
template<typename BinaryOp, typename Lhs, typename Rhs>
|
||||||
|
struct Scalar<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
||||||
|
{ typedef typename ei_result_of<BinaryOp(typename Lhs::Scalar,typename Rhs::Scalar)>::type Type; };
|
||||||
|
|
||||||
template<typename BinaryOp, typename Lhs, typename Rhs>
|
template<typename BinaryOp, typename Lhs, typename Rhs>
|
||||||
class CwiseBinaryOp : NoOperatorEquals,
|
class CwiseBinaryOp : NoOperatorEquals,
|
||||||
public MatrixBase<
|
public MatrixBase<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
||||||
typename ei_result_of<BinaryOp(typename Lhs::Scalar,typename Rhs::Scalar)>::type,
|
|
||||||
CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename ei_result_of<BinaryOp(typename Lhs::Scalar,typename Rhs::Scalar)>::type Scalar;
|
typedef typename Scalar<CwiseBinaryOp>::Type Scalar;
|
||||||
typedef typename Lhs::AsArg LhsRef;
|
typedef typename Lhs::AsArg LhsRef;
|
||||||
typedef typename Rhs::AsArg RhsRef;
|
typedef typename Rhs::AsArg RhsRef;
|
||||||
friend class MatrixBase<Scalar, CwiseBinaryOp>;
|
friend class MatrixBase<CwiseBinaryOp>;
|
||||||
friend class MatrixBase<Scalar, CwiseBinaryOp>::Traits;
|
friend class MatrixBase<CwiseBinaryOp>::Traits;
|
||||||
typedef MatrixBase<Scalar, CwiseBinaryOp> Base;
|
typedef MatrixBase<CwiseBinaryOp> Base;
|
||||||
|
|
||||||
CwiseBinaryOp(const LhsRef& lhs, const RhsRef& rhs, const BinaryOp& func = BinaryOp())
|
CwiseBinaryOp(const LhsRef& lhs, const RhsRef& rhs, const BinaryOp& func = BinaryOp())
|
||||||
: m_lhs(lhs), m_rhs(rhs), m_functor(func)
|
: m_lhs(lhs), m_rhs(rhs), m_functor(func)
|
||||||
@ -131,9 +133,9 @@ struct ScalarQuotientOp EIGEN_EMPTY_STRUCT {
|
|||||||
*
|
*
|
||||||
* \sa class CwiseBinaryOp, MatrixBase::operator-=()
|
* \sa class CwiseBinaryOp, MatrixBase::operator-=()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived1, typename Derived2>
|
template<typename Derived1, typename Derived2>
|
||||||
const CwiseBinaryOp<ScalarDifferenceOp, Derived1, Derived2>
|
const CwiseBinaryOp<ScalarDifferenceOp, Derived1, Derived2>
|
||||||
operator-(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Derived2> &mat2)
|
operator-(const MatrixBase<Derived1> &mat1, const MatrixBase<Derived2> &mat2)
|
||||||
{
|
{
|
||||||
return CwiseBinaryOp<ScalarDifferenceOp, Derived1, Derived2>(mat1.asArg(), mat2.asArg());
|
return CwiseBinaryOp<ScalarDifferenceOp, Derived1, Derived2>(mat1.asArg(), mat2.asArg());
|
||||||
}
|
}
|
||||||
@ -142,10 +144,10 @@ operator-(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Der
|
|||||||
*
|
*
|
||||||
* \returns a reference to \c *this
|
* \returns a reference to \c *this
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived &
|
Derived &
|
||||||
MatrixBase<Scalar, Derived>::operator-=(const MatrixBase<Scalar, OtherDerived> &other)
|
MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)
|
||||||
{
|
{
|
||||||
return *this = *this - other;
|
return *this = *this - other;
|
||||||
}
|
}
|
||||||
@ -157,9 +159,9 @@ MatrixBase<Scalar, Derived>::operator-=(const MatrixBase<Scalar, OtherDerived> &
|
|||||||
*
|
*
|
||||||
* \sa class CwiseBinaryOp, MatrixBase::operator+=()
|
* \sa class CwiseBinaryOp, MatrixBase::operator+=()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived1, typename Derived2>
|
template<typename Derived1, typename Derived2>
|
||||||
const CwiseBinaryOp<ScalarSumOp, Derived1, Derived2>
|
const CwiseBinaryOp<ScalarSumOp, Derived1, Derived2>
|
||||||
operator+(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Derived2> &mat2)
|
operator+(const MatrixBase<Derived1> &mat1, const MatrixBase<Derived2> &mat2)
|
||||||
{
|
{
|
||||||
return CwiseBinaryOp<ScalarSumOp, Derived1, Derived2>(mat1.asArg(), mat2.asArg());
|
return CwiseBinaryOp<ScalarSumOp, Derived1, Derived2>(mat1.asArg(), mat2.asArg());
|
||||||
}
|
}
|
||||||
@ -168,10 +170,10 @@ operator+(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Der
|
|||||||
*
|
*
|
||||||
* \returns a reference to \c *this
|
* \returns a reference to \c *this
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived &
|
Derived &
|
||||||
MatrixBase<Scalar, Derived>::operator+=(const MatrixBase<Scalar, OtherDerived>& other)
|
MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
return *this = *this + other;
|
return *this = *this + other;
|
||||||
}
|
}
|
||||||
@ -181,10 +183,10 @@ MatrixBase<Scalar, Derived>::operator+=(const MatrixBase<Scalar, OtherDerived>&
|
|||||||
*
|
*
|
||||||
* \sa class CwiseBinaryOp
|
* \sa class CwiseBinaryOp
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
const CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>
|
const CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>
|
||||||
MatrixBase<Scalar, Derived>::cwiseProduct(const MatrixBase<Scalar, OtherDerived> &other) const
|
MatrixBase<Derived>::cwiseProduct(const MatrixBase<OtherDerived> &other) const
|
||||||
{
|
{
|
||||||
return CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>(asArg(), other.asArg());
|
return CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>(asArg(), other.asArg());
|
||||||
}
|
}
|
||||||
@ -194,10 +196,10 @@ MatrixBase<Scalar, Derived>::cwiseProduct(const MatrixBase<Scalar, OtherDerived>
|
|||||||
*
|
*
|
||||||
* \sa class CwiseBinaryOp
|
* \sa class CwiseBinaryOp
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
const CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>
|
const CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>
|
||||||
MatrixBase<Scalar, Derived>::cwiseQuotient(const MatrixBase<Scalar, OtherDerived> &other) const
|
MatrixBase<Derived>::cwiseQuotient(const MatrixBase<OtherDerived> &other) const
|
||||||
{
|
{
|
||||||
return CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>(asArg(), other.asArg());
|
return CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>(asArg(), other.asArg());
|
||||||
}
|
}
|
||||||
@ -210,10 +212,10 @@ MatrixBase<Scalar, Derived>::cwiseQuotient(const MatrixBase<Scalar, OtherDerived
|
|||||||
*
|
*
|
||||||
* \sa class CwiseBinaryOp, MatrixBase::operator+, MatrixBase::operator-, MatrixBase::cwiseProduct, MatrixBase::cwiseQuotient
|
* \sa class CwiseBinaryOp, MatrixBase::operator+, MatrixBase::operator-, MatrixBase::cwiseProduct, MatrixBase::cwiseQuotient
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename CustomBinaryOp, typename OtherDerived>
|
template<typename CustomBinaryOp, typename OtherDerived>
|
||||||
const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
|
const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
|
||||||
MatrixBase<Scalar, Derived>::cwise(const MatrixBase<Scalar, OtherDerived> &other, const CustomBinaryOp& func) const
|
MatrixBase<Derived>::cwise(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func) const
|
||||||
{
|
{
|
||||||
return CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>(asArg(), other.asArg(), func);
|
return CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>(asArg(), other.asArg(), func);
|
||||||
}
|
}
|
||||||
|
@ -39,18 +39,20 @@
|
|||||||
*
|
*
|
||||||
* \sa class CwiseBinaryOp
|
* \sa class CwiseBinaryOp
|
||||||
*/
|
*/
|
||||||
|
template<typename UnaryOp, typename MatrixType>
|
||||||
|
struct Scalar<CwiseUnaryOp<UnaryOp, MatrixType> >
|
||||||
|
{ typedef typename ei_result_of<UnaryOp(typename MatrixType::Scalar)>::type Type; };
|
||||||
|
|
||||||
template<typename UnaryOp, typename MatrixType>
|
template<typename UnaryOp, typename MatrixType>
|
||||||
class CwiseUnaryOp : NoOperatorEquals,
|
class CwiseUnaryOp : NoOperatorEquals,
|
||||||
public MatrixBase<
|
public MatrixBase<CwiseUnaryOp<UnaryOp, MatrixType> >
|
||||||
typename ei_result_of<UnaryOp(typename MatrixType::Scalar)>::type,
|
|
||||||
CwiseUnaryOp<UnaryOp, MatrixType> >
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename ei_result_of<UnaryOp(typename MatrixType::Scalar)>::type Scalar;
|
typedef typename ei_result_of<UnaryOp(typename MatrixType::Scalar)>::type Scalar;
|
||||||
typedef typename MatrixType::AsArg MatRef;
|
typedef typename MatrixType::AsArg MatRef;
|
||||||
friend class MatrixBase<Scalar, CwiseUnaryOp>;
|
friend class MatrixBase<CwiseUnaryOp>;
|
||||||
friend class MatrixBase<Scalar, CwiseUnaryOp>::Traits;
|
friend class MatrixBase<CwiseUnaryOp>::Traits;
|
||||||
typedef MatrixBase<Scalar, CwiseUnaryOp> Base;
|
typedef MatrixBase<CwiseUnaryOp> Base;
|
||||||
|
|
||||||
CwiseUnaryOp(const MatRef& mat, const UnaryOp& func = UnaryOp()) : m_matrix(mat), m_functor(func) {}
|
CwiseUnaryOp(const MatRef& mat, const UnaryOp& func = UnaryOp()) : m_matrix(mat), m_functor(func) {}
|
||||||
|
|
||||||
@ -97,18 +99,18 @@ struct ScalarAbsOp EIGEN_EMPTY_STRUCT {
|
|||||||
|
|
||||||
/** \returns an expression of the opposite of \c *this
|
/** \returns an expression of the opposite of \c *this
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const CwiseUnaryOp<ScalarOppositeOp,Derived>
|
const CwiseUnaryOp<ScalarOppositeOp,Derived>
|
||||||
MatrixBase<Scalar, Derived>::operator-() const
|
MatrixBase<Derived>::operator-() const
|
||||||
{
|
{
|
||||||
return CwiseUnaryOp<ScalarOppositeOp,Derived>(asArg());
|
return CwiseUnaryOp<ScalarOppositeOp,Derived>(asArg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \returns an expression of the opposite of \c *this
|
/** \returns an expression of the opposite of \c *this
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const CwiseUnaryOp<ScalarAbsOp,Derived>
|
const CwiseUnaryOp<ScalarAbsOp,Derived>
|
||||||
MatrixBase<Scalar, Derived>::cwiseAbs() const
|
MatrixBase<Derived>::cwiseAbs() const
|
||||||
{
|
{
|
||||||
return CwiseUnaryOp<ScalarAbsOp,Derived>(asArg());
|
return CwiseUnaryOp<ScalarAbsOp,Derived>(asArg());
|
||||||
}
|
}
|
||||||
@ -124,10 +126,10 @@ MatrixBase<Scalar, Derived>::cwiseAbs() const
|
|||||||
*
|
*
|
||||||
* \sa class CwiseUnaryOp, class CwiseBinarOp, MatrixBase::operator-, MatrixBase::cwiseAbs
|
* \sa class CwiseUnaryOp, class CwiseBinarOp, MatrixBase::operator-, MatrixBase::cwiseAbs
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename CustomUnaryOp>
|
template<typename CustomUnaryOp>
|
||||||
const CwiseUnaryOp<CustomUnaryOp, Derived>
|
const CwiseUnaryOp<CustomUnaryOp, Derived>
|
||||||
MatrixBase<Scalar, Derived>::cwise(const CustomUnaryOp& func) const
|
MatrixBase<Derived>::cwise(const CustomUnaryOp& func) const
|
||||||
{
|
{
|
||||||
return CwiseUnaryOp<CustomUnaryOp, Derived>(asArg(), func);
|
return CwiseUnaryOp<CustomUnaryOp, Derived>(asArg(), func);
|
||||||
}
|
}
|
||||||
@ -145,9 +147,9 @@ struct ScalarConjugateOp EIGEN_EMPTY_STRUCT {
|
|||||||
/** \returns an expression of the complex conjugate of *this.
|
/** \returns an expression of the complex conjugate of *this.
|
||||||
*
|
*
|
||||||
* \sa adjoint() */
|
* \sa adjoint() */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const CwiseUnaryOp<ScalarConjugateOp, Derived>
|
const CwiseUnaryOp<ScalarConjugateOp, Derived>
|
||||||
MatrixBase<Scalar, Derived>::conjugate() const
|
MatrixBase<Derived>::conjugate() const
|
||||||
{
|
{
|
||||||
return CwiseUnaryOp<ScalarConjugateOp, Derived>(asArg());
|
return CwiseUnaryOp<ScalarConjugateOp, Derived>(asArg());
|
||||||
}
|
}
|
||||||
@ -173,10 +175,10 @@ struct ScalarCastOp EIGEN_EMPTY_STRUCT {
|
|||||||
*
|
*
|
||||||
* \sa class CwiseUnaryOp, class ScalarCastOp
|
* \sa class CwiseUnaryOp, class ScalarCastOp
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename NewType>
|
template<typename NewType>
|
||||||
const CwiseUnaryOp<ScalarCastOp<NewType>, Derived>
|
const CwiseUnaryOp<ScalarCastOp<NewType>, Derived>
|
||||||
MatrixBase<Scalar, Derived>::cast() const
|
MatrixBase<Derived>::cast() const
|
||||||
{
|
{
|
||||||
return CwiseUnaryOp<ScalarCastOp<NewType>, Derived>(asArg());
|
return CwiseUnaryOp<ScalarCastOp<NewType>, Derived>(asArg());
|
||||||
}
|
}
|
||||||
@ -195,34 +197,35 @@ struct ScalarMultipleOp {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** \relates MatrixBase \sa class ScalarMultipleOp */
|
/** \relates MatrixBase \sa class ScalarMultipleOp */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>
|
const CwiseUnaryOp<ScalarMultipleOp<typename Scalar<Derived>::Type>, Derived>
|
||||||
MatrixBase<Scalar, Derived>::operator*(const Scalar& scalar) const
|
MatrixBase<Derived>::operator*(const Scalar& scalar) const
|
||||||
{
|
{
|
||||||
return CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>(asArg(), ScalarMultipleOp<Scalar>(scalar));
|
return CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>(asArg(), ScalarMultipleOp<Scalar>(scalar));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \relates MatrixBase \sa class ScalarMultipleOp */
|
/** \relates MatrixBase \sa class ScalarMultipleOp */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>
|
const CwiseUnaryOp<ScalarMultipleOp<typename Scalar<Derived>::Type>, Derived>
|
||||||
MatrixBase<Scalar, Derived>::operator/(const Scalar& scalar) const
|
MatrixBase<Derived>::operator/(const Scalar& scalar) const
|
||||||
{
|
{
|
||||||
assert(NumTraits<Scalar>::HasFloatingPoint);
|
assert(NumTraits<Scalar>::HasFloatingPoint);
|
||||||
return CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>(asArg(), ScalarMultipleOp<Scalar>(static_cast<Scalar>(1) / scalar));
|
return CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>
|
||||||
|
(asArg(), ScalarMultipleOp<Scalar>(static_cast<Scalar>(1) / scalar));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \sa ScalarMultipleOp */
|
/** \sa ScalarMultipleOp */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Derived&
|
Derived&
|
||||||
MatrixBase<Scalar, Derived>::operator*=(const Scalar& other)
|
MatrixBase<Derived>::operator*=(const Scalar& other)
|
||||||
{
|
{
|
||||||
return *this = *this * other;
|
return *this = *this * other;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \sa ScalarMultipleOp */
|
/** \sa ScalarMultipleOp */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Derived&
|
Derived&
|
||||||
MatrixBase<Scalar, Derived>::operator/=(const Scalar& other)
|
MatrixBase<Derived>::operator/=(const Scalar& other)
|
||||||
{
|
{
|
||||||
return *this = *this / other;
|
return *this = *this / other;
|
||||||
}
|
}
|
||||||
|
@ -37,15 +37,19 @@
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::diagonal()
|
* \sa MatrixBase::diagonal()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<DiagonalCoeffs<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class DiagonalCoeffs
|
template<typename MatrixType> class DiagonalCoeffs
|
||||||
: public MatrixBase<typename MatrixType::Scalar, DiagonalCoeffs<MatrixType> >
|
: public MatrixBase<DiagonalCoeffs<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
typedef typename MatrixType::AsArg MatRef;
|
typedef typename MatrixType::AsArg MatRef;
|
||||||
friend class MatrixBase<Scalar, DiagonalCoeffs>;
|
friend class MatrixBase<DiagonalCoeffs>;
|
||||||
friend class MatrixBase<Scalar, DiagonalCoeffs>::Traits;
|
friend class MatrixBase<DiagonalCoeffs>::Traits;
|
||||||
typedef MatrixBase<Scalar, DiagonalCoeffs> Base;
|
typedef MatrixBase<DiagonalCoeffs> Base;
|
||||||
|
|
||||||
DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {}
|
DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {}
|
||||||
|
|
||||||
@ -87,17 +91,17 @@ template<typename MatrixType> class DiagonalCoeffs
|
|||||||
* Output: \verbinclude MatrixBase_diagonal.out
|
* Output: \verbinclude MatrixBase_diagonal.out
|
||||||
*
|
*
|
||||||
* \sa class DiagonalCoeffs */
|
* \sa class DiagonalCoeffs */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
DiagonalCoeffs<Derived>
|
DiagonalCoeffs<Derived>
|
||||||
MatrixBase<Scalar, Derived>::diagonal()
|
MatrixBase<Derived>::diagonal()
|
||||||
{
|
{
|
||||||
return DiagonalCoeffs<Derived>(asArg());
|
return DiagonalCoeffs<Derived>(asArg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of diagonal(). */
|
/** This is the const version of diagonal(). */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const DiagonalCoeffs<Derived>
|
const DiagonalCoeffs<Derived>
|
||||||
MatrixBase<Scalar, Derived>::diagonal() const
|
MatrixBase<Derived>::diagonal() const
|
||||||
{
|
{
|
||||||
return DiagonalCoeffs<Derived>(asArg());
|
return DiagonalCoeffs<Derived>(asArg());
|
||||||
}
|
}
|
||||||
|
@ -38,17 +38,20 @@
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::diagonal(const OtherDerived&)
|
* \sa MatrixBase::diagonal(const OtherDerived&)
|
||||||
*/
|
*/
|
||||||
|
template<typename CoeffsVectorType>
|
||||||
|
struct Scalar<DiagonalMatrix<CoeffsVectorType> >
|
||||||
|
{ typedef typename Scalar<CoeffsVectorType>::Type Type; };
|
||||||
|
|
||||||
template<typename CoeffsVectorType>
|
template<typename CoeffsVectorType>
|
||||||
class DiagonalMatrix : NoOperatorEquals,
|
class DiagonalMatrix : NoOperatorEquals,
|
||||||
public MatrixBase<typename CoeffsVectorType::Scalar,
|
public MatrixBase<DiagonalMatrix<CoeffsVectorType> >
|
||||||
DiagonalMatrix<CoeffsVectorType> >
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename CoeffsVectorType::Scalar Scalar;
|
typedef typename Scalar<CoeffsVectorType>::Type Scalar;
|
||||||
typedef typename CoeffsVectorType::AsArg CoeffsVecRef;
|
typedef typename CoeffsVectorType::AsArg CoeffsVecRef;
|
||||||
friend class MatrixBase<Scalar, DiagonalMatrix>;
|
friend class MatrixBase<DiagonalMatrix>;
|
||||||
friend class MatrixBase<Scalar, DiagonalMatrix>::Traits;
|
friend class MatrixBase<DiagonalMatrix>::Traits;
|
||||||
typedef MatrixBase<Scalar, DiagonalMatrix> Base;
|
typedef MatrixBase<DiagonalMatrix> Base;
|
||||||
|
|
||||||
DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs)
|
DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs)
|
||||||
{
|
{
|
||||||
@ -86,9 +89,9 @@ class DiagonalMatrix : NoOperatorEquals,
|
|||||||
*
|
*
|
||||||
* \sa class DiagonalMatrix, isDiagonal()
|
* \sa class DiagonalMatrix, isDiagonal()
|
||||||
**/
|
**/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const DiagonalMatrix<Derived>
|
const DiagonalMatrix<Derived>
|
||||||
MatrixBase<Scalar, Derived>::asDiagonal() const
|
MatrixBase<Derived>::asDiagonal() const
|
||||||
{
|
{
|
||||||
return DiagonalMatrix<Derived>(asArg());
|
return DiagonalMatrix<Derived>(asArg());
|
||||||
}
|
}
|
||||||
@ -101,8 +104,8 @@ MatrixBase<Scalar, Derived>::asDiagonal() const
|
|||||||
*
|
*
|
||||||
* \sa asDiagonal()
|
* \sa asDiagonal()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
bool MatrixBase<Scalar, Derived>::isDiagonal
|
bool MatrixBase<Derived>::isDiagonal
|
||||||
(typename NumTraits<Scalar>::Real prec) const
|
(typename NumTraits<Scalar>::Real prec) const
|
||||||
{
|
{
|
||||||
if(cols() != rows()) return false;
|
if(cols() != rows()) return false;
|
||||||
|
@ -67,9 +67,10 @@ struct DotUnroller<Index, 0, Derived1, Derived2>
|
|||||||
*
|
*
|
||||||
* \sa norm2(), norm()
|
* \sa norm2(), norm()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Scalar MatrixBase<Scalar, Derived>::dot(const MatrixBase<Scalar, OtherDerived>& other) const
|
typename Scalar<Derived>::Type
|
||||||
|
MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime
|
assert(Traits::IsVectorAtCompileTime
|
||||||
&& OtherDerived::Traits::IsVectorAtCompileTime
|
&& OtherDerived::Traits::IsVectorAtCompileTime
|
||||||
@ -80,7 +81,7 @@ Scalar MatrixBase<Scalar, Derived>::dot(const MatrixBase<Scalar, OtherDerived>&
|
|||||||
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||||
DotUnroller<Traits::SizeAtCompileTime-1,
|
DotUnroller<Traits::SizeAtCompileTime-1,
|
||||||
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::SizeAtCompileTime : Dynamic,
|
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::SizeAtCompileTime : Dynamic,
|
||||||
Derived, MatrixBase<Scalar, OtherDerived> >
|
Derived, MatrixBase<OtherDerived> >
|
||||||
::run(*static_cast<const Derived*>(this), other, res);
|
::run(*static_cast<const Derived*>(this), other, res);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -97,8 +98,8 @@ Scalar MatrixBase<Scalar, Derived>::dot(const MatrixBase<Scalar, OtherDerived>&
|
|||||||
*
|
*
|
||||||
* \sa dot(), norm()
|
* \sa dot(), norm()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::norm2() const
|
typename NumTraits<typename Scalar<Derived>::Type>::Real MatrixBase<Derived>::norm2() const
|
||||||
{
|
{
|
||||||
return ei_real(dot(*this));
|
return ei_real(dot(*this));
|
||||||
}
|
}
|
||||||
@ -109,8 +110,8 @@ typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::norm2() const
|
|||||||
*
|
*
|
||||||
* \sa dot(), norm2()
|
* \sa dot(), norm2()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::norm() const
|
typename NumTraits<typename Scalar<Derived>::Type>::Real MatrixBase<Derived>::norm() const
|
||||||
{
|
{
|
||||||
return ei_sqrt(norm2());
|
return ei_sqrt(norm2());
|
||||||
}
|
}
|
||||||
@ -121,9 +122,9 @@ typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::norm() const
|
|||||||
*
|
*
|
||||||
* \sa norm()
|
* \sa norm()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>
|
const CwiseUnaryOp<ScalarMultipleOp<typename Scalar<Derived>::Type>, Derived>
|
||||||
MatrixBase<Scalar, Derived>::normalized() const
|
MatrixBase<Derived>::normalized() const
|
||||||
{
|
{
|
||||||
return (*this) / norm();
|
return (*this) / norm();
|
||||||
}
|
}
|
||||||
@ -134,11 +135,10 @@ MatrixBase<Scalar, Derived>::normalized() const
|
|||||||
* Example: \include MatrixBase_isOrtho_vector.cpp
|
* Example: \include MatrixBase_isOrtho_vector.cpp
|
||||||
* Output: \verbinclude MatrixBase_isOrtho_vector.out
|
* Output: \verbinclude MatrixBase_isOrtho_vector.out
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
bool MatrixBase<Scalar, Derived>::isOrtho
|
bool MatrixBase<Derived>::isOrtho
|
||||||
(const MatrixBase<Scalar, OtherDerived>& other,
|
(const MatrixBase<OtherDerived>& other, RealScalar prec) const
|
||||||
typename NumTraits<Scalar>::Real prec) const
|
|
||||||
{
|
{
|
||||||
return ei_abs2(dot(other)) <= prec * prec * norm2() * other.norm2();
|
return ei_abs2(dot(other)) <= prec * prec * norm2() * other.norm2();
|
||||||
}
|
}
|
||||||
@ -154,9 +154,8 @@ bool MatrixBase<Scalar, Derived>::isOrtho
|
|||||||
* Example: \include MatrixBase_isOrtho_matrix.cpp
|
* Example: \include MatrixBase_isOrtho_matrix.cpp
|
||||||
* Output: \verbinclude MatrixBase_isOrtho_matrix.out
|
* Output: \verbinclude MatrixBase_isOrtho_matrix.out
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
bool MatrixBase<Scalar, Derived>::isOrtho
|
bool MatrixBase<Derived>::isOrtho(RealScalar prec) const
|
||||||
(typename NumTraits<Scalar>::Real prec) const
|
|
||||||
{
|
{
|
||||||
for(int i = 0; i < cols(); i++)
|
for(int i = 0; i < cols(); i++)
|
||||||
{
|
{
|
||||||
|
@ -44,6 +44,10 @@
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::eval()
|
* \sa MatrixBase::eval()
|
||||||
*/
|
*/
|
||||||
|
template<typename ExpressionType>
|
||||||
|
struct Scalar<Eval<ExpressionType> >
|
||||||
|
{ typedef typename Scalar<ExpressionType>::Type Type; };
|
||||||
|
|
||||||
template<typename ExpressionType> class Eval : NoOperatorEquals,
|
template<typename ExpressionType> class Eval : NoOperatorEquals,
|
||||||
public Matrix< typename ExpressionType::Scalar,
|
public Matrix< typename ExpressionType::Scalar,
|
||||||
ExpressionType::Traits::RowsAtCompileTime,
|
ExpressionType::Traits::RowsAtCompileTime,
|
||||||
@ -53,7 +57,7 @@ template<typename ExpressionType> class Eval : NoOperatorEquals,
|
|||||||
ExpressionType::Traits::MaxColsAtCompileTime>
|
ExpressionType::Traits::MaxColsAtCompileTime>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename ExpressionType::Scalar Scalar;
|
typedef typename Scalar<ExpressionType>::Type Scalar;
|
||||||
|
|
||||||
/** The actual matrix type to evaluate to. This type can be used independently
|
/** The actual matrix type to evaluate to. This type can be used independently
|
||||||
* of the rest of this class to get the actual matrix type to evaluate and store
|
* of the rest of this class to get the actual matrix type to evaluate and store
|
||||||
@ -86,8 +90,8 @@ template<typename ExpressionType> class Eval : NoOperatorEquals,
|
|||||||
* Output: \verbinclude MatrixBase_eval.out
|
* Output: \verbinclude MatrixBase_eval.out
|
||||||
*
|
*
|
||||||
* \sa class Eval */
|
* \sa class Eval */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eval<Derived> MatrixBase<Scalar, Derived>::eval() const
|
const Eval<Derived> MatrixBase<Derived>::eval() const
|
||||||
{
|
{
|
||||||
return Eval<Derived>(*static_cast<const Derived*>(this));
|
return Eval<Derived>(*static_cast<const Derived*>(this));
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,8 @@ template<typename ExpressionType> class EvalOMP : NoOperatorEquals,
|
|||||||
*
|
*
|
||||||
* \sa class EvalOMP, eval()
|
* \sa class EvalOMP, eval()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const EvalOMP<Derived> MatrixBase<Scalar, Derived>::evalOMP() const
|
const EvalOMP<Derived> MatrixBase<Derived>::evalOMP() const
|
||||||
{
|
{
|
||||||
return EvalOMP<Derived>(*static_cast<const Derived*>(this));
|
return EvalOMP<Derived>(*static_cast<const Derived*>(this));
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
#ifndef EIGEN_FORWARDDECLARATIONS_H
|
#ifndef EIGEN_FORWARDDECLARATIONS_H
|
||||||
#define EIGEN_FORWARDDECLARATIONS_H
|
#define EIGEN_FORWARDDECLARATIONS_H
|
||||||
|
|
||||||
|
template<typename T> struct Scalar;
|
||||||
|
|
||||||
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> class Matrix;
|
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols> class Matrix;
|
||||||
template<typename MatrixType> class MatrixRef;
|
template<typename MatrixType> class MatrixRef;
|
||||||
template<typename MatrixType> class Row;
|
template<typename MatrixType> class Row;
|
||||||
|
@ -41,9 +41,9 @@
|
|||||||
*
|
*
|
||||||
* \sa ei_isMuchSmallerThan(const RealScalar&, RealScalar) const
|
* \sa ei_isMuchSmallerThan(const RealScalar&, RealScalar) const
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
bool MatrixBase<Scalar, Derived>::isApprox(
|
bool MatrixBase<Derived>::isApprox(
|
||||||
const OtherDerived& other,
|
const OtherDerived& other,
|
||||||
typename NumTraits<Scalar>::Real prec
|
typename NumTraits<Scalar>::Real prec
|
||||||
) const
|
) const
|
||||||
@ -71,10 +71,10 @@ bool MatrixBase<Scalar, Derived>::isApprox(
|
|||||||
* \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f]
|
* \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f]
|
||||||
* For matrices, the comparison is done on all columns.
|
* For matrices, the comparison is done on all columns.
|
||||||
*
|
*
|
||||||
* \sa isApprox(), isMuchSmallerThan(const MatrixBase<Scalar, OtherDerived>&, RealScalar) const
|
* \sa isApprox(), isMuchSmallerThan(const MatrixBase<OtherDerived>&, RealScalar) const
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
bool MatrixBase<Scalar, Derived>::isMuchSmallerThan(
|
bool MatrixBase<Derived>::isMuchSmallerThan(
|
||||||
const typename NumTraits<Scalar>::Real& other,
|
const typename NumTraits<Scalar>::Real& other,
|
||||||
typename NumTraits<Scalar>::Real prec
|
typename NumTraits<Scalar>::Real prec
|
||||||
) const
|
) const
|
||||||
@ -102,10 +102,10 @@ bool MatrixBase<Scalar, Derived>::isMuchSmallerThan(
|
|||||||
*
|
*
|
||||||
* \sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const
|
* \sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
bool MatrixBase<Scalar, Derived>::isMuchSmallerThan(
|
bool MatrixBase<Derived>::isMuchSmallerThan(
|
||||||
const MatrixBase<Scalar, OtherDerived>& other,
|
const MatrixBase<OtherDerived>& other,
|
||||||
typename NumTraits<Scalar>::Real prec
|
typename NumTraits<Scalar>::Real prec
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
@ -29,10 +29,10 @@
|
|||||||
*
|
*
|
||||||
* Outputs the matrix, laid out as an array as usual, to the given stream.
|
* Outputs the matrix, laid out as an array as usual, to the given stream.
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
std::ostream & operator <<
|
std::ostream & operator <<
|
||||||
( std::ostream & s,
|
( std::ostream & s,
|
||||||
const MatrixBase<Scalar, Derived> & m )
|
const MatrixBase<Derived> & m )
|
||||||
{
|
{
|
||||||
for( int i = 0; i < m.rows(); i++ )
|
for( int i = 0; i < m.rows(); i++ )
|
||||||
{
|
{
|
||||||
|
@ -31,14 +31,18 @@
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::identity(), MatrixBase::identity(int,int), MatrixBase::setIdentity()
|
* \sa MatrixBase::identity(), MatrixBase::identity(int,int), MatrixBase::setIdentity()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<Identity<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class Identity : NoOperatorEquals,
|
template<typename MatrixType> class Identity : NoOperatorEquals,
|
||||||
public MatrixBase<typename MatrixType::Scalar, Identity<MatrixType> >
|
public MatrixBase<Identity<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
friend class MatrixBase<Scalar, Identity>;
|
friend class MatrixBase<Identity>;
|
||||||
friend class MatrixBase<Scalar, Identity>::Traits;
|
friend class MatrixBase<Identity>::Traits;
|
||||||
typedef MatrixBase<Scalar, Identity> Base;
|
typedef MatrixBase<Identity> Base;
|
||||||
|
|
||||||
Identity(int rows, int cols) : m_rows(rows), m_cols(cols)
|
Identity(int rows, int cols) : m_rows(rows), m_cols(cols)
|
||||||
{
|
{
|
||||||
@ -84,8 +88,8 @@ template<typename MatrixType> class Identity : NoOperatorEquals,
|
|||||||
*
|
*
|
||||||
* \sa identity(), setIdentity(), isIdentity()
|
* \sa identity(), setIdentity(), isIdentity()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Identity<Derived> MatrixBase<Scalar, Derived>::identity(int rows, int cols)
|
const Identity<Derived> MatrixBase<Derived>::identity(int rows, int cols)
|
||||||
{
|
{
|
||||||
return Identity<Derived>(rows, cols);
|
return Identity<Derived>(rows, cols);
|
||||||
}
|
}
|
||||||
@ -100,8 +104,8 @@ const Identity<Derived> MatrixBase<Scalar, Derived>::identity(int rows, int cols
|
|||||||
*
|
*
|
||||||
* \sa identity(int,int), setIdentity(), isIdentity()
|
* \sa identity(int,int), setIdentity(), isIdentity()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Identity<Derived> MatrixBase<Scalar, Derived>::identity()
|
const Identity<Derived> MatrixBase<Derived>::identity()
|
||||||
{
|
{
|
||||||
return Identity<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
return Identity<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||||
}
|
}
|
||||||
@ -115,8 +119,8 @@ const Identity<Derived> MatrixBase<Scalar, Derived>::identity()
|
|||||||
*
|
*
|
||||||
* \sa class Identity, identity(), identity(int,int), setIdentity()
|
* \sa class Identity, identity(), identity(int,int), setIdentity()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
bool MatrixBase<Scalar, Derived>::isIdentity
|
bool MatrixBase<Derived>::isIdentity
|
||||||
(typename NumTraits<Scalar>::Real prec) const
|
(typename NumTraits<Scalar>::Real prec) const
|
||||||
{
|
{
|
||||||
for(int j = 0; j < cols(); j++)
|
for(int j = 0; j < cols(); j++)
|
||||||
@ -145,8 +149,8 @@ bool MatrixBase<Scalar, Derived>::isIdentity
|
|||||||
*
|
*
|
||||||
* \sa class Identity, identity(), identity(int,int), isIdentity()
|
* \sa class Identity, identity(), identity(int,int), isIdentity()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Derived& MatrixBase<Scalar, Derived>::setIdentity()
|
Derived& MatrixBase<Derived>::setIdentity()
|
||||||
{
|
{
|
||||||
return *this = Identity<Derived>(rows(), cols());
|
return *this = Identity<Derived>(rows(), cols());
|
||||||
}
|
}
|
||||||
|
@ -38,14 +38,18 @@
|
|||||||
*
|
*
|
||||||
* \sa Matrix::map()
|
* \sa Matrix::map()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<Map<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class Map
|
template<typename MatrixType> class Map
|
||||||
: public MatrixBase<typename MatrixType::Scalar, Map<MatrixType> >
|
: public MatrixBase<Map<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
friend class MatrixBase<Scalar, Map>;
|
friend class MatrixBase<Map>;
|
||||||
friend class MatrixBase<Scalar, Map>::Traits;
|
friend class MatrixBase<Map>::Traits;
|
||||||
typedef MatrixBase<Scalar, Map> Base;
|
typedef MatrixBase<Map> Base;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
|
@ -71,20 +71,24 @@
|
|||||||
*
|
*
|
||||||
* Note that most of the API is in the base class MatrixBase.
|
* Note that most of the API is in the base class MatrixBase.
|
||||||
*/
|
*/
|
||||||
|
template<typename _Scalar, int _Rows, int _Cols, int _StorageOrder, int _MaxRows, int _MaxCols>
|
||||||
|
struct Scalar<Matrix<_Scalar, _Rows, _Cols, _StorageOrder, _MaxRows, _MaxCols> >
|
||||||
|
{ typedef _Scalar Type; };
|
||||||
|
|
||||||
template<typename _Scalar, int _Rows, int _Cols,
|
template<typename _Scalar, int _Rows, int _Cols,
|
||||||
int _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
|
int _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
|
||||||
int _MaxRows = _Rows, int _MaxCols = _Cols>
|
int _MaxRows = _Rows, int _MaxCols = _Cols>
|
||||||
class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
|
class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols,
|
||||||
_StorageOrder, _MaxRows, _MaxCols> >
|
_StorageOrder, _MaxRows, _MaxCols> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
friend class MatrixBase<_Scalar, Matrix>;
|
friend class MatrixBase<Matrix>;
|
||||||
friend class MatrixBase<_Scalar, Matrix>::Traits;
|
friend class MatrixBase<Matrix>::Traits;
|
||||||
friend class Map<Matrix>;
|
friend class Map<Matrix>;
|
||||||
|
|
||||||
typedef MatrixBase<_Scalar, Matrix> Base;
|
typedef MatrixBase<Matrix> Base;
|
||||||
typedef _Scalar Scalar;
|
typedef typename Scalar<Matrix>::Type Scalar;
|
||||||
typedef MatrixRef<Matrix> AsArg;
|
typedef MatrixRef<Matrix> AsArg;
|
||||||
friend class MatrixRef<Matrix>;
|
friend class MatrixRef<Matrix>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -150,7 +154,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
|
|||||||
* row-vectors remain row-vectors and vectors remain vectors.
|
* row-vectors remain row-vectors and vectors remain vectors.
|
||||||
*/
|
*/
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Matrix& operator=(const MatrixBase<Scalar, OtherDerived>& other)
|
Matrix& operator=(const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
if(RowsAtCompileTime == 1)
|
if(RowsAtCompileTime == 1)
|
||||||
{
|
{
|
||||||
@ -275,7 +279,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
|
|||||||
|
|
||||||
/** Constructor copying the value of the expression \a other */
|
/** Constructor copying the value of the expression \a other */
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Matrix(const MatrixBase<Scalar, OtherDerived>& other)
|
Matrix(const MatrixBase<OtherDerived>& other)
|
||||||
: m_storage(other.rows() * other.cols(), other.rows(), other.cols())
|
: m_storage(other.rows() * other.cols(), other.rows(), other.cols())
|
||||||
{
|
{
|
||||||
*this = other;
|
*this = other;
|
||||||
|
@ -32,9 +32,6 @@
|
|||||||
* This class is the base that is inherited by all matrix, vector, and expression
|
* This class is the base that is inherited by all matrix, vector, and expression
|
||||||
* types. Most of the Eigen API is contained in this class.
|
* types. Most of the Eigen API is contained in this class.
|
||||||
*
|
*
|
||||||
* \param Scalar is the type of the coefficients. Recall that Eigen allows
|
|
||||||
* only the following types for \a Scalar: \c int, \c float, \c double,
|
|
||||||
* \c std::complex<float>, \c std::complex<double>.
|
|
||||||
* \param Derived is the derived type, e.g. a matrix type, or an expression, etc.
|
* \param Derived is the derived type, e.g. a matrix type, or an expression, etc.
|
||||||
*
|
*
|
||||||
* When writing a function taking Eigen objects as argument, if you want your function
|
* When writing a function taking Eigen objects as argument, if you want your function
|
||||||
@ -43,8 +40,8 @@
|
|||||||
* a matrix, vector, or expression \a x, prints the first row of \a x.
|
* a matrix, vector, or expression \a x, prints the first row of \a x.
|
||||||
*
|
*
|
||||||
* \code
|
* \code
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
void printFirstRow(const Eigen::MatrixBase<Scalar, Derived>& x)
|
void printFirstRow(const Eigen::MatrixBase<Derived>& x)
|
||||||
{
|
{
|
||||||
cout << x.row(0) << endl;
|
cout << x.row(0) << endl;
|
||||||
}
|
}
|
||||||
@ -52,12 +49,14 @@
|
|||||||
*
|
*
|
||||||
* \nosubgrouping
|
* \nosubgrouping
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived> class MatrixBase
|
template<typename Derived> class MatrixBase
|
||||||
{
|
{
|
||||||
struct CommaInitializer;
|
struct CommaInitializer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
typedef typename Scalar<Derived>::Type Scalar;
|
||||||
|
|
||||||
/** \brief Some traits provided by the Derived type.
|
/** \brief Some traits provided by the Derived type.
|
||||||
*
|
*
|
||||||
* Grouping these in a nested subclass is what was needed for ICC compatibility. */
|
* Grouping these in a nested subclass is what was needed for ICC compatibility. */
|
||||||
@ -170,7 +169,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
|
|
||||||
/** Copies \a other into *this. \returns a reference to *this. */
|
/** Copies \a other into *this. \returns a reference to *this. */
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& operator=(const MatrixBase<Scalar, OtherDerived>& other);
|
Derived& operator=(const MatrixBase<OtherDerived>& other);
|
||||||
|
|
||||||
/** Special case of the template operator=, in order to prevent the compiler
|
/** Special case of the template operator=, in order to prevent the compiler
|
||||||
* from generating a default operator= (issue hit with g++ 4.1)
|
* from generating a default operator= (issue hit with g++ 4.1)
|
||||||
@ -183,7 +182,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
CommaInitializer operator<< (const Scalar& s);
|
CommaInitializer operator<< (const Scalar& s);
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
CommaInitializer operator<< (const MatrixBase<Scalar, OtherDerived>& other);
|
CommaInitializer operator<< (const MatrixBase<OtherDerived>& other);
|
||||||
|
|
||||||
/** swaps *this with the expression \a other.
|
/** swaps *this with the expression \a other.
|
||||||
*
|
*
|
||||||
@ -192,7 +191,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
* of course. TODO: get rid of const here.
|
* of course. TODO: get rid of const here.
|
||||||
*/
|
*/
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
void swap(const MatrixBase<Scalar, OtherDerived>& other);
|
void swap(const MatrixBase<OtherDerived>& other);
|
||||||
|
|
||||||
/// \name sub-matrices
|
/// \name sub-matrices
|
||||||
//@{
|
//@{
|
||||||
@ -252,7 +251,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
Scalar trace() const;
|
Scalar trace() const;
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Scalar dot(const MatrixBase<Scalar, OtherDerived>& other) const;
|
Scalar dot(const MatrixBase<OtherDerived>& other) const;
|
||||||
RealScalar norm2() const;
|
RealScalar norm2() const;
|
||||||
RealScalar norm() const;
|
RealScalar norm() const;
|
||||||
//@}
|
//@}
|
||||||
@ -282,7 +281,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
bool isDiagonal(RealScalar prec = precision<Scalar>()) const;
|
bool isDiagonal(RealScalar prec = precision<Scalar>()) const;
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
bool isOrtho(const MatrixBase<Scalar, OtherDerived>& other,
|
bool isOrtho(const MatrixBase<OtherDerived>& other,
|
||||||
RealScalar prec = precision<Scalar>()) const;
|
RealScalar prec = precision<Scalar>()) const;
|
||||||
bool isOrtho(RealScalar prec = precision<Scalar>()) const;
|
bool isOrtho(RealScalar prec = precision<Scalar>()) const;
|
||||||
|
|
||||||
@ -292,7 +291,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
bool isMuchSmallerThan(const RealScalar& other,
|
bool isMuchSmallerThan(const RealScalar& other,
|
||||||
RealScalar prec = precision<Scalar>()) const;
|
RealScalar prec = precision<Scalar>()) const;
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
bool isMuchSmallerThan(const MatrixBase<Scalar, OtherDerived>& other,
|
bool isMuchSmallerThan(const MatrixBase<OtherDerived>& other,
|
||||||
RealScalar prec = precision<Scalar>()) const;
|
RealScalar prec = precision<Scalar>()) const;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
@ -301,11 +300,11 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
const CwiseUnaryOp<ScalarOppositeOp,Derived> operator-() const;
|
const CwiseUnaryOp<ScalarOppositeOp,Derived> operator-() const;
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& operator+=(const MatrixBase<Scalar, OtherDerived>& other);
|
Derived& operator+=(const MatrixBase<OtherDerived>& other);
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& operator-=(const MatrixBase<Scalar, OtherDerived>& other);
|
Derived& operator-=(const MatrixBase<OtherDerived>& other);
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& operator*=(const MatrixBase<Scalar, OtherDerived>& other);
|
Derived& operator*=(const MatrixBase<OtherDerived>& other);
|
||||||
|
|
||||||
Derived& operator*=(const Scalar& other);
|
Derived& operator*=(const Scalar& other);
|
||||||
Derived& operator/=(const Scalar& other);
|
Derived& operator/=(const Scalar& other);
|
||||||
@ -319,17 +318,17 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
const Product<Derived, OtherDerived>
|
const Product<Derived, OtherDerived>
|
||||||
lazyProduct(const MatrixBase<Scalar, OtherDerived>& other) const EIGEN_ALWAYS_INLINE;
|
lazyProduct(const MatrixBase<OtherDerived>& other) const EIGEN_ALWAYS_INLINE;
|
||||||
|
|
||||||
const CwiseUnaryOp<ScalarAbsOp,Derived> cwiseAbs() const;
|
const CwiseUnaryOp<ScalarAbsOp,Derived> cwiseAbs() const;
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
const CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>
|
const CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>
|
||||||
cwiseProduct(const MatrixBase<Scalar, OtherDerived> &other) const;
|
cwiseProduct(const MatrixBase<OtherDerived> &other) const;
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
const CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>
|
const CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>
|
||||||
cwiseQuotient(const MatrixBase<Scalar, OtherDerived> &other) const;
|
cwiseQuotient(const MatrixBase<OtherDerived> &other) const;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// \name coefficient accessors
|
/// \name coefficient accessors
|
||||||
@ -366,7 +365,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
|||||||
|
|
||||||
template<typename CustomBinaryOp, typename OtherDerived>
|
template<typename CustomBinaryOp, typename OtherDerived>
|
||||||
const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
|
const CwiseBinaryOp<CustomBinaryOp, Derived, OtherDerived>
|
||||||
cwise(const MatrixBase<Scalar, OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const;
|
cwise(const MatrixBase<OtherDerived> &other, const CustomBinaryOp& func = CustomBinaryOp()) const;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/** puts in *row and *col the location of the coefficient of *this
|
/** puts in *row and *col the location of the coefficient of *this
|
||||||
|
@ -25,14 +25,18 @@
|
|||||||
#ifndef EIGEN_MATRIXREF_H
|
#ifndef EIGEN_MATRIXREF_H
|
||||||
#define EIGEN_MATRIXREF_H
|
#define EIGEN_MATRIXREF_H
|
||||||
|
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<MatrixRef<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class MatrixRef
|
template<typename MatrixType> class MatrixRef
|
||||||
: public MatrixBase<typename MatrixType::Scalar, MatrixRef<MatrixType> >
|
: public MatrixBase<MatrixRef<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixRef>::Type Scalar;
|
||||||
friend class MatrixBase<Scalar, MatrixRef>;
|
friend class MatrixBase<MatrixRef>;
|
||||||
friend class MatrixBase<Scalar, MatrixRef>::Traits;
|
friend class MatrixBase<MatrixRef>::Traits;
|
||||||
typedef MatrixBase<Scalar, MatrixRef> Base;
|
typedef MatrixBase<MatrixRef> Base;
|
||||||
|
|
||||||
MatrixRef(const MatrixType& matrix) : m_matrix(matrix) {}
|
MatrixRef(const MatrixType& matrix) : m_matrix(matrix) {}
|
||||||
~MatrixRef() {}
|
~MatrixRef() {}
|
||||||
|
@ -37,15 +37,19 @@
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::minor()
|
* \sa MatrixBase::minor()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<Minor<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class Minor
|
template<typename MatrixType> class Minor
|
||||||
: public MatrixBase<typename MatrixType::Scalar, Minor<MatrixType> >
|
: public MatrixBase<Minor<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
typedef typename MatrixType::AsArg MatRef;
|
typedef typename MatrixType::AsArg MatRef;
|
||||||
friend class MatrixBase<Scalar, Minor>;
|
friend class MatrixBase<Minor>;
|
||||||
friend class MatrixBase<Scalar, Minor>::Traits;
|
friend class MatrixBase<Minor>::Traits;
|
||||||
typedef MatrixBase<Scalar, Minor> Base;
|
typedef MatrixBase<Minor> Base;
|
||||||
|
|
||||||
Minor(const MatRef& matrix,
|
Minor(const MatRef& matrix,
|
||||||
int row, int col)
|
int row, int col)
|
||||||
@ -97,17 +101,17 @@ template<typename MatrixType> class Minor
|
|||||||
*
|
*
|
||||||
* \sa class Minor
|
* \sa class Minor
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Minor<Derived>
|
Minor<Derived>
|
||||||
MatrixBase<Scalar, Derived>::minor(int row, int col)
|
MatrixBase<Derived>::minor(int row, int col)
|
||||||
{
|
{
|
||||||
return Minor<Derived>(asArg(), row, col);
|
return Minor<Derived>(asArg(), row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of minor(). */
|
/** This is the const version of minor(). */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Minor<Derived>
|
const Minor<Derived>
|
||||||
MatrixBase<Scalar, Derived>::minor(int row, int col) const
|
MatrixBase<Derived>::minor(int row, int col) const
|
||||||
{
|
{
|
||||||
return Minor<Derived>(asArg(), row, col);
|
return Minor<Derived>(asArg(), row, col);
|
||||||
}
|
}
|
||||||
|
@ -32,14 +32,18 @@
|
|||||||
* \sa MatrixBase::ones(), MatrixBase::ones(int), MatrixBase::ones(int,int),
|
* \sa MatrixBase::ones(), MatrixBase::ones(int), MatrixBase::ones(int,int),
|
||||||
* MatrixBase::setOnes(), MatrixBase::isOnes()
|
* MatrixBase::setOnes(), MatrixBase::isOnes()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<Ones<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class Ones : NoOperatorEquals,
|
template<typename MatrixType> class Ones : NoOperatorEquals,
|
||||||
public MatrixBase<typename MatrixType::Scalar, Ones<MatrixType> >
|
public MatrixBase<Ones<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
friend class MatrixBase<Scalar, Ones>;
|
friend class MatrixBase<Ones>;
|
||||||
friend class MatrixBase<Scalar, Ones>::Traits;
|
friend class MatrixBase<Ones>::Traits;
|
||||||
typedef MatrixBase<Scalar, Ones> Base;
|
typedef MatrixBase<Ones> Base;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
@ -86,8 +90,8 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
|
|||||||
*
|
*
|
||||||
* \sa ones(), ones(int), isOnes(), class Ones
|
* \sa ones(), ones(int), isOnes(), class Ones
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int rows, int cols)
|
const Ones<Derived> MatrixBase<Derived>::ones(int rows, int cols)
|
||||||
{
|
{
|
||||||
return Ones<Derived>(rows, cols);
|
return Ones<Derived>(rows, cols);
|
||||||
}
|
}
|
||||||
@ -108,8 +112,8 @@ const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int rows, int cols)
|
|||||||
*
|
*
|
||||||
* \sa ones(), ones(int,int), isOnes(), class Ones
|
* \sa ones(), ones(int,int), isOnes(), class Ones
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int size)
|
const Ones<Derived> MatrixBase<Derived>::ones(int size)
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
if(Traits::RowsAtCompileTime == 1) return Ones<Derived>(1, size);
|
if(Traits::RowsAtCompileTime == 1) return Ones<Derived>(1, size);
|
||||||
@ -126,8 +130,8 @@ const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int size)
|
|||||||
*
|
*
|
||||||
* \sa ones(int), ones(int,int), isOnes(), class Ones
|
* \sa ones(int), ones(int,int), isOnes(), class Ones
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Ones<Derived> MatrixBase<Scalar, Derived>::ones()
|
const Ones<Derived> MatrixBase<Derived>::ones()
|
||||||
{
|
{
|
||||||
return Ones<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
return Ones<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||||
}
|
}
|
||||||
@ -140,8 +144,8 @@ const Ones<Derived> MatrixBase<Scalar, Derived>::ones()
|
|||||||
*
|
*
|
||||||
* \sa class Ones, ones()
|
* \sa class Ones, ones()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
bool MatrixBase<Scalar, Derived>::isOnes
|
bool MatrixBase<Derived>::isOnes
|
||||||
(typename NumTraits<Scalar>::Real prec) const
|
(typename NumTraits<Scalar>::Real prec) const
|
||||||
{
|
{
|
||||||
for(int j = 0; j < cols(); j++)
|
for(int j = 0; j < cols(); j++)
|
||||||
@ -158,8 +162,8 @@ bool MatrixBase<Scalar, Derived>::isOnes
|
|||||||
*
|
*
|
||||||
* \sa class Ones, ones()
|
* \sa class Ones, ones()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Derived& MatrixBase<Scalar, Derived>::setOnes()
|
Derived& MatrixBase<Derived>::setOnes()
|
||||||
{
|
{
|
||||||
return *this = Ones<Derived>(rows(), cols());
|
return *this = Ones<Derived>(rows(), cols());
|
||||||
}
|
}
|
||||||
|
@ -97,10 +97,10 @@ struct VectorOperatorEqualsUnroller<Derived1, Derived2, Dynamic>
|
|||||||
static void run(Derived1 &, const Derived2 &) {}
|
static void run(Derived1 &, const Derived2 &) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived& MatrixBase<Scalar, Derived>
|
Derived& MatrixBase<Derived>
|
||||||
::operator=(const MatrixBase<Scalar, OtherDerived>& other)
|
::operator=(const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
if(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime)
|
if(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime)
|
||||||
// copying a vector expression into a vector
|
// copying a vector expression into a vector
|
||||||
|
@ -72,16 +72,20 @@ struct ProductUnroller<Index, 0, Lhs, Rhs>
|
|||||||
*
|
*
|
||||||
* \sa class Sum, class Difference
|
* \sa class Sum, class Difference
|
||||||
*/
|
*/
|
||||||
|
template<typename Lhs, typename Rhs>
|
||||||
|
struct Scalar<Product<Lhs, Rhs> >
|
||||||
|
{ typedef typename Scalar<Lhs>::Type Type; };
|
||||||
|
|
||||||
template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
||||||
public MatrixBase<typename Lhs::Scalar, Product<Lhs, Rhs> >
|
public MatrixBase<Product<Lhs, Rhs> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename Lhs::Scalar Scalar;
|
typedef typename Scalar<Lhs>::Type Scalar;
|
||||||
typedef typename Lhs::AsArg LhsRef;
|
typedef typename Lhs::AsArg LhsRef;
|
||||||
typedef typename Rhs::AsArg RhsRef;
|
typedef typename Rhs::AsArg RhsRef;
|
||||||
friend class MatrixBase<Scalar, Product>;
|
friend class MatrixBase<Product>;
|
||||||
friend class MatrixBase<Scalar, Product>::Traits;
|
friend class MatrixBase<Product>::Traits;
|
||||||
typedef MatrixBase<Scalar, Product> Base;
|
typedef MatrixBase<Product> Base;
|
||||||
|
|
||||||
Product(const LhsRef& lhs, const RhsRef& rhs)
|
Product(const LhsRef& lhs, const RhsRef& rhs)
|
||||||
: m_lhs(lhs), m_rhs(rhs)
|
: m_lhs(lhs), m_rhs(rhs)
|
||||||
@ -134,10 +138,10 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
|||||||
*
|
*
|
||||||
* \sa class Product
|
* \sa class Product
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
const Product<Derived, OtherDerived>
|
const Product<Derived, OtherDerived>
|
||||||
MatrixBase<Scalar, Derived>::lazyProduct(const MatrixBase<Scalar, OtherDerived> &other) const
|
MatrixBase<Derived>::lazyProduct(const MatrixBase<OtherDerived> &other) const
|
||||||
{
|
{
|
||||||
return Product<Derived, OtherDerived>(asArg(), other.asArg());
|
return Product<Derived, OtherDerived>(asArg(), other.asArg());
|
||||||
}
|
}
|
||||||
@ -152,9 +156,9 @@ MatrixBase<Scalar, Derived>::lazyProduct(const MatrixBase<Scalar, OtherDerived>
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::lazyProduct(), MatrixBase::operator*=(const MatrixBase&)
|
* \sa MatrixBase::lazyProduct(), MatrixBase::operator*=(const MatrixBase&)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived1, typename Derived2>
|
template<typename Derived1, typename Derived2>
|
||||||
const Eval<Product<Derived1, Derived2> >
|
const Eval<Product<Derived1, Derived2> >
|
||||||
operator*(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Derived2> &mat2)
|
operator*(const MatrixBase<Derived1> &mat1, const MatrixBase<Derived2> &mat2)
|
||||||
{
|
{
|
||||||
return mat1.lazyProduct(mat2).eval();
|
return mat1.lazyProduct(mat2).eval();
|
||||||
}
|
}
|
||||||
@ -163,10 +167,10 @@ operator*(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Der
|
|||||||
*
|
*
|
||||||
* \returns a reference to \c *this
|
* \returns a reference to \c *this
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Derived &
|
Derived &
|
||||||
MatrixBase<Scalar, Derived>::operator*=(const MatrixBase<Scalar, OtherDerived> &other)
|
MatrixBase<Derived>::operator*=(const MatrixBase<OtherDerived> &other)
|
||||||
{
|
{
|
||||||
return *this = *this * other;
|
return *this = *this * other;
|
||||||
}
|
}
|
||||||
|
@ -32,14 +32,18 @@
|
|||||||
* \sa MatrixBase::random(), MatrixBase::random(int), MatrixBase::random(int,int),
|
* \sa MatrixBase::random(), MatrixBase::random(int), MatrixBase::random(int,int),
|
||||||
* MatrixBase::setRandom()
|
* MatrixBase::setRandom()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<Random<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class Random : NoOperatorEquals,
|
template<typename MatrixType> class Random : NoOperatorEquals,
|
||||||
public MatrixBase<typename MatrixType::Scalar, Random<MatrixType> >
|
public MatrixBase<Random<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename MatrixType::Scalar Scalar;
|
||||||
friend class MatrixBase<Scalar, Random>;
|
friend class MatrixBase<Random>;
|
||||||
friend class MatrixBase<Scalar, Random>::Traits;
|
friend class MatrixBase<Random>::Traits;
|
||||||
typedef MatrixBase<Scalar, Random> Base;
|
typedef MatrixBase<Random> Base;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
@ -86,9 +90,9 @@ template<typename MatrixType> class Random : NoOperatorEquals,
|
|||||||
*
|
*
|
||||||
* \sa ei_random(), ei_random(int)
|
* \sa ei_random(), ei_random(int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eval<Random<Derived> >
|
const Eval<Random<Derived> >
|
||||||
MatrixBase<Scalar, Derived>::random(int rows, int cols)
|
MatrixBase<Derived>::random(int rows, int cols)
|
||||||
{
|
{
|
||||||
return Random<Derived>(rows, cols).eval();
|
return Random<Derived>(rows, cols).eval();
|
||||||
}
|
}
|
||||||
@ -109,9 +113,9 @@ MatrixBase<Scalar, Derived>::random(int rows, int cols)
|
|||||||
*
|
*
|
||||||
* \sa ei_random(), ei_random(int,int)
|
* \sa ei_random(), ei_random(int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eval<Random<Derived> >
|
const Eval<Random<Derived> >
|
||||||
MatrixBase<Scalar, Derived>::random(int size)
|
MatrixBase<Derived>::random(int size)
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
if(Traits::RowsAtCompileTime == 1) return Random<Derived>(1, size).eval();
|
if(Traits::RowsAtCompileTime == 1) return Random<Derived>(1, size).eval();
|
||||||
@ -129,9 +133,9 @@ MatrixBase<Scalar, Derived>::random(int size)
|
|||||||
*
|
*
|
||||||
* \sa ei_random(int), ei_random(int,int)
|
* \sa ei_random(int), ei_random(int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eval<Random<Derived> >
|
const Eval<Random<Derived> >
|
||||||
MatrixBase<Scalar, Derived>::random()
|
MatrixBase<Derived>::random()
|
||||||
{
|
{
|
||||||
return Random<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime).eval();
|
return Random<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime).eval();
|
||||||
}
|
}
|
||||||
@ -143,8 +147,8 @@ MatrixBase<Scalar, Derived>::random()
|
|||||||
*
|
*
|
||||||
* \sa class Random, ei_random()
|
* \sa class Random, ei_random()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Derived& MatrixBase<Scalar, Derived>::setRandom()
|
Derived& MatrixBase<Derived>::setRandom()
|
||||||
{
|
{
|
||||||
return *this = Random<Derived>(rows(), cols());
|
return *this = Random<Derived>(rows(), cols());
|
||||||
}
|
}
|
||||||
|
@ -45,15 +45,19 @@
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::row()
|
* \sa MatrixBase::row()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<Row<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class Row
|
template<typename MatrixType> class Row
|
||||||
: public MatrixBase<typename MatrixType::Scalar, Row<MatrixType> >
|
: public MatrixBase<Row<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
typedef typename MatrixType::AsArg MatRef;
|
typedef typename MatrixType::AsArg MatRef;
|
||||||
friend class MatrixBase<Scalar, Row>;
|
friend class MatrixBase<Row>;
|
||||||
friend class MatrixBase<Scalar, Row>::Traits;
|
friend class MatrixBase<Row>::Traits;
|
||||||
typedef MatrixBase<Scalar, Row> Base;
|
typedef MatrixBase<Row> Base;
|
||||||
|
|
||||||
Row(const MatRef& matrix, int row)
|
Row(const MatRef& matrix, int row)
|
||||||
: m_matrix(matrix), m_row(row)
|
: m_matrix(matrix), m_row(row)
|
||||||
@ -61,12 +65,6 @@ template<typename MatrixType> class Row
|
|||||||
assert(row >= 0 && row < matrix.rows());
|
assert(row >= 0 && row < matrix.rows());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename OtherDerived>
|
|
||||||
Row& operator=(const MatrixBase<Scalar, OtherDerived>& other)
|
|
||||||
{
|
|
||||||
return MatrixBase<Scalar, Row<MatrixType> >::operator=(other);
|
|
||||||
}
|
|
||||||
|
|
||||||
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row)
|
EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Row)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -103,17 +101,17 @@ template<typename MatrixType> class Row
|
|||||||
* Output: \verbinclude MatrixBase_row.out
|
* Output: \verbinclude MatrixBase_row.out
|
||||||
*
|
*
|
||||||
* \sa col(), class Row */
|
* \sa col(), class Row */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Row<Derived>
|
Row<Derived>
|
||||||
MatrixBase<Scalar, Derived>::row(int i)
|
MatrixBase<Derived>::row(int i)
|
||||||
{
|
{
|
||||||
return Row<Derived>(asArg(), i);
|
return Row<Derived>(asArg(), i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of row(). */
|
/** This is the const version of row(). */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Row<Derived>
|
const Row<Derived>
|
||||||
MatrixBase<Scalar, Derived>::row(int i) const
|
MatrixBase<Derived>::row(int i) const
|
||||||
{
|
{
|
||||||
return Row<Derived>(asArg(), i);
|
return Row<Derived>(asArg(), i);
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@
|
|||||||
#ifndef EIGEN_SWAP_H
|
#ifndef EIGEN_SWAP_H
|
||||||
#define EIGEN_SWAP_H
|
#define EIGEN_SWAP_H
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
void MatrixBase<Scalar, Derived>::swap(const MatrixBase<Scalar, OtherDerived>& other)
|
void MatrixBase<Derived>::swap(const MatrixBase<OtherDerived>& other)
|
||||||
{
|
{
|
||||||
MatrixBase<Scalar, OtherDerived> *_other = const_cast<MatrixBase<Scalar, OtherDerived>*>(&other);
|
MatrixBase<OtherDerived> *_other = const_cast<MatrixBase<OtherDerived>*>(&other);
|
||||||
if(Traits::SizeAtCompileTime == Dynamic)
|
if(Traits::SizeAtCompileTime == Dynamic)
|
||||||
{
|
{
|
||||||
Scalar tmp;
|
Scalar tmp;
|
||||||
|
@ -56,8 +56,9 @@ template<int Index, typename Derived> struct TraceUnroller<Index, 0, Derived>
|
|||||||
/** \returns the trace of *this, which must be a square matrix.
|
/** \returns the trace of *this, which must be a square matrix.
|
||||||
*
|
*
|
||||||
* \sa diagonal() */
|
* \sa diagonal() */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Scalar MatrixBase<Scalar, Derived>::trace() const
|
typename Scalar<Derived>::Type
|
||||||
|
MatrixBase<Derived>::trace() const
|
||||||
{
|
{
|
||||||
assert(rows() == cols());
|
assert(rows() == cols());
|
||||||
Scalar res;
|
Scalar res;
|
||||||
|
@ -37,15 +37,19 @@
|
|||||||
*
|
*
|
||||||
* \sa MatrixBase::transpose(), MatrixBase::adjoint()
|
* \sa MatrixBase::transpose(), MatrixBase::adjoint()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<Transpose<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class Transpose
|
template<typename MatrixType> class Transpose
|
||||||
: public MatrixBase<typename MatrixType::Scalar, Transpose<MatrixType> >
|
: public MatrixBase<Transpose<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
typedef typename MatrixType::AsArg MatRef;
|
typedef typename MatrixType::AsArg MatRef;
|
||||||
friend class MatrixBase<Scalar, Transpose>;
|
friend class MatrixBase<Transpose>;
|
||||||
friend class MatrixBase<Scalar, Transpose>::Traits;
|
friend class MatrixBase<Transpose>::Traits;
|
||||||
typedef MatrixBase<Scalar, Transpose> Base;
|
typedef MatrixBase<Transpose> Base;
|
||||||
|
|
||||||
Transpose(const MatRef& matrix) : m_matrix(matrix) {}
|
Transpose(const MatRef& matrix) : m_matrix(matrix) {}
|
||||||
|
|
||||||
@ -83,17 +87,17 @@ template<typename MatrixType> class Transpose
|
|||||||
* Output: \verbinclude MatrixBase_transpose.out
|
* Output: \verbinclude MatrixBase_transpose.out
|
||||||
*
|
*
|
||||||
* \sa adjoint(), class DiagonalCoeffs */
|
* \sa adjoint(), class DiagonalCoeffs */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Transpose<Derived>
|
Transpose<Derived>
|
||||||
MatrixBase<Scalar, Derived>::transpose()
|
MatrixBase<Derived>::transpose()
|
||||||
{
|
{
|
||||||
return Transpose<Derived>(asArg());
|
return Transpose<Derived>(asArg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This is the const version of transpose(). \sa adjoint() */
|
/** This is the const version of transpose(). \sa adjoint() */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Transpose<Derived>
|
const Transpose<Derived>
|
||||||
MatrixBase<Scalar, Derived>::transpose() const
|
MatrixBase<Derived>::transpose() const
|
||||||
{
|
{
|
||||||
return Transpose<Derived>(asArg());
|
return Transpose<Derived>(asArg());
|
||||||
}
|
}
|
||||||
@ -104,9 +108,9 @@ MatrixBase<Scalar, Derived>::transpose() const
|
|||||||
* Output: \verbinclude MatrixBase_adjoint.out
|
* Output: \verbinclude MatrixBase_adjoint.out
|
||||||
*
|
*
|
||||||
* \sa transpose(), conjugate(), class Transpose, class ScalarConjugateOp */
|
* \sa transpose(), conjugate(), class Transpose, class ScalarConjugateOp */
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Transpose<CwiseUnaryOp<ScalarConjugateOp, Derived> >
|
const Transpose<CwiseUnaryOp<ScalarConjugateOp, Derived> >
|
||||||
MatrixBase<Scalar, Derived>::adjoint() const
|
MatrixBase<Derived>::adjoint() const
|
||||||
{
|
{
|
||||||
return conjugate().transpose();
|
return conjugate().transpose();
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,8 @@ using Eigen::MatrixBase;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
|
#define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
|
||||||
template<typename OtherScalar, typename OtherDerived> \
|
template<typename OtherDerived> \
|
||||||
Derived& operator Op(const MatrixBase<OtherScalar, OtherDerived>& other) \
|
Derived& operator Op(const MatrixBase<OtherDerived>& other) \
|
||||||
{ \
|
{ \
|
||||||
return Base::operator Op(other); \
|
return Base::operator Op(other); \
|
||||||
} \
|
} \
|
||||||
|
@ -32,14 +32,18 @@
|
|||||||
* \sa MatrixBase::zero(), MatrixBase::zero(int), MatrixBase::zero(int,int),
|
* \sa MatrixBase::zero(), MatrixBase::zero(int), MatrixBase::zero(int,int),
|
||||||
* MatrixBase::setZero(), MatrixBase::isZero()
|
* MatrixBase::setZero(), MatrixBase::isZero()
|
||||||
*/
|
*/
|
||||||
|
template<typename MatrixType>
|
||||||
|
struct Scalar<Zero<MatrixType> >
|
||||||
|
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||||
|
|
||||||
template<typename MatrixType> class Zero : NoOperatorEquals,
|
template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||||
public MatrixBase<typename MatrixType::Scalar, Zero<MatrixType> >
|
public MatrixBase<Zero<MatrixType> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename MatrixType::Scalar Scalar;
|
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||||
friend class MatrixBase<Scalar, Zero>;
|
friend class MatrixBase<Zero>;
|
||||||
friend class MatrixBase<Scalar, Zero>::Traits;
|
friend class MatrixBase<Zero>::Traits;
|
||||||
typedef MatrixBase<Scalar, Zero> Base;
|
typedef MatrixBase<Zero> Base;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
@ -86,8 +90,8 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
|
|||||||
*
|
*
|
||||||
* \sa zero(), zero(int)
|
* \sa zero(), zero(int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int rows, int cols)
|
const Zero<Derived> MatrixBase<Derived>::zero(int rows, int cols)
|
||||||
{
|
{
|
||||||
return Zero<Derived>(rows, cols);
|
return Zero<Derived>(rows, cols);
|
||||||
}
|
}
|
||||||
@ -108,8 +112,8 @@ const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int rows, int cols)
|
|||||||
*
|
*
|
||||||
* \sa zero(), zero(int,int)
|
* \sa zero(), zero(int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int size)
|
const Zero<Derived> MatrixBase<Derived>::zero(int size)
|
||||||
{
|
{
|
||||||
assert(Traits::IsVectorAtCompileTime);
|
assert(Traits::IsVectorAtCompileTime);
|
||||||
if(Traits::RowsAtCompileTime == 1) return Zero<Derived>(1, size);
|
if(Traits::RowsAtCompileTime == 1) return Zero<Derived>(1, size);
|
||||||
@ -126,8 +130,8 @@ const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int size)
|
|||||||
*
|
*
|
||||||
* \sa zero(int), zero(int,int)
|
* \sa zero(int), zero(int,int)
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Zero<Derived> MatrixBase<Scalar, Derived>::zero()
|
const Zero<Derived> MatrixBase<Derived>::zero()
|
||||||
{
|
{
|
||||||
return Zero<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
return Zero<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||||
}
|
}
|
||||||
@ -140,8 +144,8 @@ const Zero<Derived> MatrixBase<Scalar, Derived>::zero()
|
|||||||
*
|
*
|
||||||
* \sa class Zero, zero()
|
* \sa class Zero, zero()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
bool MatrixBase<Scalar, Derived>::isZero
|
bool MatrixBase<Derived>::isZero
|
||||||
(typename NumTraits<Scalar>::Real prec) const
|
(typename NumTraits<Scalar>::Real prec) const
|
||||||
{
|
{
|
||||||
for(int j = 0; j < cols(); j++)
|
for(int j = 0; j < cols(); j++)
|
||||||
@ -158,8 +162,8 @@ bool MatrixBase<Scalar, Derived>::isZero
|
|||||||
*
|
*
|
||||||
* \sa class Zero, zero()
|
* \sa class Zero, zero()
|
||||||
*/
|
*/
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Derived& MatrixBase<Scalar, Derived>::setZero()
|
Derived& MatrixBase<Derived>::setZero()
|
||||||
{
|
{
|
||||||
return *this = Zero<Derived>(rows(), cols());
|
return *this = Zero<Derived>(rows(), cols());
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ The To-do wiki for Eigen is here: <a href="http://techbase.kde.org/index.php?tit
|
|||||||
|
|
||||||
Eigen is standard C++98 and so should theoretically be compatible with any compliant compiler. Of course, in practice, things might be slightly different. At least, Eigen is known to compile with any version of GCC from 3.3 to 4.3 as well as with recent versions of ICC.
|
Eigen is standard C++98 and so should theoretically be compatible with any compliant compiler. Of course, in practice, things might be slightly different. At least, Eigen is known to compile with any version of GCC from 3.3 to 4.3 as well as with recent versions of ICC.
|
||||||
|
|
||||||
Eigen is well tested with recent versions of GCC and ICC. Both GCC 4.2 and ICC gives very good performance. ICC might provide even better performance when the auto-vectorization makes sense. For some reason the performance is not so great with GCC 4.1.
|
Eigen is well tested with recent versions of GCC and ICC. Both GCC 4.2 and ICC give very good performance. ICC might provide even better performance when the auto-vectorization makes sense. For some reason the performance is not so great with GCC 4.1.
|
||||||
|
|
||||||
For best performance, we recommend the following compilation flags:
|
For best performance, we recommend the following compilation flags:
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
USING_PART_OF_NAMESPACE_EIGEN
|
USING_PART_OF_NAMESPACE_EIGEN
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Eigen::Block<Derived>
|
Eigen::Block<Derived>
|
||||||
topLeftCorner(MatrixBase<Scalar, Derived>& m, int rows, int cols)
|
topLeftCorner(MatrixBase<Derived>& m, int rows, int cols)
|
||||||
{
|
{
|
||||||
return Eigen::Block<Derived>(m.asArg(), 0, 0, rows, cols);
|
return Eigen::Block<Derived>(m.asArg(), 0, 0, rows, cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eigen::Block<Derived>
|
const Eigen::Block<Derived>
|
||||||
topLeftCorner(const MatrixBase<Scalar, Derived>& m, int rows, int cols)
|
topLeftCorner(const MatrixBase<Derived>& m, int rows, int cols)
|
||||||
{
|
{
|
||||||
return Eigen::Block<Derived>(m.asArg(), 0, 0, rows, cols);
|
return Eigen::Block<Derived>(m.asArg(), 0, 0, rows, cols);
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,17 @@
|
|||||||
USING_PART_OF_NAMESPACE_EIGEN
|
USING_PART_OF_NAMESPACE_EIGEN
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eigen::CwiseUnaryOp<
|
const Eigen::CwiseUnaryOp<
|
||||||
Eigen::ScalarCastOp<typename Eigen::NumTraits<Scalar>::FloatingPoint>,
|
Eigen::ScalarCastOp<
|
||||||
Derived
|
typename Eigen::NumTraits< typename Eigen::Scalar<Derived>::Type >::FloatingPoint
|
||||||
|
>, Derived
|
||||||
>
|
>
|
||||||
castToFloatingPoint(const MatrixBase<Scalar, Derived>& m)
|
castToFloatingPoint(const MatrixBase<Derived>& m)
|
||||||
{
|
{
|
||||||
return m.template cast<typename Eigen::NumTraits<Scalar>::FloatingPoint>();
|
return m.template cast<typename Eigen::NumTraits<
|
||||||
|
typename Eigen::Scalar<Derived>::Type>::FloatingPoint
|
||||||
|
>();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
USING_PART_OF_NAMESPACE_EIGEN
|
USING_PART_OF_NAMESPACE_EIGEN
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Eigen::Column<Derived>
|
Eigen::Column<Derived>
|
||||||
firstColumn(MatrixBase<Scalar, Derived>& m)
|
firstColumn(MatrixBase<Derived>& m)
|
||||||
{
|
{
|
||||||
return Eigen::Column<Derived>(m.asArg(), 0);
|
return Eigen::Column<Derived>(m.asArg(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eigen::Column<Derived>
|
const Eigen::Column<Derived>
|
||||||
firstColumn(const MatrixBase<Scalar, Derived>& m)
|
firstColumn(const MatrixBase<Derived>& m)
|
||||||
{
|
{
|
||||||
return Eigen::Column<Derived>(m.asArg(), 0);
|
return Eigen::Column<Derived>(m.asArg(), 0);
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@ struct CwiseMinOp EIGEN_EMPTY_STRUCT {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// define a custom binary operator between two matrices
|
// define a custom binary operator between two matrices
|
||||||
template<typename Scalar, typename Derived1, typename Derived2>
|
template<typename Derived1, typename Derived2>
|
||||||
const Eigen::CwiseBinaryOp<CwiseMinOp, Derived1, Derived2>
|
const Eigen::CwiseBinaryOp<CwiseMinOp, Derived1, Derived2>
|
||||||
cwiseMin(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Derived2> &mat2)
|
cwiseMin(const MatrixBase<Derived1> &mat1, const MatrixBase<Derived2> &mat2)
|
||||||
{
|
{
|
||||||
return Eigen::CwiseBinaryOp<CwiseMinOp, Derived1, Derived2>(mat1.asArg(), mat2.asArg());
|
return Eigen::CwiseBinaryOp<CwiseMinOp, Derived1, Derived2>(mat1.asArg(), mat2.asArg());
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,6 @@ struct CwiseClampOp EIGEN_EMPTY_STRUCT {
|
|||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
Matrix4d m1 = Matrix4d::random();
|
Matrix4d m1 = Matrix4d::random();
|
||||||
cout << m1.cwise(CwiseClampOp<Matrix4d::Scalar>(-0.5,0.5)) << endl;
|
cout << m1.cwise(CwiseClampOp<double>(-0.5,0.5)) << endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
USING_PART_OF_NAMESPACE_EIGEN
|
USING_PART_OF_NAMESPACE_EIGEN
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eigen::Eval<Eigen::Transpose<Derived> >
|
const Eigen::Eval<Eigen::Transpose<Derived> >
|
||||||
evaluatedTranspose(const MatrixBase<Scalar, Derived>& m)
|
evaluatedTranspose(const MatrixBase<Derived>& m)
|
||||||
{
|
{
|
||||||
return m.transpose().eval();
|
return m.transpose().eval();
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
USING_PART_OF_NAMESPACE_EIGEN
|
USING_PART_OF_NAMESPACE_EIGEN
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Eigen::Block<Derived, 2, 2>
|
Eigen::Block<Derived, 2, 2>
|
||||||
topLeft2x2Corner(MatrixBase<Scalar, Derived>& m)
|
topLeft2x2Corner(MatrixBase<Derived>& m)
|
||||||
{
|
{
|
||||||
return Eigen::Block<Derived, 2, 2>(m.asArg(), 0, 0);
|
return Eigen::Block<Derived, 2, 2>(m.asArg(), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eigen::Block<Derived, 2, 2>
|
const Eigen::Block<Derived, 2, 2>
|
||||||
topLeft2x2Corner(const MatrixBase<Scalar, Derived>& m)
|
topLeft2x2Corner(const MatrixBase<Derived>& m)
|
||||||
{
|
{
|
||||||
return Eigen::Block<Derived, 2, 2>(m.asArg(), 0, 0);
|
return Eigen::Block<Derived, 2, 2>(m.asArg(), 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,16 @@
|
|||||||
USING_PART_OF_NAMESPACE_EIGEN
|
USING_PART_OF_NAMESPACE_EIGEN
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
Eigen::Row<Derived>
|
Eigen::Row<Derived>
|
||||||
firstRow(MatrixBase<Scalar, Derived>& m)
|
firstRow(MatrixBase<Derived>& m)
|
||||||
{
|
{
|
||||||
return Eigen::Row<Derived>(m.asArg(), 0);
|
return Eigen::Row<Derived>(m.asArg(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
const Eigen::Row<Derived>
|
const Eigen::Row<Derived>
|
||||||
firstRow(const MatrixBase<Scalar, Derived>& m)
|
firstRow(const MatrixBase<Derived>& m)
|
||||||
{
|
{
|
||||||
return Eigen::Row<Derived>(m.asArg(), 0);
|
return Eigen::Row<Derived>(m.asArg(), 0);
|
||||||
}
|
}
|
||||||
|
24
test/main.h
24
test/main.h
@ -149,25 +149,25 @@ inline bool test_ei_isApprox(const std::complex<double>& a, const std::complex<d
|
|||||||
inline bool test_ei_isMuchSmallerThan(const std::complex<double>& a, const std::complex<double>& b)
|
inline bool test_ei_isMuchSmallerThan(const std::complex<double>& a, const std::complex<double>& b)
|
||||||
{ return ei_isMuchSmallerThan(a, b, test_precision<std::complex<double> >()); }
|
{ return ei_isMuchSmallerThan(a, b, test_precision<std::complex<double> >()); }
|
||||||
|
|
||||||
template<typename Scalar, typename Derived1, typename Derived2>
|
template<typename Derived1, typename Derived2>
|
||||||
inline bool test_ei_isApprox(const MatrixBase<Scalar, Derived1>& m1,
|
inline bool test_ei_isApprox(const MatrixBase<Derived1>& m1,
|
||||||
const MatrixBase<Scalar, Derived2>& m2)
|
const MatrixBase<Derived2>& m2)
|
||||||
{
|
{
|
||||||
return m1.isApprox(m2, test_precision<Scalar>());
|
return m1.isApprox(m2, test_precision<typename Scalar<Derived1>::Type>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Scalar, typename Derived1, typename Derived2>
|
template<typename Derived1, typename Derived2>
|
||||||
inline bool test_ei_isMuchSmallerThan(const MatrixBase<Scalar, Derived1>& m1,
|
inline bool test_ei_isMuchSmallerThan(const MatrixBase<Derived1>& m1,
|
||||||
const MatrixBase<Scalar, Derived2>& m2)
|
const MatrixBase<Derived2>& m2)
|
||||||
{
|
{
|
||||||
return m1.isMuchSmallerThan(m2, test_precision<Scalar>());
|
return m1.isMuchSmallerThan(m2, test_precision<typename Scalar<Derived1>::Type>());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Scalar, typename Derived>
|
template<typename Derived>
|
||||||
inline bool test_ei_isMuchSmallerThan(const MatrixBase<Scalar, Derived>& m,
|
inline bool test_ei_isMuchSmallerThan(const MatrixBase<Derived>& m,
|
||||||
const typename NumTraits<Scalar>::Real& s)
|
const typename NumTraits<typename Scalar<Derived>::Type>::Real& s)
|
||||||
{
|
{
|
||||||
return m.isMuchSmallerThan(s, test_precision<Scalar>());
|
return m.isMuchSmallerThan(s, test_precision<typename Scalar<Derived>::Type>());
|
||||||
}
|
}
|
||||||
|
|
||||||
class EigenTest : public QObject
|
class EigenTest : public QObject
|
||||||
|
Loading…
x
Reference in New Issue
Block a user