Skip to content

Commit

Permalink
[test] Fix error in TAT.hpp test for old compiler.
Browse files Browse the repository at this point in the history
For gcc 8, arithmetic operator over valarray cannot duduce these
scalar type automatically. So, this commit converts the scalartype to
the correct type manually.
  • Loading branch information
hzhangxyz committed Dec 4, 2023
1 parent 91d7ef6 commit 9fd46bc
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tests/test_scalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ TEST(test_scalar, tensor_and_number) {
}
ASSERT_THAT(a.storage(), ElementsAreArray(std::begin(s_a), std::end(s_a)));
auto b = a + 1.0;
std::valarray<std::complex<double>> s_b = s_a + 1.0;
std::valarray<std::complex<double>> s_b = s_a + std::complex<double>(1.0);
ASSERT_THAT(b.storage(), ElementsAreArray(std::begin(s_b), std::end(s_b)));
auto c = 1.0 + a;
std::valarray<std::complex<double>> s_c = 1.0 + s_a;
std::valarray<std::complex<double>> s_c = std::complex<double>(1.0) + s_a;
ASSERT_THAT(c.storage(), ElementsAreArray(std::begin(s_c), std::end(s_c)));
auto d = a - 1.0;
std::valarray<std::complex<double>> s_d = s_a - 1.0;
std::valarray<std::complex<double>> s_d = s_a - std::complex<double>(1.0);
ASSERT_THAT(d.storage(), ElementsAreArray(std::begin(s_d), std::end(s_d)));
auto e = 1.0 - a;
std::valarray<std::complex<double>> s_e = 1.0 - s_a;
std::valarray<std::complex<double>> s_e = std::complex<double>(1.0) - s_a;
ASSERT_THAT(e.storage(), ElementsAreArray(std::begin(s_e), std::end(s_e)));
auto f = a * 1.5;
std::valarray<std::complex<double>> s_f = s_a * 1.5;
std::valarray<std::complex<double>> s_f = s_a * std::complex<double>(1.5);
ASSERT_THAT(f.storage(), ElementsAreArray(std::begin(s_f), std::end(s_f)));
auto g = 1.5 * a;
std::valarray<std::complex<double>> s_g = 1.5 * s_a;
std::valarray<std::complex<double>> s_g = std::complex<double>(1.5) * s_a;
ASSERT_THAT(g.storage(), ElementsAreArray(std::begin(s_g), std::end(s_g)));
auto h = a / 1.5;
std::valarray<std::complex<double>> s_h = s_a / 1.5;
std::valarray<std::complex<double>> s_h = s_a / std::complex<double>(1.5);
ASSERT_THAT(h.storage(), ElementsAreArray(std::begin(s_h), std::end(s_h)));
auto i = 1.5 / (a + 1);
std::valarray<std::complex<double>> s_i = 1.5 / (s_a + 1);
std::valarray<std::complex<double>> s_i = std::complex<double>(1.5) / (s_a + std::complex<double>(1));
ASSERT_THAT(i.storage(), ElementsAreArray(std::begin(s_i), std::end(s_i)));
}

Expand All @@ -62,7 +62,7 @@ TEST(test_scalar, tensor_and_tensor) {
std::valarray<double> s_e = s_a * s_b;
ASSERT_THAT(e.storage(), ElementsAreArray(std::begin(s_e), std::end(s_e)));
auto f = a / (b + 1);
std::valarray<double> s_f = s_a / (s_b + 1);
std::valarray<double> s_f = s_a / (s_b + double(1));
ASSERT_THAT(f.storage(), ElementsAreArray(std::begin(s_f), std::end(s_f)));
}

Expand Down Expand Up @@ -111,6 +111,6 @@ TEST(test_scalar, tensor_and_tensor_inplace) {
s_a -= s_b;
ASSERT_THAT(a.storage(), ElementsAreArray(std::begin(s_a), std::end(s_a)));
a /= b + 1;
s_a /= s_b + 1;
s_a /= s_b + double(1);
ASSERT_THAT(a.storage(), ElementsAreArray(std::begin(s_a), std::end(s_a)));
}

0 comments on commit 9fd46bc

Please sign in to comment.