From 21572ebf448d5c0afc0c2f5984685ffb9344e04d Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 15 Aug 2024 01:13:15 +0530 Subject: [PATCH 01/13] feat: init lapack/base/dlacn2 --- .../lapack/base/dlacn2/benchmark/benchmark.js | 104 ++++ .../dlacn2/benchmark/benchmark.ndarray.js | 104 ++++ .../lapack/base/dlacn2/docs/types/index.d.ts | 139 +++++ .../lapack/base/dlacn2/docs/types/test.ts | 550 ++++++++++++++++++ .../lapack/base/dlacn2/examples/index.js | 33 ++ .../@stdlib/lapack/base/dlacn2/lib/base.js | 253 ++++++++ .../@stdlib/lapack/base/dlacn2/lib/dlacn2.js | 61 ++ .../@stdlib/lapack/base/dlacn2/lib/index.js | 79 +++ .../@stdlib/lapack/base/dlacn2/lib/main.js | 35 ++ .../@stdlib/lapack/base/dlacn2/lib/ndarray.js | 73 +++ .../@stdlib/lapack/base/dlacn2/package.json | 69 +++ .../lapack/base/dlacn2/test/test.dlacn2.js | 239 ++++++++ .../@stdlib/lapack/base/dlacn2/test/test.js | 83 +++ .../lapack/base/dlacn2/test/test.ndarray.js | 95 +++ 14 files changed, 1917 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/lib/dlacn2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.dlacn2.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js 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..9dfecadab079 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +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' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var ISAVE = new Int32Array( [ 1, 0, 0, 0, 0 ] ); + var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + var KASE = new Int32Array( [ 0 ] ); + var EST = new Float64Array( [ 0.0 ] ); + var V = uniform( len, 1.0, 100.0, options ); + var X = uniform( len, 1.0, 100.0, options ); + + return benchmark; + + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dlacn2( len, V, X, ISGN, EST, KASE, ISAVE ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':isave=1,len='+len, 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..f9ad48e12ca3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/benchmark/benchmark.ndarray.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +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' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var ISAVE = new Int32Array( [ 1, 0, 0, 0, 0 ] ); + var ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + var KASE = new Int32Array( [ 0 ] ); + var EST = new Float64Array( [ 0.0 ] ); + var V = uniform( len, 1.0, 100.0, options ); + var X = uniform( len, 1.0, 100.0, options ); + + return benchmark; + + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dlacn2( len, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':ndarray:isave=1,len='+len, f ); + } +} + +main(); 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..20c07b93c1a3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/index.d.ts @@ -0,0 +1,139 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products. + * + * @param N - order of the matrix `A` + * @param V - array on final return, `V=A*W`, where `W` is not returned + * @param X - input array + * @param ISGN - array of signs + * @param EST - array containing estimate of lower bound of 1-norm of `A` + * @param KASE - array containing value KASE to control overwritting of `X` + * @param ISAVE - array for internal storage + * @returns `ISGN` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * + * var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); + * var KASE = new Int32Array( [ 0 ] ); + * var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + * + * ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + * // ISGN => [ 1, 1, 1, 1 ] + */ + ( N: number, V: Float64Array, X: Float64Array, ISGN: Int32Array, EST: Float64Array, KASE: Int32Array, ISAVE: Int32Array ): Int32Array; + + /** + * Estimates the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products using alternative indexing semantics. + * + * @param N - order of the matrix `A` + * @param V - array on final return, `V=A*W`, where `W` is not returned + * @param strideV - stride length for `V` + * @param offsetV - starting index of `V` + * @param X - input array + * @param strideX - stride length for `X` + * @param offsetX - starting index of `X` + * @param ISGN - array of signs + * @param strideISGN - stride length for `ISGN` + * @param offsetISGN - starting index of `ISGN` + * @param EST - array containing estimate of lower bound of 1-norm of `A` + * @param offsetEST - starting index of `EST` + * @param KASE - array containing value KASE to control overwritting of `X` + * @param offsetKASE - starting index of `KASE` + * @param ISAVE - array for internal storage + * @param strideISAVE - stride length for `ISAVE` + * @param offsetISAVE - starting index of `ISAVE` + * @returns `ISGN` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var Int32Array = require( '@stdlib/array/int32' ); + * + * var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); + * var KASE = new Int32Array( [ 0 ] ); + * var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + * + * ISGN = dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); + * // ISGN => [ 1, 1, 1, 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 ): Int32Array; +} + +/** +* Estimates the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products. +* +* @param N - order of the matrix `A` +* @param V - array on final return, `V=A*W`, where `W` is not returned +* @param X - input array +* @param ISGN - array of signs +* @param EST - array containing estimate of lower bound of 1-norm of `A` +* @param KASE - array containing value KASE to control overwritting of `X` +* @param ISAVE - array for internal storage +* @returns `ISGN` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +* var KASE = new Int32Array( [ 0 ] ); +* var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); +* +* ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +* // ISGN => [ 1, 1, 1, 1 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +* var KASE = new Int32Array( [ 0 ] ); +* var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); +* +* ISGN = dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +* // ISGN => [ 1, 1, 1, 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..2e5d8ea800e7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/types/test.ts @@ -0,0 +1,550 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 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 a Float64Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); // $ExpectType Int32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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 X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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 V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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 a Int32Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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 a Int32Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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 a Int32Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + + 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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 Float64Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); // $ExpectType Int32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( '5', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, '5', 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, '5', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, '5', 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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, 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, 0, X, '5', 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, '5', 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, false, 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 a Int32Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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, 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, '5', 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, '5', 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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, 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, '5', 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, false, 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 a Int32Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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, 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, '5', 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, false, 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 a Int32Array... +{ + const V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + + 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, 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, '5', 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, false, 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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, '5' ); // $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, false ); // $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( [ 1.0, 2.0, 3.0, 4.0 ] ); + const X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + const EST = new Float64Array( [ 0.0 ] ); + const KASE = new Int32Array( [ 0 ] ); + const ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + + 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, 10 ); // $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..4d571df66ef6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dlacn2 = require( './../lib/base.js' ); + +var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +var KASE = new Int32Array( [ 1.0 ] ); +var ISAVE = new Int32Array( [ 1, 0, 0 ] ); + +ISGN = dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +console.log( ISGN ); 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..f393049ce723 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js @@ -0,0 +1,253 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var idamax = require( '@stdlib/blas/base/idamax' ).ndarray; +var dasum = require( '@stdlib/blas/base/dasum' ).ndarray; +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var floor = require( '@stdlib/math/base/special/floor' ); +var abs = require( '@stdlib/math/base/special/abs' ); + + +// FUNCTIONS // + +/** +* Truncates a number to whole number. +* +* @private +* @param {number} x - number to truncate +* @returns {number} truncated number +* +* @example +* var v = aint( 3.14 ); +* // returns 3.0 +*/ +function aint( x ) { + var sign; + var ax; + + ax = abs( x ); + if ( x >= 0.0 ) { + sign = 1; + } else { + sign = -1; + } + + if ( ax < 1.0 ) { + return 0; + } + if ( ax >= 1.0 ) { + return sign * floor( ax ); + } +} + +/** +* Rounds a number to the nearest whole number. +* +* @private +* @param {number} x - number to round +* @returns {number} rounded number +* +* @example +* var v = nint( 3.14 ); +* // returns 3.0 +* +* @example +* var v = nint( 9.99999 ); +* // returns 10.0 +*/ +function nint( x ) { + if ( x >= 0.0 ) { + return aint( x + 0.5 ); + } + return aint( x - 0.5 ); +} + + +// MAIN // + +/** +* Estimates the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products. +* +* @private +* @param {PositiveInteger} N - order of the matrix `A` +* @param {Float64Array} V - array on final return, `V=A*W`, where `W` is not returned +* @param {integer} strideV - stride length for `V` +* @param {NonNegativeInteger} offsetV - starting index of `V` +* @param {Float64Array} X - input array +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index of `X` +* @param {Int32Array} ISGN - array of signs +* @param {integer} strideISGN - stride length for `ISGN` +* @param {NonNegativeInteger} offsetISGN - starting index of `ISGN` +* @param {Float64Array} EST - array containing estimate of lower bound of 1-norm of `A` +* @param {NonNegativeInteger} offsetEST - starting index of `EST` +* @param {Int32Array} KASE - array containing value KASE to control overwritting of `X` +* @param {NonNegativeInteger} offsetKASE - starting index of `KASE` +* @param {Int32Array} ISAVE - array for internal storage +* @param {integer} strideISAVE - stride length for `ISAVE` +* @param {NonNegativeInteger} offsetISAVE - starting index of `ISAVE` +* @returns {Int32Array} `ISGN` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +* var KASE = new Int32Array( [ 0 ] ); +* var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); +* +* ISGN = dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +* // ISGN => [ 1, 1, 1, 1 ] +*/ +function dlacn2( N, V, strideV, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ) { + var altsgn; + var estold; + var jlast; + var tmp; + var XS; + var i; + var j; + + if ( KASE[ offsetKASE ] === 0.0 ) { + for ( i = 0; i < N; i++ ) { + X[ offsetX + ( i * strideX ) ] = 1.0 / N; + } + KASE[ offsetKASE ] = 1; + ISAVE[ offsetISAVE ] = 1; + return ISGN; + } + if ( ISAVE[ offsetISAVE ] === 1 ) { + // First iteration, X has been overwritten by A*X. + if ( N === 1 ) { + V[ offsetV ] = X[ offsetX ]; + EST[ offsetEST ] = abs( V[ offsetV ] ); + KASE[ offsetKASE ] = 0; + return ISGN; + } + EST[ offsetEST ] = dasum( N, X, strideX, offsetX ); + for ( i = 0; i < N; i++ ) { + if ( X[ offsetX + ( i * strideX ) ] >= 0.0 ) { + X[ offsetX + ( i * strideX ) ] = 1; + } else { + X[ offsetX + ( i * strideX ) ] = -1; + } + ISGN[ offsetISGN + ( i * strideISGN ) ] = nint( X[ offsetX + ( i * strideX ) ] ); + } + KASE[ offsetKASE ] = 2; + ISAVE[ offsetISAVE ] = 2; + return ISGN; + } + if ( ISAVE[ offsetISAVE ] === 2 ) { + // First iteration, X has been overwritten by A^T*X. + ISAVE[ offsetISAVE + strideISAVE ] = idamax( N, X, strideX, offsetX ); + ISAVE[ offsetISAVE + ( 2*strideISAVE ) ] = 2; + for ( i = 0; i < N; i++ ) { + X[ offsetX + ( i * strideX ) ] = 0.0; + } + X[ offsetX + ( ISAVE[ offsetISAVE + strideISAVE ] * strideX ) ] = 1.0; + KASE[ offsetKASE ] = 1; + ISAVE[ offsetISAVE ] = 3; + return ISGN; + } + if ( ISAVE[ offsetISAVE ] === 3 ) { + // X has been overwritten by A*X. + dcopy( N, X, strideX, offsetX, V, strideV, offsetV ); + estold = EST[ offsetEST ]; + EST[ offsetEST ] = dasum( N, V, strideV, offsetV ); + for ( i = 0; i < N; i++ ) { + if ( X[ offsetX + ( i * strideX ) ] >= 0.0 ) { + XS = 1.0; + } else { + XS = -1.0; + } + if ( nint( XS ) !== ISGN[ offsetISGN + ( i * strideISGN ) ] ) { + // Test for cycling. + if ( EST[ offsetEST ] <= estold ) { + break; + } + for ( j = 0; j < N; j++ ) { + if ( X[ offsetX + ( j * strideX ) ] >= 0.0 ) { + X[ offsetX + ( j * strideX ) ] = 1.0; + } else { + X[ offsetX + ( j * strideX ) ] = -1.0; + } + ISGN[ offsetISGN + ( j * strideISGN ) ] = nint( X[ offsetX + ( j * strideX ) ] ); + } + KASE[ offsetKASE ] = 2; + ISAVE[ offsetISAVE ] = 4; + return ISGN; + } + } + altsgn = 1.0; + for ( i = 0; i < N; i++ ) { + X[ offsetX + ( i * strideX ) ] = altsgn * ( 1.0 + ( i / ( N - 1 ) ) ); + altsgn = -altsgn; + } + KASE[ offsetKASE ] = 1; + ISAVE[ offsetISAVE ] = 5; + return ISGN; + } + if ( ISAVE[ offsetISAVE ] === 4 ) { + // X has been overwritten by A^T*X. + 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; + for ( i = 0; i < N; i++ ) { + X[ offsetX + ( i * strideX ) ] = 0.0; + } + X[ offsetX + ( ISAVE[ offsetISAVE + strideISAVE ] * strideX ) ] = 1.0; + KASE[ offsetKASE ] = 1; + ISAVE[ offsetISAVE ] = 3; + return ISGN; + } + // Iteration completed. + altsgn = 1.0; + for ( i = 0; i < N; i++ ) { + X[ offsetX + ( i * strideX ) ] = altsgn * ( 1.0 + ( i / ( N - 1 ) ) ); + altsgn = -altsgn; + } + KASE[ offsetKASE ] = 1; + ISAVE[ offsetISAVE ] = 5; + return ISGN; + } + if ( ISAVE[ offsetISAVE ] === 5 ) { + // X has been overwritten by A*X. + tmp = 2.0 * ( dasum( N, X, strideX, offsetX ) / ( 3 * N ) ); + if ( tmp > EST[ offsetEST ] ) { + dcopy( N, X, strideX, offsetX, V, strideV, offsetV ); + EST[ offsetEST ] = tmp; + } + KASE[ offsetKASE ] = 0; + return ISGN; + } +} + + +// 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..f6792d98eabd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/dlacn2.js @@ -0,0 +1,61 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products. +* +* @param {PositiveInteger} N - order of the matrix `A` +* @param {Float64Array} V - array, on final return `V=A*W`, where `W` is not returned +* @param {Float64Array} X - input array +* @param {Int32Array} ISGN - array of signs +* @param {Float64Array} EST - array containing estimate of lower bound of 1-norm of `A` +* @param {Int32Array} KASE - array containing value KASE to control overwritting of `X` +* @param {Int32Array} ISAVE - array for internal storage +* @returns {Int32Array} `ISGN` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +* var KASE = new Int32Array( [ 0 ] ); +* var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); +* +* ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +* // ISGN => [ 1, 1, 1, 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 ); +} + + +// 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..a17e6ad14abe --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js @@ -0,0 +1,79 @@ + +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products. +* +* @module @stdlib/lapack/base/dlacn2 +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dlacn2 = require( '@stdlib/lapack/base/dlacn2' ); +* +* var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +* var KASE = new Int32Array( [ 0 ] ); +* var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); +* +* ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +* // ISGN => [ 1, 1, 1, 1 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* var dlacn2 = require( '@stdlib/lapack/base/dlacn2' ); +* +* var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +* var KASE = new Int32Array( [ 0 ] ); +* var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); +* +* ISGN = dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +* // ISGN => [ 1, 1, 1, 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..8047c83bee33 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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..ef27b6780ef0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ + +/* eslint-disable max-len, max-params */ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Estimates the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products using alternative indexing semantics. +* +* @param {PositiveInteger} N - order of the matrix `A` +* @param {Float64Array} V - array on final return, `V=A*W`, where `W` is not returned +* @param {integer} strideV - stride length for `V` +* @param {NonNegativeInteger} offsetV - starting index of `V` +* @param {Float64Array} X - input array +* @param {integer} strideX - stride length for `X` +* @param {NonNegativeInteger} offsetX - starting index of `X` +* @param {Int32Array} ISGN - array of signs +* @param {integer} strideISGN - stride length for `ISGN` +* @param {NonNegativeInteger} offsetISGN - starting index of `ISGN` +* @param {Float64Array} EST - array containing estimate of lower bound of 1-norm of `A` +* @param {NonNegativeInteger} offsetEST - starting index of `EST` +* @param {Int32Array} KASE - array containing value KASE to control overwritting of `X` +* @param {NonNegativeInteger} offsetKASE - starting index of `KASE` +* @param {Int32Array} ISAVE - array for internal storage +* @param {integer} strideISAVE - stride length for `ISAVE` +* @param {NonNegativeInteger} offsetISAVE - starting index of `ISAVE` +* @returns {Int32Array} `ISGN` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var Int32Array = require( '@stdlib/array/int32' ); +* +* var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +* var KASE = new Int32Array( [ 0 ] ); +* var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); +* +* ISGN = dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +* // ISGN => [ 1, 1, 1, 1 ] +*/ +function dlacn2( N, V, strideV, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ) { + return base( N, V, strideV, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ); +} + + +// EXPORTS // + +module.exports = dlacn2; 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..cd6e08a3d9c1 --- /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": "Estimate the 1-norm of a square, real matrix `A`, reverse communication is used 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..02dee7c506fb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.dlacn2.js @@ -0,0 +1,239 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlacn2 = require( './../lib/dlacn2.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// 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 functtion correctly estimates first iteration where `X` is overwritten by `A*X`', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + EST = new Float64Array( [ 0.0 ] ); + KASE = new Int32Array( [ 1.0 ] ); + ISAVE = new Int32Array( [ 1, 0, 0 ] ); + + ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + isApprox( t, KASE, new Int32Array( [ 2 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 10.0 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 1, 1, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 2, 0, 0 ] ), 1.0 ); + + V = new Float64Array( [ 1.0, 2.0, -3.0, 4.0 ] ); + X = new Float64Array( [ 1.0, 2.0, -3.0, 4.0 ] ); + ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + EST = new Float64Array( [ 0.0 ] ); + KASE = new Int32Array( [ 1.0 ] ); + ISAVE = new Int32Array( [ 1, 0, 0 ] ); + + ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + isApprox( t, KASE, new Int32Array( [ 2 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 10.0 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 1, -1, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1.0, 1.0, -1.0, 1.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 2, 0, 0 ] ), 1.0 ); + t.end(); +}); + +tape( 'the functtion correctly estimates first iteration where `X` is overwritten by `A^T*X`', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + EST = new Float64Array( [ 0.0 ] ); + KASE = new Int32Array( [ 1.0 ] ); + ISAVE = new Int32Array( [ 2, 0, 0 ] ); + + ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + isApprox( t, KASE, new Int32Array( [ 1 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 0.0 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 1, 1, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 0.0, 0.0, 0.0, 1.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 3, 3, 2 ] ), 1.0 ); + t.end(); +}); + +tape( 'the functtion correctly estimates 1-norm where `X` is overwritten by `A*X`', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 1.0, 2.0, -3.0, 4.0 ] ); + X = new Float64Array( [ 1.0, 2.0, -3.0, 4.0 ] ); + ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + EST = new Float64Array( [ 0.0 ] ); + KASE = new Int32Array( [ 1.0 ] ); + ISAVE = new Int32Array( [ 3, 0, 0 ] ); + + ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + isApprox( t, KASE, new Int32Array( [ 2 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 10.0 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 1, -1, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1, 1, -1, 1 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 4, 0, 0 ] ), 1.0 ); + + V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + EST = new Float64Array( [ 0.0 ] ); + KASE = new Int32Array( [ 1.0 ] ); + ISAVE = new Int32Array( [ 3, 0, 0 ] ); + + ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + isApprox( t, KASE, new Int32Array( [ 1 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 10.0 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 1, 1, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1, -1.3333333333333333, 1.6666666666666665, -2 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 5, 0, 0 ] ), 1.0 ); + t.end(); +}); + +tape( 'the functtion correctly estimates 1-norm where `X` is overwritten by `A^T*X`', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 1.0, 2.0, -3.0, 4.0 ] ); + X = new Float64Array( [ 1.0, 2.0, -3.0, 4.0 ] ); + ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + EST = new Float64Array( [ 0.0 ] ); + KASE = new Int32Array( [ 1.0 ] ); + ISAVE = new Int32Array( [ 4, 0, 0 ] ); + + ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + isApprox( t, KASE, new Int32Array( [ 1 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 0.0 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 1, 1, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 0, 0, 0, 1 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 3, 3, 1 ] ), 1.0 ); + + V = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, 5.0, 6.0 ] ); + X = new Float64Array( [ 1.0, 2.0, -3.0, 4.0, 5.0, 6.0 ] ); + ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + EST = new Float64Array( [ 0.0 ] ); + KASE = new Int32Array( [ 1.0 ] ); + ISAVE = new Int32Array( [ 4, 0, 9 ] ); + + ISGN = dlacn2( 6, V, X, ISGN, EST, KASE, ISAVE ); + console.log( 'EST: ', EST ); + console.log( 'V: ', V ); + console.log( 'X: ', X ); + console.log( 'ISGN: ', ISGN ); + console.log( 'ISAVE: ', ISAVE ); + console.log( 'KASE: ', KASE ); + isApprox( t, KASE, new Int32Array( [ 1 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 0.0 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 1, 1, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1.0, -1.2, 1.4, -1.6, 1.8, -2.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 5, 5, 9 ] ), 1.0 ); + t.end(); +}); + +tape( 'the functtion correctly estimates 1-norm where `X` is overwritten by `A*X` ( ISAVE[0] = 5 )', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 1.0, 2.0, -3.0, 4.0 ] ); + X = new Float64Array( [ 1.0, 2.0, -3.0, 4.0 ] ); + ISGN = new Int32Array( [ 1, 1, 1, 1 ] ); + EST = new Float64Array( [ 0.0 ] ); + KASE = new Int32Array( [ 1.0 ] ); + ISAVE = new Int32Array( [ 5, 0, 0 ] ); + + ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); + isApprox( t, KASE, new Int32Array( [ 0 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 1.6666666666666667 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 1, 1, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1, 2, -3, 4 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 5, 0, 0 ] ), 1.0 ); + 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..6091e782bf72 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.js @@ -0,0 +1,83 @@ + +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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..4ac608b5c3c8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js @@ -0,0 +1,95 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlacn2 = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// 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 supports accessing elements from non-contiguous arrangement of elements in different order', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 999.9, 1.0, 999.9, 999.9, 999.9, 2.0, 999.9, 999.9, 999.9, 3.0, 999.9, 999.9, 999.9, 4.0 ] ); + X = new Float64Array( [ 4.0, 999.9, 999.9, 3.0, 999.9, 999.9, 2.0, 999.9, 999.9, 1.0 ] ); + ISGN = new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ); + EST = new Float64Array( [ 0.0, 999.9 ] ); + KASE = new Int32Array( [ 999, 1 ] ); + ISAVE = new Int32Array( [ 999, 1, 999, 999, 0, 999, 999, 0 ] ); + + ISGN = dlacn2( 4, V, 4, 1, X, -3, 9, ISGN, 2, 0, EST, 0, KASE, 1, ISAVE, 3, 1 ); + isApprox( t, KASE, new Int32Array( [ 999, 2 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 10.0, 999.9 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1.0, 999.9, 999.9, 1.0, 999.9, 999.9, 1.0, 999.9, 999.9, 1.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 999, 2, 999, 999, 0, 999, 999, 0 ] ), 1.0 ); + t.end(); +}); From 04ec3a9957253d80b39a10d2c40fea264a3e11c9 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 15 Aug 2024 01:14:08 +0530 Subject: [PATCH 02/13] test: fix spelling mistake --- .../@stdlib/lapack/base/dlacn2/test/test.dlacn2.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 index 02dee7c506fb..b38b7b21f7b2 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.dlacn2.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.dlacn2.js @@ -70,7 +70,7 @@ tape( 'the function has an arity of 7', function test( t ) { t.end(); }); -tape( 'the functtion correctly estimates first iteration where `X` is overwritten by `A*X`', function test( t ) { +tape( 'the function correctly estimates first iteration where `X` is overwritten by `A*X`', function test( t ) { var ISAVE; var ISGN; var KASE; @@ -108,7 +108,7 @@ tape( 'the functtion correctly estimates first iteration where `X` is overwritte t.end(); }); -tape( 'the functtion correctly estimates first iteration where `X` is overwritten by `A^T*X`', function test( t ) { +tape( 'the function correctly estimates first iteration where `X` is overwritten by `A^T*X`', function test( t ) { var ISAVE; var ISGN; var KASE; @@ -132,7 +132,7 @@ tape( 'the functtion correctly estimates first iteration where `X` is overwritte t.end(); }); -tape( 'the functtion correctly estimates 1-norm where `X` is overwritten by `A*X`', function test( t ) { +tape( 'the function correctly estimates 1-norm where `X` is overwritten by `A*X`', function test( t ) { var ISAVE; var ISGN; var KASE; @@ -170,7 +170,7 @@ tape( 'the functtion correctly estimates 1-norm where `X` is overwritten by `A*X t.end(); }); -tape( 'the functtion correctly estimates 1-norm where `X` is overwritten by `A^T*X`', function test( t ) { +tape( 'the function correctly estimates 1-norm where `X` is overwritten by `A^T*X`', function test( t ) { var ISAVE; var ISGN; var KASE; @@ -214,7 +214,7 @@ tape( 'the functtion correctly estimates 1-norm where `X` is overwritten by `A^T t.end(); }); -tape( 'the functtion correctly estimates 1-norm where `X` is overwritten by `A*X` ( ISAVE[0] = 5 )', function test( t ) { +tape( 'the function correctly estimates 1-norm where `X` is overwritten by `A*X` ( ISAVE[0] = 5 )', function test( t ) { var ISAVE; var ISGN; var KASE; From 4aea9fa9939e0c30797bb9e84ea0eda33e04eea2 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 15 Aug 2024 01:14:28 +0530 Subject: [PATCH 03/13] docs: add repl and readme --- .../@stdlib/lapack/base/dlacn2/README.md | 273 ++++++++++++++++++ .../@stdlib/lapack/base/dlacn2/docs/repl.txt | 131 +++++++++ 2 files changed, 404 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt 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..a5b3e296f5dd --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md @@ -0,0 +1,273 @@ + + +# dlacn2 + +> Estimate the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products. + +
+ +## Usage + +```javascript +var dlacn2 = require( '@stdlib/lapack/base/dlacn2' ); +``` + +#### dlacn2( N, V, X, ISGN, EST, KASE, ISAVE ) + +Estimates the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +var KASE = new Int32Array( [ 0 ] ); +var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0] ); + +ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +// ISGN => [ 1, 1, 1, 1 ] +``` + +The function has the following parameters: + +- **N**: order of matrix `A`. +- **V** [`Float64Array`][mdn-float64array], on final return `V=A*W`, where `W` is not returned. +- **X** input [`Float64Array`][mdn-float64array]. +- **ISGN** [`Int32Array`][mdn-int32array] of signs. +- **EST** [`Float64Array`][mdn-float64array] containing estimate of lower bound of 1-norm of `A`. +- **KASE** [`Int32Array`][mdn-int32array] containing value KASE to control overwritting of `X`. +- **ISAVE** [`Int32Array`][mdn-int32array] for internal storage. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +// Initial arrays... +var V0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +var X0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +var ISGN0 = new Int32Array( [ 1, 1, 1, 1, 1 ] ); +var EST0 = new Float64Array( [ 0.0, 0.0 ] ); +var KASE0 = new Int32Array( [ 0, 0 ] ); +var ISAVE0 = new Int32Array( [ 0, 0, 0, 0, 0 ] ); + +// Create offset views... +var V1 = new Float64Array( V0.buffer, V0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var X1 = new Float64Array( X0.buffer, X0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var ISGN1 = new Int32Array( ISGN0.buffer, ISGN0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var EST1 = new Float64Array( EST0.buffer, EST0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var KASE1 = new Int32Array( KASE0.buffer, KASE0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var ISAVE1 = new Int32Array( ISAVE0.buffer, ISAVE0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +ISGN1 = dlacn2( 4, V1, X1, ISGN1, EST1, KASE1, ISAVE1 ); +// ISGN0 => [ 1, 1, 1, 1, 1 ] +``` + +#### dlacn2.ndarray( N, V, sv, ov, X, sx, ox, I, si, oi, E, oe, K, ok, S, ss, os ) + +Estimates the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +var KASE = new Int32Array( [ 0 ] ); +var ISAVE = new Int32Array( [ 0, 0, 0 ] ); + +ISGN = dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +// ISGN => [ 1, 1, 1, 1 ] +``` + +The function has the following additional parameters: + +- **sv**: stride length for `V`. +- **ov**: starting index of `V`. +- **sx**: stride length for `X`. +- **ox**: starting index of `X`. +- **si**: stride length for `I`. +- **oi**: starting index of `I`. +- **oe**: starting index of `E`. +- **ok**: starting index of `K`. +- **ss**: stride length for `S`. +- **os**: starting index of `S`. + +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 Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var ISGN = new Int32Array( [ 0, 1, 1, 1, 1 ] ); +var EST = new Float64Array( [ 0.0, 0.0 ] ); +var KASE = new Int32Array( [ 0, 0 ] ); +var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0, 0 ] ); + +ISGN = dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 1, EST, 1, KASE, 1, ISAVE, 1, 1 ); +// ISGN => [ 0, 1, 1, 1, 1 ] +``` + +
+ + + +
+ +## Notes + +- `dlacn2()` corresponds to the [LAPACK][lapack] routine [`dlacn2`][lapack-dlacn2]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dlacn2 = require( '@stdlib/lapack/base/dlacn2' ); + +var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); +var KASE = new Int32Array( [ 1.0 ] ); +var ISAVE = new Int32Array( [ 1, 0, 0 ] ); + +ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); +console.log( ISGN ); +``` + +
+ + + + + +* * * + +
+ +## 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/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt new file mode 100644 index 000000000000..dc668cbb198a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt @@ -0,0 +1,131 @@ + +{{alias}}( N, V, X, ISGN, EST, KASE, ISAVE ) + Estimates the 1-norm of a square, real matrix `A`, reverse communication + is used for evaluating matrix-vector products. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + N: integer + Order of the matrix `A`. + + V: Float64Array + On final return, `V = A * W`, where `W` is not returned. + + X: Float64Array + Input vector `X`. + + ISGN: Int32Array + Signs of elements of `X`. + + EST: Float64Array + Estimate of the lower bound of the 1-norm of `A`. + + KASE: Int32Array + Value controlling overwriting of `X`. + + ISAVE: Int32Array + Internal storage. + + Returns + ------- + ISAVE: Int32Array + Internal storage. + + Examples + -------- + > var V = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.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}}( [ 0.0 ] ); + > var KASE = new {{alias:@stdlib/array/int32}}( [ 1 ] ); + > var ISAVE = new {{alias:@stdlib/array/int32}}( [ 1, 0, 0 ] ); + > ISGN = {{alias}}( 4, V, X, ISGN, EST, KASE, ISAVE ); + > ISGN + [ 1, 1, 1, 1 ] + > EST + [ 10.0 ] + + +{{alias}}.ndarray( N, V, sv, ov, X, sx, ox, I, si, oi, E, oe, K, ok, S, ss, os ) + Estimates the 1-norm of a square, real matrix `A`, reverse communication + is used for evaluating matrix-vector products using alternative indexing + semantics. + + 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 + Order of the matrix `A`. + + V: Float64Array + On final return, `V = A * W`, where `W` is not returned. + + sv: integer + Stride length for `V`. + + ov: integer + Starting index of `V`. + + X: Float64Array + Input vector `X`. + + sx: integer + Stride length for `X`. + + ox: integer + Starting index of `X`. + + I: Int32Array + Signs of elements of `X`. + + si: integer + Stride length for `I`. + + oi: integer + Starting index of `I`. + + E: Float64Array + Estimate of the lower bound of the 1-norm of `A`. + + oe: integer + Starting index of `E`. + + K: Int32Array + Value controlling overwriting of `X`. + + ok: integer + Starting index of `K`. + + S: Int32Array + Internal storage. + + ss: integer + Stride length for `S`. + + Returns + ------- + S: Int32Array + Internal storage. + + Examples + -------- + > var V = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var X = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var I = new {{alias:@stdlib/array/int32}}( [ 0, 1, 1, 1, 1 ] ); + > var E = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] ); + > var K = new {{alias:@stdlib/array/int32}}( [ 0, 1 ] ); + > var S = new {{alias:@stdlib/array/int32}}( [ 0, 1, 0, 0, 0 ] ); + > I = {{alias}}.ndarray( 4, V, 1, 0, X, 1, 0, I, 1, 1, E, 1, K, 1, S, 1, 1 ); + > I + [ 0, 1, 1, 1, 1 ] + > E + [ 0.0, 10.0 ] + + See Also + -------- From e4f61723638cb4796e81d392bdf1f0d2db17c260 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 15 Aug 2024 10:55:21 +0530 Subject: [PATCH 04/13] chore: suppress lint error in README --- lib/node_modules/@stdlib/lapack/base/dlacn2/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md b/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md index a5b3e296f5dd..2c4caa996c13 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md @@ -87,6 +87,8 @@ ISGN1 = dlacn2( 4, V1, X1, ISGN1, EST1, KASE1, ISAVE1 ); // ISGN0 => [ 1, 1, 1, 1, 1 ] ``` + + #### dlacn2.ndarray( N, V, sv, ov, X, sx, ox, I, si, oi, E, oe, K, ok, S, ss, os ) Estimates the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products using alternative indexing semantics. From 4a67f01fdbc464673fc20489c15ca3a3d47e5cef Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 15 Aug 2024 10:57:30 +0530 Subject: [PATCH 05/13] docs: suppress lint error in repl --- lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt index dc668cbb198a..9b3507b0e4dc 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/docs/repl.txt @@ -49,7 +49,7 @@ [ 10.0 ] -{{alias}}.ndarray( N, V, sv, ov, X, sx, ox, I, si, oi, E, oe, K, ok, S, ss, os ) +{{alias}}.ndarray( N, V,sv,ov, X,sx,ox, I,si,oi, E,oe, K,ok, S,ss,os ) Estimates the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products using alternative indexing semantics. @@ -121,7 +121,7 @@ > var E = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0 ] ); > var K = new {{alias:@stdlib/array/int32}}( [ 0, 1 ] ); > var S = new {{alias:@stdlib/array/int32}}( [ 0, 1, 0, 0, 0 ] ); - > I = {{alias}}.ndarray( 4, V, 1, 0, X, 1, 0, I, 1, 1, E, 1, K, 1, S, 1, 1 ); + > I = {{alias}}.ndarray( 4, V,1,0, X,1,0, I,1,1, E,1, K,1, S,1,1 ); > I [ 0, 1, 1, 1, 1 ] > E From e79030669bd8893de8857b1a5fdd65709b3f1d7d Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 15 Aug 2024 11:00:26 +0530 Subject: [PATCH 06/13] fix: lint error in readme --- .../@stdlib/lapack/base/dlacn2/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md b/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md index 2c4caa996c13..846fbd94c540 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md @@ -129,13 +129,13 @@ var Int32Array = require( '@stdlib/array/int32' ); var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); -var ISGN = new Int32Array( [ 0, 1, 1, 1, 1 ] ); -var EST = new Float64Array( [ 0.0, 0.0 ] ); -var KASE = new Int32Array( [ 0, 0 ] ); -var ISAVE = new Int32Array( [ 0, 0, 0, 0, 0, 0 ] ); +var I = new Int32Array( [ 0, 1, 1, 1, 1 ] ); +var E = new Float64Array( [ 0.0, 0.0 ] ); +var K = new Int32Array( [ 0, 0 ] ); +var S = new Int32Array( [ 0, 0, 0 ] ); -ISGN = dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 1, EST, 1, KASE, 1, ISAVE, 1, 1 ); -// ISGN => [ 0, 1, 1, 1, 1 ] +I = dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, I, 1, 1, E, 1, K, 1, S, 1, 1 ); +// I => [ 0, 1, 1, 1, 1 ] ``` From 4280cbf45473835bf4527140137fec6e0e9d8f90 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 15 Aug 2024 11:01:24 +0530 Subject: [PATCH 07/13] fix: lint error in readme --- .../@stdlib/lapack/base/dlacn2/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md b/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md index 846fbd94c540..576c6540827a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/README.md @@ -99,13 +99,13 @@ var Int32Array = require( '@stdlib/array/int32' ); var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.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( [ 0.0 ] ); -var KASE = new Int32Array( [ 0 ] ); -var ISAVE = new Int32Array( [ 0, 0, 0 ] ); +var I = new Int32Array( [ 1, 1, 1, 1 ] ); +var E = new Float64Array( [ 0.0 ] ); +var K = new Int32Array( [ 0 ] ); +var S = new Int32Array( [ 0, 0, 0 ] ); -ISGN = dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); -// ISGN => [ 1, 1, 1, 1 ] +I = dlacn2.ndarray( 4, V, 1, 0, X, 1, 0, I, 1, 0, E, 0, K, 0, S, 1, 0 ); +// I => [ 1, 1, 1, 1 ] ``` The function has the following additional parameters: From 2f4d35ab02b9c7e5b0d6696cd8e862375ff7af27 Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:14:15 +0530 Subject: [PATCH 08/13] chore: apply suggestions from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js | 4 ++-- lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js index 4d571df66ef6..480258818909 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/examples/index.js @@ -20,7 +20,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); -var dlacn2 = require( './../lib/base.js' ); +var dlacn2 = require( './../lib' ); var V = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); @@ -29,5 +29,5 @@ var EST = new Float64Array( [ 0.0 ] ); var KASE = new Int32Array( [ 1.0 ] ); var ISAVE = new Int32Array( [ 1, 0, 0 ] ); -ISGN = dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); +ISGN = dlacn2( 4, V, X, ISGN, EST, KASE, ISAVE ); console.log( ISGN ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js index a17e6ad14abe..da1efcd17a5c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/index.js @@ -1,4 +1,3 @@ - /** * @license Apache-2.0 * From c71adae3e8b0269ae79f29f6867b603cc3c71f47 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 15 Aug 2024 11:47:38 +0530 Subject: [PATCH 09/13] refactor: ndarray implementation --- lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js index ef27b6780ef0..c7bc5fd7cf66 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/ndarray.js @@ -16,8 +16,6 @@ * limitations under the License. */ -/* eslint-disable max-len, max-params */ - 'use strict'; // MODULES // @@ -30,6 +28,7 @@ var base = require( './base.js' ); /** * Estimates the 1-norm of a square, real matrix `A`, reverse communication is used for evaluating matrix-vector products using alternative indexing semantics. * +* @type {Function} * @param {PositiveInteger} N - order of the matrix `A` * @param {Float64Array} V - array on final return, `V=A*W`, where `W` is not returned * @param {integer} strideV - stride length for `V` @@ -63,9 +62,7 @@ var base = require( './base.js' ); * ISGN = dlacn2( 4, V, 1, 0, X, 1, 0, ISGN, 1, 0, EST, 0, KASE, 0, ISAVE, 1, 0 ); * // ISGN => [ 1, 1, 1, 1 ] */ -function dlacn2( N, V, strideV, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ) { - return base( N, V, strideV, offsetV, X, strideX, offsetX, ISGN, strideISGN, offsetISGN, EST, offsetEST, KASE, offsetKASE, ISAVE, strideISAVE, offsetISAVE ); -} +var dlacn2 = base; // EXPORTS // From 0e59a433b4c52b5aa4a0076b58b10f5050747af7 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 15 Aug 2024 11:48:07 +0530 Subject: [PATCH 10/13] test: add more ndarray tests --- .../lapack/base/dlacn2/test/test.ndarray.js | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) 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 index 4ac608b5c3c8..c7d1b568aeee 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js @@ -70,7 +70,7 @@ tape( 'the function has an arity of 17', function test( t ) { t.end(); }); -tape( 'the function supports accessing elements from non-contiguous arrangement of elements in different order', function test( t ) { +tape( 'the function supports accessing elements from non-contiguous arrangement of elements in different order ( ISAVE = 1 )', function test( t ) { var ISAVE; var ISGN; var KASE; @@ -91,5 +91,45 @@ tape( 'the function supports accessing elements from non-contiguous arrangement isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ), 1.0 ); isApprox( t, X, new Float64Array( [ 1.0, 999.9, 999.9, 1.0, 999.9, 999.9, 1.0, 999.9, 999.9, 1.0 ] ), 1.0 ); isApprox( t, ISAVE, new Int32Array( [ 999, 2, 999, 999, 0, 999, 999, 0 ] ), 1.0 ); + + V = new Float64Array( [ 999.9, 1.0, 999.9, 999.9, 999.9, 2.0, 999.9, 999.9, 999.9, -3.0, 999.9, 999.9, 999.9, 4.0 ] ); + X = new Float64Array( [ 4.0, 999.9, 999.9, -3.0, 999.9, 999.9, 2.0, 999.9, 999.9, 1.0 ] ); + ISGN = new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ); + EST = new Float64Array( [ 0.0, 999.9 ] ); + KASE = new Int32Array( [ 999, 1 ] ); + ISAVE = new Int32Array( [ 999, 1, 999, 999, 0, 999, 999, 0 ] ); + + ISGN = dlacn2( 4, V, 4, 1, X, -3, 9, ISGN, 2, 0, EST, 0, KASE, 1, ISAVE, 3, 1 ); + isApprox( t, KASE, new Int32Array( [ 999, 2 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 10.0, 999.9 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, -1, 999, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1.0, 999.9, 999.9, -1.0, 999.9, 999.9, 1.0, 999.9, 999.9, 1.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 999, 2, 999, 999, 0, 999, 999, 0 ] ), 1.0 ); + t.end(); +}); + +tape( 'the function supports complex access patterns ( ISAVE = 2 )', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 999.9, 1.0, 999.9, 999.9, 999.9, 2.0, 999.9, 999.9, 999.9, 3.0, 999.9, 999.9, 999.9, 4.0 ] ); + X = new Float64Array( [ 4.0, 999.9, 999.9, 3.0, 999.9, 999.9, 2.0, 999.9, 999.9, 1.0 ] ); + ISGN = new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ); + EST = new Float64Array( [ 0.0, 999.9 ] ); + KASE = new Int32Array( [ 999, 1 ] ); + ISAVE = new Int32Array( [ 999, 2, 999, 999, 0, 999, 999, 0 ] ); + + ISGN = dlacn2( 4, V, 4, 1, X, -3, 9, ISGN, 2, 0, EST, 0, KASE, 1, ISAVE, 3, 1 ); + isApprox( t, KASE, new Int32Array( [ 999, 1 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 0.0, 999.9 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 0.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0 ] ), 1.0 ); + + // TODO: replace -1 with 3 once `idamax` supports negative strides + isApprox( t, ISAVE, new Int32Array( [ 999, 3, 999, 999, -1, 999, 999, 2 ] ), 1.0 ); t.end(); }); From 59bdc92424052c19d7f35e9d0ba0b3e53080760f Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Fri, 16 Aug 2024 19:57:28 +0530 Subject: [PATCH 11/13] test: add more ndarray tests --- .../lapack/base/dlacn2/test/test.ndarray.js | 86 ++++++++++++++++++- 1 file changed, 83 insertions(+), 3 deletions(-) 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 index c7d1b568aeee..6c97d62ea2bc 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js @@ -124,12 +124,92 @@ tape( 'the function supports complex access patterns ( ISAVE = 2 )', function te ISAVE = new Int32Array( [ 999, 2, 999, 999, 0, 999, 999, 0 ] ); ISGN = dlacn2( 4, V, 4, 1, X, -3, 9, ISGN, 2, 0, EST, 0, KASE, 1, ISAVE, 3, 1 ); + console.log( 'KASE: ', KASE ); + console.log( 'EST: ', EST ); + console.log( 'ISGN: ', ISGN ); + console.log( 'X: ', X ); + console.log( 'ISAVE: ', ISAVE ); isApprox( t, KASE, new Int32Array( [ 999, 1 ] ), 1.0 ); isApprox( t, EST, new Float64Array( [ 0.0, 999.9 ] ), 1.0 ); isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ), 1.0 ); - isApprox( t, X, new Float64Array( [ 0.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 999, 3, 999, 999, 3, 999, 999, 2 ] ), 1.0 ); + t.end(); +}); + +tape( 'the function supports complex access patterns ( ISAVE = 3 )', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 999.9, 1.0, 999.9, 999.9, 999.9, 2.0, 999.9, 999.9, 999.9, -3.0, 999.9, 999.9, 999.9, 4.0 ] ); + X = new Float64Array( [ 4.0, 999.9, 999.9, -3.0, 999.9, 999.9, 2.0, 999.9, 999.9, 1.0 ] ); + ISGN = new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ); + EST = new Float64Array( [ 0.0, 999.9 ] ); + KASE = new Int32Array( [ 999, 1 ] ); + ISAVE = new Int32Array( [ 999, 3, 999, 999, 3, 999, 999, 2 ] ); + + ISGN = dlacn2( 4, V, 4, 1, X, -3, 9, ISGN, 2, 0, EST, 0, KASE, 1, ISAVE, 3, 1 ); + isApprox( t, KASE, new Int32Array( [ 999, 2 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 10.0, 999.9 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, -1, 999, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1.0, 999.9, 999.9, -1.0, 999.9, 999.9, 1.0, 999.9, 999.9, 1.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 999, 4, 999, 999, 3, 999, 999, 2 ] ), 1.0 ); + t.end(); +}); + +tape( 'the function supports complex access patterns ( ISAVE = 4 )', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 999.9, 1.0, 999.9, 999.9, 999.9, 2.0, 999.9, 999.9, 999.9, -3.0, 999.9, 999.9, 999.9, 4.0 ] ); + X = new Float64Array( [ 4.0, 999.9, 999.9, -3.0, 999.9, 999.9, 2.0, 999.9, 999.9, 1.0 ] ); + ISGN = new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ); + EST = new Float64Array( [ 0.0, 999.9 ] ); + KASE = new Int32Array( [ 999, 1 ] ); + ISAVE = new Int32Array( [ 999, 4, 999, 999, 0, 999, 999, 0 ] ); - // TODO: replace -1 with 3 once `idamax` supports negative strides - isApprox( t, ISAVE, new Int32Array( [ 999, 3, 999, 999, -1, 999, 999, 2 ] ), 1.0 ); + ISGN = dlacn2( 4, V, 4, 1, X, -3, 9, ISGN, 2, 0, EST, 0, KASE, 1, ISAVE, 3, 1 ); + console.log( 'KASE: ', KASE ); + console.log( 'EST: ', EST ); + console.log( 'ISGN: ', ISGN ); + console.log( 'X: ', X ); + console.log( 'ISAVE: ', ISAVE ); + isApprox( t, KASE, new Int32Array( [ 999, 1 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 0.0, 999.9 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 1.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0, 999.9, 999.9, 0.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 999, 3, 999, 999, 3, 999, 999, 1 ] ), 1.0 ); + t.end(); +}); + +tape( 'the function supports complex access patterns ( ISAVE = 5 )', function test( t ) { + var ISAVE; + var ISGN; + var KASE; + var EST; + var V; + var X; + + V = new Float64Array( [ 999.9, 1.0, 999.9, 999.9, 999.9, 2.0, 999.9, 999.9, 999.9, -3.0, 999.9, 999.9, 999.9, 4.0 ] ); + X = new Float64Array( [ 4.0, 999.9, 999.9, -3.0, 999.9, 999.9, 2.0, 999.9, 999.9, 1.0 ] ); + ISGN = new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ); + EST = new Float64Array( [ 0.0, 999.9 ] ); + KASE = new Int32Array( [ 999, 1 ] ); + ISAVE = new Int32Array( [ 999, 5, 999, 999, 0, 999, 999, 0 ] ); + + ISGN = dlacn2( 4, V, 4, 1, X, -3, 9, ISGN, 2, 0, EST, 0, KASE, 1, ISAVE, 3, 1 ); + isApprox( t, KASE, new Int32Array( [ 999, 0 ] ), 1.0 ); + isApprox( t, EST, new Float64Array( [ 1.6666666666666667, 999.9 ] ), 1.0 ); + isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ), 1.0 ); + isApprox( t, X, new Float64Array( [ 4.0, 999.9, 999.9, -3.0, 999.9, 999.9, 2.0, 999.9, 999.9, 1.0 ] ), 1.0 ); + isApprox( t, ISAVE, new Int32Array( [ 999, 5, 999, 999, 0, 999, 999, 0 ] ), 1.0 ); t.end(); }); From e0cd46ef998947ca722f1cb6a65efdbc93d4cb97 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Fri, 16 Aug 2024 19:57:59 +0530 Subject: [PATCH 12/13] chore: remove console statements --- .../@stdlib/lapack/base/dlacn2/test/test.ndarray.js | 10 ---------- 1 file changed, 10 deletions(-) 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 index 6c97d62ea2bc..36ee8ef9d7a9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/test/test.ndarray.js @@ -124,11 +124,6 @@ tape( 'the function supports complex access patterns ( ISAVE = 2 )', function te ISAVE = new Int32Array( [ 999, 2, 999, 999, 0, 999, 999, 0 ] ); ISGN = dlacn2( 4, V, 4, 1, X, -3, 9, ISGN, 2, 0, EST, 0, KASE, 1, ISAVE, 3, 1 ); - console.log( 'KASE: ', KASE ); - console.log( 'EST: ', EST ); - console.log( 'ISGN: ', ISGN ); - console.log( 'X: ', X ); - console.log( 'ISAVE: ', ISAVE ); isApprox( t, KASE, new Int32Array( [ 999, 1 ] ), 1.0 ); isApprox( t, EST, new Float64Array( [ 0.0, 999.9 ] ), 1.0 ); isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ), 1.0 ); @@ -177,11 +172,6 @@ tape( 'the function supports complex access patterns ( ISAVE = 4 )', function te ISAVE = new Int32Array( [ 999, 4, 999, 999, 0, 999, 999, 0 ] ); ISGN = dlacn2( 4, V, 4, 1, X, -3, 9, ISGN, 2, 0, EST, 0, KASE, 1, ISAVE, 3, 1 ); - console.log( 'KASE: ', KASE ); - console.log( 'EST: ', EST ); - console.log( 'ISGN: ', ISGN ); - console.log( 'X: ', X ); - console.log( 'ISAVE: ', ISAVE ); isApprox( t, KASE, new Int32Array( [ 999, 1 ] ), 1.0 ); isApprox( t, EST, new Float64Array( [ 0.0, 999.9 ] ), 1.0 ); isApprox( t, ISGN, new Int32Array( [ 1, 999, 1, 999, 1, 999, 1 ] ), 1.0 ); From 8230c1a9468cd7d7df3795ef12ffcc8a13d5b8e8 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Fri, 16 Aug 2024 19:59:21 +0530 Subject: [PATCH 13/13] chore: apply suggestion from code review --- lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js index f393049ce723..9707bf5a7e47 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacn2/lib/base.js @@ -43,6 +43,7 @@ var abs = require( '@stdlib/math/base/special/abs' ); * // returns 3.0 */ function aint( x ) { + // TODO: shall be replaced once a dedicated math function is available var sign; var ax; @@ -77,6 +78,7 @@ function aint( x ) { * // returns 10.0 */ function nint( x ) { + // TODO: shall be replaced once a dedicated math function is available if ( x >= 0.0 ) { return aint( x + 0.5 ); }