Bug #1785: Introduce numext::rint.

This provides a new op that matches std::rint and previous behavior of
pround. Also adds corresponding unsupported/../Tensor op.
Performance is the same as e. g. floor (tested SSE/AVX).
This commit is contained in:
Ilya Tokar
2019-12-16 16:00:35 -05:00
parent d0ae052da4
commit 19876ced76
12 changed files with 117 additions and 1 deletions

View File

@@ -32,6 +32,7 @@ typedef CwiseUnaryOp<internal::scalar_cosh_op<Scalar>, const Derived> CoshReturn
typedef CwiseUnaryOp<internal::scalar_square_op<Scalar>, const Derived> SquareReturnType;
typedef CwiseUnaryOp<internal::scalar_cube_op<Scalar>, const Derived> CubeReturnType;
typedef CwiseUnaryOp<internal::scalar_round_op<Scalar>, const Derived> RoundReturnType;
typedef CwiseUnaryOp<internal::scalar_rint_op<Scalar>, const Derived> RintReturnType;
typedef CwiseUnaryOp<internal::scalar_floor_op<Scalar>, const Derived> FloorReturnType;
typedef CwiseUnaryOp<internal::scalar_ceil_op<Scalar>, const Derived> CeilReturnType;
typedef CwiseUnaryOp<internal::scalar_isnan_op<Scalar>, const Derived> IsNaNReturnType;
@@ -427,6 +428,20 @@ cube() const
return CubeReturnType(derived());
}
/** \returns an expression of the coefficient-wise rint of *this.
*
* Example: \include Cwise_rint.cpp
* Output: \verbinclude Cwise_rint.out
*
* \sa <a href="group__CoeffwiseMathFunctions.html#cwisetable_rint">Math functions</a>, ceil(), floor()
*/
EIGEN_DEVICE_FUNC
inline const RintReturnType
rint() const
{
return RintReturnType(derived());
}
/** \returns an expression of the coefficient-wise round of *this.
*
* Example: \include Cwise_round.cpp