Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 2 additions & 2 deletions include/xsf/amos/amos.h
Original file line number Diff line number Diff line change
Expand Up @@ -4476,8 +4476,8 @@ namespace amos {
//
s1 = w[0];
s2 = w[1];
l = 3;
for (int l = 3; l < (nn + 1); l++) {
int l;
for (l = 3; l < (nn + 1); l++) {
Comment on lines +4479 to +4480

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.

Indeed, this seems to fix the translation error.

ck = s2;
s2 = s1 + (ak + fnu) * rz * s2;
s1 = ck;
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 @@ -62,6 +62,36 @@ TEST_CASE("amos besi vectorized", "[amos][xsf_tests]") {
}
}

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

@fbourgey fbourgey Jun 7, 2026

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.

This test seems useful but should we not add a sentinel regression test as you did #158? It passes on main.

@JaRoSchm JaRoSchm Jun 8, 2026

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.

Thanks for checking! Seems like I have mixed up what this PR actually fixes with some other PR. I have now added a test similar to #153 here.

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

using test_case = std::tuple<complex<double>, double, int, int, int, double>;
auto [z, fnu, kode, m, n, rtol] = GENERATE(
test_case{complex{14.0, -3.0}, 1.0, 1, 1, 260, 4e-13} // gh-92
);

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

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

REQUIRE(ierr == 0);

complex<double> ref;

for (int i = 0; i < n; ++i) {
nz = xsf::amos::besh(z, fnu + i, kode, m, 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);
}
}

TEST_CASE("amos asyi buffer overflow gh-158", "[amos][xsf_tests]") {
using std::complex;

Expand Down
Loading