dlassq
Return an updated sum of squares represented in scaled form.
This routine returns the values $s{textrm{out}}$ and $\textrm{ss}{\textrm{out}}$ such that
where $xi = X{(i-1) \cdot \textrm{sx}}$ and $\textrm{sx}$ is the stride of X
. The value of $\textrm{ss}_{\textrm{in}}$ is assumed to be nonnegative.
Usage
var dlassq = require( '@stdlib/lapack/base/dlassq' );
dlassq( N, X, strideX, scale, sumsq )
Returns an updated sum of squares represented in scaled form.
var Float64Array = require( '@stdlib/array/float64' );
var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
var out = dlassq( 4, X, 1, 1.0, 0.0 );
// returns <Float64Array>[ 1.0, 30.0 ]
The function has the following parameters:
- N: number of indexed elements.
- X: input
Float64Array
. - strideX: stride length for
X
. - scale: scaling factor.
- sumsq: basic sum of squares from which output is factored out.
Note that indexing is relative to the first index. To introduce an offset, use typed array
views.
var Float64Array = require( '@stdlib/array/float64' );
// Initial array:
var X0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] );
// Create an offset view:
var X1 = new Float64Array( X0.buffer, X0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
// Compute the sum of squares:
var out = dlassq( X1.length, X1, 1, 1.0, 0.0 );
// returns <Float64Array>[ 1.0, 30.0 ]
The returned Float64Array
contains an updated scale factor and an updated sum of squares, respectively.
dlassq.ndarray( N, X, sx, ox, scale, sumsq, out, so, oo )
Returns an updated sum of squares represented in scaled form using alternative indexing semantics.
var Float64Array = require( '@stdlib/array/float64' );
var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
var out = new Float64Array( [ 0.0, 0.0 ] );
dlassq.ndarray( 4, X, 1, 0, 1.0, 0.0, out, 1, 0 );
// out => <Float64Array>[ 1.0, 30.0 ]
The function has the following additional parameters:
- ox: starting index for
X
. - out: output
Float64Array
- so: stride length for
out
. - oo: 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 X = new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0 ] );
var out = new Float64Array( [ 0.0, 0.0, 999.9, 0.0, 999.9 ] );
dlassq.ndarray( 4, X, 2, 0, 1.0, 0.0, out, 2, 1 );
// out => <Float64Array>[ 0.0, 1.0, 999.9, 30.0, 999.9 ]
Notes
Examples
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var dlassq = require( '@stdlib/lapack/base/dlassq' );
var X = discreteUniform( 10, -10, 10, {
'dtype': 'float64'
});
console.log( X );
var out = dlassq( X.length, X, 1, 1.0, 0.0 );
console.log( out );
C APIs
Usage
TODO
TODO
TODO.
TODO
TODO
TODO
Examples
TODO