Clang-format tests, examples, libraries, benchmarks, etc.

This commit is contained in:
Antonio Sánchez
2023-12-05 21:22:55 +00:00
committed by Rasmus Munk Larsen
parent 3252ecc7a4
commit 46e9cdb7fe
876 changed files with 33453 additions and 37795 deletions

View File

@@ -12,48 +12,44 @@
#include <Eigen/CXX11/Tensor>
#include <utility>
using Eigen::Tensor;
using Eigen::RowMajor;
using Eigen::Tensor;
static void calc_indices(int i, int& x, int& y, int& z)
{
static void calc_indices(int i, int& x, int& y, int& z) {
x = i / 4;
y = (i % 4) / 2;
z = i % 2;
}
static void test_move()
{
static void test_move() {
int x;
int y;
int z;
Tensor<int,3> tensor1(2, 2, 2);
Tensor<int,3,RowMajor> tensor2(2, 2, 2);
Tensor<int, 3> tensor1(2, 2, 2);
Tensor<int, 3, RowMajor> tensor2(2, 2, 2);
for (int i = 0; i < 8; i++)
{
for (int i = 0; i < 8; i++) {
calc_indices(i, x, y, z);
tensor1(x,y,z) = i;
tensor2(x,y,z) = 2 * i;
tensor1(x, y, z) = i;
tensor2(x, y, z) = 2 * i;
}
// Invokes the move constructor.
Tensor<int,3> moved_tensor1 = std::move(tensor1);
Tensor<int,3,RowMajor> moved_tensor2 = std::move(tensor2);
Tensor<int, 3> moved_tensor1 = std::move(tensor1);
Tensor<int, 3, RowMajor> moved_tensor2 = std::move(tensor2);
VERIFY_IS_EQUAL(tensor1.size(), 0);
VERIFY_IS_EQUAL(tensor2.size(), 0);
for (int i = 0; i < 8; i++)
{
for (int i = 0; i < 8; i++) {
calc_indices(i, x, y, z);
VERIFY_IS_EQUAL(moved_tensor1(x,y,z), i);
VERIFY_IS_EQUAL(moved_tensor2(x,y,z), 2 * i);
VERIFY_IS_EQUAL(moved_tensor1(x, y, z), i);
VERIFY_IS_EQUAL(moved_tensor2(x, y, z), 2 * i);
}
Tensor<int,3> moved_tensor3(2,2,2);
Tensor<int,3,RowMajor> moved_tensor4(2,2,2);
Tensor<int, 3> moved_tensor3(2, 2, 2);
Tensor<int, 3, RowMajor> moved_tensor4(2, 2, 2);
moved_tensor3.setZero();
moved_tensor4.setZero();
@@ -62,15 +58,11 @@ static void test_move()
moved_tensor3 = std::move(moved_tensor1);
moved_tensor4 = std::move(moved_tensor2);
for (int i = 0; i < 8; i++)
{
for (int i = 0; i < 8; i++) {
calc_indices(i, x, y, z);
VERIFY_IS_EQUAL(moved_tensor3(x,y,z), i);
VERIFY_IS_EQUAL(moved_tensor4(x,y,z), 2 * i);
VERIFY_IS_EQUAL(moved_tensor3(x, y, z), i);
VERIFY_IS_EQUAL(moved_tensor4(x, y, z), 2 * i);
}
}
EIGEN_DECLARE_TEST(cxx11_tensor_move)
{
CALL_SUBTEST(test_move());
}
EIGEN_DECLARE_TEST(cxx11_tensor_move) { CALL_SUBTEST(test_move()); }