2014-10-03 01:39:36 +08:00
|
|
|
// This file is part of Eigen, a lightweight C++ template library
|
|
|
|
// for linear algebra.
|
|
|
|
//
|
|
|
|
// Copyright (C) 2014 Benoit Steiner <benoit.steiner.goog@gmail.com>
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla
|
|
|
|
// Public License v. 2.0. If a copy of the MPL was not distributed
|
|
|
|
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
#include <Eigen/CXX11/Tensor>
|
|
|
|
|
|
|
|
using Eigen::Tensor;
|
|
|
|
|
|
|
|
|
|
|
|
static void test_dynamic_size()
|
|
|
|
{
|
2014-11-05 23:49:51 +08:00
|
|
|
Eigen::DSizes<int, 3> dimensions(Eigen::array<int, 3>{{2,3,7}});
|
2014-10-03 01:39:36 +08:00
|
|
|
|
|
|
|
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<0>(dimensions), 2);
|
|
|
|
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<1>(dimensions), 3);
|
|
|
|
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<2>(dimensions), 7);
|
|
|
|
VERIFY_IS_EQUAL(dimensions.TotalSize(), (size_t)2*3*7);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_fixed_size()
|
|
|
|
{
|
|
|
|
Eigen::Sizes<2,3,7> dimensions;
|
|
|
|
|
|
|
|
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<0>(dimensions), 2);
|
|
|
|
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<1>(dimensions), 3);
|
|
|
|
VERIFY_IS_EQUAL((int)Eigen::internal::array_get<2>(dimensions), 7);
|
|
|
|
VERIFY_IS_EQUAL(dimensions.TotalSize(), (size_t)2*3*7);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void test_match()
|
|
|
|
{
|
2014-11-05 23:49:51 +08:00
|
|
|
Eigen::DSizes<int, 3> dyn(Eigen::array<int, 3>{{2,3,7}});
|
2014-10-03 01:39:36 +08:00
|
|
|
Eigen::Sizes<2,3,7> stat;
|
|
|
|
VERIFY_IS_EQUAL(Eigen::internal::dimensions_match(dyn, stat), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_cxx11_tensor_dimension()
|
|
|
|
{
|
|
|
|
CALL_SUBTEST(test_dynamic_size());
|
|
|
|
CALL_SUBTEST(test_fixed_size());
|
|
|
|
CALL_SUBTEST(test_match());
|
|
|
|
}
|