GeoStat-Framework / pentapy

A Python toolbox for pentadiagonal linear systems
https://pentapy.readthedocs.io/
MIT License
14 stars 4 forks source link

[Bug] Wrong Memory Access in edge case of `n=3` #24

Open MothNik opened 3 months ago

MothNik commented 3 months ago

The special case of a 3x3 matrix is not handled correctly by both algorithm I and algorithm II. They have the access pattern first 2 rows - all rows in between - last 2 rows, but for a 3x3 matrix, the first and last 2 rows have an overlap because the second row belongs to both.

This is an edge case, but yet it can happen and lead to wrong memory access.

Unfortunately, the tests do not capture this case because they only capture a single case of n=1_000.

I have already fixed this for #11 by falling back to np.linalg.solve for this special case.

MuellerSeb commented 2 months ago

Good catch. Thanks