Fix code and unit test for a few corner cases in vectorized pow()

(cherry picked from commit 7a87ed1b6a)
This commit is contained in:
Rasmus Munk Larsen
2022-08-08 18:48:36 +00:00
committed by Antonio Sanchez
parent 61efca2e90
commit a9490cd3c5
2 changed files with 36 additions and 43 deletions

View File

@@ -72,9 +72,9 @@ void pow_test() {
for (int j = 0; j < num_cases; ++j) {
Scalar e = static_cast<Scalar>(std::pow(x(i,j), y(i,j)));
Scalar a = actual(i, j);
bool fail = !(a==e) && !internal::isApprox(a, e, tol) && !((numext::isnan)(a) && (numext::isnan)(e));
all_pass &= !fail;
if (fail) {
bool success = (a==e) || ((numext::isfinite)(e) && internal::isApprox(a, e, tol)) || ((numext::isnan)(a) && (numext::isnan)(e));
all_pass &= success;
if (!success) {
std::cout << "pow(" << x(i,j) << "," << y(i,j) << ") = " << a << " != " << e << std::endl;
}
}