Skip to content

Latest commit

 

History

History
262 lines (156 loc) · 6.52 KB

File metadata and controls

262 lines (156 loc) · 6.52 KB

dlasv2

Compute the singular value decomposition of a 2x2 upper triangular matrix.

The singular value decomposition of a 2x2 upper triangular matrix $ \begin{bmatrix} F & G \ 0 & H \end{bmatrix}$ is given by

$$\left[\begin{array}{rr}\mathrm{CSL} & \mathrm{SNL} \\\ -\mathrm{SNL} & \mathrm{CSL}\end{array}\right] \left[\begin{array}{rr}F & G \\\ 0 & H\end{array}\right] \left[\begin{array}{rr}\mathrm{CSR} & -\mathrm{SNR} \\\ \mathrm{SNR} & \mathrm{CSR}\end{array}\right] = \left[\begin{array}{rr}\mathrm{SSMAX} & 0 \\\ 0 & \mathrm{SSMIN}\end{array}\right]$$

where CSL,SNL,CSR,SNR define orthogonal rotations and $\mathrm{SSMAX}^2, \mathrm{SSMIN}^2$ are the eigenvalues of $A^{T}A$.

Usage

var dlasv2 = require( '@stdlib/lapack/base/dlasv2' );

dlasv2( F, G, H, out )

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 true

The 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: Float64Array output array containing SSMIN, SSMAX, SNR, CSR, SNL, and CSL respectively.

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 ]

dlasv2.ndarray( F, G, H, out, strideOut, offsetOut )

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 ]

Notes

Examples

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 );

C APIs

Usage

TODO

TODO

TODO.

TODO

TODO

TODO

Examples

TODO