Lines 44-74
void test_evaluators()
Link Here
|
44 |
|
44 |
|
45 |
VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Zero()); |
45 |
VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Zero()); |
46 |
|
46 |
|
47 |
VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Constant(3)); |
47 |
VERIFY_IS_APPROX_EVALUATOR(w, RowVector2d::Constant(3)); |
48 |
|
48 |
|
49 |
// mix CwiseNullaryOp and transpose |
49 |
// mix CwiseNullaryOp and transpose |
50 |
VERIFY_IS_APPROX_EVALUATOR(w, Vector2d::Zero().transpose()); |
50 |
VERIFY_IS_APPROX_EVALUATOR(w, Vector2d::Zero().transpose()); |
51 |
|
51 |
|
52 |
{ |
52 |
// This fails because there is no evaluator for GeneralProduct, which is the expression |
53 |
int s = internal::random<int>(1,100); |
53 |
// type produced by operator* acting on matrices. |
54 |
MatrixXf a(s,s), b(s,s), c(s,s), d(s,s); |
54 |
// |
55 |
a.setRandom(); |
55 |
// { |
56 |
b.setRandom(); |
56 |
// int s = internal::random<int>(1,100); |
57 |
c.setRandom(); |
57 |
// MatrixXf a(s,s), b(s,s), c(s,s), d(s,s); |
58 |
d.setRandom(); |
58 |
// a.setRandom(); |
59 |
VERIFY_IS_APPROX_EVALUATOR(d, (a + b)); |
59 |
// b.setRandom(); |
60 |
VERIFY_IS_APPROX_EVALUATOR(d, (a + b).transpose()); |
60 |
// c.setRandom(); |
61 |
VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b).transpose(), (a*b).transpose()); |
61 |
// d.setRandom(); |
62 |
VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + prod(b,c), a*b + b*c); |
62 |
// VERIFY_IS_APPROX_EVALUATOR(d, (a + b)); |
63 |
|
63 |
// VERIFY_IS_APPROX_EVALUATOR(d, (a + b).transpose()); |
64 |
// copy_using_evaluator(d, a.transpose() + (a.transpose() * (b+b))); |
64 |
// VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b).transpose(), (a*b).transpose()); |
65 |
// cout << d << endl; |
65 |
// VERIFY_IS_APPROX_EVALUATOR2(d, prod(a,b) + prod(b,c), a*b + b*c); |
66 |
} |
66 |
// |
|
|
67 |
// copy_using_evaluator(d, a.transpose() + (a.transpose() * (b+b))); |
68 |
// cout << d << endl; |
69 |
// } |
67 |
|
70 |
|
68 |
// this does not work because Random is eval-before-nested: |
71 |
// this does not work because Random is eval-before-nested: |
69 |
// copy_using_evaluator(w, Vector2d::Random().transpose()); |
72 |
// copy_using_evaluator(w, Vector2d::Random().transpose()); |
70 |
|
73 |
|
71 |
// test CwiseUnaryOp |
74 |
// test CwiseUnaryOp |
72 |
VERIFY_IS_APPROX_EVALUATOR(v2, 3 * v); |
75 |
VERIFY_IS_APPROX_EVALUATOR(v2, 3 * v); |
73 |
VERIFY_IS_APPROX_EVALUATOR(w, (3 * v).transpose()); |
76 |
VERIFY_IS_APPROX_EVALUATOR(w, (3 * v).transpose()); |
74 |
VERIFY_IS_APPROX_EVALUATOR(b, (a + 3).transpose()); |
77 |
VERIFY_IS_APPROX_EVALUATOR(b, (a + 3).transpose()); |