ndarray-crout-decomposition

    1.1.0 • Public • Published

    ndarray-crout-decomposition

    LU decomposition using the crout algorithm

    testling badge

    build status

    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.000
    

    or 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.500
    

    methods

    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-decomposition
    

    license

    MIT

    Install

    npm i ndarray-crout-decomposition

    DownloadsWeekly Downloads

    6,514

    Version

    1.1.0

    License

    MIT

    Last publish

    Collaborators

    • substack
    • mikolalysenko
    • rreusser
    • jaspervdg
    • planeshifter
    • hughsk