From 6da31f2f086259d72cc8037a504ab60f14f0c563 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Wed, 31 Jul 2024 23:49:06 +0530 Subject: [PATCH 1/3] feat: add lapack/base/slacpy --- .../@stdlib/lapack/base/slacpy/README.md | 260 ++++++++++ .../lapack/base/slacpy/benchmark/benchmark.js | 105 ++++ .../slacpy/benchmark/benchmark.ndarray.js | 105 ++++ .../@stdlib/lapack/base/slacpy/docs/repl.txt | 108 +++++ .../lapack/base/slacpy/docs/types/index.d.ts | 117 +++++ .../lapack/base/slacpy/docs/types/test.ts | 358 ++++++++++++++ .../lapack/base/slacpy/examples/index.js | 44 ++ .../@stdlib/lapack/base/slacpy/lib/base.js | 459 ++++++++++++++++++ .../@stdlib/lapack/base/slacpy/lib/index.js | 70 +++ .../@stdlib/lapack/base/slacpy/lib/main.js | 35 ++ .../@stdlib/lapack/base/slacpy/lib/ndarray.js | 78 +++ .../@stdlib/lapack/base/slacpy/lib/slacpy.js | 104 ++++ .../@stdlib/lapack/base/slacpy/package.json | 67 +++ .../@stdlib/lapack/base/slacpy/test/test.js | 82 ++++ .../lapack/base/slacpy/test/test.ndarray.js | 270 +++++++++++ .../lapack/base/slacpy/test/test.slacpy.js | 282 +++++++++++ 16 files changed, 2544 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/lib/slacpy.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/slacpy/test/test.slacpy.js diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/README.md b/lib/node_modules/@stdlib/lapack/base/slacpy/README.md new file mode 100644 index 00000000000..3ac87bcb487 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/README.md @@ -0,0 +1,260 @@ + + +# slacpy + +> Copy all or part of a matrix `A` to another matrix `B`. + +
+ +## Usage + +```javascript +var slacpy = require( '@stdlib/lapack/base/slacpy' ); +``` + +#### slacpy( order, uplo, M, N, A, LDA, B, LDB ) + +Copies all or part of a matrix `A` to another matrix `B`. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var B = new Float32Array( 4 ); + +slacpy( 'row-major', 'all', 2, 2, A, 2, B, 2 ); +// B => [ 1.0, 2.0, 3.0, 4.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether to copy the upper or lower triangular/trapezoidal part of a matrix `A`. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input [`Float32Array`][mdn-Float32Array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **B**: output [`Float32Array`][mdn-Float32Array]. +- **LDB**: stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`). + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial arrays... +var A0 = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var B0 = new Float32Array( 5 ); + +// Create offset views... +var A1 = new Float32Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var B1 = new Float32Array( B0.buffer, B0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +slacpy( 'row-major', 'all', 2, 2, A1, 2, B1, 2 ); +// B0 => [ 0.0, 2.0, 3.0, 4.0, 5.0 ] +``` + +#### slacpy.ndarray( uplo, M, N, A, sa1, sa2, oa, B, sb1, sb2, ob ) + +Copies all or part of a matrix `A` to another matrix `B` using alternative indexing semantics. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +var B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0 ] ); + +slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); +// B => [ 1.0, 2.0, 3.0, 4.0 ] +``` + +The function has the following parameters: + +- **uplo**: specifies whether to copy the upper or lower triangular/trapezoidal part of a matrix `A`. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **A**: input [`Float32Array`][mdn-Float32Array]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **B**: output [`Float32Array`][mdn-Float32Array]. +- **sb1**: stride of the first dimension of `B`. +- **sb2**: stride of the second dimension of `B`. +- **ob**: starting index for `B`. + +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 Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +var B = new Float32Array( [ 0.0, 0.0, 11.0, 312.0, 53.0, 412.0 ] ); + +slacpy.ndarray( 'all', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +// B => [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] +``` + +
+ + + +
+ +## Notes + +- `slacpy()` corresponds to the [LAPACK][lapack] routine [`slacpy`][lapack-slacpy]. + +
+ + + +
+ +## Examples + + + +```javascript +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var uniform = require( '@stdlib/random/array/discrete-uniform' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var slacpy = require( '@stdlib/lapack/base/slacpy' ); + +var shape = [ 5, 8 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var N = numel( shape ); + +var A = uniform( N, -10, 10, { + 'dtype': 'float32' +}); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var B = uniform( N, -10, 10, { + 'dtype': 'float32' +}); +console.log( ndarray2array( B, shape, strides, 0, order ) ); + +slacpy( order, 'all', shape[ 0 ], shape[ 1 ], A, strides[ 0 ], B, strides[ 0 ] ); +console.log( ndarray2array( B, shape, strides, 0, order ) ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/slacpy/benchmark/benchmark.js new file mode 100644 index 00000000000..7fabfbbe26b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var slacpy = require( './../lib/slacpy.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var opts; + var A; + var B; + + opts = { + 'dtype': 'float32' + }; + + A = uniform( N*N, -10.0, 10.0, opts ); + B = uniform( N*N, -10.0, 10.0, opts ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = slacpy( 'column-major', 'all', N, N, A, N, B, N ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':order=column-major,size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/slacpy/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..40e2ad9e571 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var slacpy = require( './../lib/ndarray.js' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var opts; + var A; + var B; + + opts = { + 'dtype': 'float32' + }; + + A = uniform( N*N, -10.0, 10.0, opts ); + B = uniform( N*N, -10.0, 10.0, opts ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = slacpy( 'all', N, N, A, 1, N, 0, B, 1, N, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':ndarray:order=column-major,size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/slacpy/docs/repl.txt new file mode 100644 index 00000000000..837293c812d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/docs/repl.txt @@ -0,0 +1,108 @@ + +{{alias}}( order, uplo, M, N, A, LDA, B, LDB ) + Copies all or part of a matrix `A` to another matrix `B`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether to copy the upper or lower triangular/trapezoidal part + of a matrix `A`. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Float32Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + B: Float32Array + Output matrix `B`. + + LDB: integer + Stride of the first dimension of `B` (a.k.a., leading dimension of the + matrix `B`). + + Returns + ------- + B: Float32Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 3.0, 0.0, 4.0 ] ); + > var B = new {{alias:@stdlib/array/float32}}( [ 5.0, 7.0, 0.0, 8.0 ] ); + > {{alias}}( 'row-major', 'all', 2, 2, A, 2, B, 2 ) + [ 1.0, 3.0, 0.0, 4.0 ] + + +{{alias}}.ndarray( uplo, M, N, A, sa1, sa2, oa, B, sb1, sb2, ob ) + Copies all or part of a matrix `A` to another matrix `B` 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 + ---------- + uplo: string + Specifies whether to copy the upper or lower triangular/trapezoidal part + of a matrix `A`. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + A: Float32Array + Input matrix `A`. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + B: Float32Array + Output matrix `B`. + + sb1: integer + Stride of the first dimension of `B`. + + sb2: integer + Stride of the second dimension of `B`. + + ob: integer + Starting index for `B`. + + Returns + ------- + B: Float32Array + Output matrix. + + Examples + -------- + > var A = new {{alias:@stdlib/array/float32}}( [ 0.0, 1.0, 3.0, 0.0, 4.0 ] ); + > var B = new {{alias:@stdlib/array/float32}}( [ 0.0, 0.0, 5.0, 7.0, 0.0, 8.0 ] ); + > {{alias}}.ndarray( 'all', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ) + [ 0.0, 0.0, 1.0, 3.0, 0.0, 4.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/slacpy/docs/types/index.d.ts new file mode 100644 index 00000000000..8a09fe303f0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/docs/types/index.d.ts @@ -0,0 +1,117 @@ +/* +* @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 + +/// + +import { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `slacpy`. +*/ +interface Routine { + /** + * Copies all or part of a matrix `A` to another matrix `B`. + * + * @param order - storage layout of `A` and `B` + * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param B - output matrix + * @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) + * @returns `B` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + * var B = new Float32Array( 4 ); + * + * slacpy( 'row-major', 'all', 2, 2, A, 2, B, 2 ); + * // B => [ 1.0, 2.0, 3.0, 4.0 ] + */ + ( order: Layout, uplo: string, M: number, N: number, A: Float32Array, LDA: number, B: Float32Array, LDB: number ): Float32Array; + + /** + * Copies all or part of a matrix `A` to another matrix `B` using alternative indexing semantics. + * + * @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param A - input matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @param B - output matrix + * @param strideB1 - stride of the first dimension of `B` + * @param strideB2 - stride of the second dimension of `B` + * @param offsetB - starting index for `B` + * @returns `B` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); + * var B = new Float32Array( [ 0.0, 0.0, 11.0, 312.0, 53.0, 412.0 ] ); + * + * slacpy.ndarray( 'all', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); + * // B => [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] + */ + ndarray( uplo: string, M: number, N: number, A: Float32Array, strideA1: number, strideA2: number, offsetA: number, B: Float32Array, strideB1: number, strideB2: number, offsetB: number ): Float32Array; +} + +/** +* Copies all or part of a matrix `A` to another matrix `B`. +* +* @param order - storage layout of `A` and `B` +* @param uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param M - number of rows in matrix `A` +* @param N - number of columns in matrix `A` +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param B - output matrix +* @param LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @returns `B` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* slacpy( 'row-major', 'all', 2, 2, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( [ 0.0, 0.0, 11.0, 312.0, 53.0, 412.0 ] ); +* +* slacpy.ndarray( 'all', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +* // B => [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] +*/ +declare var slacpy: Routine; + + +// EXPORTS // + +export = slacpy; diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/slacpy/docs/types/test.ts new file mode 100644 index 00000000000..8fbd84fca2b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/docs/types/test.ts @@ -0,0 +1,358 @@ +/* +* @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 slacpy = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy( 'row-major', 'all', 2, 2, A, 2, B, 2 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy( 5, 'all', 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( true, 'all', 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( false, 'all', 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( null, 'all', 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( void 0, 'all', 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( [], 'all', 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( {}, 'all', 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( ( x: number ): number => x, 'all', 2, 2, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy( 'row-major', 5, 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', true, 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', false, 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', null, 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', void 0, 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', [], 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', {}, 2, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', ( x: number ): number => x, 2, 2, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy( 'row-major', 'all', '5', 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', true, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', false, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', null, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', void 0, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', [], 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', {}, 2, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', ( x: number ): number => x, 2, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy( 'row-major', 'all', 2, '5', A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, true, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, false, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, null, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, void 0, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, [], A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, {}, A, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, ( x: number ): number => x, A, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float32Array... +{ + const B = new Float32Array( 4 ); + + slacpy( 'row-major', 'all', 2, 2, '5', 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, 5, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, true, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, false, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, null, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, void 0, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, [], 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, {}, 2, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, ( x: number ): number => x, 2, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy( 'row-major', 'all', 2, 2, A, '5', B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, true, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, false, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, null, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, void 0, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, [], B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, {}, B, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, ( x: number ): number => x, B, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float32Array... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + slacpy( 'row-major', 'all', 2, 2, A, 2, '5', 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, 5, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, true, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, false, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, null, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, void 0, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, [], 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, {}, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy( 'row-major', 'all', 2, 2, A, 2, B, '5' ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, B, true ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, B, false ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, B, null ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, B, void 0 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, B, [] ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, B, {} ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, B, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy(); // $ExpectError + slacpy( 'row-major' ); // $ExpectError + slacpy( 'row-major', 'all' ); // $ExpectError + slacpy( 'row-major', 'all', 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2 ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, B ); // $ExpectError + slacpy( 'row-major', 'all', 2, 2, A, 2, B, 2, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 5, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( true, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( false, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( null, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( void 0, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( [], 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( {}, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( ( x: number ): number => x, 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', '5', 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', true, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', false, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', null, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', void 0, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', [], 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', {}, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', ( x: number ): number => x, 2, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', 2, '5', A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, true, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, false, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, null, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, void 0, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, [], A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, {}, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, ( x: number ): number => x, A, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float32Array... +{ + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', 2, 2, '5', 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, 5, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, true, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, false, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, null, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, void 0, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, [], 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, {}, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, ( x: number ): number => x, 2, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', 2, 2, A, '5', 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, true, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, false, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, null, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, void 0, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, [], 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, {}, 1, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, ( x: number ): number => x, 1, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', 2, 2, A, 2, '5', 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, true, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, false, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, null, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, void 0, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, [], 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, {}, 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, ( x: number ): number => x, 0, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', 2, 2, A, 2, 1, '5', B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, true, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, false, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, null, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, void 0, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, [], B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, {}, B, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, ( x: number ): number => x, B, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a Float32Array... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, '5', 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, 5, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, true, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, false, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, null, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, void 0, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, [], 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, {}, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, ( x: number ): number => x, 2, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, '5', 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, true, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, false, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, null, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, void 0, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, [], 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, {}, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, '5', 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, true, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, false, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, null, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, void 0, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, [], 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, {}, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, '5' ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, true ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, false ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, null ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, void 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, [] ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, {} ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + const B = new Float32Array( 4 ); + + slacpy.ndarray(); // $ExpectError + slacpy.ndarray( 'all' ); // $ExpectError + slacpy.ndarray( 'all', 2 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1 ); // $ExpectError + slacpy.ndarray( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/examples/index.js b/lib/node_modules/@stdlib/lapack/base/slacpy/examples/index.js new file mode 100644 index 00000000000..0a54b31b9ec --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/examples/index.js @@ -0,0 +1,44 @@ +/** +* @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 ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var uniform = require( '@stdlib/random/array/discrete-uniform' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var slacpy = require( './../lib' ); + +var shape = [ 5, 8 ]; +var order = 'row-major'; +var strides = shape2strides( shape, order ); + +var N = numel( shape ); + +var A = uniform( N, -10, 10, { + 'dtype': 'float32' +}); +console.log( ndarray2array( A, shape, strides, 0, order ) ); + +var B = uniform( N, -10, 10, { + 'dtype': 'float32' +}); +console.log( ndarray2array( B, shape, strides, 0, order ) ); + +slacpy( order, 'all', shape[ 0 ], shape[ 1 ], A, strides[ 0 ], B, strides[ 0 ] ); +console.log( ndarray2array( B, shape, strides, 0, order ) ); diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/lib/base.js b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/base.js new file mode 100644 index 00000000000..d5affe96a0c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/base.js @@ -0,0 +1,459 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' ); +var min = require( '@stdlib/math/base/special/fast/min' ); + + +// FUNCTIONS // + +/** +* Copies all of a matrix `A` to another matrix `B`. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {PositiveInteger} offsetA - starting index for `A` +* @param {Float32Array} B - output matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {PositiveInteger} offsetB - starting index for `B` +* @returns {Float32Array} `B` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyAll( 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyAll( 2, 2, A, 2, -1, 1, B, 2, 1, 0 ); +* // B => [ 2.0, 1.0, 4.0, 3.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyAll( 2, 2, A, -2, 1, 2, B, 2, 1, 0 ); +* // B => [ 3.0, 4.0, 1.0, 2.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyAll( 2, 2, A, -2, -1, 3, B, 2, 1, 0 ); +* // B => [ 4.0, 3.0, 2.0, 1.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyAll( 2, 2, A, 1, 2, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 3.0, 2.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyAll( 2, 2, A, -1, 2, 1, B, 2, 1, 0 ); +* // B => [ 2.0, 4.0, 1.0, 3.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyAll( 2, 2, A, 1, -2, 2, B, 2, 1, 0 ); +* // B => [ 3.0, 1.0, 4.0, 2.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyAll( 2, 2, A, -1, -2, 3, B, 2, 1, 0 ); +* // B => [ 4.0, 2.0, 3.0, 1.0 ] +*/ +function copyAll( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { + var da0; + var da1; + var db0; + var db1; + var sh; + var S0; + var S1; + var sa; + var sb; + var ia; + var ib; + var i0; + var i1; + var o; + + // Resolve the loop interchange order: + o = loopOrder( [ M, N ], [ strideA1, strideA2 ], [ strideB1, strideB2 ] ); + sh = o.sh; + sa = o.sx; + sb = o.sy; + + // Extract loop variables for purposes of loop interchange: dimensions and loop offset (pointer) increments... + S0 = sh[ 0 ]; + S1 = sh[ 1 ]; + da0 = sa[ 0 ]; + da1 = sa[ 1 ] - ( S0*sa[0] ); + db0 = sb[ 0 ]; + db1 = sb[ 1 ] - ( S0*sb[0] ); + + // Set the pointers to the first indexed elements in the respective matrices... + ia = offsetA; + ib = offsetB; + + // Iterate over the matrix dimensions... + for ( i1 = 0; i1 < S1; i1++ ) { + for ( i0 = 0; i0 < S0; i0++ ) { + B[ ib ] = A[ ia ]; + ia += da0; + ib += db0; + } + ia += da1; + ib += db1; + } + return B; +} + +/** +* Copies the upper triangular/trapezoidal part of a matrix `A` to another matrix `B`. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {PositiveInteger} offsetA - starting index for `A` +* @param {Float32Array} B - output matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {PositiveInteger} offsetB - starting index for `B` +* @returns {Float32Array} `B` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyUpper( 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 0.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyUpper( 2, 2, A, 2, -1, 1, B, 2, 1, 0 ); +* // B => [ 2.0, 1.0, 0.0, 3.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyUpper( 2, 2, A, -2, 1, 2, B, 2, 1, 0 ); +* // B => [ 3.0, 4.0, 0.0, 2.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyUpper( 2, 2, A, -2, -1, 3, B, 2, 1, 0 ); +* // B => [ 4.0, 3.0, 0.0, 1.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyUpper( 2, 2, A, 1, 2, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 3.0, 0.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyUpper( 2, 2, A, -1, 2, 1, B, 2, 1, 0 ); +* // B => [ 2.0, 4.0, 0.0, 3.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyUpper( 2, 2, A, 1, -2, 2, B, 2, 1, 0 ); +* // B => [ 3.0, 1.0, 0.0, 2.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyUpper( 2, 2, A, -1, -2, 3, B, 2, 1, 0 ); +* // B => [ 4.0, 2.0, 0.0, 1.0 ] +*/ +function copyUpper( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { + var ia; + var ib; + var i0; + var i1; + + ia = offsetA; + ib = offsetB; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = i1; i0 < N; i0++ ) { + B[ ib+(i0*strideB2) ] = A[ ia+(i0*strideA2) ]; + } + ia += strideA1; + ib += strideB1; + } + return B; + } + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = 0; i0 <= min( i1, M-1 ); i0++ ) { + B[ ib+(i0*strideB1) ] = A[ ia+(i0*strideA1) ]; + } + ia += strideA2; + ib += strideB2; + } + return B; +} + +/** +* Copies the lower triangular/trapezoidal part of a matrix `A` to another matrix `B`. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {PositiveInteger} offsetA - starting index for `A` +* @param {Float32Array} B - output matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {PositiveInteger} offsetB - starting index for `B` +* @returns {Float32Array} `B` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyLower( 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 0.0, 3.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyLower( 2, 2, A, 2, -1, 1, B, 2, 1, 0 ); +* // B => [ 2.0, 0.0, 4.0, 3.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyLower( 2, 2, A, -2, 1, 2, B, 2, 1, 0 ); +* // B => [ 3.0, 0.0, 1.0, 2.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyLower( 2, 2, A, -2, -1, 3, B, 2, 1, 0 ); +* // B => [ 4.0, 0.0, 2.0, 1.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyLower( 2, 2, A, 1, 2, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 0.0, 2.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyLower( 2, 2, A, -1, 2, 1, B, 2, 1, 0 ); +* // B => [ 2.0, 0.0, 1.0, 3.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyLower( 2, 2, A, 1, -2, 2, B, 2, 1, 0 ); +* // B => [ 3.0, 0.0, 4.0, 2.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* copyLower( 2, 2, A, -1, -2, 3, B, 2, 1, 0 ); +* // B => [ 4.0, 0.0, 3.0, 1.0 ] +*/ +function copyLower( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { + var ia; + var ib; + var i0; + var i1; + + ia = offsetA; + ib = offsetB; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i1 = 0; i1 < M; i1++ ) { + for ( i0 = 0; i0 <= min( i1, N-1 ); i0++ ) { + B[ ib+(i0*strideB2) ] = A[ ia+(i0*strideA2) ]; + } + ia += strideA1; + ib += strideB1; + } + return B; + } + for ( i1 = 0; i1 < N; i1++ ) { + for ( i0 = i1; i0 < M; i0++ ) { + B[ ib+(i0*strideB1) ] = A[ ia+(i0*strideA1) ]; + } + ia += strideA2; + ib += strideB2; + } + return B; +} + + +// MAIN // + +/** +* Copies all or part of a matrix `A` to another matrix `B`. +* +* @private +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {PositiveInteger} offsetA - starting index for `A` +* @param {Float32Array} B - output matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {PositiveInteger} offsetB - starting index for `B` +* @returns {Float32Array} `B` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* slacpy( 'all', 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* slacpy( 'upper', 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 2.0, 0.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* slacpy( 'lower', 2, 2, A, 2, 1, 0, B, 2, 1, 0 ); +* // B => [ 1.0, 0.0, 3.0, 4.0 ] +*/ +function slacpy( uplo, M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { + if ( uplo === 'upper' ) { + return copyUpper( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); + } + if ( uplo === 'lower' ) { + return copyLower( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); + } + return copyAll( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); +} + + +// EXPORTS // + +module.exports = slacpy; diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/lib/index.js b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/index.js new file mode 100644 index 00000000000..d1dcba5d061 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/index.js @@ -0,0 +1,70 @@ +/** +* @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 copy all or part of a matrix `A` to another matrix `B`. +* +* @module @stdlib/lapack/base/slacpy +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var slacpy = require( '@stdlib/lapack/base/slacpy' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* slacpy( 'row-major', 'all', 2, 2, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var slacpy = require( '@stdlib/lapack/base/slacpy' ); +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( [ 0.0, 0.0, 11.0, 312.0, 53.0, 412.0 ] ); +* +* slacpy.ndarray( 'all', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +* // B => [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] +*/ + +// 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 slacpy; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + slacpy = main; +} else { + slacpy = tmp; +} + + +// EXPORTS // + +module.exports = slacpy; + +// exports: { "ndarray": "slacpy.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/lib/main.js b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/main.js new file mode 100644 index 00000000000..68f349393af --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/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 slacpy = require( './slacpy.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( slacpy, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = slacpy; diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/ndarray.js new file mode 100644 index 00000000000..5e6c0590f10 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/ndarray.js @@ -0,0 +1,78 @@ +/** +* @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 // + +/** +* Copies all or part of a matrix `A` to another matrix `B` using alternative indexing semantics. +* +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {PositiveInteger} offsetA - starting index for `A` +* @param {Float32Array} B - output matrix +* @param {integer} strideB1 - stride of the first dimension of `B` +* @param {integer} strideB2 - stride of the second dimension of `B` +* @param {PositiveInteger} offsetB - starting index for `B` +* @returns {Float32Array} `B` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( [ 0.0, 0.0, 11.0, 312.0, 53.0, 412.0 ] ); +* +* slacpy( 'all', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +* // B => [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( [ 0.0, 0.0, 11.0, 312.0, 53.0, 412.0 ] ); +* +* slacpy( 'upper', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +* // B => [ 0.0, 0.0, 1.0, 2.0, 53.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( [ 0.0, 0.0, 11.0, 312.0, 53.0, 412.0 ] ); +* +* slacpy( 'lower', 2, 2, A, 2, 1, 1, B, 2, 1, 2 ); +* // B => [ 0.0, 0.0, 1.0, 312.0, 3.0, 4.0 ] +*/ +function slacpy( uplo, M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ) { // eslint-disable-line max-len, max-params + return base( uplo, M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, offsetB ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = slacpy; diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/lib/slacpy.js b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/slacpy.js new file mode 100644 index 00000000000..5fd47c543c4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/slacpy.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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Copies all or part of a matrix `A` to another matrix `B`. +* +* @param {string} order - storage layout of `A` and `B` +* @param {string} uplo - specifies whether to copy the upper or lower triangular/trapezoidal part of matrix `A` +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {Float32Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float32Array} B - output matrix +* @param {PositiveInteger} LDB - stride of the first dimension of `B` (a.k.a., leading dimension of the matrix `B`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} sixth argument must be greater than or equal to `N` +* @throws {RangeError} eighth argument must be greater than or equal to `N` +* @returns {Float32Array} `B` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* slacpy( 'row-major', 'all', 2, 2, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* slacpy( 'row-major', 'upper', 2, 2, A, 2, B, 2 ); +* // B => [ 1.0, 2.0, 0.0, 4.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); +* var B = new Float32Array( 4 ); +* +* slacpy( 'row-major', 'lower', 2, 2, A, 2, B, 2 ); +* // B => [ 1.0, 0.0, 3.0, 4.0 ] +*/ +function slacpy( order, uplo, M, N, A, LDA, B, LDB ) { + var sa1; + var sa2; + var sb1; + var sb2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + sb1 = 1; + sb2 = LDB; + } else { // order === 'row-major' + if ( LDA < N ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to %d. Value: `%d`.', N, LDA ) ); + } + if ( LDB < N ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to %d. Value: `%d`.', N, LDB ) ); + } + sa1 = LDA; + sa2 = 1; + sb1 = LDB; + sb2 = 1; + } + return base( uplo, M, N, A, sa1, sa2, 0, B, sb1, sb2, 0 ); +} + + +// EXPORTS // + +module.exports = slacpy; diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/package.json b/lib/node_modules/@stdlib/lapack/base/slacpy/package.json new file mode 100644 index 00000000000..dd70a49b031 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/lapack/base/slacpy", + "version": "0.0.0", + "description": "Copy all or part of a matrix A to another matrix B.", + "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", + "slacpy", + "copy", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "matrix", + "float32" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/test/test.js b/lib/node_modules/@stdlib/lapack/base/slacpy/test/test.js new file mode 100644 index 00000000000..2e06e4e0a1c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/test/test.js @@ -0,0 +1,82 @@ +/** +* @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 slacpy = 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 slacpy, '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 slacpy.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 slacpy = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( slacpy, 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 slacpy; + var main; + + main = require( './../lib/slacpy.js' ); + + slacpy = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( slacpy, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/slacpy/test/test.ndarray.js new file mode 100644 index 00000000000..b14e8085ae4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/test/test.ndarray.js @@ -0,0 +1,270 @@ +/** +* @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 */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var slacpy = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof slacpy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( slacpy.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (row-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = slacpy( 'all', 2, 3, A, 3, 1, 1, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + out = slacpy( 'all', 2, 3, A, -3, -1, 6, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = slacpy( 'all', 3, 2, A, 2, 1, 1, B, 2, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies part of a matrix `A` to another matrix `B` (row-major, upper)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 0.0, 5.0, 6.0 ] ); + + out = slacpy( 'upper', 2, 3, A, 3, 1, 1, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 3.0, 2.0, 1.0, 0.0, 5.0, 4.0 ] ); + + out = slacpy( 'upper', 2, 3, A, 3, -1, 3, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 4.0, 0.0, 0.0 ] ); + + out = slacpy( 'upper', 3, 2, A, 2, 1, 1, B, 2, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies part of a matrix `A` to another matrix `B` (row-major, lower)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 4.0, 5.0, 0.0 ] ); + + out = slacpy( 'lower', 2, 3, A, 3, 1, 1, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 4.0, 0.0, 0.0, 1.0, 2.0, 0.0 ] ); + + out = slacpy( 'lower', 2, 3, A, -3, 1, 4, B, 3, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = slacpy( 'lower', 3, 2, A, 2, 1, 1, B, 2, 1, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (column-major)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = slacpy( 'all', 2, 3, A, 1, 2, 1, B, 1, 2, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0 ] ); + + out = slacpy( 'all', 2, 3, A, 1, 2, 1, B, -1, -2, 8 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = slacpy( 'all', 3, 2, A, 1, 3, 1, B, 1, 3, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies part of a matrix `A` to another matrix `B` (column-major, upper)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = slacpy( 'upper', 2, 3, A, 1, 2, 1, B, 1, 2, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 4.0, 3.0, 6.0, 5.0 ] ); + + out = slacpy( 'upper', 2, 3, A, 1, 2, 1, B, -1, 2, 4 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 4.0, 5.0, 0.0 ] ); + + out = slacpy( 'upper', 3, 2, A, 1, 3, 1, B, 1, 3, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies part of a matrix `A` to another matrix `B` (column-major, lower)', function test( t ) { + var expected; + var out; + var A; + var B; + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 0.0, 4.0, 0.0, 0.0 ] ); + + out = slacpy( 'lower', 2, 3, A, 1, 2, 1, B, 1, 2, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4.0, 1.0, 2.0 ] ); + + out = slacpy( 'lower', 2, 3, A, 1, 2, 1, B, 1, -2, 7 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + B = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float32Array( [ 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 0.0, 5.0, 6.0 ] ); + + out = slacpy( 'lower', 3, 2, A, 1, 3, 1, B, 1, 3, 3 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (column-major, lower, complex access patterns)', function test( t ) { + var out; + var A; + var B; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float32Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 3, + 999, 0, 999, 4, 999, 5, + 999, 0, 999, 0, 999, 6, + 999, 999, 999, 999, 999, 999 + ]); + B = new Float32Array([ + 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999, + 999, 999, 999, 999, 999, 999 + ]); + + /* eslint-enable array-element-newline, no-multi-spaces */ + + out = slacpy( 'all', 3, 3, A, 2, 6, 7, B, 2, 6, 7 ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/test/test.slacpy.js b/lib/node_modules/@stdlib/lapack/base/slacpy/test/test.slacpy.js new file mode 100644 index 00000000000..83e5da4bcf9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/test/test.slacpy.js @@ -0,0 +1,282 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var Float32Array = require( '@stdlib/array/float32' ); +var slacpy = require( './../lib/slacpy.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof slacpy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( slacpy.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + B = new Float32Array( 4 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + slacpy( value, 'all', 2, 2, A, 2, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument (row-major)', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 0, + 1 + ]; + + A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + B = new Float32Array( 4 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + slacpy( 'row-major', 'all', 2, 2, A, value, B, 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument (row-major)', function test( t ) { + var values; + var A; + var B; + var i; + + values = [ + 0, + 1 + ]; + + A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + B = new Float32Array( 4 ); + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + slacpy( 'row-major', 'all', 2, 2, A, 2, B, value ); + }; + } +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (row-major)', function test( t ) { + var opts; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + opts = { + 'dtype': 'float32' + }; + + A = uniform( M*N, -10.0, 10.0, opts ); + B = new Float32Array( M*N ); + + out = slacpy( 'row-major', 'all', M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies a part of a matrix `A` to another matrix `B` (row-major, upper)', function test( t ) { + var opts; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + opts = { + 'dtype': 'float32' + }; + + A = uniform( M*N, -10.0, 10.0, opts ); + B = new Float32Array( M*N ); + + out = slacpy( 'row-major', 'lower', M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + + out = slacpy( 'row-major', 'upper', M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies a part of a matrix `A` to another matrix `B` (row-major, lower)', function test( t ) { + var opts; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + opts = { + 'dtype': 'float32' + }; + + A = uniform( M*N, -10.0, 10.0, opts ); + B = new Float32Array( M*N ); + + out = slacpy( 'row-major', 'upper', M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + + out = slacpy( 'row-major', 'lower', M, N, A, N, B, N ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies all of a matrix `A` to another matrix `B` (column-major)', function test( t ) { + var opts; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + opts = { + 'dtype': 'float32' + }; + + A = uniform( M*N, -10.0, 10.0, opts ); + B = new Float32Array( M*N ); + + out = slacpy( 'column-major', 'all', M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies a part of a matrix `A` to another matrix `B` (column-major, upper)', function test( t ) { + var opts; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + opts = { + 'dtype': 'float32' + }; + + A = uniform( M*N, -10.0, 10.0, opts ); + B = new Float32Array( M*N ); + + out = slacpy( 'column-major', 'lower', M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + + out = slacpy( 'column-major', 'upper', M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function copies a part of a matrix `A` to another matrix `B` (column-major, lower)', function test( t ) { + var opts; + var out; + var A; + var B; + var M; + var N; + + M = 5; + N = 8; + + opts = { + 'dtype': 'float32' + }; + + A = uniform( M*N, -10.0, 10.0, opts ); + B = new Float32Array( M*N ); + + out = slacpy( 'column-major', 'upper', M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + + out = slacpy( 'column-major', 'lower', M, N, A, M, B, M ); + t.strictEqual( out, B, 'returns expected value' ); + t.deepEqual( out, A, 'returns expected value' ); + + t.end(); +}); From d994cd198f1ed714eb9738ceb5f61b193a4da16b Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 31 Jul 2024 14:22:46 -0700 Subject: [PATCH 2/3] docs: fix offset types --- .../@stdlib/lapack/base/dlacpy/lib/base.js | 16 ++++++++-------- .../@stdlib/lapack/base/dlacpy/lib/ndarray.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/base.js index 183fb4f6802..6eda3d563cc 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/base.js @@ -38,11 +38,11 @@ var min = require( '@stdlib/math/base/special/fast/min' ); * @param {Float64Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float64Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float64Array} `B` * * @example @@ -173,11 +173,11 @@ function copyAll( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, o * @param {Float64Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float64Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float64Array} `B` * * @example @@ -289,11 +289,11 @@ function copyUpper( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, * @param {Float64Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float64Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float64Array} `B` * * @example @@ -409,11 +409,11 @@ function copyLower( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, * @param {Float64Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float64Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float64Array} `B` * * @example diff --git a/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/ndarray.js index a4aee3e1018..66b722fcd1d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlacpy/lib/ndarray.js @@ -34,11 +34,11 @@ var base = require( './base.js' ); * @param {Float64Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float64Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float64Array} `B` * * @example From 3f432e56d24f40f81f74ed076c0124ad5201566c Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 31 Jul 2024 14:25:11 -0700 Subject: [PATCH 3/3] docs: fix offset types --- .../@stdlib/lapack/base/slacpy/lib/base.js | 16 ++++++++-------- .../@stdlib/lapack/base/slacpy/lib/ndarray.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/lib/base.js b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/base.js index d5affe96a0c..7b99e4dae80 100644 --- a/lib/node_modules/@stdlib/lapack/base/slacpy/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/base.js @@ -38,11 +38,11 @@ var min = require( '@stdlib/math/base/special/fast/min' ); * @param {Float32Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float32Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float32Array} `B` * * @example @@ -173,11 +173,11 @@ function copyAll( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, o * @param {Float32Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float32Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float32Array} `B` * * @example @@ -289,11 +289,11 @@ function copyUpper( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, * @param {Float32Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float32Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float32Array} `B` * * @example @@ -409,11 +409,11 @@ function copyLower( M, N, A, strideA1, strideA2, offsetA, B, strideB1, strideB2, * @param {Float32Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float32Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float32Array} `B` * * @example diff --git a/lib/node_modules/@stdlib/lapack/base/slacpy/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/ndarray.js index 5e6c0590f10..94a4bc87324 100644 --- a/lib/node_modules/@stdlib/lapack/base/slacpy/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/slacpy/lib/ndarray.js @@ -34,11 +34,11 @@ var base = require( './base.js' ); * @param {Float32Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {PositiveInteger} offsetA - starting index for `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` * @param {Float32Array} B - output matrix * @param {integer} strideB1 - stride of the first dimension of `B` * @param {integer} strideB2 - stride of the second dimension of `B` -* @param {PositiveInteger} offsetB - starting index for `B` +* @param {NonNegativeInteger} offsetB - starting index for `B` * @returns {Float32Array} `B` * * @example