This implements the Gaussian elimination algorithm in PureScript, and can be used for solving systems of linear equations.
Let's say you have the following system of linear equations:
x - z = 0
x + y = 1
-x + y + z = 4
Filling in the coefficients and the constant results in the following augmented matrix:
let m = Matrix
[ [ 1.0, 0.0, -1.0, 0.0 ]
, [ 1.0, 1.0, 0.0, 1.0 ]
, [ -1.0, 1.0, 1.0, 4.0 ]
]
Pass this to the gauss
function defined in Data.Gaussian
, and the result will be:
> gauss m
[ -1.0, 4.0, -1.0 ]
wrapped in an Either
.