Daniel-Diaz / matrix

A Haskell native implementation of matrices and their operations.
BSD 3-Clause "New" or "Revised" License
35 stars 31 forks source link

Guard call to inverse #40

Closed istathar closed 1 year ago

istathar commented 8 years ago

Use detLU to check that the input matrix is not singular before attempting to calculate the inverse.

Would close #38, though in a clumsy fashion.

Right now the inverse function (or rather, internal rref) has a ton of error checking. I feel like there should be two paths to calculate the inverse; a safe, guarded one that accepts it might be more expensive to run (in which case might as well use the Caley-Hamilton method) and an unsafe, express, assume-you-know-what-you're-doing, maybe

unsafeInverse :: Matrix a -> Matrix a

anyway, patch attached

AfC