-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:
Benoit Jacob
2008-04-03 11:10:17 +00:00
parent e74fbfb2bc
commit d1a29d6319
28 changed files with 379 additions and 212 deletions

View File

@@ -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);