diff options
author | Abraham Bachrach <abachrach@gmail.com> | 2012-01-11 11:00:30 -0500 |
---|---|---|
committer | Abraham Bachrach <abachrach@gmail.com> | 2012-01-11 11:00:30 -0500 |
commit | 039408cd66fdf106e153169c250a6ad696b84af3 (patch) | |
tree | e8969d50b4f05424fb18d61f10b7d8bf98ec5f19 /Eigen/src/plugins/ArrayCwiseBinaryOps.h | |
parent | 238999045c0c870834620d9d86a0254d2dd2f6d6 (diff) |
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
Diffstat (limited to 'Eigen/src/plugins/ArrayCwiseBinaryOps.h')
-rw-r--r-- | Eigen/src/plugins/ArrayCwiseBinaryOps.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Eigen/src/plugins/ArrayCwiseBinaryOps.h b/Eigen/src/plugins/ArrayCwiseBinaryOps.h index c5eaaa6fa..5b979ebf8 100644 --- a/Eigen/src/plugins/ArrayCwiseBinaryOps.h +++ b/Eigen/src/plugins/ArrayCwiseBinaryOps.h @@ -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 |