mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-12 19:59:05 +08:00
Added a test to validate the behavior of some of the tensor syntactic sugar.
This commit is contained in:
parent
9f5740cbc1
commit
e5f25622e2
@ -32,7 +32,30 @@ static void test_comparison_sugar() {
|
|||||||
#undef TEST_TENSOR_EQUAL
|
#undef TEST_TENSOR_EQUAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void test_scalar_sugar() {
|
||||||
|
Tensor<float, 3> A(6, 7, 5);
|
||||||
|
Tensor<float, 3> B(6, 7, 5);
|
||||||
|
A.setRandom();
|
||||||
|
B.setRandom();
|
||||||
|
|
||||||
|
const float alpha = 0.43f;
|
||||||
|
const float beta = 0.21f;
|
||||||
|
|
||||||
|
Tensor<float, 3> R = A * A.constant(alpha) + B * B.constant(beta);
|
||||||
|
Tensor<float, 3> S = A * alpha + B * beta;
|
||||||
|
|
||||||
|
// TODO: add enough syntactic sugar to support this
|
||||||
|
// Tensor<float, 3> T = alpha * A + beta * B;
|
||||||
|
|
||||||
|
for (int i = 0; i < 6*7*5; ++i) {
|
||||||
|
VERIFY_IS_APPROX(R(i), S(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_cxx11_tensor_sugar()
|
void test_cxx11_tensor_sugar()
|
||||||
{
|
{
|
||||||
CALL_SUBTEST(test_comparison_sugar());
|
CALL_SUBTEST(test_comparison_sugar());
|
||||||
|
CALL_SUBTEST(test_scalar_sugar());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user