mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +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:
@@ -56,17 +56,19 @@
|
||||
*
|
||||
* \sa MatrixBase::block(int,int,int,int), MatrixBase::block(int,int), class VectorBlock
|
||||
*/
|
||||
template<typename MatrixType,
|
||||
int BlockRows/*=Dynamic*/, int BlockCols/*=Dynamic*/> class Block
|
||||
: public MatrixBase<typename MatrixType::Scalar,
|
||||
Block<MatrixType, BlockRows, BlockCols> >
|
||||
template<typename MatrixType, int BlockRows, int BlockCols>
|
||||
struct Scalar<Block<MatrixType, BlockRows, BlockCols> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType, int BlockRows, int BlockCols> class Block
|
||||
: public MatrixBase<Block<MatrixType, BlockRows, BlockCols> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Scalar, Block>;
|
||||
friend class MatrixBase<Scalar, Block>::Traits;
|
||||
typedef MatrixBase<Scalar, Block> Base;
|
||||
friend class MatrixBase<Block>;
|
||||
friend class MatrixBase<Block>::Traits;
|
||||
typedef MatrixBase<Block> Base;
|
||||
|
||||
/** Fixed-size constructor
|
||||
*/
|
||||
@@ -143,16 +145,16 @@ template<typename MatrixType,
|
||||
*
|
||||
* \sa class Block, block(int,int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
Block<Derived> MatrixBase<Derived>
|
||||
::block(int startRow, int startCol, int blockRows, int blockCols)
|
||||
{
|
||||
return Block<Derived>(asArg(), startRow, startCol, blockRows, blockCols);
|
||||
}
|
||||
|
||||
/** This is the const version of block(int,int,int,int). */
|
||||
template<typename Scalar, typename Derived>
|
||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
const Block<Derived> MatrixBase<Derived>
|
||||
::block(int startRow, int startCol, int blockRows, int blockCols) const
|
||||
{
|
||||
return Block<Derived>(asArg(), startRow, startCol, blockRows, blockCols);
|
||||
@@ -174,8 +176,8 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa class Block, block(int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
Block<Derived> MatrixBase<Derived>
|
||||
::block(int start, int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -186,8 +188,8 @@ Block<Derived> MatrixBase<Scalar, Derived>
|
||||
}
|
||||
|
||||
/** This is the const version of block(int,int).*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
const Block<Derived> MatrixBase<Derived>
|
||||
::block(int start, int size) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -212,8 +214,8 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa class Block, block(int,int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
Block<Derived> MatrixBase<Derived>
|
||||
::start(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -223,8 +225,8 @@ Block<Derived> MatrixBase<Scalar, Derived>
|
||||
}
|
||||
|
||||
/** This is the const version of start(int).*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
const Block<Derived> MatrixBase<Derived>
|
||||
::start(int size) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -248,8 +250,8 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa class Block, block(int,int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
Block<Derived> MatrixBase<Derived>
|
||||
::end(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -261,8 +263,8 @@ Block<Derived> MatrixBase<Scalar, Derived>
|
||||
}
|
||||
|
||||
/** This is the const version of end(int).*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
const Block<Derived> MatrixBase<Derived>
|
||||
::end(int size) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -289,8 +291,8 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa class Block, block(int,int,int,int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
Block<Derived> MatrixBase<Derived>
|
||||
::corner(CornerType type, int cRows, int cCols)
|
||||
{
|
||||
if(type == TopLeft)
|
||||
@@ -304,8 +306,8 @@ Block<Derived> MatrixBase<Scalar, Derived>
|
||||
}
|
||||
|
||||
/** This is the const version of corner(CornerType, int, int).*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
const Block<Derived> MatrixBase<Derived>
|
||||
::corner(CornerType type, int cRows, int cCols) const
|
||||
{
|
||||
if(type == TopLeft)
|
||||
@@ -334,18 +336,18 @@ const Block<Derived> MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa class Block, block(int,int,int,int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<int BlockRows, int BlockCols>
|
||||
Block<Derived, BlockRows, BlockCols> MatrixBase<Scalar, Derived>
|
||||
Block<Derived, BlockRows, BlockCols> MatrixBase<Derived>
|
||||
::block(int startRow, int startCol)
|
||||
{
|
||||
return Block<Derived, BlockRows, BlockCols>(asArg(), startRow, startCol);
|
||||
}
|
||||
|
||||
/** This is the const version of block<>(int, int). */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
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
|
||||
{
|
||||
return Block<Derived, BlockRows, BlockCols>(asArg(), startRow, startCol);
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
*
|
||||
* \sa operator()(int,int) const, coeffRef(int,int), coeff(int) const
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
::coeff(int row, int col) const
|
||||
{
|
||||
eigen_internal_assert(row >= 0 && row < rows()
|
||||
@@ -52,8 +52,8 @@ Scalar MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa operator()(int,int), operator[](int) const
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
::operator()(int row, int col) const
|
||||
{
|
||||
assert(row >= 0 && row < rows()
|
||||
@@ -75,8 +75,8 @@ Scalar MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa operator()(int,int), coeff(int, int) const, coeffRef(int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
::coeffRef(int row, int col)
|
||||
{
|
||||
eigen_internal_assert(row >= 0 && row < rows()
|
||||
@@ -88,8 +88,8 @@ Scalar& MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa operator()(int,int) const, operator[](int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
::operator()(int row, int col)
|
||||
{
|
||||
assert(row >= 0 && row < rows()
|
||||
@@ -111,8 +111,8 @@ Scalar& MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa operator[](int) const, coeffRef(int), coeff(int,int) const
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
::coeff(int index) const
|
||||
{
|
||||
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -135,8 +135,8 @@ Scalar MatrixBase<Scalar, Derived>
|
||||
* \sa operator[](int), operator()(int,int) const, x() const, y() const,
|
||||
* z() const, w() const
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
::operator[](int index) const
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -166,8 +166,8 @@ Scalar MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa operator[](int), coeff(int) const, coeffRef(int,int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
::coeffRef(int index)
|
||||
{
|
||||
eigen_internal_assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -189,8 +189,8 @@ Scalar& MatrixBase<Scalar, Derived>
|
||||
*
|
||||
* \sa operator[](int) const, operator()(int,int), x(), y(), z(), w()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
::operator[](int index)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
@@ -207,43 +207,43 @@ Scalar& MatrixBase<Scalar, Derived>
|
||||
}
|
||||
|
||||
/** equivalent to operator[](0). \only_for_vectors */
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
::x() const { return (*this)[0]; }
|
||||
|
||||
/** equivalent to operator[](1). \only_for_vectors */
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
::y() const { return (*this)[1]; }
|
||||
|
||||
/** equivalent to operator[](2). \only_for_vectors */
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
::z() const { return (*this)[2]; }
|
||||
|
||||
/** equivalent to operator[](3). \only_for_vectors */
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type MatrixBase<Derived>
|
||||
::w() const { return (*this)[3]; }
|
||||
|
||||
/** equivalent to operator[](0). \only_for_vectors */
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
::x() { return (*this)[0]; }
|
||||
|
||||
/** equivalent to operator[](1). \only_for_vectors */
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
::y() { return (*this)[1]; }
|
||||
|
||||
/** equivalent to operator[](2). \only_for_vectors */
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
::z() { return (*this)[2]; }
|
||||
|
||||
/** equivalent to operator[](3). \only_for_vectors */
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar& MatrixBase<Scalar, Derived>
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type& MatrixBase<Derived>
|
||||
::w() { return (*this)[3]; }
|
||||
|
||||
#endif // EIGEN_COEFFS_H
|
||||
|
||||
@@ -45,15 +45,19 @@
|
||||
*
|
||||
* \sa MatrixBase::col()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Column<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType> class Column
|
||||
: public MatrixBase<typename MatrixType::Scalar, Column<MatrixType> >
|
||||
: public MatrixBase<Column<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Scalar, Column>;
|
||||
friend class MatrixBase<Scalar, Column>::Traits;
|
||||
typedef MatrixBase<Scalar, Column> Base;
|
||||
friend class MatrixBase<Column>;
|
||||
friend class MatrixBase<Column>::Traits;
|
||||
typedef MatrixBase<Column> Base;
|
||||
|
||||
Column(const MatRef& matrix, int col)
|
||||
: m_matrix(matrix), m_col(col)
|
||||
@@ -96,17 +100,17 @@ template<typename MatrixType> class Column
|
||||
* Output: \verbinclude MatrixBase_col.out
|
||||
*
|
||||
* \sa row(), class Column */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
Column<Derived>
|
||||
MatrixBase<Scalar, Derived>::col(int i)
|
||||
MatrixBase<Derived>::col(int i)
|
||||
{
|
||||
return Column<Derived>(asArg(), i);
|
||||
}
|
||||
|
||||
/** This is the const version of col(). */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const Column<Derived>
|
||||
MatrixBase<Scalar, Derived>::col(int i) const
|
||||
MatrixBase<Derived>::col(int i) const
|
||||
{
|
||||
return Column<Derived>(asArg(), i);
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
/** \internal
|
||||
* Helper class to define the MatrixBase::operator<<
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
struct MatrixBase<Scalar, Derived>::CommaInitializer
|
||||
template<typename Derived>
|
||||
struct MatrixBase<Derived>::CommaInitializer
|
||||
{
|
||||
CommaInitializer(Derived& mat, const Scalar& s)
|
||||
: m_matrix(mat), m_row(0), m_col(1), m_currentBlockRows(1)
|
||||
@@ -39,7 +39,7 @@ struct MatrixBase<Scalar, Derived>::CommaInitializer
|
||||
}
|
||||
|
||||
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.block(0, 0, other.rows(), other.cols()) = other;
|
||||
@@ -60,7 +60,7 @@ struct MatrixBase<Scalar, Derived>::CommaInitializer
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
CommaInitializer& operator,(const MatrixBase<Scalar, OtherDerived>& other)
|
||||
CommaInitializer& operator,(const MatrixBase<OtherDerived>& other)
|
||||
{
|
||||
if (m_col==m_matrix.cols())
|
||||
{
|
||||
@@ -94,15 +94,16 @@ struct MatrixBase<Scalar, Derived>::CommaInitializer
|
||||
* Example: \include MatrixBase_set.cpp
|
||||
* Output: \verbinclude MatrixBase_set.out
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
typename MatrixBase<Scalar, Derived>::CommaInitializer MatrixBase<Scalar, Derived>::operator<< (const Scalar& s)
|
||||
template<typename Derived>
|
||||
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>
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -46,19 +46,21 @@
|
||||
*
|
||||
* \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>
|
||||
class CwiseBinaryOp : NoOperatorEquals,
|
||||
public MatrixBase<
|
||||
typename ei_result_of<BinaryOp(typename Lhs::Scalar,typename Rhs::Scalar)>::type,
|
||||
CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
||||
public MatrixBase<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
|
||||
{
|
||||
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 Rhs::AsArg RhsRef;
|
||||
friend class MatrixBase<Scalar, CwiseBinaryOp>;
|
||||
friend class MatrixBase<Scalar, CwiseBinaryOp>::Traits;
|
||||
typedef MatrixBase<Scalar, CwiseBinaryOp> Base;
|
||||
friend class MatrixBase<CwiseBinaryOp>;
|
||||
friend class MatrixBase<CwiseBinaryOp>::Traits;
|
||||
typedef MatrixBase<CwiseBinaryOp> Base;
|
||||
|
||||
CwiseBinaryOp(const LhsRef& lhs, const RhsRef& rhs, const BinaryOp& func = BinaryOp())
|
||||
: m_lhs(lhs), m_rhs(rhs), m_functor(func)
|
||||
@@ -131,9 +133,9 @@ struct ScalarQuotientOp EIGEN_EMPTY_STRUCT {
|
||||
*
|
||||
* \sa class CwiseBinaryOp, MatrixBase::operator-=()
|
||||
*/
|
||||
template<typename Scalar, typename Derived1, typename Derived2>
|
||||
template<typename Derived1, typename 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());
|
||||
}
|
||||
@@ -142,10 +144,10 @@ operator-(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Der
|
||||
*
|
||||
* \returns a reference to \c *this
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
Derived &
|
||||
MatrixBase<Scalar, Derived>::operator-=(const MatrixBase<Scalar, OtherDerived> &other)
|
||||
MatrixBase<Derived>::operator-=(const MatrixBase<OtherDerived> &other)
|
||||
{
|
||||
return *this = *this - other;
|
||||
}
|
||||
@@ -157,9 +159,9 @@ MatrixBase<Scalar, Derived>::operator-=(const MatrixBase<Scalar, OtherDerived> &
|
||||
*
|
||||
* \sa class CwiseBinaryOp, MatrixBase::operator+=()
|
||||
*/
|
||||
template<typename Scalar, typename Derived1, typename Derived2>
|
||||
template<typename Derived1, typename 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());
|
||||
}
|
||||
@@ -168,10 +170,10 @@ operator+(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Der
|
||||
*
|
||||
* \returns a reference to \c *this
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
Derived &
|
||||
MatrixBase<Scalar, Derived>::operator+=(const MatrixBase<Scalar, OtherDerived>& other)
|
||||
MatrixBase<Derived>::operator+=(const MatrixBase<OtherDerived>& other)
|
||||
{
|
||||
return *this = *this + other;
|
||||
}
|
||||
@@ -181,10 +183,10 @@ MatrixBase<Scalar, Derived>::operator+=(const MatrixBase<Scalar, OtherDerived>&
|
||||
*
|
||||
* \sa class CwiseBinaryOp
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename 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());
|
||||
}
|
||||
@@ -194,10 +196,10 @@ MatrixBase<Scalar, Derived>::cwiseProduct(const MatrixBase<Scalar, OtherDerived>
|
||||
*
|
||||
* \sa class CwiseBinaryOp
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename 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());
|
||||
}
|
||||
@@ -210,10 +212,10 @@ MatrixBase<Scalar, Derived>::cwiseQuotient(const MatrixBase<Scalar, OtherDerived
|
||||
*
|
||||
* \sa class CwiseBinaryOp, MatrixBase::operator+, MatrixBase::operator-, MatrixBase::cwiseProduct, MatrixBase::cwiseQuotient
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename CustomBinaryOp, typename 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);
|
||||
}
|
||||
|
||||
@@ -39,18 +39,20 @@
|
||||
*
|
||||
* \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>
|
||||
class CwiseUnaryOp : NoOperatorEquals,
|
||||
public MatrixBase<
|
||||
typename ei_result_of<UnaryOp(typename MatrixType::Scalar)>::type,
|
||||
CwiseUnaryOp<UnaryOp, MatrixType> >
|
||||
public MatrixBase<CwiseUnaryOp<UnaryOp, MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename ei_result_of<UnaryOp(typename MatrixType::Scalar)>::type Scalar;
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Scalar, CwiseUnaryOp>;
|
||||
friend class MatrixBase<Scalar, CwiseUnaryOp>::Traits;
|
||||
typedef MatrixBase<Scalar, CwiseUnaryOp> Base;
|
||||
friend class MatrixBase<CwiseUnaryOp>;
|
||||
friend class MatrixBase<CwiseUnaryOp>::Traits;
|
||||
typedef MatrixBase<CwiseUnaryOp> Base;
|
||||
|
||||
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
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const CwiseUnaryOp<ScalarOppositeOp,Derived>
|
||||
MatrixBase<Scalar, Derived>::operator-() const
|
||||
MatrixBase<Derived>::operator-() const
|
||||
{
|
||||
return CwiseUnaryOp<ScalarOppositeOp,Derived>(asArg());
|
||||
}
|
||||
|
||||
/** \returns an expression of the opposite of \c *this
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const CwiseUnaryOp<ScalarAbsOp,Derived>
|
||||
MatrixBase<Scalar, Derived>::cwiseAbs() const
|
||||
MatrixBase<Derived>::cwiseAbs() const
|
||||
{
|
||||
return CwiseUnaryOp<ScalarAbsOp,Derived>(asArg());
|
||||
}
|
||||
@@ -124,10 +126,10 @@ MatrixBase<Scalar, Derived>::cwiseAbs() const
|
||||
*
|
||||
* \sa class CwiseUnaryOp, class CwiseBinarOp, MatrixBase::operator-, MatrixBase::cwiseAbs
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename CustomUnaryOp>
|
||||
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);
|
||||
}
|
||||
@@ -145,9 +147,9 @@ struct ScalarConjugateOp EIGEN_EMPTY_STRUCT {
|
||||
/** \returns an expression of the complex conjugate of *this.
|
||||
*
|
||||
* \sa adjoint() */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const CwiseUnaryOp<ScalarConjugateOp, Derived>
|
||||
MatrixBase<Scalar, Derived>::conjugate() const
|
||||
MatrixBase<Derived>::conjugate() const
|
||||
{
|
||||
return CwiseUnaryOp<ScalarConjugateOp, Derived>(asArg());
|
||||
}
|
||||
@@ -173,10 +175,10 @@ struct ScalarCastOp EIGEN_EMPTY_STRUCT {
|
||||
*
|
||||
* \sa class CwiseUnaryOp, class ScalarCastOp
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename NewType>
|
||||
const CwiseUnaryOp<ScalarCastOp<NewType>, Derived>
|
||||
MatrixBase<Scalar, Derived>::cast() const
|
||||
MatrixBase<Derived>::cast() const
|
||||
{
|
||||
return CwiseUnaryOp<ScalarCastOp<NewType>, Derived>(asArg());
|
||||
}
|
||||
@@ -195,34 +197,35 @@ struct ScalarMultipleOp {
|
||||
};
|
||||
|
||||
/** \relates MatrixBase \sa class ScalarMultipleOp */
|
||||
template<typename Scalar, typename Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>
|
||||
MatrixBase<Scalar, Derived>::operator*(const Scalar& scalar) const
|
||||
template<typename Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<typename Scalar<Derived>::Type>, Derived>
|
||||
MatrixBase<Derived>::operator*(const Scalar& scalar) const
|
||||
{
|
||||
return CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>(asArg(), ScalarMultipleOp<Scalar>(scalar));
|
||||
}
|
||||
|
||||
/** \relates MatrixBase \sa class ScalarMultipleOp */
|
||||
template<typename Scalar, typename Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>
|
||||
MatrixBase<Scalar, Derived>::operator/(const Scalar& scalar) const
|
||||
template<typename Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<typename Scalar<Derived>::Type>, Derived>
|
||||
MatrixBase<Derived>::operator/(const Scalar& scalar) const
|
||||
{
|
||||
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 */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
Derived&
|
||||
MatrixBase<Scalar, Derived>::operator*=(const Scalar& other)
|
||||
MatrixBase<Derived>::operator*=(const Scalar& other)
|
||||
{
|
||||
return *this = *this * other;
|
||||
}
|
||||
|
||||
/** \sa ScalarMultipleOp */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
Derived&
|
||||
MatrixBase<Scalar, Derived>::operator/=(const Scalar& other)
|
||||
MatrixBase<Derived>::operator/=(const Scalar& other)
|
||||
{
|
||||
return *this = *this / other;
|
||||
}
|
||||
|
||||
@@ -37,15 +37,19 @@
|
||||
*
|
||||
* \sa MatrixBase::diagonal()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<DiagonalCoeffs<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType> class DiagonalCoeffs
|
||||
: public MatrixBase<typename MatrixType::Scalar, DiagonalCoeffs<MatrixType> >
|
||||
: public MatrixBase<DiagonalCoeffs<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Scalar, DiagonalCoeffs>;
|
||||
friend class MatrixBase<Scalar, DiagonalCoeffs>::Traits;
|
||||
typedef MatrixBase<Scalar, DiagonalCoeffs> Base;
|
||||
friend class MatrixBase<DiagonalCoeffs>;
|
||||
friend class MatrixBase<DiagonalCoeffs>::Traits;
|
||||
typedef MatrixBase<DiagonalCoeffs> Base;
|
||||
|
||||
DiagonalCoeffs(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
@@ -87,17 +91,17 @@ template<typename MatrixType> class DiagonalCoeffs
|
||||
* Output: \verbinclude MatrixBase_diagonal.out
|
||||
*
|
||||
* \sa class DiagonalCoeffs */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
DiagonalCoeffs<Derived>
|
||||
MatrixBase<Scalar, Derived>::diagonal()
|
||||
MatrixBase<Derived>::diagonal()
|
||||
{
|
||||
return DiagonalCoeffs<Derived>(asArg());
|
||||
}
|
||||
|
||||
/** This is the const version of diagonal(). */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const DiagonalCoeffs<Derived>
|
||||
MatrixBase<Scalar, Derived>::diagonal() const
|
||||
MatrixBase<Derived>::diagonal() const
|
||||
{
|
||||
return DiagonalCoeffs<Derived>(asArg());
|
||||
}
|
||||
|
||||
@@ -38,17 +38,20 @@
|
||||
*
|
||||
* \sa MatrixBase::diagonal(const OtherDerived&)
|
||||
*/
|
||||
template<typename CoeffsVectorType>
|
||||
struct Scalar<DiagonalMatrix<CoeffsVectorType> >
|
||||
{ typedef typename Scalar<CoeffsVectorType>::Type Type; };
|
||||
|
||||
template<typename CoeffsVectorType>
|
||||
class DiagonalMatrix : NoOperatorEquals,
|
||||
public MatrixBase<typename CoeffsVectorType::Scalar,
|
||||
DiagonalMatrix<CoeffsVectorType> >
|
||||
public MatrixBase<DiagonalMatrix<CoeffsVectorType> >
|
||||
{
|
||||
public:
|
||||
typedef typename CoeffsVectorType::Scalar Scalar;
|
||||
typedef typename Scalar<CoeffsVectorType>::Type Scalar;
|
||||
typedef typename CoeffsVectorType::AsArg CoeffsVecRef;
|
||||
friend class MatrixBase<Scalar, DiagonalMatrix>;
|
||||
friend class MatrixBase<Scalar, DiagonalMatrix>::Traits;
|
||||
typedef MatrixBase<Scalar, DiagonalMatrix> Base;
|
||||
friend class MatrixBase<DiagonalMatrix>;
|
||||
friend class MatrixBase<DiagonalMatrix>::Traits;
|
||||
typedef MatrixBase<DiagonalMatrix> Base;
|
||||
|
||||
DiagonalMatrix(const CoeffsVecRef& coeffs) : m_coeffs(coeffs)
|
||||
{
|
||||
@@ -86,9 +89,9 @@ class DiagonalMatrix : NoOperatorEquals,
|
||||
*
|
||||
* \sa class DiagonalMatrix, isDiagonal()
|
||||
**/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const DiagonalMatrix<Derived>
|
||||
MatrixBase<Scalar, Derived>::asDiagonal() const
|
||||
MatrixBase<Derived>::asDiagonal() const
|
||||
{
|
||||
return DiagonalMatrix<Derived>(asArg());
|
||||
}
|
||||
@@ -101,8 +104,8 @@ MatrixBase<Scalar, Derived>::asDiagonal() const
|
||||
*
|
||||
* \sa asDiagonal()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
bool MatrixBase<Scalar, Derived>::isDiagonal
|
||||
template<typename Derived>
|
||||
bool MatrixBase<Derived>::isDiagonal
|
||||
(typename NumTraits<Scalar>::Real prec) const
|
||||
{
|
||||
if(cols() != rows()) return false;
|
||||
|
||||
@@ -67,9 +67,10 @@ struct DotUnroller<Index, 0, Derived1, Derived2>
|
||||
*
|
||||
* \sa norm2(), norm()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
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
|
||||
&& OtherDerived::Traits::IsVectorAtCompileTime
|
||||
@@ -80,7 +81,7 @@ Scalar MatrixBase<Scalar, Derived>::dot(const MatrixBase<Scalar, OtherDerived>&
|
||||
&& Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT)
|
||||
DotUnroller<Traits::SizeAtCompileTime-1,
|
||||
Traits::SizeAtCompileTime <= EIGEN_UNROLLING_LIMIT_PRODUCT ? Traits::SizeAtCompileTime : Dynamic,
|
||||
Derived, MatrixBase<Scalar, OtherDerived> >
|
||||
Derived, MatrixBase<OtherDerived> >
|
||||
::run(*static_cast<const Derived*>(this), other, res);
|
||||
else
|
||||
{
|
||||
@@ -97,8 +98,8 @@ Scalar MatrixBase<Scalar, Derived>::dot(const MatrixBase<Scalar, OtherDerived>&
|
||||
*
|
||||
* \sa dot(), norm()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::norm2() const
|
||||
template<typename Derived>
|
||||
typename NumTraits<typename Scalar<Derived>::Type>::Real MatrixBase<Derived>::norm2() const
|
||||
{
|
||||
return ei_real(dot(*this));
|
||||
}
|
||||
@@ -109,8 +110,8 @@ typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::norm2() const
|
||||
*
|
||||
* \sa dot(), norm2()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::norm() const
|
||||
template<typename Derived>
|
||||
typename NumTraits<typename Scalar<Derived>::Type>::Real MatrixBase<Derived>::norm() const
|
||||
{
|
||||
return ei_sqrt(norm2());
|
||||
}
|
||||
@@ -121,9 +122,9 @@ typename NumTraits<Scalar>::Real MatrixBase<Scalar, Derived>::norm() const
|
||||
*
|
||||
* \sa norm()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<Scalar>, Derived>
|
||||
MatrixBase<Scalar, Derived>::normalized() const
|
||||
template<typename Derived>
|
||||
const CwiseUnaryOp<ScalarMultipleOp<typename Scalar<Derived>::Type>, Derived>
|
||||
MatrixBase<Derived>::normalized() const
|
||||
{
|
||||
return (*this) / norm();
|
||||
}
|
||||
@@ -134,11 +135,10 @@ MatrixBase<Scalar, Derived>::normalized() const
|
||||
* Example: \include MatrixBase_isOrtho_vector.cpp
|
||||
* Output: \verbinclude MatrixBase_isOrtho_vector.out
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
bool MatrixBase<Scalar, Derived>::isOrtho
|
||||
(const MatrixBase<Scalar, OtherDerived>& other,
|
||||
typename NumTraits<Scalar>::Real prec) const
|
||||
bool MatrixBase<Derived>::isOrtho
|
||||
(const MatrixBase<OtherDerived>& other, RealScalar prec) const
|
||||
{
|
||||
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
|
||||
* Output: \verbinclude MatrixBase_isOrtho_matrix.out
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
bool MatrixBase<Scalar, Derived>::isOrtho
|
||||
(typename NumTraits<Scalar>::Real prec) const
|
||||
template<typename Derived>
|
||||
bool MatrixBase<Derived>::isOrtho(RealScalar prec) const
|
||||
{
|
||||
for(int i = 0; i < cols(); i++)
|
||||
{
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
*
|
||||
* \sa MatrixBase::eval()
|
||||
*/
|
||||
template<typename ExpressionType>
|
||||
struct Scalar<Eval<ExpressionType> >
|
||||
{ typedef typename Scalar<ExpressionType>::Type Type; };
|
||||
|
||||
template<typename ExpressionType> class Eval : NoOperatorEquals,
|
||||
public Matrix< typename ExpressionType::Scalar,
|
||||
ExpressionType::Traits::RowsAtCompileTime,
|
||||
@@ -53,7 +57,7 @@ template<typename ExpressionType> class Eval : NoOperatorEquals,
|
||||
ExpressionType::Traits::MaxColsAtCompileTime>
|
||||
{
|
||||
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
|
||||
* 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
|
||||
*
|
||||
* \sa class Eval */
|
||||
template<typename Scalar, typename Derived>
|
||||
const Eval<Derived> MatrixBase<Scalar, Derived>::eval() const
|
||||
template<typename Derived>
|
||||
const Eval<Derived> MatrixBase<Derived>::eval() const
|
||||
{
|
||||
return Eval<Derived>(*static_cast<const Derived*>(this));
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ template<typename ExpressionType> class EvalOMP : NoOperatorEquals,
|
||||
*
|
||||
* \sa class EvalOMP, eval()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const EvalOMP<Derived> MatrixBase<Scalar, Derived>::evalOMP() const
|
||||
template<typename Derived>
|
||||
const EvalOMP<Derived> MatrixBase<Derived>::evalOMP() const
|
||||
{
|
||||
return EvalOMP<Derived>(*static_cast<const Derived*>(this));
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#ifndef 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 MatrixType> class MatrixRef;
|
||||
template<typename MatrixType> class Row;
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
*
|
||||
* \sa ei_isMuchSmallerThan(const RealScalar&, RealScalar) const
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
bool MatrixBase<Scalar, Derived>::isApprox(
|
||||
bool MatrixBase<Derived>::isApprox(
|
||||
const OtherDerived& other,
|
||||
typename NumTraits<Scalar>::Real prec
|
||||
) const
|
||||
@@ -71,10 +71,10 @@ bool MatrixBase<Scalar, Derived>::isApprox(
|
||||
* \f[ \Vert v \Vert \leqslant p\,\vert x\vert. \f]
|
||||
* 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>
|
||||
bool MatrixBase<Scalar, Derived>::isMuchSmallerThan(
|
||||
template<typename Derived>
|
||||
bool MatrixBase<Derived>::isMuchSmallerThan(
|
||||
const typename NumTraits<Scalar>::Real& other,
|
||||
typename NumTraits<Scalar>::Real prec
|
||||
) const
|
||||
@@ -102,10 +102,10 @@ bool MatrixBase<Scalar, Derived>::isMuchSmallerThan(
|
||||
*
|
||||
* \sa isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
bool MatrixBase<Scalar, Derived>::isMuchSmallerThan(
|
||||
const MatrixBase<Scalar, OtherDerived>& other,
|
||||
bool MatrixBase<Derived>::isMuchSmallerThan(
|
||||
const MatrixBase<OtherDerived>& other,
|
||||
typename NumTraits<Scalar>::Real prec
|
||||
) const
|
||||
{
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
*
|
||||
* 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 & s,
|
||||
const MatrixBase<Scalar, Derived> & m )
|
||||
const MatrixBase<Derived> & m )
|
||||
{
|
||||
for( int i = 0; i < m.rows(); i++ )
|
||||
{
|
||||
|
||||
@@ -31,14 +31,18 @@
|
||||
*
|
||||
* \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,
|
||||
public MatrixBase<typename MatrixType::Scalar, Identity<MatrixType> >
|
||||
public MatrixBase<Identity<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Identity>;
|
||||
friend class MatrixBase<Scalar, Identity>::Traits;
|
||||
typedef MatrixBase<Scalar, Identity> Base;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
friend class MatrixBase<Identity>;
|
||||
friend class MatrixBase<Identity>::Traits;
|
||||
typedef MatrixBase<Identity> Base;
|
||||
|
||||
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()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Identity<Derived> MatrixBase<Scalar, Derived>::identity(int rows, int cols)
|
||||
template<typename Derived>
|
||||
const Identity<Derived> MatrixBase<Derived>::identity(int rows, int 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()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Identity<Derived> MatrixBase<Scalar, Derived>::identity()
|
||||
template<typename Derived>
|
||||
const Identity<Derived> MatrixBase<Derived>::identity()
|
||||
{
|
||||
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()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
bool MatrixBase<Scalar, Derived>::isIdentity
|
||||
template<typename Derived>
|
||||
bool MatrixBase<Derived>::isIdentity
|
||||
(typename NumTraits<Scalar>::Real prec) const
|
||||
{
|
||||
for(int j = 0; j < cols(); j++)
|
||||
@@ -145,8 +149,8 @@ bool MatrixBase<Scalar, Derived>::isIdentity
|
||||
*
|
||||
* \sa class Identity, identity(), identity(int,int), isIdentity()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Derived& MatrixBase<Scalar, Derived>::setIdentity()
|
||||
template<typename Derived>
|
||||
Derived& MatrixBase<Derived>::setIdentity()
|
||||
{
|
||||
return *this = Identity<Derived>(rows(), cols());
|
||||
}
|
||||
|
||||
@@ -38,14 +38,18 @@
|
||||
*
|
||||
* \sa Matrix::map()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Map<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType> class Map
|
||||
: public MatrixBase<typename MatrixType::Scalar, Map<MatrixType> >
|
||||
: public MatrixBase<Map<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Map>;
|
||||
friend class MatrixBase<Scalar, Map>::Traits;
|
||||
typedef MatrixBase<Scalar, Map> Base;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
friend class MatrixBase<Map>;
|
||||
friend class MatrixBase<Map>::Traits;
|
||||
typedef MatrixBase<Map> Base;
|
||||
|
||||
private:
|
||||
enum {
|
||||
|
||||
@@ -71,20 +71,24 @@
|
||||
*
|
||||
* 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,
|
||||
int _StorageOrder = EIGEN_DEFAULT_MATRIX_STORAGE_ORDER,
|
||||
int _MaxRows = _Rows, int _MaxCols = _Cols>
|
||||
class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
|
||||
_StorageOrder, _MaxRows, _MaxCols> >
|
||||
class Matrix : public MatrixBase<Matrix<_Scalar, _Rows, _Cols,
|
||||
_StorageOrder, _MaxRows, _MaxCols> >
|
||||
{
|
||||
public:
|
||||
friend class MatrixBase<_Scalar, Matrix>;
|
||||
friend class MatrixBase<_Scalar, Matrix>::Traits;
|
||||
friend class MatrixBase<Matrix>;
|
||||
friend class MatrixBase<Matrix>::Traits;
|
||||
friend class Map<Matrix>;
|
||||
|
||||
typedef MatrixBase<_Scalar, Matrix> Base;
|
||||
typedef _Scalar Scalar;
|
||||
typedef MatrixRef<Matrix> AsArg;
|
||||
typedef MatrixBase<Matrix> Base;
|
||||
typedef typename Scalar<Matrix>::Type Scalar;
|
||||
typedef MatrixRef<Matrix> AsArg;
|
||||
friend class MatrixRef<Matrix>;
|
||||
|
||||
private:
|
||||
@@ -150,7 +154,7 @@ class Matrix : public MatrixBase<_Scalar, Matrix<_Scalar, _Rows, _Cols,
|
||||
* row-vectors remain row-vectors and vectors remain vectors.
|
||||
*/
|
||||
template<typename OtherDerived>
|
||||
Matrix& operator=(const MatrixBase<Scalar, OtherDerived>& other)
|
||||
Matrix& operator=(const MatrixBase<OtherDerived>& other)
|
||||
{
|
||||
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 */
|
||||
template<typename OtherDerived>
|
||||
Matrix(const MatrixBase<Scalar, OtherDerived>& other)
|
||||
Matrix(const MatrixBase<OtherDerived>& other)
|
||||
: m_storage(other.rows() * other.cols(), other.rows(), other.cols())
|
||||
{
|
||||
*this = other;
|
||||
|
||||
@@ -32,9 +32,6 @@
|
||||
* 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.
|
||||
*
|
||||
* \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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* \code
|
||||
template<typename Scalar, typename Derived>
|
||||
void printFirstRow(const Eigen::MatrixBase<Scalar, Derived>& x)
|
||||
template<typename Derived>
|
||||
void printFirstRow(const Eigen::MatrixBase<Derived>& x)
|
||||
{
|
||||
cout << x.row(0) << endl;
|
||||
}
|
||||
@@ -52,12 +49,14 @@
|
||||
*
|
||||
* \nosubgrouping
|
||||
*/
|
||||
template<typename Scalar, typename Derived> class MatrixBase
|
||||
template<typename Derived> class MatrixBase
|
||||
{
|
||||
struct CommaInitializer;
|
||||
|
||||
public:
|
||||
|
||||
typedef typename Scalar<Derived>::Type Scalar;
|
||||
|
||||
/** \brief Some traits provided by the Derived type.
|
||||
*
|
||||
* 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. */
|
||||
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
|
||||
* 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);
|
||||
|
||||
template<typename OtherDerived>
|
||||
CommaInitializer operator<< (const MatrixBase<Scalar, OtherDerived>& other);
|
||||
CommaInitializer operator<< (const MatrixBase<OtherDerived>& 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.
|
||||
*/
|
||||
template<typename OtherDerived>
|
||||
void swap(const MatrixBase<Scalar, OtherDerived>& other);
|
||||
void swap(const MatrixBase<OtherDerived>& other);
|
||||
|
||||
/// \name sub-matrices
|
||||
//@{
|
||||
@@ -252,7 +251,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
Scalar trace() const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
Scalar dot(const MatrixBase<Scalar, OtherDerived>& other) const;
|
||||
Scalar dot(const MatrixBase<OtherDerived>& other) const;
|
||||
RealScalar norm2() const;
|
||||
RealScalar norm() const;
|
||||
//@}
|
||||
@@ -282,7 +281,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
bool isDiagonal(RealScalar prec = precision<Scalar>()) const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
bool isOrtho(const MatrixBase<Scalar, OtherDerived>& other,
|
||||
bool isOrtho(const MatrixBase<OtherDerived>& other,
|
||||
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,
|
||||
RealScalar prec = precision<Scalar>()) const;
|
||||
template<typename OtherDerived>
|
||||
bool isMuchSmallerThan(const MatrixBase<Scalar, OtherDerived>& other,
|
||||
bool isMuchSmallerThan(const MatrixBase<OtherDerived>& other,
|
||||
RealScalar prec = precision<Scalar>()) const;
|
||||
//@}
|
||||
|
||||
@@ -301,11 +300,11 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
const CwiseUnaryOp<ScalarOppositeOp,Derived> operator-() const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
Derived& operator+=(const MatrixBase<Scalar, OtherDerived>& other);
|
||||
Derived& operator+=(const MatrixBase<OtherDerived>& other);
|
||||
template<typename OtherDerived>
|
||||
Derived& operator-=(const MatrixBase<Scalar, OtherDerived>& other);
|
||||
Derived& operator-=(const MatrixBase<OtherDerived>& other);
|
||||
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);
|
||||
@@ -319,17 +318,17 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
|
||||
template<typename 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;
|
||||
|
||||
template<typename OtherDerived>
|
||||
const CwiseBinaryOp<ScalarProductOp, Derived, OtherDerived>
|
||||
cwiseProduct(const MatrixBase<Scalar, OtherDerived> &other) const;
|
||||
cwiseProduct(const MatrixBase<OtherDerived> &other) const;
|
||||
|
||||
template<typename OtherDerived>
|
||||
const CwiseBinaryOp<ScalarQuotientOp, Derived, OtherDerived>
|
||||
cwiseQuotient(const MatrixBase<Scalar, OtherDerived> &other) const;
|
||||
cwiseQuotient(const MatrixBase<OtherDerived> &other) const;
|
||||
//@}
|
||||
|
||||
/// \name coefficient accessors
|
||||
@@ -366,7 +365,7 @@ template<typename Scalar, typename Derived> class MatrixBase
|
||||
|
||||
template<typename CustomBinaryOp, typename 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
|
||||
|
||||
@@ -25,14 +25,18 @@
|
||||
#ifndef 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
|
||||
: public MatrixBase<typename MatrixType::Scalar, MatrixRef<MatrixType> >
|
||||
: public MatrixBase<MatrixRef<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, MatrixRef>;
|
||||
friend class MatrixBase<Scalar, MatrixRef>::Traits;
|
||||
typedef MatrixBase<Scalar, MatrixRef> Base;
|
||||
typedef typename Scalar<MatrixRef>::Type Scalar;
|
||||
friend class MatrixBase<MatrixRef>;
|
||||
friend class MatrixBase<MatrixRef>::Traits;
|
||||
typedef MatrixBase<MatrixRef> Base;
|
||||
|
||||
MatrixRef(const MatrixType& matrix) : m_matrix(matrix) {}
|
||||
~MatrixRef() {}
|
||||
|
||||
@@ -37,15 +37,19 @@
|
||||
*
|
||||
* \sa MatrixBase::minor()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Minor<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType> class Minor
|
||||
: public MatrixBase<typename MatrixType::Scalar, Minor<MatrixType> >
|
||||
: public MatrixBase<Minor<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Scalar, Minor>;
|
||||
friend class MatrixBase<Scalar, Minor>::Traits;
|
||||
typedef MatrixBase<Scalar, Minor> Base;
|
||||
friend class MatrixBase<Minor>;
|
||||
friend class MatrixBase<Minor>::Traits;
|
||||
typedef MatrixBase<Minor> Base;
|
||||
|
||||
Minor(const MatRef& matrix,
|
||||
int row, int col)
|
||||
@@ -97,17 +101,17 @@ template<typename MatrixType> class Minor
|
||||
*
|
||||
* \sa class Minor
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
Minor<Derived>
|
||||
MatrixBase<Scalar, Derived>::minor(int row, int col)
|
||||
MatrixBase<Derived>::minor(int row, int col)
|
||||
{
|
||||
return Minor<Derived>(asArg(), row, col);
|
||||
}
|
||||
|
||||
/** This is the const version of minor(). */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename 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);
|
||||
}
|
||||
|
||||
@@ -32,14 +32,18 @@
|
||||
* \sa MatrixBase::ones(), MatrixBase::ones(int), MatrixBase::ones(int,int),
|
||||
* MatrixBase::setOnes(), MatrixBase::isOnes()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Ones<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType> class Ones : NoOperatorEquals,
|
||||
public MatrixBase<typename MatrixType::Scalar, Ones<MatrixType> >
|
||||
public MatrixBase<Ones<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Ones>;
|
||||
friend class MatrixBase<Scalar, Ones>::Traits;
|
||||
typedef MatrixBase<Scalar, Ones> Base;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
friend class MatrixBase<Ones>;
|
||||
friend class MatrixBase<Ones>::Traits;
|
||||
typedef MatrixBase<Ones> Base;
|
||||
|
||||
private:
|
||||
enum {
|
||||
@@ -86,8 +90,8 @@ template<typename MatrixType> class Ones : NoOperatorEquals,
|
||||
*
|
||||
* \sa ones(), ones(int), isOnes(), class Ones
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int rows, int cols)
|
||||
template<typename Derived>
|
||||
const Ones<Derived> MatrixBase<Derived>::ones(int rows, int 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
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Ones<Derived> MatrixBase<Scalar, Derived>::ones(int size)
|
||||
template<typename Derived>
|
||||
const Ones<Derived> MatrixBase<Derived>::ones(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
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
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Ones<Derived> MatrixBase<Scalar, Derived>::ones()
|
||||
template<typename Derived>
|
||||
const Ones<Derived> MatrixBase<Derived>::ones()
|
||||
{
|
||||
return Ones<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||
}
|
||||
@@ -140,8 +144,8 @@ const Ones<Derived> MatrixBase<Scalar, Derived>::ones()
|
||||
*
|
||||
* \sa class Ones, ones()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
bool MatrixBase<Scalar, Derived>::isOnes
|
||||
template<typename Derived>
|
||||
bool MatrixBase<Derived>::isOnes
|
||||
(typename NumTraits<Scalar>::Real prec) const
|
||||
{
|
||||
for(int j = 0; j < cols(); j++)
|
||||
@@ -158,8 +162,8 @@ bool MatrixBase<Scalar, Derived>::isOnes
|
||||
*
|
||||
* \sa class Ones, ones()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Derived& MatrixBase<Scalar, Derived>::setOnes()
|
||||
template<typename Derived>
|
||||
Derived& MatrixBase<Derived>::setOnes()
|
||||
{
|
||||
return *this = Ones<Derived>(rows(), cols());
|
||||
}
|
||||
|
||||
@@ -97,10 +97,10 @@ struct VectorOperatorEqualsUnroller<Derived1, Derived2, Dynamic>
|
||||
static void run(Derived1 &, const Derived2 &) {}
|
||||
};
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
Derived& MatrixBase<Scalar, Derived>
|
||||
::operator=(const MatrixBase<Scalar, OtherDerived>& other)
|
||||
Derived& MatrixBase<Derived>
|
||||
::operator=(const MatrixBase<OtherDerived>& other)
|
||||
{
|
||||
if(Traits::IsVectorAtCompileTime && OtherDerived::Traits::IsVectorAtCompileTime)
|
||||
// copying a vector expression into a vector
|
||||
|
||||
@@ -72,16 +72,20 @@ struct ProductUnroller<Index, 0, Lhs, Rhs>
|
||||
*
|
||||
* \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,
|
||||
public MatrixBase<typename Lhs::Scalar, Product<Lhs, Rhs> >
|
||||
public MatrixBase<Product<Lhs, Rhs> >
|
||||
{
|
||||
public:
|
||||
typedef typename Lhs::Scalar Scalar;
|
||||
typedef typename Scalar<Lhs>::Type Scalar;
|
||||
typedef typename Lhs::AsArg LhsRef;
|
||||
typedef typename Rhs::AsArg RhsRef;
|
||||
friend class MatrixBase<Scalar, Product>;
|
||||
friend class MatrixBase<Scalar, Product>::Traits;
|
||||
typedef MatrixBase<Scalar, Product> Base;
|
||||
friend class MatrixBase<Product>;
|
||||
friend class MatrixBase<Product>::Traits;
|
||||
typedef MatrixBase<Product> Base;
|
||||
|
||||
Product(const LhsRef& lhs, const RhsRef& rhs)
|
||||
: m_lhs(lhs), m_rhs(rhs)
|
||||
@@ -134,10 +138,10 @@ template<typename Lhs, typename Rhs> class Product : NoOperatorEquals,
|
||||
*
|
||||
* \sa class Product
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename 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());
|
||||
}
|
||||
@@ -152,9 +156,9 @@ MatrixBase<Scalar, Derived>::lazyProduct(const MatrixBase<Scalar, OtherDerived>
|
||||
*
|
||||
* \sa MatrixBase::lazyProduct(), MatrixBase::operator*=(const MatrixBase&)
|
||||
*/
|
||||
template<typename Scalar, typename Derived1, typename Derived2>
|
||||
template<typename Derived1, typename 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();
|
||||
}
|
||||
@@ -163,10 +167,10 @@ operator*(const MatrixBase<Scalar, Derived1> &mat1, const MatrixBase<Scalar, Der
|
||||
*
|
||||
* \returns a reference to \c *this
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
Derived &
|
||||
MatrixBase<Scalar, Derived>::operator*=(const MatrixBase<Scalar, OtherDerived> &other)
|
||||
MatrixBase<Derived>::operator*=(const MatrixBase<OtherDerived> &other)
|
||||
{
|
||||
return *this = *this * other;
|
||||
}
|
||||
|
||||
@@ -32,14 +32,18 @@
|
||||
* \sa MatrixBase::random(), MatrixBase::random(int), MatrixBase::random(int,int),
|
||||
* MatrixBase::setRandom()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Random<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType> class Random : NoOperatorEquals,
|
||||
public MatrixBase<typename MatrixType::Scalar, Random<MatrixType> >
|
||||
public MatrixBase<Random<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Random>;
|
||||
friend class MatrixBase<Scalar, Random>::Traits;
|
||||
typedef MatrixBase<Scalar, Random> Base;
|
||||
friend class MatrixBase<Random>;
|
||||
friend class MatrixBase<Random>::Traits;
|
||||
typedef MatrixBase<Random> Base;
|
||||
|
||||
private:
|
||||
enum {
|
||||
@@ -86,9 +90,9 @@ template<typename MatrixType> class Random : NoOperatorEquals,
|
||||
*
|
||||
* \sa ei_random(), ei_random(int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename 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();
|
||||
}
|
||||
@@ -109,9 +113,9 @@ MatrixBase<Scalar, Derived>::random(int rows, int cols)
|
||||
*
|
||||
* \sa ei_random(), ei_random(int,int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const Eval<Random<Derived> >
|
||||
MatrixBase<Scalar, Derived>::random(int size)
|
||||
MatrixBase<Derived>::random(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
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)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const Eval<Random<Derived> >
|
||||
MatrixBase<Scalar, Derived>::random()
|
||||
MatrixBase<Derived>::random()
|
||||
{
|
||||
return Random<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime).eval();
|
||||
}
|
||||
@@ -143,8 +147,8 @@ MatrixBase<Scalar, Derived>::random()
|
||||
*
|
||||
* \sa class Random, ei_random()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Derived& MatrixBase<Scalar, Derived>::setRandom()
|
||||
template<typename Derived>
|
||||
Derived& MatrixBase<Derived>::setRandom()
|
||||
{
|
||||
return *this = Random<Derived>(rows(), cols());
|
||||
}
|
||||
|
||||
@@ -45,15 +45,19 @@
|
||||
*
|
||||
* \sa MatrixBase::row()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Row<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType> class Row
|
||||
: public MatrixBase<typename MatrixType::Scalar, Row<MatrixType> >
|
||||
: public MatrixBase<Row<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Scalar, Row>;
|
||||
friend class MatrixBase<Scalar, Row>::Traits;
|
||||
typedef MatrixBase<Scalar, Row> Base;
|
||||
friend class MatrixBase<Row>;
|
||||
friend class MatrixBase<Row>::Traits;
|
||||
typedef MatrixBase<Row> Base;
|
||||
|
||||
Row(const MatRef& matrix, int row)
|
||||
: m_matrix(matrix), m_row(row)
|
||||
@@ -61,12 +65,6 @@ template<typename MatrixType> class Row
|
||||
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)
|
||||
|
||||
private:
|
||||
@@ -103,17 +101,17 @@ template<typename MatrixType> class Row
|
||||
* Output: \verbinclude MatrixBase_row.out
|
||||
*
|
||||
* \sa col(), class Row */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
Row<Derived>
|
||||
MatrixBase<Scalar, Derived>::row(int i)
|
||||
MatrixBase<Derived>::row(int i)
|
||||
{
|
||||
return Row<Derived>(asArg(), i);
|
||||
}
|
||||
|
||||
/** This is the const version of row(). */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const Row<Derived>
|
||||
MatrixBase<Scalar, Derived>::row(int i) const
|
||||
MatrixBase<Derived>::row(int i) const
|
||||
{
|
||||
return Row<Derived>(asArg(), i);
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
#ifndef EIGEN_SWAP_H
|
||||
#define EIGEN_SWAP_H
|
||||
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
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)
|
||||
{
|
||||
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.
|
||||
*
|
||||
* \sa diagonal() */
|
||||
template<typename Scalar, typename Derived>
|
||||
Scalar MatrixBase<Scalar, Derived>::trace() const
|
||||
template<typename Derived>
|
||||
typename Scalar<Derived>::Type
|
||||
MatrixBase<Derived>::trace() const
|
||||
{
|
||||
assert(rows() == cols());
|
||||
Scalar res;
|
||||
|
||||
@@ -37,15 +37,19 @@
|
||||
*
|
||||
* \sa MatrixBase::transpose(), MatrixBase::adjoint()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Transpose<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType> class Transpose
|
||||
: public MatrixBase<typename MatrixType::Scalar, Transpose<MatrixType> >
|
||||
: public MatrixBase<Transpose<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
typedef typename MatrixType::AsArg MatRef;
|
||||
friend class MatrixBase<Scalar, Transpose>;
|
||||
friend class MatrixBase<Scalar, Transpose>::Traits;
|
||||
typedef MatrixBase<Scalar, Transpose> Base;
|
||||
friend class MatrixBase<Transpose>;
|
||||
friend class MatrixBase<Transpose>::Traits;
|
||||
typedef MatrixBase<Transpose> Base;
|
||||
|
||||
Transpose(const MatRef& matrix) : m_matrix(matrix) {}
|
||||
|
||||
@@ -83,17 +87,17 @@ template<typename MatrixType> class Transpose
|
||||
* Output: \verbinclude MatrixBase_transpose.out
|
||||
*
|
||||
* \sa adjoint(), class DiagonalCoeffs */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
Transpose<Derived>
|
||||
MatrixBase<Scalar, Derived>::transpose()
|
||||
MatrixBase<Derived>::transpose()
|
||||
{
|
||||
return Transpose<Derived>(asArg());
|
||||
}
|
||||
|
||||
/** This is the const version of transpose(). \sa adjoint() */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const Transpose<Derived>
|
||||
MatrixBase<Scalar, Derived>::transpose() const
|
||||
MatrixBase<Derived>::transpose() const
|
||||
{
|
||||
return Transpose<Derived>(asArg());
|
||||
}
|
||||
@@ -104,9 +108,9 @@ MatrixBase<Scalar, Derived>::transpose() const
|
||||
* Output: \verbinclude MatrixBase_adjoint.out
|
||||
*
|
||||
* \sa transpose(), conjugate(), class Transpose, class ScalarConjugateOp */
|
||||
template<typename Scalar, typename Derived>
|
||||
template<typename Derived>
|
||||
const Transpose<CwiseUnaryOp<ScalarConjugateOp, Derived> >
|
||||
MatrixBase<Scalar, Derived>::adjoint() const
|
||||
MatrixBase<Derived>::adjoint() const
|
||||
{
|
||||
return conjugate().transpose();
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ using Eigen::MatrixBase;
|
||||
#endif
|
||||
|
||||
#define EIGEN_INHERIT_ASSIGNMENT_OPERATOR(Derived, Op) \
|
||||
template<typename OtherScalar, typename OtherDerived> \
|
||||
Derived& operator Op(const MatrixBase<OtherScalar, OtherDerived>& other) \
|
||||
template<typename OtherDerived> \
|
||||
Derived& operator Op(const MatrixBase<OtherDerived>& other) \
|
||||
{ \
|
||||
return Base::operator Op(other); \
|
||||
} \
|
||||
|
||||
@@ -32,14 +32,18 @@
|
||||
* \sa MatrixBase::zero(), MatrixBase::zero(int), MatrixBase::zero(int,int),
|
||||
* MatrixBase::setZero(), MatrixBase::isZero()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
struct Scalar<Zero<MatrixType> >
|
||||
{ typedef typename Scalar<MatrixType>::Type Type; };
|
||||
|
||||
template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||
public MatrixBase<typename MatrixType::Scalar, Zero<MatrixType> >
|
||||
public MatrixBase<Zero<MatrixType> >
|
||||
{
|
||||
public:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
friend class MatrixBase<Scalar, Zero>;
|
||||
friend class MatrixBase<Scalar, Zero>::Traits;
|
||||
typedef MatrixBase<Scalar, Zero> Base;
|
||||
typedef typename Scalar<MatrixType>::Type Scalar;
|
||||
friend class MatrixBase<Zero>;
|
||||
friend class MatrixBase<Zero>::Traits;
|
||||
typedef MatrixBase<Zero> Base;
|
||||
|
||||
private:
|
||||
enum {
|
||||
@@ -86,8 +90,8 @@ template<typename MatrixType> class Zero : NoOperatorEquals,
|
||||
*
|
||||
* \sa zero(), zero(int)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int rows, int cols)
|
||||
template<typename Derived>
|
||||
const Zero<Derived> MatrixBase<Derived>::zero(int rows, int 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)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Zero<Derived> MatrixBase<Scalar, Derived>::zero(int size)
|
||||
template<typename Derived>
|
||||
const Zero<Derived> MatrixBase<Derived>::zero(int size)
|
||||
{
|
||||
assert(Traits::IsVectorAtCompileTime);
|
||||
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)
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
const Zero<Derived> MatrixBase<Scalar, Derived>::zero()
|
||||
template<typename Derived>
|
||||
const Zero<Derived> MatrixBase<Derived>::zero()
|
||||
{
|
||||
return Zero<Derived>(Traits::RowsAtCompileTime, Traits::ColsAtCompileTime);
|
||||
}
|
||||
@@ -140,8 +144,8 @@ const Zero<Derived> MatrixBase<Scalar, Derived>::zero()
|
||||
*
|
||||
* \sa class Zero, zero()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
bool MatrixBase<Scalar, Derived>::isZero
|
||||
template<typename Derived>
|
||||
bool MatrixBase<Derived>::isZero
|
||||
(typename NumTraits<Scalar>::Real prec) const
|
||||
{
|
||||
for(int j = 0; j < cols(); j++)
|
||||
@@ -158,8 +162,8 @@ bool MatrixBase<Scalar, Derived>::isZero
|
||||
*
|
||||
* \sa class Zero, zero()
|
||||
*/
|
||||
template<typename Scalar, typename Derived>
|
||||
Derived& MatrixBase<Scalar, Derived>::setZero()
|
||||
template<typename Derived>
|
||||
Derived& MatrixBase<Derived>::setZero()
|
||||
{
|
||||
return *this = Zero<Derived>(rows(), cols());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user