ralna / spral

Sparse Parallel Robust Algorithms Library
https://ralna.github.io/spral/
Other
104 stars 27 forks source link

Make `find_maxloc` test more robust #155

Closed mjacobse closed 11 months ago

mjacobse commented 11 months ago

The test could fail in case of multiple entries with maximum absolute value in the randomly generated test matrix. The actual function to be tested basically looks through the matrix in a different order than the simple reference implementation that is compared with. That means that the two functions may find the maximum first at different entries.

To make this more robust, check in the simple implementation whether there are multiple entries that have the maximum absolute value. If so, only test for the absolute value to be equal. Otherwise, the full comparison of value, row and column index can be done as before.

Fixes #144