Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/xsimd/arch/common/xsimd_common_trigo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ namespace xsimd
{
using batch_type = batch<std::complex<T>, A>;
batch_type w = acos(z);
w = batch_type(-w.imag(), w.real());
return w;
return batch_type(abs(w.imag()), copysign(w.real(), z.imag()));
}

// asin
Expand Down Expand Up @@ -141,8 +140,9 @@ namespace xsimd

return select(y == real_batch(0.),
select(fabs(x) > real_batch(1.),
batch_type(constants::pio2<real_batch>(), real_batch(0.)),
batch_type(asin(x), real_batch(0.))),
batch_type(copysign(constants::pio2<real_batch>(), x),
copysign(acosh(max(fabs(x), real_batch(1.))), y)),
batch_type(asin(x), y)),
resg);
}

Expand Down
31 changes: 31 additions & 0 deletions test/test_complex_hyperbolic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,37 @@ struct complex_hyperbolic_test
detail::load_batch(ref, expected, i);
CHECK_BATCH_EQ(ref, out);
}

using R = real_value_type;
const R zero(0);
const R re[] = { -R(4), -R(2), -R(1), -R(0.5), R(0.5), R(1), R(2), R(4) };
const R im[] = { -R(2), -R(1), -R(0.5), -zero, zero, R(0.5), R(1), R(2) };
vector_type inputs;
inputs.reserve(64 + size);
for (R real : re)
{
for (R imag : im)
{
inputs.push_back(value_type(real, imag));
}
}
while (inputs.size() % size != 0)
{
inputs.push_back(inputs.front());
}
for (size_t i = 0; i < inputs.size(); i += size)
{
batch_type in, out, ref;
detail::load_batch(in, inputs, i);
out = acosh(in);
vector_type scalar(size);
for (size_t lane = 0; lane < size; ++lane)
{
scalar[lane] = std::acosh(inputs[i + lane]);
}
detail::load_batch(ref, scalar, 0);
CHECK_BATCH_EQ(ref, out);
}
}

void test_atanh()
Expand Down