ndarray-gram-schmidt-qr
v1.0.3
Published
Modified Gram-Schmidt Algorithm for QR Factorization
Downloads
8
Readme
ndarray-gram-schmidt-qr
A module for calculating the in-place QR decomposition of a matrix
Introduction
The algorithm is the numerically stable variant of the Gram-Schmidt QR decomposition as found on p. 58 of Trefethen and Bau's Numerical Linear Algebra. In pseudocode, the algorithm is:
for i = 1 to n
v_i = a_i
for i = 1 to n
r_ii = ||v_i||
q_i = v_i / r_ii
for j = i+1 to n
r_ij = q_i' * v_j
v_j = v_j - r_ij * q_i
Only square matrices are currently tested. For complex numbers see ndarray-gram-schmidt-qr-complex.
Usage
The algorithm currently only calculates the in-place QR decomposition and returns true on successful completion.
var qr = require('ndarray-gram-schmidt-qr'),
pool = require('ndarray-scratch');
var A = ndarray( new Float64Array([1,2,7,4,5,1,7,4,9]), [3,3] );
var R = pool.zeros( A.shape, A.dtype );
qr( A, R );
Then the product A * R is approximately equal to the original matrix.
Credits
(c) 2015 Ricky Reusser. MIT License