1.1.0 • Published 11 years ago
ndarray-crout-decomposition v1.1.0
ndarray-crout-decomposition
LU decomposition using the crout algorithm
example
var ndarray = require('ndarray');
var zeros = require('zeros');
var show = require('ndarray-show');
var crout = require('ndarray-crout-decomposition');
var A = ndarray([ 4, 3, 6, 3 ], [ 2, 2 ]);
var L = zeros([ 2, 2 ]);
var U = zeros([ 2, 2 ]);
crout(A, L, U);
console.log('L=\n' + show(L));
console.log('U=\n' + show(U));output:
L=
4.000 0.000
3.000 -1.500
U=
1.000 1.500
0.000 1.000or to save space, you can use a single matrix to store the L and U values:
var ndarray = require('ndarray');
var zeros = require('zeros');
var show = require('ndarray-show');
var crout = require('ndarray-crout-decomposition');
var A = ndarray([ 4, 3, 6, 3 ], [ 2, 2 ]);
var LU = zeros([ 2, 2 ]);
crout(A, LU);
console.log('LU=\n' + show(LU));output:
LU=
4.000 1.500
3.000 -1.500methods
var crout = require('ndarray-crout-decomposition')var ok = crout(A, L, U)
Decompose the matrix A into L and U, mutating L and U in-place.
A is not modified.
If you don't pass in a U matrix, L will be used to store both the L and
U values, omitting the diagonal of ones from U to make room.
If A was non-square or the algorithm could not find a solution, ok is
false. Otherwise ok is true.
install
With npm do:
npm install ndarray-crout-decompositionlicense
MIT

