Skip to content

Comments

BUG: amos/amos.h: fix loop upper bound in buni#93

Open
JaRoSchm wants to merge 1 commit intoscipy:mainfrom
JaRoSchm:amos_buni_fix
Open

BUG: amos/amos.h: fix loop upper bound in buni#93
JaRoSchm wants to merge 1 commit intoscipy:mainfrom
JaRoSchm:amos_buni_fix

Conversation

@JaRoSchm
Copy link

@JaRoSchm JaRoSchm commented Feb 3, 2026

Hi, I detected this error in the same way as in #92. This time I used z = 90.0 - 3.0j and n = 30 in https://github.com/JaRoSchm/pyamos/blob/main/compare_xsf_zbessel.py for finding the bug. This was simply incorrectly translated from FORTRAN, see https://github.com/scipy/scipy/blob/4edfcaa3ce8a387450b6efce968572def71be089/scipy/special/amos/zbuni.f#L114, where only the lower bound has been shifted by one but not the upper bound. As k is reduced by one for each loop, it will become -1 during the last iteration, such that y as accessed at -1. Regarding testing the same question/comment from #92 applies.

Fix the upper bound of the loop in buni, which was incorrectly
translated from FORTRAN. This allowed to access the result array out of
its bounds.
@JaRoSchm JaRoSchm changed the title BUG: amos/amos.h: fix loop upper bound in buni BUG: amos/amos.h: fix loop upper bound in buni Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant