zscilib icon indicating copy to clipboard operation
zscilib copied to clipboard

matrices.c: 0 not ignored when inverting diagonals in pseudoinverse

Open stonemaguire opened this issue 1 year ago • 0 comments

https://github.com/zephyrproject-rtos/zscilib/blob/34c3432e81085bb717e4871d21ca419ae0058ec5/src/matrices.c#L1785-L1791

In the if statement on line 1788, x > -epsilon always evaluates to true when x is 0 because epsilon is equal to 1e-6 and 0 is always bigger than -1e-6. This causes an incorrect output matrix with infinity values since 0 should be ignored.

I changed line 1788 to the below code to fix this issue: if (((x < epsilon) || (x > -epsilon)) && x != 0) {

stonemaguire avatar Jul 06 '23 17:07 stonemaguire