@stdlib/lapack-base-dlassq
v0.1.1
Published
Return an updated sum of squares represented in scaled form.
Downloads
220
Readme
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 $x_i = 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.
Installation
npm install @stdlib/lapack-base-dlassqUsage
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
TODOTODO
TODO.
TODOTODO
TODOExamples
TODOReferences
- Blue, James L. 1978. "A Portable Fortran Program to Find the Euclidean Norm of a Vector." ACM Transactions on Mathematical Software 4 (1). New York, NY, USA: Association for Computing Machinery: 15–23. doi:10.1145/355769.355771.
- Anderson, Edward. 2017. "Algorithm 978: Safe Scaling in the Level 1 BLAS." ACM Transactions on Mathematical Software 44 (1). New York, NY, USA: Association for Computing Machinery: 1–28. doi:10.1145/3061665.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
