diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md b/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md new file mode 100644 index 000000000000..3eaac8c2e4c1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md @@ -0,0 +1,362 @@ + + +# dlacn2 + +> LAPACK routine to estimate the one-norm of a square matrix `A`, using reverse communication for evaluating matrix-vector products. + +
+ +## Usage + +```javascript +var dlacn2 = require( '@stdlib/lapack/base/dlacn2' ); +``` + +#### dlacn2( N, V, X, ISGN, EST, KASE, ISAVE ) + +Estimates the one-norm of a square matrix `A`, using alternative indexing semantics and reverse communication for evaluating matrix-vector products. + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); +var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); +var EST = new Float64Array( [ 10 ] ); +var KASE = new Int32Array( [ 1 ] ); +var ISAVE = new Int32Array( [ 2, 3, 1 ] ); + +dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +// X => [ 0.0, 0.0, 0.0, 1.0 ] +// V => [ 5.0, 3.0, 1.0, 5.0 ] +// EST => [ 10.0 ] +// KASE => [ 1 ] +``` + +The function has the following parameters: + +- **N**: number of rows/columns in `A`. +- **V**: workspace [`Float64Array`][mdn-float64array] having `N` indexed elements, used internally to store intermediate vectors. +- **X**: input/output [`Float64Array`][mdn-float64array] having `N` indexed elements, contains the current or next matrix-vector product. +- **ISGN**: [`Int32Array`][mdn-int32array] having `N` indexed elements, stores the sign of each element in `X` during iterations. +- **EST**: single-element [`Float64Array`][mdn-float64array], on output, contains the estimated one-norm of the matrix `A`. +- **KASE**: single-element [`Int32Array`][mdn-int32array] that controls the reverse communication. +- **ISAVE**: [`Int32Array`][mdn-int32array] having 3 indexed elements, used internally to maintain state across multiple calls. + +The reverse communication takes place using `KASE`, it may have any of these values: + +- `0`: estimation is complete. +- `1`: caller must compute `A * X` and store the result back in `X`. +- `2`: caller must compute `A^T * X` (transpose) and store the result back in `X`. + +`V` is over written by `A * W` where `EST` contains `norm( A ) / norm( W )`. (W is not returned). + +`ISAVE` has the following three elements: + +- the first indexed element of `ISAVE` is used to determine the control flow for the algorithm. +- the second indexed element of `ISAVE` holds the index of the largest absolute value in `X`. +- the third indexed element of `ISAVE` counts the number of refinement iterations in the algorithm. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var V0 = new Float64Array( [ 0.0, 5.0, 3.0, 1.0, 5.0 ] ); +var X0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +var ISGN0 = new Int32Array( [ 0, 1, 1, 1, 1 ] ); +var EST0 = new Float64Array( [ 0.0, 10.0 ] ); +var KASE0 = new Int32Array( [ 0, 1 ] ); +var ISAVE0 = new Int32Array( [ 0, 2, 3, 1 ] ); + +// Create offset views... +var V = new Float64Array( V0.buffer, V0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var X = new Float64Array( X0.buffer, X0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var ISGN = new Int32Array( ISGN0.buffer, ISGN0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var EST = new Float64Array( EST0.buffer, EST0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var KASE = new Int32Array( KASE0.buffer, KASE0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var ISAVE = new Int32Array( ISAVE0.buffer, ISAVE0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +// X0 => [ 0.0, 0.0, 0.0, 0.0, 1.0 ] +// V0 => [ 0.0, 5.0, 3.0, 1.0, 5.0 ] +// EST0 => [ 0.0, 10.0 ] +// KASE0 => [ 0, 1 ] +``` + + + +#### dlacn2.ndarray( N, V, sv, ov, X, sx, ox, ISGN, sisgn, oisgn, EST, oe, KASE, ok, ISAVE, sisave, oisave ) + +Estimates the one-norm of a square matrix `A`, using alternative indexing semantics and reverse communication for evaluating matrix-vector products. + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); +var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); +var EST = new Float64Array( [ 10 ] ); +var KASE = new Int32Array( [ 1 ] ); +var ISAVE = new Int32Array( [ 2, 3, 1 ] ); + +dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +// X => [ 0.0, 0.0, 0.0, 1.0 ] +// V => [ 5.0, 3.0, 1.0, 5.0 ] +// EST => [ 10.0 ] +// KASE => [ 1 ] +``` + +The function has the following parameters: + +- **N**: number of rows/columns in `A`. +- **V**: workspace [`Float64Array`][mdn-float64array] having `N` indexed elements, used internally to store intermediate vectors. +- **sv**: stride length for `V`. +- **ov**: starting index for `V`. +- **X**: input/output [`Float64Array`][mdn-float64array] having `N` indexed elements, contains the current or next matrix-vector product. +- **sx**: stride length for `X`. +- **ox**: starting index for `X`. +- **ISGN**: [`Int32Array`][mdn-int32array] having `N` indexed elements, stores the sign of each element in `X` during iterations. +- **sisgn**: stride length for `ISGN`. +- **oisgn**: starting index for `ISGN`. +- **EST**: single-element [`Float64Array`][mdn-float64array], on output, contains the estimated one-norm of the matrix `A`. +- **oe**: starting index for `EST`. +- **KASE**: single-element [`Int32Array`][mdn-int32array] that controls the reverse communication. +- **ok**: starting index for `KASE`. +- **ISAVE**: [`Int32Array`][mdn-int32array] having 3 indexed elements, used internally to maintain state across multiple calls. +- **sisave**: stride length for `ISAVE`. +- **oisave**: starting index for `ISAVE`. + +The reverse communication takes place using `KASE`, it may have any of these values: + +- `0`: estimation is complete. +- `1`: caller must compute `A * X` and store the result back in `X`. +- `2`: caller must compute `A^T * X` (transpose) and store the result back in `X`. + +`V` is over written by `A * W` where `EST` contains `norm( A ) / norm( W )`. (W is not returned). + +`ISAVE` has the following three elements: + +- the first indexed element of `ISAVE` is used to determine the control flow for the algorithm. +- the second indexed element of `ISAVE` holds the index of the largest absolute value in `X`. +- the third indexed element of `ISAVE` counts the number of refinement iterations in the algorithm. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var V = new Float64Array( [ 0.0, 5.0, 3.0, 1.0, 5.0 ] ); +var X = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +var ISGN = new Int32Array( [ 0, 1, 1, 1, 1 ] ); +var EST = new Float64Array( [ 0.0, 10.0 ] ); +var KASE = new Int32Array( [ 0, 1 ] ); +var ISAVE = new Int32Array( [ 0, 2, 3, 1 ] ); + +dlacn2.ndarray( 4, V, 1, 1, X, 1, 1, ISGN, 1, 1, EST, 1, KASE, 1, ISAVE, 1, 1 ); +// X => [ 0.0, 0.0, 0.0, 0.0, 1.0 ] +// V => [ 0.0, 5.0, 3.0, 1.0, 5.0 ] +// EST => [ 0.0, 10.0 ] +// KASE => [ 0, 1 ] +``` + +
+ + + +
+ +## Notes + +- `dlacn2()` corresponds to the [LAPACK][LAPACK] function [`dlacn2`][lapack-dlacn2]. + +
+ + + +
+ +## Examples + + + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgemv = require( '@stdlib/blas/base/dgemv' ); +var dcopy = require( '@stdlib/blas/base/dcopy' ); +var dlacn2 = require( '@stdlib/lapack/base/dlacn2' ); + +// Specify matrix meta data: +var shape = [ 4, 4 ]; +var strides = [ 4, 1 ]; +var offset = 0; +var order = 'row-major'; + +// Create a matrix stored in linear memory: +var A = new Float64Array([ + 1.0, -2.0, 0.0, 0.0, + 3.0, 4.0, -5.0, 0.0, + 0.0, 6.0, 7.0, -8.0, + 0.0, 0.0, 9.0, 10.0 +]); + +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +var KASE = new Int32Array( 1 ); +var EST = new Float64Array( 1 ); +var ISGN = new Int32Array( 4 ); +var ISAVE = new Int32Array( 3 ); +var X = new Float64Array( 4 ); +var V = new Float64Array( 4 ); + +var work = new Float64Array( 4 ); + +while ( true ) { + dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'row-major', 'no-transpose', shape[ 0 ], shape[ 1 ], 1.0, A, strides[ 0 ], X, 1, 0, work, 1 ); + dcopy( shape[ 0 ], work, 1, X, 1 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'row-major', 'transpose', shape[ 0 ], shape[ 1 ], 1.0, A, strides[ 0 ], X, 1, 0, work, 1 ); + dcopy( shape[ 0 ], work, 1, X, 1 ); + } +} + +console.log( 'estimated norm: ', EST[ 0 ] ); +console.log( 'V: ', V ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.js new file mode 100644 index 000000000000..34365003d68c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dlacn2 = require( './../lib/dlacn2.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var intOpts; + var ISAVE; + var KASE; + var opts; + var ISGN; + var EST; + var X; + var V; + + opts = { + 'dtype': 'float64' + }; + intOpts = { + 'dtype': 'int32' + }; + + X = uniform( N, 0.0, 100.0, opts ); + V = uniform( N, 0.0, 100.0, opts ); + ISAVE = discreteUniform( 3, 0, N, intOpts ); + KASE = discreteUniform( 1, 0, 2, intOpts ); + EST = uniform( 1, 0.0, 1000.0, opts ); + ISGN = discreteUniform( N, 1, 1, intOpts ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dlacn2( N, V, X, ISGN, EST, KASE, ISAVE ); + if ( isnan( EST[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( EST[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( pkg+':order=column-major,size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..23904b9a77e9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.ndarray.js @@ -0,0 +1,116 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dlacn2 = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var intOpts; + var ISAVE; + var KASE; + var opts; + var ISGN; + var EST; + var X; + var V; + + opts = { + 'dtype': 'float64' + }; + intOpts = { + 'dtype': 'int32' + }; + + X = uniform( N, 0.0, 100.0, opts ); + V = uniform( N, 0.0, 100.0, opts ); + ISAVE = discreteUniform( 3, 0, N, intOpts ); + KASE = discreteUniform( 1, 0, 2, intOpts ); + EST = uniform( 1, 0.0, 1000.0, opts ); + ISGN = discreteUniform( N, 1, 1, intOpts ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + dlacn2( N, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // eslint-disable-line max-len + if ( isnan( EST[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( EST[ 0 ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = pow( 10, i ); + f = createBenchmark( N ); + bench( pkg+':order=column-major,size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt new file mode 100644 index 000000000000..ac457dc905c1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt @@ -0,0 +1,151 @@ + +{{alias}}( N, V, X, ISGN, EST, KASE, ISAVE ) + Estimates the one-norm of a square matrix `A`, using reverse communication + for evaluating matrix-vector products. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + N: integer + Number of rows/columns in `A`. + + V: Float64Array + Workspace array having `N` indexed elements, used internally to store + intermediate vectors. + + X: Float64Array + Input/Output vector having `N` indexed elements, contains the current + or next matrix-vector product. + + ISGN: Int32Array + Integer array having `N` indexed elements, stores the sign of each + element in `X` during iterations. + + EST: Float64Array + Single-element array, on output, contains the estimated one-norm of the + matrix `A`. + + KASE: Int32Array + Single-element array that controls the reverse communication. + + ISAVE: Int32Array + Integer array having 3 indexed elements, used internally to maintain + state across multiple calls. + + Returns + ------- + out: undefined + Writes the arrays in place. + + Examples + -------- + > var V = new {{alias:@stdlib/array/float64}}( [ 5.0, 3.0, 1.0, 5.0 ] ); + > var X = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var ISGN = new {{alias:@stdlib/array/int32}}( [ 1, 1, 1, 1 ] ); + > var EST = new {{alias:@stdlib/array/float64}}( [ 10 ] ); + > var KASE = new {{alias:@stdlib/array/int32}}( [ 1 ] ); + > var ISAVE = new {{alias:@stdlib/array/int32}}( [ 2, 3, 1 ] ); + > {{alias}}( 4, V, X, ISGN, EST, KASE, ISAVE ); + > X + [ 0.0, 0.0, 0.0, 1.0 ] + > V + [ 5.0, 3.0, 1.0, 5.0 ] + > EST + [ 10.0 ] + > KASE + [ 1 ] + + +{{alias}}.ndarray(N,V,sv,ov,X,sx,ox,ISGN,sis,ois,EST,oe,KASE,ok,ISAVE,sis1,ois1) + Estimates the one-norm of a square matrix `A`, using alternative indexing + semantics and reverse communication for evaluating matrix-vector products. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Number of rows/columns in `A`. + + V: Float64Array + Workspace array having `N` indexed elements, used internally to store + intermediate vectors. + + sv: integer + Stride length for `V`. + + ov: integer + Starting index for `V`. + + X: Float64Array + Input/Output vector having `N` indexed elements, contains the current + or next matrix-vector product. + + sx: integer + Stride length for `X`. + + ox: integer + Starting index for `X`. + + ISGN: Int32Array + Integer array having `N` indexed elements, stores the sign of each + element in `X` during iterations. + + sis: integer + Stride length for `ISGN`. + + ois: integer + Starting index for `ISGN`. + + EST: Float64Array + Single-element array, on output, contains the estimated one-norm of the + matrix `A`. + + oe: integer + Starting index for `EST`. + + KASE: Int32Array + Single-element array that controls the reverse communication. + + ok: integer + Starting index for `KASE`. + + ISAVE: Int32Array + Integer array having 3 indexed elements, used internally to maintain + state across multiple calls. + + sis1: integer + Stride length for `ISAVE`. + + ois1: integer + Starting index for `ISAVE`. + + Returns + ------- + out: undefined + Writes the arrays in place. + + Examples + -------- + > var V = new {{alias:@stdlib/array/float64}}( [ 5.0, 3.0, 1.0, 5.0 ] ); + > var X = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var ISGN = new {{alias:@stdlib/array/int32}}( [ 1, 1, 1, 1 ] ); + > var EST = new {{alias:@stdlib/array/float64}}( [ 10 ] ); + > var KASE = new {{alias:@stdlib/array/int32}}( [ 1 ] ); + > var ISAVE = new {{alias:@stdlib/array/int32}}( [ 2, 3, 1 ] ); + > {{alias}}.ndarray( 4, V,1,0, X,1,0, ISGN,1,0, EST,0, KASE,0, ISAVE,1,0 ); + > X + [ 0.0, 0.0, 0.0, 1.0 ] + > V + [ 5.0, 3.0, 1.0, 5.0 ] + > EST + [ 10.0 ] + > KASE + [ 1 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/index.d.ts new file mode 100644 index 000000000000..eddf520d7691 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/index.d.ts @@ -0,0 +1,197 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Interface describing `dlacn2`. +*/ +interface Routine { + /** + * Estimates the one-norm of a square matrix `A`, using alternative indexing semantics and reverse communication for evaluating matrix-vector products. + * + * ## Notes + * + * the reverse communication takes place using `KASE`, it may have any of these values: + * + * - `0`: estimation is complete + * - `1`: caller must compute `A * X` and store the result back in `X` + * - `2`: caller must compute `A^T * X` (transpose) and store the result back in `X` + * + * `V` is over written by `A * W` where `EST` contains `norm( A ) / norm( W )`. (W is not returned) + * + * `ISAVE` has the following three elements: + * + * - the first indexed element of `ISAVE` is used to determine the control flow for the algorithm. + * - the second indexed element of `ISAVE` holds the index of the largest absolute value in `X` + * - the third indexed element of `ISAVE` counts the number of refinement iterations in the algorithm. + * + * @param N - number of rows/columns in `A` + * @param V - workspace array having `N` indexed elements, used internally to store intermediate vectors + * @param X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product + * @param ISGN - integer array having `N` indexed elements, stores the sign of each element in `X` during iterations + * @param EST - single-element array, on output, contains the estimated one-norm of the matrix `A` + * @param KASE - single-element array that controls the reverse communication. + * @param ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls + * @returns `B` + * + * @example + * var Int32Array = require( '@stdlib/array/int32' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); + * var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + * var EST = new Float64Array( [ 10 ] ); + * var KASE = new Int32Array( [ 1 ] ) + * var ISAVE = new Int32Array( [ 2, 3, 1 ] ); + * + * dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + * // X => [ 0.0, 0.0, 0.0, 1.0 ] + * // V => [ 5.0, 3.0, 1.0, 5.0 ] + * // EST => [ 10.0 ] + * // KASE => [ 1 ] + */ + ( N: number, V: Float64Array, X: Float64Array, ISGN: Int32Array, EST: Float64Array, KASE: Int32Array, ISAVE: Int32Array ): void; + + /** + * Estimates the one-norm of a square matrix `A`, using alternative indexing semantics and reverse communication for evaluating matrix-vector products. + * + * ## Notes + * + * the reverse communication takes place using `KASE`, it may have any of these values: + * + * - `0`: estimation is complete + * - `1`: caller must compute `A * X` and store the result back in `X` + * - `2`: caller must compute `A^T * X` (transpose) and store the result back in `X` + * + * `V` is over written by `A * W` where `EST` contains `norm( A ) / norm( W )`. (W is not returned) + * + * `ISAVE` has the following three elements: + * + * - the first indexed element of `ISAVE` is used to determine the control flow for the algorithm. + * - the second indexed element of `ISAVE` holds the index of the largest absolute value in `X` + * - the third indexed element of `ISAVE` counts the number of refinement iterations in the algorithm. + * + * @param N - number of rows/columns in `A` + * @param V - workspace array having `N` indexed elements, used internally to store intermediate vectors + * @param strideV - stride length for `V` + * @param offsetV - starting index for `V` + * @param X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product + * @param strideX - stride length for `X` + * @param offsetX - starting index for `X` + * @param ISGN - integer array having `N` indexed elements, stores the sign of each element in `X` during iterations + * @param strideISGN - stride length for `ISGN` + * @param offsetISGN - starting index for `ISGN` + * @param EST - single-element array, on output, contains the estimated one-norm of the matrix `A` + * @param offsetEST - starting index for `EST` + * @param KASE - single-element array that controls the reverse communication. + * @param offsetKASE - starting index for `KASE` + * @param ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls + * @param strideISAVE - stride length for `ISAVE` + * @param offsetISAVE - starting index for `ISAVE` + * @returns `B` + * + * @example + * var Int32Array = require( '@stdlib/array/int32' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); + * var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + * var EST = new Float64Array( [ 10 ] ); + * var KASE = new Int32Array( [ 1 ] ) + * var ISAVE = new Int32Array( [ 2, 3, 1 ] ); + * + * dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); + * // X => [ 0.0, 0.0, 0.0, 1.0 ] + * // V => [ 5.0, 3.0, 1.0, 5.0 ] + * // EST => [ 10.0 ] + * // KASE => [ 1 ] + */ + ndarray( N: number, V: Float64Array, strideV: number, offsetV: number, X: Float64Array, strideX: number, offsetX: number, ISGN: Int32Array, strideISGN: number, offsetISGN: number, EST: Float64Array, offsetEST: number, KASE: Int32Array, offsetKASE: number, ISAVE: Int32Array, strideISAVE: number, offsetISAVE: number ): void; +} + +/** +* Estimates the one-norm of a square matrix `A`, using alternative indexing semantics and reverse communication for evaluating matrix-vector products. +* +* ## Notes +* +* the reverse communication takes place using `KASE`, it may have any of these values: +* +* - `0`: estimation is complete +* - `1`: caller must compute `A * X` and store the result back in `X` +* - `2`: caller must compute `A^T * X` (transpose) and store the result back in `X` +* +* `V` is over written by `A * W` where `EST` contains `norm( A ) / norm( W )`. (W is not returned) +* +* `ISAVE` has the following three elements: +* +* - the first indexed element of `ISAVE` is used to determine the control flow for the algorithm. +* - the second indexed element of `ISAVE` holds the index of the largest absolute value in `X` +* - the third indexed element of `ISAVE` counts the number of refinement iterations in the algorithm. +* +* @param N - number of rows/columns in `A` +* @param V - workspace array having `N` indexed elements, used internally to store intermediate vectors +* @param X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param ISGN - integer array having `N` indexed elements, stores the sign of each element in `X` during iterations +* @param EST - single-element array, on output, contains the estimated one-norm of the matrix `A` +* @param KASE - single-element array that controls the reverse communication. +* @param ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @returns `B` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); +* var EST = new Float64Array( [ 10 ] ); +* var KASE = new Int32Array( [ 1 ] ) +* var ISAVE = new Int32Array( [ 2, 3, 1 ] ); +* +* dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +* // X => [ 0.0, 0.0, 0.0, 1.0 ] +* // V => [ 5.0, 3.0, 1.0, 5.0 ] +* // EST => [ 10.0 ] +* // KASE => [ 1 ] +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); +* var EST = new Float64Array( [ 10 ] ); +* var KASE = new Int32Array( [ 1 ] ) +* var ISAVE = new Int32Array( [ 2, 3, 1 ] ); +* +* dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +* // X => [ 0.0, 0.0, 0.0, 1.0 ] +* // V => [ 5.0, 3.0, 1.0, 5.0 ] +* // EST => [ 10.0 ] +* // KASE => [ 1 ] +*/ +declare var dlacn2: Routine; + + +// EXPORTS // + +export = dlacn2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/test.ts new file mode 100644 index 000000000000..94fcf446bd53 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/test.ts @@ -0,0 +1,536 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dlacn2 = require( './index' ); + + +// TESTS // + +// The function returns undefined... +{ + const KASE = new Int32Array( 1 ); + const EST = new Float64Array( 1 ); + const ISGN = new Int32Array( 4 ); + const ISAVE = new Int32Array( 3 ); + const X = new Float64Array( 4 ); + const V = new Float64Array( 4 ); + + dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); // $ExpectType void +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + const X = new Float64Array( 4 ); + const V = new Float64Array( 4 ); + + dlacn2( '5', V, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( true, V, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( false, V, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( null, V, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( void 0, V, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( [], V, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( {}, V, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( ( x: number ): number => x, V, X, ISGN, EST, KASE, ISAVE ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + const X = new Float64Array( 4 ); + + dlacn2( 4, '5', X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, 5, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, true, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, false, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, null, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, void 0, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, [], X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, {}, X, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, ( x: number ): number => x, X, ISGN, EST, KASE, ISAVE ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + const V = new Float64Array( 4 ); + + dlacn2( 4, V, '5', ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, 5, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, true, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, false, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, null, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, void 0, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, [], ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, {}, ISGN, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, ( x: number ): number => x, ISGN, EST, KASE, ISAVE ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not an Int32Array... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2( 4, V, X, '5', EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, 5, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, true, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, false, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, null, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, void 0, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, [], EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, {}, EST, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ( x: number ): number => x, EST, KASE, ISAVE ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2( 4, V, X, ISGN, '5', KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, 5, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, true, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, false, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, null, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, void 0, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, [], KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, {}, KASE, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, ( x: number ): number => x, KASE, ISAVE ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not an Int32Array... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2( 4, V, X, ISGN, EST, '5', ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, 5, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, true, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, false, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, null, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, void 0, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, [], ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, {}, ISAVE ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, ( x: number ): number => x, ISAVE ); // $ExpectError +} +// The compiler throws an error if the function is provided a seventh argument which is not an Int32Array... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + + dlacn2( 4, V, X, ISGN, EST, KASE, '5' ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE, 5 ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE, true ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE, false ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE, null ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE, void 0 ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE, [] ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE, {} ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2(); // $ExpectError + dlacn2( 4 ); // $ExpectError + dlacn2( 4, V ); // $ExpectError + dlacn2( 4, V, X ); // $ExpectError + dlacn2( 4, V, X, ISGN ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE ); // $ExpectError + dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a undefined... +{ + const KASE = new Int32Array( 1 ); + const EST = new Float64Array( 1 ); + const ISGN = new Int32Array( 4 ); + const ISAVE = new Int32Array( 3 ); + const X = new Float64Array( 4 ); + const V = new Float64Array( 4 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectType void +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( '4', V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( true, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( false, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( null, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( void 0, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( [], V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( {}, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( ( x: number ): number => x, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float64Array... +{ + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, 'V', 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, 5, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, true, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, null, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, void 0, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, [], 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, {}, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, ( x: number ): number => x, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, '1', 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, true, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, false, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, null, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, void 0, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, [], 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, {}, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, ( x: number ): number => x, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, '0', X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, true, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, false, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, null, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, void 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, [], X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, {}, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, ( x: number ): number => x, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const V = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, 'X', 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, 5, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, true, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, null, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, void 0, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, [], 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, {}, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, ( x: number ): number => x, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, '1', 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, true, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, null, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, void 0, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, [], 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, {}, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, ( x: number ): number => x, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, '0', ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, true, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, null, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, void 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, [], ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, {}, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, ( x: number ): number => x, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not an Int32Array... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, '0', 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, 5, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, true, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, null, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, void 0, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, [], 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, {}, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ( x: number ): number => x, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, '1', 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, true, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, null, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, void 0, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, [], 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, {}, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, ( x: number ): number => x, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, '0', EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, true, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, null, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, void 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, [], EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, {}, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, ( x: number ): number => x, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a Float64Array... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, '0', 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, 5, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, true, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, null, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, void 0, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, [], 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, {}, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, ( x: number ): number => x, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, '0', KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, true, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, null, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, void 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, [], KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, {}, KASE, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, ( x: number ): number => x, KASE, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not an Int32Array... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, '0', 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, 5, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, true, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, null, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, void 0, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, [], 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, {}, 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, ( x: number ): number => x, 0, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourteenth argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, '0', ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, true, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, null, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, void 0, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, [], ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, {}, ISAVE, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, ( x: number ): number => x, ISAVE, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifteenth argument which is not an Int32Array... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, '0', 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, 5, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, true, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, null, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, void 0, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, [], 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, {}, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixteenth argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, '1', 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, true, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, null, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, void 0, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, [], 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, {}, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventeenth argument which is not a number... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, '0' ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, true ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, null ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, void 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, [] ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, {} ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const V = new Float64Array( 4 ); + const X = new Float64Array( 4 ); + const ISGN = new Int32Array( 4 ); + const EST = new Float64Array( 1 ); + const KASE = new Int32Array( 1 ); + const ISAVE = new Int32Array( 3 ); + + dlacn2.ndarray(); // $ExpectError + dlacn2.ndarray( 4 ); // $ExpectError + dlacn2.ndarray( 4, V ); // $ExpectError + dlacn2.ndarray( 4, V, 1 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1 ); // $ExpectError + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0, 0 ); // $ExpectError +} + diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js new file mode 100644 index 000000000000..34bd6c592c1c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/* eslint-disable array-element-newline */ + +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dgemv = require( '@stdlib/blas/base/dgemv' ); +var dcopy = require( '@stdlib/blas/base/dcopy' ); +var dlacn2 = require( './../lib' ); + +// Specify matrix meta data: +var shape = [ 4, 4 ]; +var strides = [ 4, 1 ]; +var offset = 0; +var order = 'row-major'; + +// Create a matrix stored in linear memory: +var A = new Float64Array([ + 1.0, -2.0, 0.0, 0.0, + 3.0, 4.0, -5.0, 0.0, + 0.0, 6.0, 7.0, -8.0, + 0.0, 0.0, 9.0, 10.0 +]); + +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +var KASE = new Int32Array( 1 ); +var EST = new Float64Array( 1 ); +var ISGN = new Int32Array( 4 ); +var ISAVE = new Int32Array( 3 ); +var X = new Float64Array( 4 ); +var V = new Float64Array( 4 ); + +var work = new Float64Array( 4 ); + +while ( true ) { + dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'row-major', 'no-transpose', shape[ 0 ], shape[ 1 ], 1.0, A, strides[ 0 ], X, 1, 0, work, 1 ); + dcopy( shape[ 0 ], work, 1, X, 1 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'row-major', 'transpose', shape[ 0 ], shape[ 1 ], 1.0, A, strides[ 0 ], X, 1, 0, work, 1 ); + dcopy( shape[ 0 ], work, 1, X, 1 ); + } +} + +console.log( 'estimated norm: ', EST[ 0 ] ); +console.log( 'V: ', V ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js new file mode 100644 index 000000000000..c408a7489eec --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js @@ -0,0 +1,487 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/* eslint-disable max-len, max-params */ + +// MODULES // + +var abs = require( '@stdlib/math/base/special/abs' ); +var idamax = require( '@stdlib/blas/base/idamax' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var dasum = require( '@stdlib/blas/base/dasum' ).ndarray; +var nint = require( './nint.js' ); + + +// MAIN // + +/** +* Applies a deterministic fallback vector for final evaluation. +* +* @private +* @param {PositiveInteger} N - number of rows/columns in `A` +* @param {Float64Array} X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Int32Array} KASE - single-element array that controls the reverse communication. +* @param {NonNegativeInteger} offsetKASE - starting index for `KASE` +* @param {Int32Array} ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @param {NonNegativeInteger} offsetISAVE - starting index for `ISAVE` +* @returns {void} +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( 4 ); +* var KASE = new Int32Array( [ 0 ] ); +* var ISAVE = new Int32Array( [ 0 ] ); +* +* finalStep( 4, X, 1, 0, KASE, 0, ISAVE, 0 ); +* +* // X => [ 1.0, ~-1.33, ~1.67, -2.0 ] +* // KASE => [ 1 ] +* // ISAVE => [ 5 ] +*/ +function finalStep( N, X, strideX, offsetX, KASE, offsetKASE, ISAVE, offsetISAVE ) { + var altsgn; + var ix; + var i; + + ix = offsetX; + altsgn = 1.0; + for ( i = 0; i < N; i++ ) { + X[ ix ] = altsgn * ( 1.0 + ( i / ( N - 1 ) ) ); + altsgn *= -1; + + ix += strideX; + } + + KASE[ offsetKASE ] = 1; + ISAVE[ offsetISAVE ] = 5; +} + +/** +* Initializes the estimation of the one-norm of a square matrix `A`. +* +* @private +* @param {PositiveInteger} N - number of rows/columns in `A` +* @param {Float64Array} V - workspace array having `N` indexed elements, used internally to store intermediate vectors +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @param {Float64Array} X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Int32Array} ISGN - integer array having `N` indexed elements, stores the sign of each element in `X` during iterations +* @param {integer} strideISGN - stride length for `ISGN` +* @param {NonNegativeInteger} offsetISGN - starting index for `ISGN` +* @param {Float64Array} EST - single-element array, on output, contains the estimated one-norm of the matrix `A` +* @param {NonNegativeInteger} offsetEST - starting index for `EST` +* @param {Int32Array} KASE - single-element array that controls the reverse communication. +* @param {NonNegativeInteger} offsetKASE - starting index for `KASE` +* @param {Int32Array} ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @param {NonNegativeInteger} offsetISAVE - starting index for `ISAVE` +* @returns {void} +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( [ -2.0, 3.0, 0.0, -4.0 ] ); +* var V = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); +* var ISGN = new Int32Array( [ 0, 0, 0, 0 ] ); +* var EST = new Float64Array( [ 0.0 ] ); +* var KASE = new Int32Array( [ -1 ] ); +* var ISAVE = new Int32Array( [ 0 ] ); +* +* isaveIsOne( 4, V, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 0 ); +* +* // EST => [ 9.0 ] +* // X => [ -1.0, 1.0, 1.0, -1.0 ] +* // ISGN => [ -1, 1, 1, -1 ] +* // KASE => [ 2 ] +* // ISAVE => [ 2 ] +*/ +function isaveIsOne( N, V, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, offsetISAVE ) { + var is; + var ix; + var i; + + if ( N === 1 ) { + V[ offsetV ] = X[ offsetX ]; + EST[ offsetEST ] = abs( V[ offsetV ] ); + KASE[ offsetKASE ] = 0; + return; + } + + EST[ offsetEST ] = dasum( N, X, strideX, offsetX ); + + ix = offsetX; + is = offsetISGN; + for ( i = 0; i < N; i++ ) { + if ( X[ ix ] >= 0.0 ) { + X[ ix ] = 1.0; + } else { + X[ ix ] = -1.0; + } + ISGN[ is ] = nint( X[ ix ] ); + + ix += strideX; + is += strideISGN; + } + KASE[ offsetKASE ] = 2; + ISAVE[ offsetISAVE ] = 2; +} + +/** +* Performs an initial pivot based on the largest magnitude element of `X`. +* +* @private +* @param {PositiveInteger} N - number of rows/columns in `A` +* @param {Float64Array} X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Int32Array} KASE - single-element array that controls the reverse communication. +* @param {NonNegativeInteger} offsetKASE - starting index for `KASE` +* @param {Int32Array} ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @param {integer} strideISAVE - stride length for `ISAVE` +* @param {NonNegativeInteger} offsetISAVE - starting index for `ISAVE` +* @returns {void} +* +* @example +* var X = new Float64Array( [ 1.0, -5.0, 2.0, 0.5 ] ); +* var KASE = new Int32Array( [ 0 ] ); +* var ISAVE = new Int32Array( [ 0, 0, 0 ] ); +* +* isaveIsTwo( 4, X, 1, 0, KASE, 0, ISAVE, 1, 0 ); +* +* // X => [ 0.0, 1.0, 0.0, 0.0 ] +* // ISAVE => [ 3, 1, 2 ] +* // KASE => [ 1 ] +*/ +function isaveIsTwo( N, X, strideX, offsetX, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ) { + var ix; + var i; + + ISAVE[ offsetISAVE + strideISAVE ] = idamax( N, X, strideX, offsetX ); + ISAVE[ offsetISAVE + ( 2 * strideISAVE ) ] = 2; + + ix = offsetX; + for ( i = 0; i < N; i++ ) { + X[ ix ] = 0.0; + ix += strideX; + } + + X[ offsetX + ( ISAVE[ offsetISAVE + strideISAVE ] * strideX ) ] = 1.0; + KASE[ offsetKASE ] = 1; + ISAVE[ offsetISAVE ] = 3; +} + +/** +* Updates estimates and checks whether convergence has occurred. +* +* @private +* @param {PositiveInteger} N - number of rows/columns in `A` +* @param {Float64Array} X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Float64Array} V - workspace array having `N` indexed elements, used internally to store intermediate vectors +* @param {integer} strideV - stride length for `V` +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @param {Float64Array} EST - single-element array, on output, contains the estimated one-norm of the matrix `A` +* @param {NonNegativeInteger} offsetEST - starting index for `EST` +* @param {Int32Array} KASE - single-element array that controls the reverse communication. +* @param {NonNegativeInteger} offsetKASE - starting index for `KASE` +* @param {Int32Array} ISGN - integer array having `N` indexed elements, stores the sign of each element in `X` during iterations +* @param {integer} strideISGN - stride length for `ISGN` +* @param {NonNegativeInteger} offsetISGN - starting index for `ISGN` +* @param {Int32Array} ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @param {NonNegativeInteger} offsetISAVE - starting index for `ISAVE` +* @returns {void} +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( [ -2.0, 0.0, 3.0, -4.0 ] ); +* var V = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); +* var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); // Deliberate mismatch +* var EST = new Float64Array( [ 6.0 ] ); // estold +* var KASE = new Int32Array( [ -1 ] ); +* var ISAVE = new Int32Array( [ 3 ] ); +* +* isaveIsThree( 4, X, 1, 0, V, 1, 0, EST, 0, KASE, 0, ISGN, 1, 0, ISAVE, 0 ); +* +* // EST => [ 9.0 ] +* // X => [ -1.0, 1.0, -1.0, -1.0 ] +* // ISGN => [ -1, 1, -1, -1 ] +* // KASE => [ 2 ] +* // ISAVE => [ 4 ] +* // V => [ -2.0, 0.0, 3.0, -4.0 ] +*/ +function isaveIsThree( N, X, strideX, offsetX, V, strideV, offsetV, EST, offsetEST, KASE, offsetKASE, ISGN, strideISGN, offsetISGN, ISAVE, offsetISAVE ) { + var estold; + var ix1; + var is1; + var ix; + var is; + var xs; + var i; + var j; + + dcopy( N, X, strideX, offsetX, V, strideV, offsetV ); + estold = EST[ offsetEST ]; + EST[ offsetEST ] = dasum( N, V, strideV, offsetV ); + + ix = offsetX; + is = offsetISGN; + for ( i = 0; i < N; i++ ) { + if ( X[ ix ] >= 0.0 ) { + xs = 1.0; + } else { + xs = -1.0; + } + + if ( nint( xs ) !== ISGN[ is ] ) { + if ( EST[ offsetEST ] <= estold ) { + finalStep( N, X, strideX, offsetX, KASE, offsetKASE, ISAVE, offsetISAVE ); + return; + } + + ix1 = offsetX; + is1 = offsetISGN; + for ( j = 0; j < N; j++ ) { + if ( X[ ix1 ] >= 0.0 ) { + X[ ix1 ] = 1.0; + } else { + X[ ix1 ] = -1.0; + } + ISGN[ is1 ] = nint( X[ ix1 ] ); + + ix1 += strideX; + is1 += strideISGN; + } + KASE[ offsetKASE ] = 2; + ISAVE[ offsetISAVE ] = 4; + return; + } + + ix += strideX; + is += strideISGN; + } + + finalStep( N, X, strideX, offsetX, KASE, offsetKASE, ISAVE, offsetISAVE ); +} + +/** +* Attempts to refine the estimate by cycling through multiple basis vectors. +* +* @private +* @param {PositiveInteger} N - number of rows/columns in `A` +* @param {Float64Array} X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Int32Array} ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @param {integer} strideISAVE - stride length for `ISAVE` +* @param {NonNegativeInteger} offsetISAVE - starting index for `ISAVE` +* @param {Int32Array} KASE - single-element array that controls the reverse communication. +* @param {NonNegativeInteger} offsetKASE - starting index for `KASE` +* @returns {void} +* +* @example +* var X = new Float64Array( [ 2.0, 0.5, -3.0, 4.0 ] ); +* var ISAVE = new Int32Array( [ 2, 1, 3 ] ); +* var KASE = new Int32Array( [ -1 ] ); +* +* isaveIsFour( 4, X, 1, 0, ISAVE, 1, 0, KASE, 0 ); +* +* // X => [ 0.0, 0.0, 0.0, 1.0 ] +* // ISAVE => [ 3, 3, 4 ] +* // KASE => [ 1 ] +*/ +function isaveIsFour( N, X, strideX, offsetX, ISAVE, strideISAVE, offsetISAVE, KASE, offsetKASE ) { + var jlast; + var ix; + var i; + + jlast = ISAVE[ offsetISAVE + strideISAVE ]; + ISAVE[ offsetISAVE + strideISAVE ] = idamax( N, X, strideX, offsetX ); + + if ( X[ offsetX + ( jlast * strideX ) ] !== abs( X[ offsetX + ( ISAVE[ offsetISAVE + strideISAVE ] * strideX ) ] ) && ISAVE[ offsetISAVE + ( 2 * strideISAVE ) ] < 5 ) { + ISAVE[ offsetISAVE + ( 2 * strideISAVE ) ] += 1; + ix = offsetX; + for ( i = 0; i < N; i++ ) { + X[ ix ] = 0.0; + ix += strideX; + } + X[ offsetX + ( ISAVE[ offsetISAVE + strideISAVE ] * strideX ) ] = 1.0; + KASE[ offsetKASE ] = 1; + ISAVE[ offsetISAVE ] = 3; + return; + } + + finalStep( N, X, strideX, offsetX, KASE, offsetKASE, ISAVE, offsetISAVE ); +} + +/** +* Final test to refine the current estimate. +* +* @private +* @param {PositiveInteger} N - number of rows/columns in `A` +* @param {Float64Array} V - workspace array having `N` indexed elements, used internally to store intermediate vectors +* @param {integer} strideV - stride length for `V` +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @param {Float64Array} X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Float64Array} EST - single-element array, on output, contains the estimated one-norm of the matrix `A` +* @param {NonNegativeInteger} offsetEST - starting index for `EST` +* @param {Int32Array} KASE - single-element array that controls the reverse communication. +* @param {NonNegativeInteger} offsetKASE - starting index for `KASE` +* @param {Int32Array} ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @param {integer} strideISAVE - stride length for `ISAVE` +* @param {NonNegativeInteger} offsetISAVE - starting index for `ISAVE` +* @returns {void} +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 0.0, 0.0, 0.0, 0.0 ] ); +* var X = new Float64Array( [ 3.0, 1.0, -2.0, 4.0 ] ); +* var EST = new Float64Array( [ 1.0 ] ); +* var KASE = new Int32Array( [ 1 ] ); +* +* isaveIsFive( 4, V, 1, 0, X, 1, 0, EST, 0, KASE, 0 ); +* +* // EST => [ 2.5 ] +* // V => [ 3.0, 1.0, -2.0, 4.0 ] +* // KASE => [ 0 ] +*/ +function isaveIsFive( N, V, strideV, offsetV, X, strideX, offsetX, EST, offsetEST, KASE, offsetKASE ) { + var temp; + + temp = 2.0 * dasum( N, X, strideX, offsetX ) / ( 3 * N ); + if ( temp > EST[ offsetEST ] ) { + dcopy( N, X, strideX, offsetX, V, strideV, offsetV ); + EST[ offsetEST ] = temp; + } + + KASE[ offsetKASE ] = 0; +} + +/** +* Estimates the one-norm of a square matrix `A`, using reverse communication for evaluating matrix-vector products. +* +* ## Notes +* +* the reverse communication takes place using `KASE`, it may have any of these values: +* +* - `0`: estimation is complete +* - `1`: caller must compute `A * X` and store the result back in `X` +* - `2`: caller must compute `A^T * X` (transpose) and store the result back in `X` +* +* `V` is over written by `A * W` where `EST` contains `norm( A ) / norm( W )`. (W is not returned) +* +* `ISAVE` has the following three elements: +* +* - the first indexed element of `ISAVE` is used to determine the control flow for the algorithm +* - the second indexed element of `ISAVE` holds the index of the largest absolute value in `X` +* - the third indexed element of `ISAVE` counts the number of refinement iterations in the algorithm +* +* @private +* @param {PositiveInteger} N - number of rows/columns in `A` +* @param {Float64Array} V - workspace array having `N` indexed elements, used internally to store intermediate vectors +* @param {integer} strideV - stride length for `V` +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @param {Float64Array} X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Int32Array} ISGN - integer array having `N` indexed elements, stores the sign of each element in `X` during iterations +* @param {integer} strideISGN - stride length for `ISGN` +* @param {NonNegativeInteger} offsetISGN - starting index for `ISGN` +* @param {Float64Array} EST - single-element array, on output, contains the estimated one-norm of the matrix `A` +* @param {NonNegativeInteger} offsetEST - starting index for `EST` +* @param {Int32Array} KASE - single-element array that controls the reverse communication. +* @param {NonNegativeInteger} offsetKASE - starting index for `KASE` +* @param {Int32Array} ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @param {integer} strideISAVE - stride length for `ISAVE` +* @param {NonNegativeInteger} offsetISAVE - starting index for `ISAVE` +* @returns {void} +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); +* var EST = new Float64Array( [ 10 ] ); +* var KASE = new Int32Array( [ 1 ] ) +* var ISAVE = new Int32Array( [ 2, 3, 1 ] ); +* +* dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +* // X => [ 0.0, 0.0, 0.0, 1.0 ] +* // V => [ 5.0, 3.0, 1.0, 5.0 ] +* // EST => [ 10.0 ] +* // KASE => [ 1 ] +*/ +function dlacn2( N, V, strideV, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ) { + var ix; + var i; + + if ( KASE[ offsetKASE ] === 0 ) { + ix = offsetX; + for ( i = 0; i < N; i++ ) { + X[ ix ] = 1 / N; + ix += strideX; + } + KASE[ offsetKASE ] = 1; + ISAVE[ offsetISAVE ] = 1; + return; + } + + if ( ISAVE[ offsetISAVE ] === 1 ) { + isaveIsOne( N, V, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, offsetISAVE ); + return; + } + + if ( ISAVE[ offsetISAVE ] === 2 ) { + isaveIsTwo( N, X, strideX, offsetX, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ); + return; + } + + if ( ISAVE[ offsetISAVE ] === 3 ) { + isaveIsThree( N, X, strideX, offsetX, V, strideV, offsetV, EST, offsetEST, KASE, offsetKASE, ISGN, strideISGN, offsetISGN, ISAVE, offsetISAVE ); + return; + } + + if ( ISAVE[ offsetISAVE ] === 4 ) { + isaveIsFour( N, X, strideX, offsetX, ISAVE, strideISAVE, offsetISAVE, KASE, offsetKASE ); + return; + } + + if ( ISAVE[ offsetISAVE ] === 5 ) { + isaveIsFive( N, V, strideV, offsetV, X, strideX, offsetX, EST, offsetEST, KASE, offsetKASE ); + } +} + + +// EXPORTS // + +module.exports = dlacn2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/dlacn2.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/dlacn2.js new file mode 100644 index 000000000000..3d8df2a26706 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/dlacn2.js @@ -0,0 +1,80 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Estimates the one-norm of a square matrix `A`, using alternative indexing semantics and reverse communication for evaluating matrix-vector products. +* +* ## Notes +* +* the reverse communication takes place using `KASE`, it may have any of these values: +* +* - `0`: estimation is complete +* - `1`: caller must compute `A * X` and store the result back in `X` +* - `2`: caller must compute `A^T * X` (transpose) and store the result back in `X` +* +* `V` is over written by `A * W` where `EST` contains `norm( A ) / norm( W )`. (W is not returned) +* +* `ISAVE` has the following three elements: +* +* - the first indexed element of `ISAVE` is used to determine the control flow for the algorithm +* - the second indexed element of `ISAVE` holds the index of the largest absolute value in `X` +* - the third indexed element of `ISAVE` counts the number of refinement iterations in the algorithm +* +* @param {PositiveInteger} N - number of rows/columns in `A` +* @param {Float64Array} V - workspace array having `N` indexed elements, used internally to store intermediate vectors +* @param {Float64Array} X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param {Int32Array} ISGN - integer array having `N` indexed elements, stores the sign of each element in `X` during iterations +* @param {Float64Array} EST - single-element array, on output, contains the estimated one-norm of the matrix `A` +* @param {Int32Array} KASE - single-element array that controls the reverse communication. +* @param {Int32Array} ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @returns {void} +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); +* var EST = new Float64Array( [ 10 ] ); +* var KASE = new Int32Array( [ 1 ] ) +* var ISAVE = new Int32Array( [ 2, 3, 1 ] ); +* +* dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +* // X => [ 0.0, 0.0, 0.0, 1.0 ] +* // V => [ 5.0, 3.0, 1.0, 5.0 ] +* // EST => [ 10.0 ] +* // KASE => [ 1 ] +*/ +function dlacn2( N, V, X, ISGN, EST, KASE, ISAVE ) { + return base( N, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dlacn2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js new file mode 100644 index 000000000000..a819f3650790 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to estimate the one-norm of a square matrix `A`, using reverse communication for evaluating matrix-vector products. +* +* @module @stdlib/lapack/base/dlacn2 +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlacn2 = require( '@stdlib/lapack/base/dlacn2' ); +* +* var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); +* var EST = new Float64Array( [ 10 ] ); +* var KASE = new Int32Array( [ 1 ] ) +* var ISAVE = new Int32Array( [ 2, 3, 1 ] ); +* +* dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +* // X => [ 0.0, 0.0, 0.0, 1.0 ] +* // V => [ 5.0, 3.0, 1.0, 5.0 ] +* // EST => [ 10.0 ] +* // KASE => [ 1 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var dlacn2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlacn2 = main; +} else { + dlacn2 = tmp; +} + + +// EXPORTS // + +module.exports = dlacn2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/main.js new file mode 100644 index 000000000000..95209612ef75 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var dlacn2 = require( './dlacn2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlacn2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlacn2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js new file mode 100644 index 000000000000..3506e7f466ab --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js @@ -0,0 +1,90 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Estimates the one-norm of a square matrix `A`, using alternative indexing semantics and reverse communication for evaluating matrix-vector products. +* +* ## Notes +* +* the reverse communication takes place using `KASE`, it may have any of these values: +* +* - `0`: estimation is complete +* - `1`: caller must compute `A * X` and store the result back in `X` +* - `2`: caller must compute `A^T * X` (transpose) and store the result back in `X` +* +* `V` is over written by `A * W` where `EST` contains `norm( A ) / norm( W )`. (W is not returned) +* +* `ISAVE` has the following three elements: +* +* - the first indexed element of `ISAVE` is used to determine the control flow for the algorithm. +* - the second indexed element of `ISAVE` holds the index of the largest absolute value in `X` +* - the third indexed element of `ISAVE` counts the number of refinement iterations in the algorithm. +* +* @param {PositiveInteger} N - number of rows/columns in `A` +* @param {Float64Array} V - workspace array having `N` indexed elements, used internally to store intermediate vectors +* @param {integer} strideV - stride length for `V` +* @param {NonNegativeInteger} offsetV - starting index for `V` +* @param {Float64Array} X - input/output vector having `N` indexed elements, contains the current or next matrix-vector product +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Int32Array} ISGN - integer array having `N` indexed elements, stores the sign of each element in `X` during iterations +* @param {integer} strideISGN - stride length for `ISGN` +* @param {NonNegativeInteger} offsetISGN - starting index for `ISGN` +* @param {Float64Array} EST - single-element array, on output, contains the estimated one-norm of the matrix `A` +* @param {NonNegativeInteger} offsetEST - starting index for `EST` +* @param {Int32Array} KASE - single-element array that controls the reverse communication. +* @param {NonNegativeInteger} offsetKASE - starting index for `KASE` +* @param {Int32Array} ISAVE - integer array having 3 indexed elements, used internally to maintain state across multiple calls +* @param {integer} strideISAVE - stride length for `ISAVE` +* @param {NonNegativeInteger} offsetISAVE - starting index for `ISAVE` +* @returns {void} +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var V = new Float64Array( [ 5.0, 3.0, 1.0, 5.0 ] ); +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); +* var EST = new Float64Array( [ 10 ] ); +* var KASE = new Int32Array( [ 1 ] ) +* var ISAVE = new Int32Array( [ 2, 3, 1 ] ); +* +* dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +* // X => [ 0.0, 0.0, 0.0, 1.0 ] +* // V => [ 5.0, 3.0, 1.0, 5.0 ] +* // EST => [ 10.0 ] +* // KASE => [ 1 ] +*/ +function dlacn2( N, V, strideV, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ) { // eslint-disable-line max-len, max-params + return base( N, V, strideV, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dlacn2; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/nint.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/nint.js new file mode 100644 index 000000000000..2fc213aac233 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/nint.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var floor = require( '@stdlib/math/base/special/floor' ); +var isEven = require( '@stdlib/math/base/assert/is-even' ); + + +// MAIN // + +/** +* Rounds X to the nearest integer following Baker's rounding. +* +* @private +* @param {PositiveInteger} X - input number +* @returns {number} nearest integer +* +* @example +* var out = nint( 4.5 ); +* // returns 4.0 +*/ +function nint( X ) { + var frac; + var flo; + + flo = floor( X ); + frac = X - flo; + + if ( frac < 0.5 ) { + return flo; + } + + if ( frac > 0.5 ) { + return flo + 1; + } + + if ( isEven( flo ) ) { + return flo; + } + + return flo + 1; +} + + +// EXPORTS // + +module.exports = nint; diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/package.json b/lib/node_modules/@stdlib/lapack/base/dlacn2/package.json new file mode 100644 index 000000000000..f56f48336fb9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/lapack/base/dlacn2", + "version": "0.0.0", + "description": "LAPACK routine to estimate the one-norm of a square matrix `A`, using reverse communication for evaluating matrix-vector products.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "lapack", + "dlacn2", + "norm", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.dlacn2.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.dlacn2.js new file mode 100644 index 000000000000..dc7403f190b1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.dlacn2.js @@ -0,0 +1,222 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/* eslint-disable array-element-newline */ + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgemv = require( '@stdlib/blas/base/dgemv' ); +var dcopy = require( '@stdlib/blas/base/dcopy' ); +var dlacn2 = require( './../lib/dlacn2.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlacn2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 7', function test( t ) { + t.strictEqual( dlacn2.length, 7, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix for N = 1', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array( [ -25.0 ] ); + + KASE = new Int32Array( 1 ); + EST = new Float64Array( 1 ); + ISGN = new Int32Array( 1 ); + ISAVE = new Int32Array( 3 ); + X = new Float64Array( 1 ); + V = new Float64Array( 1 ); + + work = new Float64Array( 1 ); + + while ( true ) { + dlacn2( 1, V, X, ISGN, EST, KASE, ISAVE ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'row-major', 'no-transpose', 1, 1, 1.0, A, 1, X, 1, 0, work, 1 ); + dcopy( 1, work, 1, X, 1 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'row-major', 'transpose', 1, 1, 1.0, A, 1, X, 1, 0, work, 1 ); + dcopy( 1, work, 1, X, 1 ); + } + } + + expectedEST = new Float64Array( [ 25.0 ] ); + expectedV = new Float64Array( [ -25.0 ] ); + expectedKASE = new Int32Array( [ 0 ] ); + expectedISGN = new Int32Array( [ 0 ] ); + expectedISAVE = new Int32Array( [ 1, 0, 0 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, -2.0, 0.0, 0.0, + 3.0, 4.0, -5.0, 0.0, + 0.0, 6.0, 7.0, -8.0, + 0.0, 0.0, 9.0, 10.0 + ]); + + KASE = new Int32Array( 1 ); + EST = new Float64Array( 1 ); + ISGN = new Int32Array( 4 ); + ISAVE = new Int32Array( 3 ); + X = new Float64Array( 4 ); + V = new Float64Array( 4 ); + + work = new Float64Array( 4 ); + + while ( true ) { + dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'row-major', 'no-transpose', 4, 4, 1.0, A, 4, X, 1, 0, work, 1 ); + dcopy( 4, work, 1, X, 1 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'row-major', 'transpose', 4, 4, 1.0, A, 4, X, 1, 0, work, 1 ); + dcopy( 4, work, 1, X, 1 ); + } + } + + expectedEST = new Float64Array( [ 12.0 ] ); + expectedV = new Float64Array( [ -2.0, 4.0, 6.0, 0.0 ] ); + expectedKASE = new Int32Array( [ 0 ] ); + expectedISGN = new Int32Array( [ -1, 1, 1, 1 ] ); + expectedISAVE = new Int32Array( [ 5, 1, 2 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, 10.0, 0.0, 0.0, + 1.0, 10.0, 0.0, 0.0, + 1.0, -1.0, 1.0, 1.0, + 1.0, -1.0, 1.0, 1.0 + ]); + + KASE = new Int32Array( 1 ); + EST = new Float64Array( 1 ); + ISGN = new Int32Array( 4 ); + ISAVE = new Int32Array( 3 ); + X = new Float64Array( 4 ); + V = new Float64Array( 4 ); + + work = new Float64Array( 4 ); + + while ( true ) { + dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'row-major', 'no-transpose', 4, 4, 1.0, A, 4, X, 1, 0, work, 1 ); + dcopy( 4, work, 1, X, 1 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'row-major', 'transpose', 4, 4, 1.0, A, 4, X, 1, 0, work, 1 ); + dcopy( 4, work, 1, X, 1 ); + } + } + + expectedEST = new Float64Array( [ 22.0 ] ); + expectedV = new Float64Array( [ 10.0, 10.0, -1.0, -1.0 ] ); + expectedKASE = new Int32Array( [ 0 ] ); + expectedISGN = new Int32Array( [ 1, 1, -1, -1 ] ); + expectedISAVE = new Int32Array( [ 5, 1, 2 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.js new file mode 100644 index 000000000000..112dac9c75b9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dlacn2 = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlacn2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof dlacn2.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var dlacn2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlacn2, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var dlacn2; + var main; + + main = require( './../lib/dlacn2.js' ); + + dlacn2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlacn2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js new file mode 100644 index 000000000000..eba56b468c81 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js @@ -0,0 +1,588 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/* eslint-disable array-element-newline, max-len */ + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dgemv = require( '@stdlib/blas/base/dgemv' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var dlacn2 = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlacn2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 17', function test( t ) { + t.strictEqual( dlacn2.length, 17, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix for N = 1', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array( [ -25.0 ] ); + + KASE = new Int32Array( 1 ); + EST = new Float64Array( 1 ); + ISGN = new Int32Array( 1 ); + ISAVE = new Int32Array( 3 ); + X = new Float64Array( 1 ); + V = new Float64Array( 1 ); + + work = new Float64Array( 1 ); + + while ( true ) { + dlacn2( 1, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'no-transpose', 1, 1, 1.0, A, 1, 1, 0, X, 1, 0, 0, work, 1, 0 ); + dcopy( 1, work, 1, 0, X, 1, 0 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'transpose', 1, 1, 1.0, A, 1, 1, 0, X, 1, 0, work, 1 ); + dcopy( 1, work, 1, X, 0 ); + } + } + + expectedEST = new Float64Array( [ 25.0 ] ); + expectedV = new Float64Array( [ -25.0 ] ); + expectedKASE = new Int32Array( [ 0 ] ); + expectedISGN = new Int32Array( [ 0 ] ); + expectedISAVE = new Int32Array( [ 1, 0, 0 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, -2.0, 0.0, 0.0, + 3.0, 4.0, -5.0, 0.0, + 0.0, 6.0, 7.0, -8.0, + 0.0, 0.0, 9.0, 10.0 + ]); + + KASE = new Int32Array( 1 ); + EST = new Float64Array( 1 ); + ISGN = new Int32Array( 4 ); + ISAVE = new Int32Array( 3 ); + X = new Float64Array( 4 ); + V = new Float64Array( 4 ); + + work = new Float64Array( 4 ); + + while ( true ) { + dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'no-transpose', 4, 4, 1.0, A, 4, 1, 0, X, 1, 0, 0, work, 1, 0 ); + dcopy( 4, work, 1, 0, X, 1, 0 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'transpose', 4, 4, 1.0, A, 4, 1, 0, X, 1, 0, 0, work, 1, 0 ); + dcopy( 4, work, 1, 0, X, 1, 0 ); + } + } + + expectedEST = new Float64Array( [ 12.0 ] ); + expectedV = new Float64Array( [ -2.0, 4.0, 6.0, 0.0 ] ); + expectedKASE = new Int32Array( [ 0 ] ); + expectedISGN = new Int32Array( [ -1, 1, 1, 1 ] ); + expectedISAVE = new Int32Array( [ 5, 1, 2 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, 10.0, 0.0, 0.0, + 1.0, 10.0, 0.0, 0.0, + 1.0, -1.0, 1.0, 1.0, + 1.0, -1.0, 1.0, 1.0 + ]); + + KASE = new Int32Array( 1 ); + EST = new Float64Array( 1 ); + ISGN = new Int32Array( 4 ); + ISAVE = new Int32Array( 3 ); + X = new Float64Array( 4 ); + V = new Float64Array( 4 ); + + work = new Float64Array( 4 ); + + while ( true ) { + dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'no-transpose', 4, 4, 1.0, A, 4, 1, 0, X, 1, 0, 0, work, 1, 0 ); + dcopy( 4, work, 1, 0, X, 1, 0 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'transpose', 4, 4, 1.0, A, 4, 1, 0, X, 1, 0, 0, work, 1, 0 ); + dcopy( 4, work, 1, 0, X, 1, 0 ); + } + } + + expectedEST = new Float64Array( [ 22.0 ] ); + expectedV = new Float64Array( [ 10.0, 10.0, -1.0, -1.0 ] ); + expectedKASE = new Int32Array( [ 0 ] ); + expectedISGN = new Int32Array( [ 1, 1, -1, -1 ] ); + expectedISAVE = new Int32Array( [ 5, 1, 2 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix (offsets)', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, -2.0, 0.0, 0.0, + 3.0, 4.0, -5.0, 0.0, + 0.0, 6.0, 7.0, -8.0, + 0.0, 0.0, 9.0, 10.0 + ]); + + KASE = new Int32Array( 2 ); + EST = new Float64Array( 2 ); + ISGN = new Int32Array( 5 ); + ISAVE = new Int32Array( 4 ); + X = new Float64Array( 5 ); + V = new Float64Array( 5 ); + + work = new Float64Array( 5 ); + + while ( true ) { + dlacn2( 4, V, 1, 1, X, 1, 1, ISGN, 1, 1, EST, 1, KASE, 1, ISAVE, 1, 1 ); + + if ( KASE[ 1 ] === 0 ) { + break; + } + else if ( KASE[ 1 ] === 1 ) { + dgemv( 'no-transpose', 4, 4, 1.0, A, 4, 1, 0, X, 1, 1, 0, work, 1, 1 ); + dcopy( 4, work, 1, 1, X, 1, 1 ); + } else if ( KASE[ 1 ] === 2 ) { + dgemv( 'transpose', 4, 4, 1.0, A, 4, 1, 0, X, 1, 1, 0, work, 1, 1 ); + dcopy( 4, work, 1, 1, X, 1, 1 ); + } + } + + expectedEST = new Float64Array( [ 0.0, 12.0 ] ); + expectedV = new Float64Array( [ 0.0, -2.0, 4.0, 6.0, 0.0 ] ); + expectedKASE = new Int32Array( [ 0, 0 ] ); + expectedISGN = new Int32Array( [ 0, -1, 1, 1, 1 ] ); + expectedISAVE = new Int32Array( [ 0.0, 5, 1, 2 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix (offsets)', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, 10.0, 0.0, 0.0, + 1.0, 10.0, 0.0, 0.0, + 1.0, -1.0, 1.0, 1.0, + 1.0, -1.0, 1.0, 1.0 + ]); + + KASE = new Int32Array( 2 ); + EST = new Float64Array( 2 ); + ISGN = new Int32Array( 5 ); + ISAVE = new Int32Array( 4 ); + X = new Float64Array( 5 ); + V = new Float64Array( 5 ); + + work = new Float64Array( 5 ); + + while ( true ) { + dlacn2( 4, V, 1, 1, X, 1, 1, ISGN, 1, 1, EST, 1, KASE, 1, ISAVE, 1, 1 ); + + if ( KASE[ 1 ] === 0 ) { + break; + } + else if ( KASE[ 1 ] === 1 ) { + dgemv( 'no-transpose', 4, 4, 1.0, A, 4, 1, 0, X, 1, 1, 0, work, 1, 1 ); + dcopy( 4, work, 1, 1, X, 1, 1 ); + } else if ( KASE[ 1 ] === 2 ) { + dgemv( 'transpose', 4, 4, 1.0, A, 4, 1, 0, X, 1, 1, 0, work, 1, 1 ); + dcopy( 4, work, 1, 1, X, 1, 1 ); + } + } + + expectedEST = new Float64Array( [ 0.0, 22.0 ] ); + expectedV = new Float64Array( [ 0.0, 10.0, 10.0, -1.0, -1.0 ] ); + expectedKASE = new Int32Array( [ 0, 0 ] ); + expectedISGN = new Int32Array( [ 0, 1, 1, -1, -1 ] ); + expectedISAVE = new Int32Array( [ 0.0, 5, 1, 2 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix (negative strides)', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, -2.0, 0.0, 0.0, + 3.0, 4.0, -5.0, 0.0, + 0.0, 6.0, 7.0, -8.0, + 0.0, 0.0, 9.0, 10.0 + ]); + + KASE = new Int32Array( 1 ); + EST = new Float64Array( 1 ); + ISGN = new Int32Array( 4 ); + ISAVE = new Int32Array( 3 ); + X = new Float64Array( 4 ); + V = new Float64Array( 4 ); + + work = new Float64Array( 4 ); + + while ( true ) { + dlacn2( 4, V, -1, 3, X, -1, 3, ISGN, -1, 3, EST, 0, KASE, 0, ISAVE, -1, 2 ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'no-transpose', 4, 4, 1.0, A, 4, 1, 0, X, -1, 3, 0, work, 1, 0 ); + dcopy( 4, work, 1, 0, X, -1, 3 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'transpose', 4, 4, 1.0, A, 4, 1, 0, X, -1, 3, 0, work, 1, 0 ); + dcopy( 4, work, 1, 0, X, -1, 3 ); + } + } + + expectedEST = new Float64Array( [ 12.0 ] ); + expectedV = new Float64Array( [ 0, 6, 4, -2 ] ); + expectedKASE = new Int32Array( [ 0 ] ); + expectedISGN = new Int32Array( [ 1, 1, 1, -1 ] ); + expectedISAVE = new Int32Array( [ 2, 1, 5 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix (negative strides)', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, 10.0, 0.0, 0.0, + 1.0, 10.0, 0.0, 0.0, + 1.0, -1.0, 1.0, 1.0, + 1.0, -1.0, 1.0, 1.0 + ]); + + KASE = new Int32Array( 1 ); + EST = new Float64Array( 1 ); + ISGN = new Int32Array( 4 ); + ISAVE = new Int32Array( 3 ); + X = new Float64Array( 4 ); + V = new Float64Array( 4 ); + + work = new Float64Array( 4 ); + + while ( true ) { + dlacn2( 4, V, -1, 3, X, -1, 3, ISGN, -1, 3, EST, 0, KASE, 0, ISAVE, -1, 2 ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'no-transpose', 4, 4, 1.0, A, 4, 1, 0, X, -1, 3, 0, work, 1, 0 ); + dcopy( 4, work, 1, 0, X, -1, 3 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'transpose', 4, 4, 1.0, A, 4, 1, 0, X, -1, 3, 0, work, 1, 0 ); + dcopy( 4, work, 1, 0, X, -1, 3 ); + } + } + + expectedEST = new Float64Array( [ 22.0 ] ); + expectedV = new Float64Array( [ -1.0, -1.0, 10.0, 10.0 ] ); + expectedKASE = new Int32Array( [ 0 ] ); + expectedISGN = new Int32Array( [ -1, -1, 1, 1 ] ); + expectedISAVE = new Int32Array( [ 2, 1, 5 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix (large strides)', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, -2.0, 0.0, 0.0, + 3.0, 4.0, -5.0, 0.0, + 0.0, 6.0, 7.0, -8.0, + 0.0, 0.0, 9.0, 10.0 + ]); + + KASE = new Int32Array( 2 ); + EST = new Float64Array( 2 ); + ISGN = new Int32Array( 8 ); + ISAVE = new Int32Array( 6 ); + X = new Float64Array( 8 ); + V = new Float64Array( 8 ); + + work = new Float64Array( 8 ); + + while ( true ) { + dlacn2( 4, V, 2, 0, X, 2, 0, ISGN, 2, 0, EST, 0, KASE, 0, ISAVE, 2, 0 ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'no-transpose', 4, 4, 1.0, A, 4, 1, 0, X, 2, 0, 0, work, 2, 0 ); + dcopy( 4, work, 2, 0, X, 2, 0 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'transpose', 4, 4, 1.0, A, 4, 1, 0, X, 2, 0, 0, work, 2, 0 ); + dcopy( 4, work, 2, 0, X, 2, 0 ); + } + } + + expectedEST = new Float64Array( [ 12.0, 0.0 ] ); + expectedV = new Float64Array( [ -2.0, 0.0, 4.0, 0.0, 6.0, 0.0, 0.0, 0.0 ] ); + expectedKASE = new Int32Array( [ 0, 0 ] ); + expectedISGN = new Int32Array( [ -1, 0, 1, 0, 1, 0, 1, 0 ] ); + expectedISAVE = new Int32Array( [ 5, 0, 1, 0, 2, 0 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns expected values when calculating the one-norm of a square matrix (large strides)', function test( t ) { + var expectedISAVE; + var expectedKASE; + var expectedISGN; + var expectedEST; + var expectedV; + var ISAVE; + var KASE; + var ISGN; + var work; + var EST; + var X; + var V; + var A; + + A = new Float64Array([ + 1.0, 10.0, 0.0, 0.0, + 1.0, 10.0, 0.0, 0.0, + 1.0, -1.0, 1.0, 1.0, + 1.0, -1.0, 1.0, 1.0 + ]); + + KASE = new Int32Array( 2 ); + EST = new Float64Array( 2 ); + ISGN = new Int32Array( 8 ); + ISAVE = new Int32Array( 6 ); + X = new Float64Array( 8 ); + V = new Float64Array( 8 ); + + work = new Float64Array( 8 ); + + while ( true ) { + dlacn2( 4, V, 2, 0, X, 2, 0, ISGN, 2, 0, EST, 0, KASE, 0, ISAVE, 2, 0 ); + + if ( KASE[ 0 ] === 0 ) { + break; + } + else if ( KASE[ 0 ] === 1 ) { + dgemv( 'no-transpose', 4, 4, 1.0, A, 4, 1, 0, X, 2, 0, 0, work, 2, 0 ); + dcopy( 4, work, 2, 0, X, 2, 0 ); + } else if ( KASE[ 0 ] === 2 ) { + dgemv( 'transpose', 4, 4, 1.0, A, 4, 1, 0, X, 2, 0, 0, work, 2, 0 ); + dcopy( 4, work, 2, 0, X, 2, 0 ); + } + } + + expectedEST = new Float64Array( [ 22.0, 0.0 ] ); + expectedV = new Float64Array( [ 10.0, 0.0, 10.0, 0.0, -1.0, 0.0, -1.0, 0.0 ] ); + expectedKASE = new Int32Array( [ 0, 0 ] ); + expectedISGN = new Int32Array( [ 1, 0, 1, 0, -1, 0, -1, 0 ] ); + expectedISAVE = new Int32Array( [ 5, 0, 1, 0, 2, 0 ] ); + + t.deepEqual( KASE, expectedKASE, 'returns expected value' ); + t.deepEqual( ISGN, expectedISGN, 'returns expected value' ); + t.deepEqual( EST, expectedEST, 'returns expected value' ); + t.deepEqual( V, expectedV, 'returns expected value' ); + t.deepEqual( ISAVE, expectedISAVE, 'returns expected value' ); + + t.end(); +});