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
@@ -11,8 +11,8 @@
|
||||
|
||||
#include <Eigen/CXX11/Tensor>
|
||||
|
||||
using Eigen::Tensor;
|
||||
using Eigen::RowMajor;
|
||||
using Eigen::Tensor;
|
||||
|
||||
using Scalar = float;
|
||||
|
||||
@@ -23,18 +23,17 @@ using TypedGEOp = internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_GE, true
|
||||
using TypedEQOp = internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_EQ, true>;
|
||||
using TypedNEOp = internal::scalar_cmp_op<Scalar, Scalar, internal::cmp_NEQ, true>;
|
||||
|
||||
static void test_orderings()
|
||||
{
|
||||
Tensor<Scalar, 3> mat1(2,3,7);
|
||||
Tensor<Scalar, 3> mat2(2,3,7);
|
||||
static void test_orderings() {
|
||||
Tensor<Scalar, 3> mat1(2, 3, 7);
|
||||
Tensor<Scalar, 3> mat2(2, 3, 7);
|
||||
|
||||
mat1.setRandom();
|
||||
mat2.setRandom();
|
||||
|
||||
Tensor<bool, 3> lt(2,3,7);
|
||||
Tensor<bool, 3> le(2,3,7);
|
||||
Tensor<bool, 3> gt(2,3,7);
|
||||
Tensor<bool, 3> ge(2,3,7);
|
||||
Tensor<bool, 3> lt(2, 3, 7);
|
||||
Tensor<bool, 3> le(2, 3, 7);
|
||||
Tensor<bool, 3> gt(2, 3, 7);
|
||||
Tensor<bool, 3> ge(2, 3, 7);
|
||||
|
||||
Tensor<Scalar, 3> typed_lt(2, 3, 7);
|
||||
Tensor<Scalar, 3> typed_le(2, 3, 7);
|
||||
@@ -54,10 +53,10 @@ static void test_orderings()
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
for (int k = 0; k < 7; ++k) {
|
||||
VERIFY_IS_EQUAL(lt(i,j,k), mat1(i,j,k) < mat2(i,j,k));
|
||||
VERIFY_IS_EQUAL(le(i,j,k), mat1(i,j,k) <= mat2(i,j,k));
|
||||
VERIFY_IS_EQUAL(gt(i,j,k), mat1(i,j,k) > mat2(i,j,k));
|
||||
VERIFY_IS_EQUAL(ge(i,j,k), mat1(i,j,k) >= mat2(i,j,k));
|
||||
VERIFY_IS_EQUAL(lt(i, j, k), mat1(i, j, k) < mat2(i, j, k));
|
||||
VERIFY_IS_EQUAL(le(i, j, k), mat1(i, j, k) <= mat2(i, j, k));
|
||||
VERIFY_IS_EQUAL(gt(i, j, k), mat1(i, j, k) > mat2(i, j, k));
|
||||
VERIFY_IS_EQUAL(ge(i, j, k), mat1(i, j, k) >= mat2(i, j, k));
|
||||
|
||||
VERIFY_IS_EQUAL(lt(i, j, k), (bool)typed_lt(i, j, k));
|
||||
VERIFY_IS_EQUAL(le(i, j, k), (bool)typed_le(i, j, k));
|
||||
@@ -68,11 +67,9 @@ static void test_orderings()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void test_equality()
|
||||
{
|
||||
Tensor<Scalar, 3> mat1(2,3,7);
|
||||
Tensor<Scalar, 3> mat2(2,3,7);
|
||||
static void test_equality() {
|
||||
Tensor<Scalar, 3> mat1(2, 3, 7);
|
||||
Tensor<Scalar, 3> mat2(2, 3, 7);
|
||||
|
||||
mat1.setRandom();
|
||||
mat2.setRandom();
|
||||
@@ -80,14 +77,14 @@ static void test_equality()
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
for (int k = 0; k < 7; ++k) {
|
||||
if (internal::random<bool>()) {
|
||||
mat2(i,j,k) = mat1(i,j,k);
|
||||
mat2(i, j, k) = mat1(i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tensor<bool, 3> eq(2,3,7);
|
||||
Tensor<bool, 3> ne(2,3,7);
|
||||
Tensor<bool, 3> eq(2, 3, 7);
|
||||
Tensor<bool, 3> ne(2, 3, 7);
|
||||
|
||||
Tensor<Scalar, 3> typed_eq(2, 3, 7);
|
||||
Tensor<Scalar, 3> typed_ne(2, 3, 7);
|
||||
@@ -101,46 +98,41 @@ static void test_equality()
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
for (int k = 0; k < 7; ++k) {
|
||||
VERIFY_IS_EQUAL(eq(i,j,k), mat1(i,j,k) == mat2(i,j,k));
|
||||
VERIFY_IS_EQUAL(ne(i,j,k), mat1(i,j,k) != mat2(i,j,k));
|
||||
VERIFY_IS_EQUAL(eq(i, j, k), mat1(i, j, k) == mat2(i, j, k));
|
||||
VERIFY_IS_EQUAL(ne(i, j, k), mat1(i, j, k) != mat2(i, j, k));
|
||||
|
||||
VERIFY_IS_EQUAL(eq(i, j, k), (bool)typed_eq(i,j,k));
|
||||
VERIFY_IS_EQUAL(ne(i, j, k), (bool)typed_ne(i,j,k));
|
||||
VERIFY_IS_EQUAL(eq(i, j, k), (bool)typed_eq(i, j, k));
|
||||
VERIFY_IS_EQUAL(ne(i, j, k), (bool)typed_ne(i, j, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void test_isnan()
|
||||
{
|
||||
Tensor<Scalar, 3> mat(2,3,7);
|
||||
static void test_isnan() {
|
||||
Tensor<Scalar, 3> mat(2, 3, 7);
|
||||
|
||||
mat.setRandom();
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
for (int k = 0; k < 7; ++k) {
|
||||
if (internal::random<bool>()) {
|
||||
mat(i,j,k) = std::numeric_limits<Scalar>::quiet_NaN();
|
||||
mat(i, j, k) = std::numeric_limits<Scalar>::quiet_NaN();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Tensor<bool, 3> nan(2,3,7);
|
||||
Tensor<bool, 3> nan(2, 3, 7);
|
||||
nan = (mat.isnan)();
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
for (int k = 0; k < 7; ++k) {
|
||||
VERIFY_IS_EQUAL(nan(i,j,k), (std::isnan)(mat(i,j,k)));
|
||||
VERIFY_IS_EQUAL(nan(i, j, k), (std::isnan)(mat(i, j, k)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_comparisons)
|
||||
{
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_comparisons) {
|
||||
CALL_SUBTEST(test_orderings());
|
||||
CALL_SUBTEST(test_equality());
|
||||
CALL_SUBTEST(test_isnan());
|
||||
|
||||
Reference in New Issue
Block a user