mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-07 21:51:47 +08:00
Fix documentation of MatrixBase::applyOnTheLeft (bug #739)
Add examples; move methods from EigenBase.h to MatrixBase.h (grafted from 7ea6ef89693b0d70db29ccad1a3cc7771195e318 )
This commit is contained in:
parent
6a4489c523
commit
b5333b6760
@ -126,36 +126,6 @@ Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived> &other)
|
|||||||
return derived();
|
return derived();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** replaces \c *this by \c *this * \a other.
|
|
||||||
*
|
|
||||||
* \returns a reference to \c *this
|
|
||||||
*/
|
|
||||||
template<typename Derived>
|
|
||||||
template<typename OtherDerived>
|
|
||||||
inline Derived&
|
|
||||||
MatrixBase<Derived>::operator*=(const EigenBase<OtherDerived> &other)
|
|
||||||
{
|
|
||||||
other.derived().applyThisOnTheRight(derived());
|
|
||||||
return derived();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** replaces \c *this by \c *this * \a other. It is equivalent to MatrixBase::operator*=().
|
|
||||||
*/
|
|
||||||
template<typename Derived>
|
|
||||||
template<typename OtherDerived>
|
|
||||||
inline void MatrixBase<Derived>::applyOnTheRight(const EigenBase<OtherDerived> &other)
|
|
||||||
{
|
|
||||||
other.derived().applyThisOnTheRight(derived());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** replaces \c *this by \c *this * \a other. */
|
|
||||||
template<typename Derived>
|
|
||||||
template<typename OtherDerived>
|
|
||||||
inline void MatrixBase<Derived>::applyOnTheLeft(const EigenBase<OtherDerived> &other)
|
|
||||||
{
|
|
||||||
other.derived().applyThisOnTheLeft(derived());
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_EIGENBASE_H
|
#endif // EIGEN_EIGENBASE_H
|
||||||
|
@ -510,6 +510,51 @@ template<typename Derived> class MatrixBase
|
|||||||
{EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
|
{EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************************************
|
||||||
|
* Implementation of matrix base methods
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/** replaces \c *this by \c *this * \a other.
|
||||||
|
*
|
||||||
|
* \returns a reference to \c *this
|
||||||
|
*
|
||||||
|
* Example: \include MatrixBase_applyOnTheRight.cpp
|
||||||
|
* Output: \verbinclude MatrixBase_applyOnTheRight.out
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
template<typename OtherDerived>
|
||||||
|
inline Derived&
|
||||||
|
MatrixBase<Derived>::operator*=(const EigenBase<OtherDerived> &other)
|
||||||
|
{
|
||||||
|
other.derived().applyThisOnTheRight(derived());
|
||||||
|
return derived();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** replaces \c *this by \c *this * \a other. It is equivalent to MatrixBase::operator*=().
|
||||||
|
*
|
||||||
|
* Example: \include MatrixBase_applyOnTheRight.cpp
|
||||||
|
* Output: \verbinclude MatrixBase_applyOnTheRight.out
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
template<typename OtherDerived>
|
||||||
|
inline void MatrixBase<Derived>::applyOnTheRight(const EigenBase<OtherDerived> &other)
|
||||||
|
{
|
||||||
|
other.derived().applyThisOnTheRight(derived());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** replaces \c *this by \a other * \c *this.
|
||||||
|
*
|
||||||
|
* Example: \include MatrixBase_applyOnTheLeft.cpp
|
||||||
|
* Output: \verbinclude MatrixBase_applyOnTheLeft.out
|
||||||
|
*/
|
||||||
|
template<typename Derived>
|
||||||
|
template<typename OtherDerived>
|
||||||
|
inline void MatrixBase<Derived>::applyOnTheLeft(const EigenBase<OtherDerived> &other)
|
||||||
|
{
|
||||||
|
other.derived().applyThisOnTheLeft(derived());
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#endif // EIGEN_MATRIXBASE_H
|
#endif // EIGEN_MATRIXBASE_H
|
||||||
|
7
doc/snippets/MatrixBase_applyOnTheLeft.cpp
Normal file
7
doc/snippets/MatrixBase_applyOnTheLeft.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Matrix3f A = Matrix3f::Random(3,3), B;
|
||||||
|
B << 0,1,0,
|
||||||
|
0,0,1,
|
||||||
|
1,0,0;
|
||||||
|
cout << "At start, A = " << endl << A << endl;
|
||||||
|
A.applyOnTheLeft(B);
|
||||||
|
cout << "After applyOnTheLeft, A = " << endl << A << endl;
|
9
doc/snippets/MatrixBase_applyOnTheRight.cpp
Normal file
9
doc/snippets/MatrixBase_applyOnTheRight.cpp
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Matrix3f A = Matrix3f::Random(3,3), B;
|
||||||
|
B << 0,1,0,
|
||||||
|
0,0,1,
|
||||||
|
1,0,0;
|
||||||
|
cout << "At start, A = " << endl << A << endl;
|
||||||
|
A *= B;
|
||||||
|
cout << "After A *= B, A = " << endl << A << endl;
|
||||||
|
A.applyOnTheRight(B); // equivalent to A *= B
|
||||||
|
cout << "After applyOnTheRight, A = " << endl << A << endl;
|
Loading…
x
Reference in New Issue
Block a user