Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
9 changes: 4 additions & 5 deletions include/xsf/amos/amos.h
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ namespace amos {
return nz;
}
ck = std::exp(cz);
for (int i = 0; i < (nn + 1); i++) {
for (int i = 0; i < nn; i++) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y[i] *= ck;
}
/* 90 */
Expand Down Expand Up @@ -1770,7 +1770,7 @@ namespace amos {
*ierr = 2;
return 0;
}
if (xx > 0.0) {
if (xx >= 0.0) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return nz;
}
//
Expand Down Expand Up @@ -5622,7 +5622,7 @@ namespace amos {
return -1;
}
nz = n;
for (i = 0; i < (n + 1); i++) {
for (i = 0; i < n; i++) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y[i] = 0.0;
}
return nz;
Expand Down Expand Up @@ -6067,8 +6067,7 @@ namespace amos {
// REFINE ESTIMATE AND TEST
//
aphi = std::abs(phid);
aarg = std::abs(argd);
rs1 += std::log(aphi) - 0.25 * std::log(aarg) - aic;
rs1 += std::log(aphi);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (std::fabs(rs1) < elim) {
goto L120;
}
Expand Down
30 changes: 30 additions & 0 deletions tests/xsf_tests/test_amos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,33 @@ TEST_CASE("amos besj vectorized", "[amos][xsf_tests]") {
REQUIRE(rel_error <= rtol);
}
}

TEST_CASE("amos besi vectorized", "[amos][xsf_tests]") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a small regression test for asyi too? A regression test forunk1 and unk2 would be nice too but they look harder to hit.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Your intuition was right, I did not find a way to hit the fixes in unk1 and unk2.

// tests the functionality of amos to return multiple consecutive orders for besi
// by comparing to the versions returning only a single order
using std::complex;

using test_case = std::tuple<complex<double>, double, int, int, double>;
auto [z, fnu, kode, n, rtol] = GENERATE(
test_case{complex{0.0, -15.0}, 0.0, 1, 10, 1e-15} // gh-158
);

std::vector<complex<double>> cy(n);
int ierr = 0;
int nz;

nz = xsf::amos::besi(z, fnu, kode, n, cy.data(), &ierr);

REQUIRE(ierr == 0);

complex<double> ref;

for (int i = 0; i < n; ++i) {
nz = xsf::amos::besi(z, fnu + i, kode, 1, &ref, &ierr);
REQUIRE(ierr == 0);

const auto rel_error = xsf::extended_relative_error(cy[i], ref);
CAPTURE(i, cy[i], ref, rel_error);
REQUIRE(rel_error <= rtol);
}
}
Loading