laplace-determinant
recursive determinant computation using Laplace expansion
Usage
Signature is (data [, scalar] [, order])
where:
- data is an array which lenght must be a square.
- scalar is an optional object used to compute determinant over any field (see below).
- order defaults to Math.sqrt(data.lenght) and is used internally by recursion sub step.
All code in the examples below is intended to be contained into a single file
Basic usage is to compute determinant of matrices of common numbers.
var det = // order = 1 // 10 // order = 2 // 1 // -1 // order = 3 // 1 // -2 // order = 4 // 1
The algorithm is recursive, so any order is allowed. If you want to benchmark it and compare this package with other implementations, you are welcome! Just contact me and I will happy to get this kind of useful feedback.
Optional scalar object defaults to common Real field, i.e.
scalar = { return a + b } { return a * b } { return -a }
It is possible to compute determinant over any field. Consider for example the Boolean algebra.
var boole = { return a && b } { return a || b } { return !a } // true