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
@@ -2,8 +2,8 @@
|
||||
|
||||
#include <Eigen/CXX11/Tensor>
|
||||
|
||||
using Eigen::Tensor;
|
||||
using Eigen::RowMajor;
|
||||
using Eigen::Tensor;
|
||||
|
||||
static void test_comparison_sugar() {
|
||||
// we already trust comparisons between tensors, we're simply checking that
|
||||
@@ -12,9 +12,9 @@ static void test_comparison_sugar() {
|
||||
|
||||
t.setRandom();
|
||||
// make sure we have at least one value == 0
|
||||
t(0,0,0) = 0;
|
||||
t(0, 0, 0) = 0;
|
||||
|
||||
Tensor<bool,0> b;
|
||||
Tensor<bool, 0> b;
|
||||
|
||||
#define TEST_TENSOR_EQUAL(e1, e2) \
|
||||
b = ((e1) == (e2)).all(); \
|
||||
@@ -32,7 +32,6 @@ static void test_comparison_sugar() {
|
||||
#undef TEST_TENSOR_EQUAL
|
||||
}
|
||||
|
||||
|
||||
static void test_scalar_sugar_add_mul() {
|
||||
Tensor<float, 3> A(6, 7, 5);
|
||||
Tensor<float, 3> B(6, 7, 5);
|
||||
@@ -47,7 +46,7 @@ static void test_scalar_sugar_add_mul() {
|
||||
Tensor<float, 3> S = A * alpha + B * beta + gamma;
|
||||
Tensor<float, 3> T = gamma + alpha * A + beta * B;
|
||||
|
||||
for (int i = 0; i < 6*7*5; ++i) {
|
||||
for (int i = 0; i < 6 * 7 * 5; ++i) {
|
||||
VERIFY_IS_APPROX(R(i), S(i));
|
||||
VERIFY_IS_APPROX(R(i), T(i));
|
||||
}
|
||||
@@ -64,17 +63,15 @@ static void test_scalar_sugar_sub_div() {
|
||||
const float gamma = 0.14f;
|
||||
const float delta = 0.32f;
|
||||
|
||||
Tensor<float, 3> R = A.constant(gamma) - A / A.constant(alpha)
|
||||
- B.constant(beta) / B - A.constant(delta);
|
||||
Tensor<float, 3> R = A.constant(gamma) - A / A.constant(alpha) - B.constant(beta) / B - A.constant(delta);
|
||||
Tensor<float, 3> S = gamma - A / alpha - beta / B - delta;
|
||||
|
||||
for (int i = 0; i < 6*7*5; ++i) {
|
||||
for (int i = 0; i < 6 * 7 * 5; ++i) {
|
||||
VERIFY_IS_APPROX(R(i), S(i));
|
||||
}
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_sugar)
|
||||
{
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_sugar) {
|
||||
CALL_SUBTEST(test_comparison_sugar());
|
||||
CALL_SUBTEST(test_scalar_sugar_add_mul());
|
||||
CALL_SUBTEST(test_scalar_sugar_sub_div());
|
||||
|
||||
Reference in New Issue
Block a user