Skip to content

Latest commit

 

History

History
257 lines (160 loc) · 6.61 KB

File metadata and controls

257 lines (160 loc) · 6.61 KB

dlarfg

LAPACK routine to generate a real elementary reflector H of order N such that applying H to a vector [alpha; x] zeros out X.

Usage

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

dlarfg( N, X, incx, out )

Generates a real elementary reflector H of order N such that applying H to a vector [alpha; x] zeros out X.

var Float64Array = require( '@stdlib/array/float64' );

var X = new Float64Array( [ 2.0, 3.0, 4.0 ] );
var out = new Float64Array( [ 4.0, 0.0 ] );

dlarfg( 4, X, 1, out );
// X => <Float64Array>[ ~0.19, ~0.28, ~0.37 ]
// out => <Float64Array>[ ~-6.7, ~1.6 ]

The function has the following parameters:

  • N: number of rows/columns of the elementary reflector H.
  • X: overwritten by the vector V on exit, expects N - 1 indexed elements Float64Array.
  • incx: stride length of X.
  • out: output Float64Array, the first element of out represents alpha and the second element of out represents tau.

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 X0 = new Float64Array( [ 0.0, 2.0, 3.0, 4.0 ] );
var out0 = new Float64Array( [ 0.0, 4.0, 0.0 ] );

// Create offset views...
var X1 = new Float64Array( X0.buffer, X0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element

dlarfg( 4, X1, 1, out1 );
// X0 => <Float64Array>[ 0.0, ~0.19, ~0.28, ~0.37 ]
// out0 => <Float64Array>[ 0.0, ~6.7, ~1.6 ]

dlarfg.ndarray( N, X, strideX, offsetX, out, strideOut, offsetOut )

Generates a real elementary reflector H of order N such that applying H to a vector [alpha; x] zeros out X using alternative indexing semantics.

var Float64Array = require( '@stdlib/array/float64' );

var X = new Float64Array( [ 2.0, 3.0, 4.0 ] );
var out = new Float64Array( [ 4.0, 0.0 ] );

dlarfg.ndarray( 4, X, 1, 0, out, 1, 0 );
// X => <Float64Array>[ ~0.19, ~0.28, ~0.37 ]
// out => <Float64Array>[ ~-6.7, ~1.6 ]

The function has the following parameters:

  • N: number of rows/columns of the elementary reflector H.
  • X: overwritten by the vector V on exit, expects N - 1 indexed elements Float64Array.
  • strideX: stride length of X.
  • offsetX: starting index of X.
  • out: output Float64Array, the first element of out represents alpha and the second element of out represents tau.
  • strideOut: stride length of out.
  • offsetOut: starting index of 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 X = new Float64Array( [ 0.0, 2.0, 3.0, 4.0 ] );
var out = new Float64Array( [ 0.0, 4.0, 0.0 ] );

dlarfg.ndarray( 4, X, 1, 1, out, 1, 1 );
// X => <Float64Array>[ 0.0, ~0.19, ~0.28, ~0.37 ]
// out => <Float64Array>[ 0.0, ~6.7, ~1.6 ]

Notes

  • H is a Householder matrix with the form H = I - tau * [1; v] * [1, v^T], where tau is a scalar and v is a vector.
  • the input vector is [alpha; x], where alpha is a scalar and X is a real (n-1)-element vector.
  • the result of applying H to [alpha; x] is [beta; 0], with beta being a scalar and the rest of the vector zeroed.
  • if all elements of X are zero, then tau = 0 and H is the identity matrix.
  • otherwise, 1 <= tau <= 2
  • dlarfg() corresponds to the LAPACK routine dlarfg.

Examples

var uniform = require( '@stdlib/random/array/discrete-uniform' );
var Float64Array = require( '@stdlib/array/float64' );
var dlarfg = require( '@stdlib/lapack/base/dlarfg' );

var N = 4;

var X = uniform( N - 1, -10, 10, {
    'dtype': 'float64'
});
console.log( 'X: ', X );

var alpha = 4.0;

var out = new Float64Array( [ alpha, 0.0 ] );

dlarfg( N, X, 1, out );

console.log( 'V: ', X );
console.log( 'beta: ', out[ 0 ] );
console.log( 'tau: ', out[ 1 ] );

C APIs

Usage

TODO

TODO

TODO.

TODO

TODO

TODO

Examples

TODO