mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
Add unit test for CoeffReadCost
This commit is contained in:
parent
321cb56bf6
commit
78b8c344b5
@ -94,6 +94,7 @@ namespace Eigen {
|
||||
|
||||
}
|
||||
|
||||
template<typename XprType> long get_cost(const XprType& ) { return Eigen::internal::evaluator<XprType>::CoeffReadCost; }
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -470,7 +471,6 @@ void test_evaluators()
|
||||
VERIFY_IS_APPROX_EVALUATOR2(B, prod(A.triangularView<Upper>(),A), MatrixXd(A.triangularView<Upper>()*A));
|
||||
|
||||
VERIFY_IS_APPROX_EVALUATOR2(B, prod(A.selfadjointView<Upper>(),A), MatrixXd(A.selfadjointView<Upper>()*A));
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
@ -481,6 +481,19 @@ void test_evaluators()
|
||||
|
||||
VERIFY_IS_APPROX_EVALUATOR2(B, lazyprod(d.asDiagonal(),A), MatrixXd(d.asDiagonal()*A));
|
||||
VERIFY_IS_APPROX_EVALUATOR2(B, lazyprod(A,d.asDiagonal()), MatrixXd(A*d.asDiagonal()));
|
||||
}
|
||||
|
||||
{
|
||||
// test CoeffReadCost
|
||||
Matrix4d a, b;
|
||||
VERIFY_IS_EQUAL( get_cost(a), 1 );
|
||||
VERIFY_IS_EQUAL( get_cost(a+b), 3);
|
||||
VERIFY_IS_EQUAL( get_cost(2*a+b), 4);
|
||||
VERIFY_IS_EQUAL( get_cost(a*b), 1);
|
||||
VERIFY_IS_EQUAL( get_cost(a.lazyProduct(b)), 15);
|
||||
VERIFY_IS_EQUAL( get_cost(a*(a*b)), 1);
|
||||
VERIFY_IS_EQUAL( get_cost(a.lazyProduct(a*b)), 15);
|
||||
VERIFY_IS_EQUAL( get_cost(a*(a+b)), 1);
|
||||
VERIFY_IS_EQUAL( get_cost(a.lazyProduct(a+b)), 15);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user