mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -13,9 +13,8 @@
|
||||
|
||||
using Eigen::Tensor;
|
||||
|
||||
template<int DataLayout>
|
||||
static void test_dimension_failures()
|
||||
{
|
||||
template <int DataLayout>
|
||||
static void test_dimension_failures() {
|
||||
Tensor<int, 3, DataLayout> left(2, 3, 1);
|
||||
Tensor<int, 3, DataLayout> right(3, 3, 1);
|
||||
left.setRandom();
|
||||
@@ -33,9 +32,8 @@ static void test_dimension_failures()
|
||||
VERIFY_RAISES_ASSERT(concatenation = left.concatenate(right, -1));
|
||||
}
|
||||
|
||||
template<int DataLayout>
|
||||
static void test_static_dimension_failure()
|
||||
{
|
||||
template <int DataLayout>
|
||||
static void test_static_dimension_failure() {
|
||||
Tensor<int, 2, DataLayout> left(2, 3);
|
||||
Tensor<int, 3, DataLayout> right(2, 3, 1);
|
||||
|
||||
@@ -46,22 +44,18 @@ static void test_static_dimension_failure()
|
||||
#endif
|
||||
|
||||
// This can be worked around in this case.
|
||||
Tensor<int, 3, DataLayout> concatenation = left
|
||||
.reshape(Tensor<int, 3>::Dimensions(2, 3, 1))
|
||||
.concatenate(right, 0);
|
||||
Tensor<int, 3, DataLayout> concatenation = left.reshape(Tensor<int, 3>::Dimensions(2, 3, 1)).concatenate(right, 0);
|
||||
Tensor<int, 2, DataLayout> alternative = left
|
||||
// Clang compiler break with {{{}}} with an ambiguous error on copy constructor
|
||||
// the variadic DSize constructor added for #ifndef EIGEN_EMULATE_CXX11_META_H.
|
||||
// Solution:
|
||||
// either the code should change to
|
||||
// Tensor<int, 2>::Dimensions{{2, 3}}
|
||||
// or Tensor<int, 2>::Dimensions{Tensor<int, 2>::Dimensions{{2, 3}}}
|
||||
.concatenate(right.reshape(Tensor<int, 2>::Dimensions(2, 3)), 0);
|
||||
// Clang compiler break with {{{}}} with an ambiguous error on copy
|
||||
// constructor the variadic DSize constructor added for #ifndef
|
||||
// EIGEN_EMULATE_CXX11_META_H. Solution: either the code should change to
|
||||
// Tensor<int, 2>::Dimensions{{2, 3}}
|
||||
// or Tensor<int, 2>::Dimensions{Tensor<int, 2>::Dimensions{{2, 3}}}
|
||||
.concatenate(right.reshape(Tensor<int, 2>::Dimensions(2, 3)), 0);
|
||||
}
|
||||
|
||||
template<int DataLayout>
|
||||
static void test_simple_concatenation()
|
||||
{
|
||||
template <int DataLayout>
|
||||
static void test_simple_concatenation() {
|
||||
Tensor<int, 3, DataLayout> left(2, 3, 1);
|
||||
Tensor<int, 3, DataLayout> right(2, 3, 1);
|
||||
left.setRandom();
|
||||
@@ -105,12 +99,10 @@ static void test_simple_concatenation()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO(phli): Add test once we have a real vectorized implementation.
|
||||
// static void test_vectorized_concatenation() {}
|
||||
|
||||
static void test_concatenation_as_lvalue()
|
||||
{
|
||||
static void test_concatenation_as_lvalue() {
|
||||
Tensor<int, 2> t1(2, 3);
|
||||
Tensor<int, 2> t2(2, 3);
|
||||
t1.setRandom();
|
||||
@@ -123,21 +115,18 @@ static void test_concatenation_as_lvalue()
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
VERIFY_IS_EQUAL(t1(i, j), result(i, j));
|
||||
VERIFY_IS_EQUAL(t2(i, j), result(i+2, j));
|
||||
VERIFY_IS_EQUAL(t2(i, j), result(i + 2, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_concatenation)
|
||||
{
|
||||
CALL_SUBTEST(test_dimension_failures<ColMajor>());
|
||||
CALL_SUBTEST(test_dimension_failures<RowMajor>());
|
||||
CALL_SUBTEST(test_static_dimension_failure<ColMajor>());
|
||||
CALL_SUBTEST(test_static_dimension_failure<RowMajor>());
|
||||
CALL_SUBTEST(test_simple_concatenation<ColMajor>());
|
||||
CALL_SUBTEST(test_simple_concatenation<RowMajor>());
|
||||
// CALL_SUBTEST(test_vectorized_concatenation());
|
||||
CALL_SUBTEST(test_concatenation_as_lvalue());
|
||||
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_concatenation) {
|
||||
CALL_SUBTEST(test_dimension_failures<ColMajor>());
|
||||
CALL_SUBTEST(test_dimension_failures<RowMajor>());
|
||||
CALL_SUBTEST(test_static_dimension_failure<ColMajor>());
|
||||
CALL_SUBTEST(test_static_dimension_failure<RowMajor>());
|
||||
CALL_SUBTEST(test_simple_concatenation<ColMajor>());
|
||||
CALL_SUBTEST(test_simple_concatenation<RowMajor>());
|
||||
// CALL_SUBTEST(test_vectorized_concatenation());
|
||||
CALL_SUBTEST(test_concatenation_as_lvalue());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user