TensorAsExpressionRank0TestHelpers.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 
10 
11 namespace TestHelpers::TensorExpressions {
12 /// \ingroup TestingFrameworkGroup
13 /// \brief Test that the transformation between LHS and RHS multi-indices and
14 /// the subsequent computed RHS multi-index of a rank 0 tensor is correctly
15 /// computed by the functions of TensorAsExpression
16 ///
17 /// \details The functions tested are:
18 /// - `TensorAsExpression::compute_index_transformation`
19 /// - `TensorAsExpression::compute_rhs_multi_index`
21  const Tensor<double> rhs_tensor{{{2.6}}};
22  // Get TensorExpression from RHS tensor
23  const auto R_expr = rhs_tensor();
24 
25  const std::array<size_t, 0> index_order = {};
26 
27  const std::array<size_t, 0> actual_transformation =
28  R_expr.compute_index_transformation(index_order);
29  const std::array<size_t, 0> expected_transformation = {};
30  CHECK(actual_transformation == expected_transformation);
31 
32  const std::array<size_t, 0> tensor_multi_index = {};
33  CHECK(R_expr.compute_rhs_multi_index(
34  tensor_multi_index, expected_transformation) == tensor_multi_index);
35 }
36 } // namespace TestHelpers::TensorExpressions
TensorExpression.hpp
TestHelpers::TensorExpressions::test_tensor_as_expression_rank_0
void test_tensor_as_expression_rank_0() noexcept
Test that the transformation between LHS and RHS multi-indices and the subsequent computed RHS multi-...
Definition: TensorAsExpressionRank0TestHelpers.hpp:20
cstddef
std::array
Tensor.hpp