mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
-new: recursive costs system, useful to determine automatically
when to evaluate arguments and when to meta-unroll. -use it in Product to determine when to eval args. not yet used to determine when to unroll. for now, not used anywhere else but that'll follow. -fix badness of my last commit
This commit is contained in:
@@ -30,8 +30,9 @@
|
||||
|
||||
namespace Eigen {
|
||||
|
||||
struct AddIfNull {
|
||||
template<typename Scalar> Scalar operator() (const Scalar a, const Scalar b) const {return a<=1e-3 ? b : a;}
|
||||
template<typename Scalar> struct AddIfNull {
|
||||
const Scalar operator() (const Scalar a, const Scalar b) const {return a<=1e-3 ? b : a;}
|
||||
enum { Cost = NumTraits<Scalar>::AddCost };
|
||||
};
|
||||
|
||||
template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
@@ -55,7 +56,7 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
v2 = VectorType::random(rows),
|
||||
vzero = VectorType::zero(rows);
|
||||
|
||||
m2 = m2.template cwise<AddIfNull>(mones);
|
||||
m2 = m2.template cwise<AddIfNull<Scalar> >(mones);
|
||||
|
||||
VERIFY_IS_APPROX( mzero, m1-m1);
|
||||
VERIFY_IS_APPROX( m2, m1+m2-m1);
|
||||
|
||||
Reference in New Issue
Block a user