Compute the singular value decomposition of a 2x2 upper triangular matrix.
The singular value decomposition of a 2x2 upper triangular matrix $ A = \begin{bmatrix} F & G \ 0 & H \end{bmatrix}$ is given by
where CSL,SNL,CSR,SNR define orthogonal rotations and
var dlasv2 = require( '@stdlib/lapack/base/dlasv2' );Computes the singular value decomposition of a 2x2 upper triangular matrix.
var Float64Array = require( '@stdlib/array/float64' );
var out = new Float64Array( 6 );
var v = dlasv2( 2.0, 3.0, 4.0, out );
// returns <Float64Array>[ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ]
var bool = ( v === out );
// returns trueThe function has the following parameters:
- F: the (0,0) element of matrix.
- G: the (0,1) element of matrix.
- H: the (1,1) element of matrix.
- out:
Float64Arrayoutput array containingSSMIN,SSMAX,SNR,CSR,SNL, andCSLrespectively.
On return, abs(SSMAX) is the larger singular value, abs(SSMIN) is the smaller singular value, and (CSL,SNL) and (CSR,SNR) are the left and right singular vectors for abs(SSMAX) as described in the decomposition.
Note that indexing is relative to the first index. To introduce an offset, use typed array views.
var Float64Array = require( '@stdlib/array/float64' );
// Initial arrays...
var OUT0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
// Create offset views...
var OUT1 = new Float64Array( OUT0.buffer, OUT0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
dlasv2( 2.0, 3.0, 4.0, OUT1 );
// OUT0 => <Float64Array>[ 0.0, ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ]Computes the singular value decomposition of a 2x2 upper triangular matrix using alternative indexing semantics.
var Float64Array = require( '@stdlib/array/float64' );
var out = new Float64Array( 6 );
dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 0 );
// out => <Float64Array>[ ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ]The function has the following additional parameters:
- strideOut: stride length for
Out. - offsetOut: starting index for
Out.
While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example,
var Float64Array = require( '@stdlib/array/float64' );
var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
dlasv2.ndarray( 2.0, 3.0, 4.0, out, 1, 1 );
// out => <Float64Array>[ 0.0, ~1.5513, ~5.1569, ~0.9665, ~0.2567, ~0.7497, ~0.6618 ]var Float64Array = require( '@stdlib/array/float64' );
var dlasv2 = require( '@stdlib/lapack/base/dlasv2' );
var out = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] );
dlasv2( 1.0, 1e6, 2.0, out );
console.log( out );
dlasv2.ndarray( 1.0, 1e6, 2.0, out, 1, 0 );
console.log( out );TODOTODO.
TODOTODO
TODOTODO