forked from OSchip/llvm-project
Rename some test data (and make it const) to rid us of some shadowing warnings in the test suite. No functional change. Thanks to STL@microsoft for the report and patch.
llvm-svn: 271919
This commit is contained in:
parent
811e1ee03e
commit
217cf69b92
|
@ -17,7 +17,7 @@
|
|||
#include <complex>
|
||||
#include <cassert>
|
||||
|
||||
std::complex<double> x[] =
|
||||
const std::complex<double> testcases[] =
|
||||
{
|
||||
std::complex<double>( 1.e-6, 1.e-6),
|
||||
std::complex<double>(-1.e-6, 1.e-6),
|
||||
|
|
|
@ -37,16 +37,16 @@ test()
|
|||
|
||||
void test_edges()
|
||||
{
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j < N; ++j)
|
||||
{
|
||||
std::complex<double> r = x[i] / x[j];
|
||||
switch (classify(x[i]))
|
||||
std::complex<double> r = testcases[i] / testcases[j];
|
||||
switch (classify(testcases[i]))
|
||||
{
|
||||
case zero:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == NaN);
|
||||
|
@ -66,7 +66,7 @@ void test_edges()
|
|||
}
|
||||
break;
|
||||
case non_zero:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == inf);
|
||||
|
@ -86,7 +86,7 @@ void test_edges()
|
|||
}
|
||||
break;
|
||||
case inf:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == inf);
|
||||
|
@ -106,7 +106,7 @@ void test_edges()
|
|||
}
|
||||
break;
|
||||
case NaN:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == NaN);
|
||||
|
@ -126,7 +126,7 @@ void test_edges()
|
|||
}
|
||||
break;
|
||||
case non_zero_nan:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == inf);
|
||||
|
|
|
@ -39,16 +39,16 @@ test()
|
|||
|
||||
void test_edges()
|
||||
{
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j < N; ++j)
|
||||
{
|
||||
std::complex<double> r = x[i] * x[j];
|
||||
switch (classify(x[i]))
|
||||
std::complex<double> r = testcases[i] * testcases[j];
|
||||
switch (classify(testcases[i]))
|
||||
{
|
||||
case zero:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == zero);
|
||||
|
@ -68,7 +68,7 @@ void test_edges()
|
|||
}
|
||||
break;
|
||||
case non_zero:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == zero);
|
||||
|
@ -88,7 +88,7 @@ void test_edges()
|
|||
}
|
||||
break;
|
||||
case inf:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == NaN);
|
||||
|
@ -108,7 +108,7 @@ void test_edges()
|
|||
}
|
||||
break;
|
||||
case NaN:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == NaN);
|
||||
|
@ -128,7 +128,7 @@ void test_edges()
|
|||
}
|
||||
break;
|
||||
case non_zero_nan:
|
||||
switch (classify(x[j]))
|
||||
switch (classify(testcases[j]))
|
||||
{
|
||||
case zero:
|
||||
assert(classify(r) == NaN);
|
||||
|
|
|
@ -36,94 +36,94 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = acos(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = acos(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
is_about(r.real(), pi/2);
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) != std::signbit(r.imag()));
|
||||
}
|
||||
else if (x[i].real() == 0 && std::isnan(x[i].imag()))
|
||||
else if (testcases[i].real() == 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
is_about(r.real(), pi/2);
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
is_about(r.real(), pi/2);
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) != std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && x[i].real() != 0 && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && testcases[i].real() != 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() < 0 && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
is_about(r.real(), pi);
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) != std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) != std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() < 0 && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
is_about(r.real(), 0.75 * pi);
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) != std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
is_about(r.real(), 0.25 * pi);
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) != std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isinf(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) != std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) != std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (!std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
|
||||
else if (!std::signbit(testcases[i].real()) && !std::signbit(testcases[i].imag()))
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
assert( std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::signbit(x[i].real()) && !std::signbit(x[i].imag()))
|
||||
else if (std::signbit(testcases[i].real()) && !std::signbit(testcases[i].imag()))
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
assert( std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::signbit(x[i].real()) && std::signbit(x[i].imag()))
|
||||
else if (std::signbit(testcases[i].real()) && std::signbit(testcases[i].imag()))
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(!std::signbit(r.imag()));
|
||||
}
|
||||
else if (!std::signbit(x[i].real()) && std::signbit(x[i].imag()))
|
||||
else if (!std::signbit(testcases[i].real()) && std::signbit(testcases[i].imag()))
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(!std::signbit(r.imag()));
|
||||
|
|
|
@ -36,91 +36,91 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = acosh(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = acosh(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi/2);
|
||||
else
|
||||
is_about(r.imag(), pi/2);
|
||||
}
|
||||
else if (x[i].real() == 1 && x[i].imag() == 0)
|
||||
else if (testcases[i].real() == 1 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi/2);
|
||||
else
|
||||
is_about(r.imag(), pi/2);
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() < 0 && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi);
|
||||
else
|
||||
is_about(r.imag(), pi);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() < 0 && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -0.75 * pi);
|
||||
else
|
||||
is_about(r.imag(), 0.75 * pi);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -0.25 * pi);
|
||||
else
|
||||
is_about(r.imag(), 0.25 * pi);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
|
@ -128,7 +128,7 @@ void test_edges()
|
|||
else
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,77 +36,77 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = asin(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = asin(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
|
||||
else if ( testcases[i].real() == 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
if (x[i].real() > 0)
|
||||
if (testcases[i].real() > 0)
|
||||
is_about(r.real(), pi/2);
|
||||
else
|
||||
is_about(r.real(), - pi/2);
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
if (std::signbit(x[i].real()))
|
||||
if (std::signbit(testcases[i].real()))
|
||||
is_about(r.real(), -pi/4);
|
||||
else
|
||||
is_about(r.real(), pi/4);
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].real()) != std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].real()) != std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isinf(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,76 +36,76 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = asinh(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = asinh(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(x[i].imag()))
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi/2);
|
||||
else
|
||||
is_about(r.imag(), pi/2);
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(x[i].imag()))
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi/4);
|
||||
else
|
||||
is_about(r.imag(), pi/4);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && x[i].imag() == 0)
|
||||
else if (std::isnan(testcases[i].real()) && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@ test()
|
|||
void test_edges()
|
||||
{
|
||||
typedef std::complex<double> C;
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = atan(x[i]);
|
||||
std::complex<double> t1(-imag(x[i]), real(x[i]));
|
||||
std::complex<double> r = atan(testcases[i]);
|
||||
std::complex<double> t1(-imag(testcases[i]), real(testcases[i]));
|
||||
std::complex<double> t2 = atanh(t1);
|
||||
std::complex<double> z(imag(t2), -real(t2));
|
||||
if (std::isnan(real(r)))
|
||||
|
|
|
@ -36,89 +36,89 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = atanh(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = atanh(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if ( x[i].real() == 0 && std::isnan(x[i].imag()))
|
||||
else if ( testcases[i].real() == 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::abs(x[i].real()) == 1 && x[i].imag() == 0)
|
||||
else if (std::abs(testcases[i].real()) == 1 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
if (x[i].imag() > 0)
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
if (testcases[i].imag() > 0)
|
||||
is_about(r.imag(), pi/2);
|
||||
else
|
||||
is_about(r.imag(), -pi/2);
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(x[i].imag()))
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi/2);
|
||||
else
|
||||
is_about(r.imag(), pi/2);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(x[i].imag()))
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi/2);
|
||||
else
|
||||
is_about(r.imag(), pi/2);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(x[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(x[i].imag()))
|
||||
assert(std::signbit(testcases[i].real()) == std::signbit(r.real()));
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi/2);
|
||||
else
|
||||
is_about(r.imag(), pi/2);
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,11 +36,11 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = cos(x[i]);
|
||||
std::complex<double> t1(-imag(x[i]), real(x[i]));
|
||||
std::complex<double> r = cos(testcases[i]);
|
||||
std::complex<double> t1(-imag(testcases[i]), real(testcases[i]));
|
||||
std::complex<double> z = cosh(t1);
|
||||
if (std::isnan(real(r)))
|
||||
assert(std::isnan(real(z)));
|
||||
|
|
|
@ -36,72 +36,72 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = cosh(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = cosh(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(r.real() == 1);
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (x[i].real() == 0 && std::isinf(x[i].imag()))
|
||||
else if (testcases[i].real() == 0 && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
}
|
||||
else if (x[i].real() == 0 && std::isnan(x[i].imag()))
|
||||
else if (testcases[i].real() == 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].imag() == 0)
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::signbit(r.real()) == std::signbit(cos(x[i].imag())));
|
||||
assert(std::signbit(r.real()) == std::signbit(cos(testcases[i].imag())));
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].real() * sin(x[i].imag())));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].real() * sin(testcases[i].imag())));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && x[i].imag() == 0)
|
||||
else if (std::isnan(testcases[i].real()) && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
|
|
|
@ -34,73 +34,73 @@ test()
|
|||
|
||||
void test_edges()
|
||||
{
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = exp(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = exp(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(r.real() == 1.0);
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && x[i].imag() == 0)
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() < 0 && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(r.imag() == 0);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() < 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(r.imag() == 0);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && x[i].imag() == 0)
|
||||
else if (std::isnan(testcases[i].real()) && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && x[i].imag() != 0)
|
||||
else if (std::isnan(testcases[i].real()) && testcases[i].imag() != 0)
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].imag()) && std::abs(x[i].imag()) <= 1)
|
||||
else if (std::isfinite(testcases[i].imag()) && std::abs(testcases[i].imag()) <= 1)
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,17 +35,17 @@ test()
|
|||
void test_edges()
|
||||
{
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = log(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = log(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
if (std::signbit(x[i].real()))
|
||||
if (std::signbit(testcases[i].real()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() < 0);
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi);
|
||||
else
|
||||
is_about(r.imag(), pi);
|
||||
|
@ -55,24 +55,24 @@ void test_edges()
|
|||
assert(std::isinf(r.real()));
|
||||
assert(r.real() < 0);
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
if (x[i].imag() > 0)
|
||||
if (testcases[i].imag() > 0)
|
||||
is_about(r.imag(), pi/2);
|
||||
else
|
||||
is_about(r.imag(), -pi/2);
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() < 0 && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()) && r.real() > 0);
|
||||
if (r.imag() > 0)
|
||||
|
@ -80,44 +80,44 @@ void test_edges()
|
|||
else
|
||||
is_about(r.imag(), -pi);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()) && r.real() > 0);
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (x[i].real() == 1 && x[i].imag() == 0)
|
||||
else if (testcases[i].real() == 1 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (x[i].real() == 0 && x[i].imag() == 1)
|
||||
else if (testcases[i].real() == 0 && testcases[i].imag() == 1)
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
is_about(r.imag(), pi/2);
|
||||
}
|
||||
else if (x[i].real() == -1 && x[i].imag() == 0)
|
||||
else if (testcases[i].real() == -1 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r.imag(), -pi);
|
||||
else
|
||||
is_about(r.imag(), pi);
|
||||
}
|
||||
else if (x[i].real() == 0 && x[i].imag() == -1)
|
||||
else if (testcases[i].real() == 0 && testcases[i].imag() == -1)
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
is_about(r.imag(), -pi/2);
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) < 1)
|
||||
else if (std::isfinite(testcases[i].real()) && std::isfinite(testcases[i].imag()) && abs(testcases[i]) < 1)
|
||||
{
|
||||
assert( std::signbit(r.real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isfinite(x[i].imag()) && abs(x[i]) > 1)
|
||||
else if (std::isfinite(testcases[i].real()) && std::isfinite(testcases[i].imag()) && abs(testcases[i]) > 1)
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@ test()
|
|||
void test_edges()
|
||||
{
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = log10(x[i]);
|
||||
std::complex<double> z = log(x[i])/std::log(10);
|
||||
std::complex<double> r = log10(testcases[i]);
|
||||
std::complex<double> z = log(testcases[i])/std::log(10);
|
||||
if (std::isnan(real(r)))
|
||||
assert(std::isnan(real(z)));
|
||||
else
|
||||
|
|
|
@ -37,13 +37,13 @@ test()
|
|||
void test_edges()
|
||||
{
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j < N; ++j)
|
||||
{
|
||||
std::complex<double> r = pow(x[i], x[j]);
|
||||
std::complex<double> z = exp(x[j] * log(x[i]));
|
||||
std::complex<double> r = pow(testcases[i], testcases[j]);
|
||||
std::complex<double> z = exp(testcases[j] * log(testcases[i]));
|
||||
if (std::isnan(real(r)))
|
||||
assert(std::isnan(real(z)));
|
||||
else
|
||||
|
|
|
@ -37,13 +37,13 @@ test()
|
|||
void test_edges()
|
||||
{
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j < N; ++j)
|
||||
{
|
||||
std::complex<double> r = pow(x[i], real(x[j]));
|
||||
std::complex<double> z = exp(std::complex<double>(real(x[j])) * log(x[i]));
|
||||
std::complex<double> r = pow(testcases[i], real(testcases[j]));
|
||||
std::complex<double> z = exp(std::complex<double>(real(testcases[j])) * log(testcases[i]));
|
||||
if (std::isnan(real(r)))
|
||||
assert(std::isnan(real(z)));
|
||||
else
|
||||
|
|
|
@ -37,13 +37,13 @@ test()
|
|||
void test_edges()
|
||||
{
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
for (unsigned j = 0; j < N; ++j)
|
||||
{
|
||||
std::complex<double> r = pow(real(x[i]), x[j]);
|
||||
std::complex<double> z = exp(x[j] * log(std::complex<double>(real(x[i]))));
|
||||
std::complex<double> r = pow(real(testcases[i]), testcases[j]);
|
||||
std::complex<double> z = exp(testcases[j] * log(std::complex<double>(real(testcases[i]))));
|
||||
if (std::isnan(real(r)))
|
||||
assert(std::isnan(real(z)));
|
||||
else
|
||||
|
|
|
@ -36,11 +36,11 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = sin(x[i]);
|
||||
std::complex<double> t1(-imag(x[i]), real(x[i]));
|
||||
std::complex<double> r = sin(testcases[i]);
|
||||
std::complex<double> t1(-imag(testcases[i]), real(testcases[i]));
|
||||
std::complex<double> t2 = sinh(t1);
|
||||
std::complex<double> z(imag(t2), -real(t2));
|
||||
if (std::isnan(real(r)))
|
||||
|
|
|
@ -36,73 +36,73 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = sinh(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = sinh(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real()));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (x[i].real() == 0 && std::isinf(x[i].imag()))
|
||||
else if (testcases[i].real() == 0 && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (x[i].real() == 0 && std::isnan(x[i].imag()))
|
||||
else if (testcases[i].real() == 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].imag() == 0)
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real()));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real() * cos(x[i].imag())));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real() * cos(testcases[i].imag())));
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(sin(x[i].imag())));
|
||||
assert(std::signbit(r.imag()) == std::signbit(sin(testcases[i].imag())));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && x[i].imag() == 0)
|
||||
else if (std::isnan(testcases[i].real()) && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
|
|
|
@ -36,58 +36,58 @@ test()
|
|||
|
||||
void test_edges()
|
||||
{
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = sqrt(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = sqrt(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() < 0 && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(std::isinf(r.imag()));
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r.imag()));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() < 0 && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() < 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isinf(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && x[i].real() > 0 && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && testcases[i].real() > 0 && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isinf(r.real()));
|
||||
assert(r.real() > 0);
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && (std::isfinite(x[i].imag()) || std::isnan(x[i].imag())))
|
||||
else if (std::isnan(testcases[i].real()) && (std::isfinite(testcases[i].imag()) || std::isnan(testcases[i].imag())))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::signbit(x[i].imag()))
|
||||
else if (std::signbit(testcases[i].imag()))
|
||||
{
|
||||
assert(!std::signbit(r.real()));
|
||||
assert(std::signbit(r.imag()));
|
||||
|
|
|
@ -37,11 +37,11 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = tan(x[i]);
|
||||
std::complex<double> t1(-imag(x[i]), real(x[i]));
|
||||
std::complex<double> r = tan(testcases[i]);
|
||||
std::complex<double> t1(-imag(testcases[i]), real(testcases[i]));
|
||||
std::complex<double> t2 = tanh(t1);
|
||||
std::complex<double> z(imag(t2), -real(t2));
|
||||
if (std::isnan(real(r)))
|
||||
|
|
|
@ -36,55 +36,55 @@ void test_edges()
|
|||
{
|
||||
typedef std::complex<double> C;
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = tanh(x[i]);
|
||||
if (x[i].real() == 0 && x[i].imag() == 0)
|
||||
std::complex<double> r = tanh(testcases[i]);
|
||||
if (testcases[i].real() == 0 && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(r.real() == 0);
|
||||
assert(std::signbit(r.real()) == std::signbit(x[i].real()));
|
||||
assert(std::signbit(r.real()) == std::signbit(testcases[i].real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isfinite(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isfinite(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 1);
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(sin(2*x[i].imag())));
|
||||
assert(std::signbit(r.imag()) == std::signbit(sin(2*testcases[i].imag())));
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 1);
|
||||
assert(r.imag() == 0);
|
||||
}
|
||||
else if (std::isinf(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isinf(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(r.real() == 1);
|
||||
assert(r.imag() == 0);
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && x[i].imag() == 0)
|
||||
else if (std::isnan(testcases[i].real()) && testcases[i].imag() == 0)
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(r.imag() == 0);
|
||||
assert(std::signbit(r.imag()) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r.imag()) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isfinite(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isfinite(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
}
|
||||
else if (std::isnan(x[i].real()) && std::isnan(x[i].imag()))
|
||||
else if (std::isnan(testcases[i].real()) && std::isnan(testcases[i].imag()))
|
||||
{
|
||||
assert(std::isnan(r.real()));
|
||||
assert(std::isnan(r.imag()));
|
||||
|
|
|
@ -28,11 +28,11 @@ test()
|
|||
|
||||
void test_edges()
|
||||
{
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
double r = abs(x[i]);
|
||||
switch (classify(x[i]))
|
||||
double r = abs(testcases[i]);
|
||||
switch (classify(testcases[i]))
|
||||
{
|
||||
case zero:
|
||||
assert(r == 0);
|
||||
|
|
|
@ -29,42 +29,42 @@ test()
|
|||
void test_edges()
|
||||
{
|
||||
const double pi = std::atan2(+0., -0.);
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
double r = arg(x[i]);
|
||||
if (std::isnan(x[i].real()) || std::isnan(x[i].imag()))
|
||||
double r = arg(testcases[i]);
|
||||
if (std::isnan(testcases[i].real()) || std::isnan(testcases[i].imag()))
|
||||
assert(std::isnan(r));
|
||||
else
|
||||
{
|
||||
switch (classify(x[i]))
|
||||
switch (classify(testcases[i]))
|
||||
{
|
||||
case zero:
|
||||
if (std::signbit(x[i].real()))
|
||||
if (std::signbit(testcases[i].real()))
|
||||
{
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r, -pi);
|
||||
else
|
||||
is_about(r, pi);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r));
|
||||
}
|
||||
break;
|
||||
case non_zero:
|
||||
if (x[i].real() == 0)
|
||||
if (testcases[i].real() == 0)
|
||||
{
|
||||
if (x[i].imag() < 0)
|
||||
if (testcases[i].imag() < 0)
|
||||
is_about(r, -pi/2);
|
||||
else
|
||||
is_about(r, pi/2);
|
||||
}
|
||||
else if (x[i].imag() == 0)
|
||||
else if (testcases[i].imag() == 0)
|
||||
{
|
||||
if (x[i].real() < 0)
|
||||
if (testcases[i].real() < 0)
|
||||
{
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r, -pi);
|
||||
else
|
||||
is_about(r, pi);
|
||||
|
@ -72,37 +72,37 @@ void test_edges()
|
|||
else
|
||||
{
|
||||
assert(r == 0);
|
||||
assert(std::signbit(x[i].imag()) == std::signbit(r));
|
||||
assert(std::signbit(testcases[i].imag()) == std::signbit(r));
|
||||
}
|
||||
}
|
||||
else if (x[i].imag() > 0)
|
||||
else if (testcases[i].imag() > 0)
|
||||
assert(r > 0);
|
||||
else
|
||||
assert(r < 0);
|
||||
break;
|
||||
case inf:
|
||||
if (std::isinf(x[i].real()) && std::isinf(x[i].imag()))
|
||||
if (std::isinf(testcases[i].real()) && std::isinf(testcases[i].imag()))
|
||||
{
|
||||
if (x[i].real() < 0)
|
||||
if (testcases[i].real() < 0)
|
||||
{
|
||||
if (x[i].imag() > 0)
|
||||
if (testcases[i].imag() > 0)
|
||||
is_about(r, 0.75 * pi);
|
||||
else
|
||||
is_about(r, -0.75 * pi);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x[i].imag() > 0)
|
||||
if (testcases[i].imag() > 0)
|
||||
is_about(r, 0.25 * pi);
|
||||
else
|
||||
is_about(r, -0.25 * pi);
|
||||
}
|
||||
}
|
||||
else if (std::isinf(x[i].real()))
|
||||
else if (std::isinf(testcases[i].real()))
|
||||
{
|
||||
if (x[i].real() < 0)
|
||||
if (testcases[i].real() < 0)
|
||||
{
|
||||
if (std::signbit(x[i].imag()))
|
||||
if (std::signbit(testcases[i].imag()))
|
||||
is_about(r, -pi);
|
||||
else
|
||||
is_about(r, pi);
|
||||
|
@ -110,12 +110,12 @@ void test_edges()
|
|||
else
|
||||
{
|
||||
assert(r == 0);
|
||||
assert(std::signbit(r) == std::signbit(x[i].imag()));
|
||||
assert(std::signbit(r) == std::signbit(testcases[i].imag()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x[i].imag() < 0)
|
||||
if (testcases[i].imag() < 0)
|
||||
is_about(r, -pi/2);
|
||||
else
|
||||
is_about(r, pi/2);
|
||||
|
|
|
@ -28,11 +28,11 @@ test()
|
|||
|
||||
void test_edges()
|
||||
{
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
double r = norm(x[i]);
|
||||
switch (classify(x[i]))
|
||||
double r = norm(testcases[i]);
|
||||
switch (classify(testcases[i]))
|
||||
{
|
||||
case zero:
|
||||
assert(r == 0);
|
||||
|
|
|
@ -46,11 +46,11 @@ test()
|
|||
|
||||
void test_edges()
|
||||
{
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
double r = real(x[i]);
|
||||
double theta = imag(x[i]);
|
||||
double r = real(testcases[i]);
|
||||
double theta = imag(testcases[i]);
|
||||
std::complex<double> z = std::polar(r, theta);
|
||||
switch (classify(r))
|
||||
{
|
||||
|
|
|
@ -37,26 +37,26 @@ test()
|
|||
|
||||
void test_edges()
|
||||
{
|
||||
const unsigned N = sizeof(x) / sizeof(x[0]);
|
||||
const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
|
||||
for (unsigned i = 0; i < N; ++i)
|
||||
{
|
||||
std::complex<double> r = proj(x[i]);
|
||||
switch (classify(x[i]))
|
||||
std::complex<double> r = proj(testcases[i]);
|
||||
switch (classify(testcases[i]))
|
||||
{
|
||||
case zero:
|
||||
case non_zero:
|
||||
assert(r == x[i]);
|
||||
assert(std::signbit(real(r)) == std::signbit(real(x[i])));
|
||||
assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
|
||||
assert(r == testcases[i]);
|
||||
assert(std::signbit(real(r)) == std::signbit(real(testcases[i])));
|
||||
assert(std::signbit(imag(r)) == std::signbit(imag(testcases[i])));
|
||||
break;
|
||||
case inf:
|
||||
assert(std::isinf(real(r)) && real(r) > 0);
|
||||
assert(imag(r) == 0);
|
||||
assert(std::signbit(imag(r)) == std::signbit(imag(x[i])));
|
||||
assert(std::signbit(imag(r)) == std::signbit(imag(testcases[i])));
|
||||
break;
|
||||
case NaN:
|
||||
case non_zero_nan:
|
||||
assert(classify(r) == classify(x[i]));
|
||||
assert(classify(r) == classify(testcases[i]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue