mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
added functions to allow for cwise min/max operations with scalar argument (bug #400).
added function for array.min(), array.max(), matrix.cwiseMin(), matrix.cwiseMax(). The matrix.cwiseMin/Max functions required the definition of the ConstantReturnType typedef. However, it wasn't defined until after MatrixCwiseBinaryOps was included in Eigen/src/SparseCore/SparseMatrixBase.h, so I moved those includes after the definition of the typedefs. tests for both the regular and scalar min/max functions were added as well
This commit is contained in:
@@ -29,6 +29,16 @@ operator/(const EIGEN_CURRENT_STORAGE_BASE_CLASS<OtherDerived> &other) const
|
||||
*/
|
||||
EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op)
|
||||
|
||||
/** \returns an expression of the coefficient-wise min of \c *this and scalar \a other
|
||||
*
|
||||
* \sa max()
|
||||
*/
|
||||
EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar>, const Derived, const ConstantReturnType>
|
||||
(min)(const Scalar &other) const
|
||||
{
|
||||
return (min)(Derived::PlainObject::Constant(rows(), cols(), other));
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise max of \c *this and \a other
|
||||
*
|
||||
* Example: \include Cwise_max.cpp
|
||||
@@ -38,6 +48,16 @@ EIGEN_MAKE_CWISE_BINARY_OP(min,internal::scalar_min_op)
|
||||
*/
|
||||
EIGEN_MAKE_CWISE_BINARY_OP(max,internal::scalar_max_op)
|
||||
|
||||
/** \returns an expression of the coefficient-wise max of \c *this and scalar \a other
|
||||
*
|
||||
* \sa min()
|
||||
*/
|
||||
EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived, const ConstantReturnType>
|
||||
(max)(const Scalar &other) const
|
||||
{
|
||||
return (max)(Derived::PlainObject::Constant(rows(), cols(), other));
|
||||
}
|
||||
|
||||
/** \returns an expression of the coefficient-wise \< operator of *this and \a other
|
||||
*
|
||||
* Example: \include Cwise_less.cpp
|
||||
|
||||
Reference in New Issue
Block a user