mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-08 09:49:03 +08:00
add cwise operator *= and /=.
Keir says hi!!
This commit is contained in:
parent
28e15574df
commit
a30b498ab4
@ -418,6 +418,43 @@ inline ExpressionType& Cwise<ExpressionType>::operator+=(const Scalar& scalar)
|
||||
return m_matrix.const_cast_derived() = *this + scalar;
|
||||
}
|
||||
|
||||
|
||||
//=============
|
||||
|
||||
/** \array_module
|
||||
*
|
||||
* Replaces this expression by its coefficient-wise product with \a other.
|
||||
*
|
||||
* Example: \include Cwise_times_equal.cpp
|
||||
* Output: \verbinclude Cwise_times_equal.out
|
||||
*
|
||||
* \sa operator*(), operator/=()
|
||||
*/
|
||||
template<typename ExpressionType>
|
||||
template<typename OtherDerived>
|
||||
inline ExpressionType& Cwise<ExpressionType>::operator*=(const MatrixBase<OtherDerived> &other)
|
||||
{
|
||||
return m_matrix.const_cast_derived() = *this * other;
|
||||
}
|
||||
|
||||
/** \array_module
|
||||
*
|
||||
* Replaces this expression by its coefficient-wise quotient with \a other.
|
||||
*
|
||||
* Example: \include Cwise_slash_equal.cpp
|
||||
* Output: \verbinclude Cwise_slash_equal.out
|
||||
*
|
||||
* \sa operator/(), operator*=()
|
||||
*/
|
||||
template<typename ExpressionType>
|
||||
template<typename OtherDerived>
|
||||
inline ExpressionType& Cwise<ExpressionType>::operator/=(const MatrixBase<OtherDerived> &other)
|
||||
{
|
||||
return m_matrix.const_cast_derived() = *this / other;
|
||||
}
|
||||
|
||||
//=============
|
||||
|
||||
/** \array_module
|
||||
*
|
||||
* \returns an expression of \c *this with each coeff decremented by the constant \a scalar
|
||||
|
@ -128,6 +128,12 @@ template<typename ExpressionType> class Cwise
|
||||
|
||||
ExpressionType& operator-=(const Scalar& scalar);
|
||||
|
||||
template<typename OtherDerived>
|
||||
inline ExpressionType& operator*=(const MatrixBase<OtherDerived> &other);
|
||||
|
||||
template<typename OtherDerived>
|
||||
inline ExpressionType& operator/=(const MatrixBase<OtherDerived> &other);
|
||||
|
||||
template<typename OtherDerived> const EIGEN_CWISE_BINOP_RETURN_TYPE(std::less)
|
||||
operator<(const MatrixBase<OtherDerived>& other) const;
|
||||
|
||||
|
4
doc/snippets/Cwise_slash_equal.cpp
Normal file
4
doc/snippets/Cwise_slash_equal.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
Vector3d v(3,2,4);
|
||||
Vector3d w(5,4,2);
|
||||
v.cwise() /= w;
|
||||
cout << v << endl;
|
4
doc/snippets/Cwise_times_equal.cpp
Normal file
4
doc/snippets/Cwise_times_equal.cpp
Normal file
@ -0,0 +1,4 @@
|
||||
Vector3d v(1,2,3);
|
||||
Vector3d w(2,3,0);
|
||||
v.cwise() *= w;
|
||||
cout << v << endl;
|
Loading…
x
Reference in New Issue
Block a user