diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 52469d11e58..75689323de2 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -32,7 +32,7 @@ var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); #### dlaswp( N, A, LDA, k1, k2, IPIV, incx ) -Perform a series of row interchanges on an input matrix `A` using pivot indices stored in `IPIV`. +Performs a series of row interchanges on an input matrix `A` using pivot indices stored in `IPIV`. ```javascript var Int32Array = require( '@stdlib/array/int32' ); diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/README.md b/lib/node_modules/@stdlib/lapack/base/slaswp/README.md new file mode 100644 index 00000000000..8b29a1fc6ab --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/README.md @@ -0,0 +1,293 @@ + + +# slaswp + +> Perform a series of row interchanges on an input matrix. + +
+ +## Usage + +```javascript +var slaswp = require( '@stdlib/lapack/base/slaswp' ); +``` + +#### slaswp( N, A, LDA, k1, k2, IPIV, incx ) + +Performs a series of row interchanges on an input matrix `A` using pivot indices stored in `IPIV`. + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +var IPIV = new Int32Array( [ 2, 0, 1 ] ); + +slaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **N**: number of columns in `A`. +- **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-Float32Array]. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **k1**: index of first row to interchange when `incx` is positive and the index of the last row to interchange when `incx` is negative. +- **k2**: index of last row to interchange when `incx` is positive and the index of the first row to interchange when `incx` is negative. +- **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array]. Must contain at least `k1+(k2-k1)*abs(incx)` elements. Only the elements in positions `k1` through `k1+(k2-k1)*abs(incx)` are accessed. +- **incx**: increment between successive values of `IPIV`. Elements from `IPIV` are accessed according to `IPIV[k1+(k-k1)*abs(incx)] = j`, thus implying that rows `k` and `j` should be interchanged. If `incx` is negative, the pivots are applied in reverse order. + +The sign of the increment parameter `incx` determines the order in which pivots are applied. For example, to apply pivots in reverse order, + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +var IPIV = new Int32Array( [ 2, 0, 1 ] ); + +slaswp( 'row-major', 2, A, 2, 0, 2, IPIV, -1 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +``` + +To perform strided access over `IPIV`, provide an `abs(incx)` value greater than one. For example, to access every other element in `IPIV`, + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +var IPIV = new Int32Array( [ 2, 999, 0, 999, 1 ] ); + +slaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 2 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial arrays... +var A0 = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var IPIV0 = new Int32Array( [ 0, 2, 0, 1] ); + +// Create offset views... +var A1 = new Float32Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var IPIV1 = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +slaswp( 'row-major', 2, A1, 2, 0, 2, IPIV1, 1 ); +// A0 => [ 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +``` + +#### slaswp.ndarray( N, A, sa1, sa2, oa, k1, k2, inck, IPIV, si, oi ) + +Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +var IPIV = new Int32Array( [ 2, 0, 1 ] ); + +slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +``` + +The function has the following additional parameters: + +- **N**: number of columns in `A`. +- **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. +- **k1**: index of first row to interchange when `inck` is positive and the index of the last row to interchange when `inck` is negative. +- **k2**: index of last row to interchange when `inck` is positive and the index of the first row to interchange when `inck` is negative. +- **inck**: direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order). +- **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array]. +- **si**: index increment for `IPIV`. +- **oi**: starting index for `IPIV`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var IPIV = new Int32Array( [ 0, 0, 2, 0, 1 ] ); + +slaswp.ndarray( 2, A, 2, 1, 4, 0, 2, 1, IPIV, 1, 2 ); +// A => [ 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +``` + +
+ + + +
+ +## Notes + +- Both functions access `k2-k1+1` elements from `IPIV`. +- While `slaswp` conflates the order in which pivots are applied with the order in which elements in `IPIV` are accessed, the `ndarray` method delineates control of those behaviors with separate parameters `inck` and `si`. +- `slaswp()` corresponds to the [LAPACK][LAPACK] level 1 function [`slaswp`][lapack-slaswp]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var slaswp = require( '@stdlib/lapack/base/slaswp' ); + +// Specify matrix meta data: +var shape = [ 4, 2 ]; +var strides = [ 1, 4 ]; +var offset = 0; +var order = 'column-major'; + +// Create a matrix stored in linear memory: +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +// Define a vector of pivot indices: +var IPIV = new Int32Array( [ 2, 0, 3, 1 ] ); + +// Interchange rows: +slaswp( order, shape[ 1 ], A, strides[ 1 ], 0, shape[ 0 ]-1, IPIV, 1 ); +console.log( ndarray2array( A, shape, strides, offset, 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/slaswp/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/slaswp/benchmark/benchmark.js new file mode 100644 index 00000000000..fd6b3f40a55 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/benchmark/benchmark.js @@ -0,0 +1,125 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-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 slaswp = require( './../lib/slaswp.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} nrows - number of rows to interchange +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N, nrows ) { + var IPIV; + var A; + + IPIV = discreteUniform( nrows, 0, N-1, { + 'dtype': 'int32' + }); + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float32' + }); + 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 = slaswp( order, N, A, N, 0, nrows-1, IPIV, 1 ); + 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 ord; + var N; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + j = 1; + while ( j <= N ) { + f = createBenchmark( ord, N, j ); + bench( pkg+'::square_matrix:order='+ord+',nrows='+j+',size='+(N*N), f ); + j *= 2; + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/slaswp/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..2fe4fdfbb2b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/benchmark/benchmark.ndarray.js @@ -0,0 +1,134 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-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 slaswp = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} nrows - number of rows to interchange +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N, nrows ) { + var IPIV; + var sa1; + var sa2; + var A; + + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } + IPIV = discreteUniform( nrows, 0, N-1, { + 'dtype': 'int32' + }); + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float32' + }); + 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 = slaswp( N, A, sa1, sa2, 0, 0, nrows-1, 1, IPIV, 1, 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 ord; + var N; + var f; + var i; + var j; + var k; + + min = 1; // 10^min + max = 6; // 10^max + + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + j = 1; + while ( j <= N ) { + f = createBenchmark( ord, N, j ); + bench( pkg+'::square_matrix:ndarray:order='+ord+',nrows='+j+',size='+(N*N), f ); + j *= 2; + } + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/slaswp/docs/repl.txt new file mode 100644 index 00000000000..2b3edad68cb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/docs/repl.txt @@ -0,0 +1,119 @@ + +{{alias}}( order, N, A, LDA, k1, k2, IPIV, incx ) + Performs a series of row interchanges on the matrix `A` using pivot indices + stored in `IPIV`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `incx` is equal to `0`, the function returns `A` unchanged. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + N: integer + Number of columns in `A`. + + A: Float32Array + Input matrix. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + k1: integer + Index of first row to interchange. + + k2: integer + Index of last row to interchange. + + IPIV: Int32Array + Array of pivot indices. + + incx: integer + Increment between successive values of `IPIV`. + + Returns + ------- + A: Float32Array + Mutated input matrix. + + Examples + -------- + > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var ord = 'row-major'; + > {{alias}}( ord, 2, A, 2, 0, 2, IPIV, 1 ) + [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] + + // Using typed array views: + > var IPIV0 = new {{alias:@stdlib/array/int32}}( [ 0, 2, 0, 1 ] ); + > var A0 = new {{alias:@stdlib/array/float32}}( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > IPIV = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); + > A = new Float32Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( ord, 2, A, 2, 0, 2, IPIV, 1 ); + > A0 + [ 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] + + +{{alias}}.ndarray( N, A, sa1, sa2, oa, k1, k2, inck, IPIV, si, oi ) + Performs a series of row interchanges on the matrix `A` using pivot indices + stored in `IPIV` and alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Number of columns in `A`. + + A: Float32Array + Input matrix. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Index offset for `A`. + + k1: integer + Index of first row to interchange. + + k2: integer + Index of last row to interchange. + + inck: integer + Direction in which to apply pivots (-1 to apply pivots in reverse order; + otherwise, apply in provided order). + + IPIV: Int32Array + Array of pivot indices. + + si: integer + Index increment for `IPIV`. + + oi: integer + Index offset for `IPIV`. + + Returns + ------- + A: Float32Array + Mutated input matrix. + + Examples + -------- + > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ) + [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/slaswp/docs/types/index.d.ts new file mode 100644 index 00000000000..3bdbfb615c4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/docs/types/index.d.ts @@ -0,0 +1,121 @@ +/* +* @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 `slaswp`. +*/ +interface Routine { + /** + * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. + * + * @param order - storage layout + * @param N - number of columns in `A` + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param k1 - index of first row to interchange + * @param k2 - index of last row to interchange + * @param IPIV - vector of pivot indices + * @param incx - increment between successive values of `IPIV` + * @returns permuted matrix `A` + * + * @example + * var Int32Array = require( '@stdlib/array/int32' ); + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var IPIV = new Int32Array( [ 2, 0, 1 ] ); + * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] + * + * slaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); + * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] + */ + ( order: Layout, N: number, A: Float32Array, LDA: number, k1: number, k2: number, IPIV: Int32Array, incx: number ): Float32Array; + + /** + * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. + * + * @param N - number of columns in `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 - index offset for `A` + * @param k1 - index of first row to interchange + * @param k2 - index of last row to interchange + * @param inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order) + * @param IPIV - vector of pivot indices + * @param strideIPIV - `IPIV` stride length + * @param offsetIPIV - index offset for `IPIV` + * @returns permuted matrix `A` + * + * @example + * var Int32Array = require( '@stdlib/array/int32' ); + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var IPIV = new Int32Array( [ 2, 0, 1 ] ); + * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] + * + * slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); + * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] + */ + ndarray( N: number, A: Float32Array, strideA1: number, strideA2: number, offsetA: number, k1: number, k2: number, inck: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number ): Float32Array; +} + +/** +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. +* +* @param order - storage layout +* @param N - number of columns in `A` +* @param A - input matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param k1 - index of first row to interchange +* @param k2 - index of last row to interchange +* @param IPIV - vector of pivot indices +* @param incx - increment between successive values of `IPIV` +* @returns permuted matrix `A` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* slaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +*/ +declare var slaswp: Routine; + + +// EXPORTS // + +export = slaswp; diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/slaswp/docs/types/test.ts new file mode 100644 index 00000000000..53f380e09ef --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/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 slaswp = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp( 5, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( true, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( false, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( null, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( void 0, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( [], 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( {}, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( ( x: number ): number => x, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp( 'column-major', '5', A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', true, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', false, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', null, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', void 0, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', [], A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', {}, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', ( x: number ): number => x, A, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float32Array... +{ + const IPIV = new Int32Array( 3 ); + + slaswp( 'column-major', 3, '5', 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, 5, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, true, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, false, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, null, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, void 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, [], 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, {}, 2, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, ( x: number ): number => x, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp( 'column-major', 3, A, '5', 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, true, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, false, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, null, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, void 0, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, [], 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, {}, 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, ( x: number ): number => x, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp( 'column-major', 3, A, 2, '5', 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, true, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, false, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, null, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, void 0, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, [], 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, {}, 2, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, ( x: number ): number => x, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp( 'column-major', 3, A, 2, 0, '5', IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, true, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, false, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, null, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, void 0, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, [], IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, {}, IPIV, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, ( x: number ): number => x, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not an Int32Array... +{ + const A = new Float32Array( 6 ); + + slaswp( 'column-major', 3, A, 2, 0, 2, '5', 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, 5, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, true, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, false, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, null, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, void 0, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, [], 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, {}, 1 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, '5' ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, true ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, false ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, null ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, void 0 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, [] ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, {} ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp(); // $ExpectError + slaswp( 'column-major' ); // $ExpectError + slaswp( 'column-major', 3 ); // $ExpectError + slaswp( 'column-major', 3, A ); // $ExpectError + slaswp( 'column-major', 3, A, 2 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2 ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV ); // $ExpectError + slaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( '5', A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( true, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( false, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( null, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( void 0, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( [], A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( {}, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( ( x: number ): number => x, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a Float32Array... +{ + const IPIV = new Int32Array( 3 ); + + slaswp.ndarray( 2, '5', 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, 5, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, true, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, false, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, null, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, void 0, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, [], 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, {}, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, ( x: number ): number => x, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, '5', 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, true, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, false, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, null, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, void 0, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, [], 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, {}, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, ( x: number ): number => x, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, 2, '5', 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, true, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, false, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, null, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, void 0, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, [], 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, {}, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, ( x: number ): number => x, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, 2, 1, '5', 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, true, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, false, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, null, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, void 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, [], 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, {}, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, ( x: number ): number => x, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, 2, 1, 0, '5', 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, true, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, false, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, null, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, void 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, [], 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, {}, 2, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, ( x: number ): number => x, 2, 1, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, 2, 1, 0, 0, '5', 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, true, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, false, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, null, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, void 0, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, [], 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, {}, 1, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, ( x: number ): number => x, 1, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, '5', IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, true, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, false, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, null, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, void 0, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, [], IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, {}, IPIV, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, ( x: number ): number => x, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not an Int32Array... +{ + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, '5', 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, 5, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, true, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, false, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, null, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, void 0, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, [], 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, {}, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, ( 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 IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, '5', 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, true, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, false, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, null, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, void 0, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, [], 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, {}, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, ( 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 IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, '5' ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, true ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, false ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, null ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, void 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, [] ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, {} ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float32Array( 6 ); + + slaswp.ndarray(); // $ExpectError + slaswp.ndarray( 2 ); // $ExpectError + slaswp.ndarray( 2, A ); // $ExpectError + slaswp.ndarray( 2, A, 2 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1 ); // $ExpectError + slaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/examples/index.js b/lib/node_modules/@stdlib/lapack/base/slaswp/examples/index.js new file mode 100644 index 00000000000..ee22b93a918 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/examples/index.js @@ -0,0 +1,41 @@ +/** +* @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 Float32Array = require( '@stdlib/array/float32' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var slaswp = require( './../lib' ); + +// Specify matrix meta data: +var shape = [ 4, 2 ]; +var strides = [ 1, 4 ]; +var offset = 0; +var order = 'column-major'; + +// Create a matrix stored in linear memory: +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +// Define a vector of pivot indices: +var IPIV = new Int32Array( [ 2, 0, 3, 1 ] ); + +// Interchange rows: +slaswp( order, shape[ 1 ], A, strides[ 1 ], 0, shape[ 0 ]-1, IPIV, 1 ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/slaswp/lib/base.js new file mode 100644 index 00000000000..f0f9d4f7c97 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/lib/base.js @@ -0,0 +1,140 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var sswap = require( '@stdlib/blas/base/sswap' ).ndarray; + + +// VARIABLES // + +var BLOCK_SIZE = 32; + + +// MAIN // + +/** +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. +* +* @private +* @param {PositiveInteger} N - number of columns in `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 {NonNegativeInteger} offsetA - index offset for `A` +* @param {NonNegativeInteger} k1 - index of first row to interchange +* @param {NonNegativeInteger} k2 - index of last row to interchange +* @param {integer} inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order) +* @param {Int32Array} IPIV - vector of pivot indices +* @param {integer} strideIPIV - `IPIV` stride length +* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV` +* @returns {Float32Array} permuted matrix `A` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* slaswp( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +*/ +function slaswp( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params + var nrows; + var n32; + var tmp; + var row; + var ia1; + var ia2; + var ip; + var i; + var j; + var k; + var n; + var o; + + // Compute the number of rows to be interchanged: + if ( inck > 0 ) { + nrows = k2 - k1; + } else { + nrows = k1 - k2; + } + nrows += 1; + + // If the order is row-major, we can delegate to the Level 1 routine `sswap` for interchanging rows... + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + ip = offsetIPIV; + for ( i = 0, k = k1; i < nrows; i++, k += inck ) { + row = IPIV[ ip ]; + if ( row !== k ) { + sswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); // eslint-disable-line max-len + } + ip += strideIPIV; + } + return A; + } + // If the order is column-major, we need to use loop tiling to ensure efficient cache access when accessing matrix elements... + n32 = floor( N/BLOCK_SIZE ) * BLOCK_SIZE; + if ( n32 !== 0 ) { + for ( j = 0; j < n32; j += BLOCK_SIZE ) { + ip = offsetIPIV; + for ( i = 0, k = k1; i < nrows; i++, k += inck ) { + row = IPIV[ ip ]; + if ( row !== k ) { + ia1 = offsetA + ( k*strideA1 ); + ia2 = offsetA + ( row*strideA1 ); + for ( n = j; n < j+BLOCK_SIZE; n++ ) { + o = n * strideA2; + tmp = A[ ia1+o ]; + A[ ia1+o ] = A[ ia2+o ]; + A[ ia2+o ] = tmp; + } + } + ip += strideIPIV; + } + } + } + if ( n32 !== N ) { + ip = offsetIPIV; + for ( i = 0, k = k1; i < nrows; i++, k += inck ) { + row = IPIV[ ip ]; + if ( row !== k ) { + ia1 = offsetA + ( k*strideA1 ); + ia2 = offsetA + ( row*strideA1 ); + for ( n = n32; n < N; n++ ) { + o = n * strideA2; + tmp = A[ ia1+o ]; + A[ ia1+o ] = A[ ia2+o ]; + A[ ia2+o ] = tmp; + } + } + ip += strideIPIV; + } + } + return A; +} + + +// EXPORTS // + +module.exports = slaswp; diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/lib/index.js b/lib/node_modules/@stdlib/lapack/base/slaswp/lib/index.js new file mode 100644 index 00000000000..14042d15ee6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/lib/index.js @@ -0,0 +1,59 @@ +/** +* @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 perform a series of row interchanges on an input matrix. +* +* @module @stdlib/lapack/base/slaswp +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float32Array = require( '@stdlib/array/float32' ); +* var slaswp = require( '@stdlib/lapack/base/slaswp' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* slaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.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 slaswp; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + slaswp = main; +} else { + slaswp = tmp; +} + + +// EXPORTS // + +module.exports = slaswp; diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/lib/main.js b/lib/node_modules/@stdlib/lapack/base/slaswp/lib/main.js new file mode 100644 index 00000000000..b3d7706d202 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/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 slaswp = require( './slaswp.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( slaswp, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = slaswp; diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/slaswp/lib/ndarray.js new file mode 100644 index 00000000000..aede91e3716 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/lib/ndarray.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. +* +* @param {PositiveInteger} N - number of columns in `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 {NonNegativeInteger} offsetA - index offset for `A` +* @param {NonNegativeInteger} k1 - index of first row to interchange +* @param {NonNegativeInteger} k2 - index of last row to interchange +* @param {integer} inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order) +* @param {Int32Array} IPIV - vector of pivot indices +* @param {integer} strideIPIV - `IPIV` stride length +* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV` +* @returns {Float32Array} permuted matrix `A` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* slaswp( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +*/ +function slaswp( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params + var tmp; + if ( inck < 0 ) { + offsetIPIV += k2 * strideIPIV; + strideIPIV *= -1; + tmp = k1; + k1 = k2; + k2 = tmp; + inck = -1; + } else { + offsetIPIV += k1 * strideIPIV; + inck = 1; + } + return base( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = slaswp; diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/lib/slaswp.js b/lib/node_modules/@stdlib/lapack/base/slaswp/lib/slaswp.js new file mode 100644 index 00000000000..936c151a468 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/lib/slaswp.js @@ -0,0 +1,93 @@ +/** +* @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 max = require( '@stdlib/math/base/special/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. +* +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of columns in `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 {NonNegativeInteger} k1 - index of first row to interchange +* @param {NonNegativeInteger} k2 - index of last row to interchange +* @param {Int32Array} IPIV - vector of pivot indices +* @param {integer} incx - increment between successive values of `IPIV` +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} fourth argument must be greater than or equal to max(1,N) +* @returns {Float32Array} permuted matrix `A` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] +* +* slaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +*/ +function slaswp( order, N, A, LDA, k1, k2, IPIV, incx ) { + var tmp; + var inc; + var sa1; + var sa2; + var io; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( order === 'row-major' && LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + if ( incx > 0 ) { + inc = 1; + io = k1; + } else if ( incx < 0 ) { + inc = -1; + io = k1 + ( (k1-k2) * incx ); + tmp = k1; + k1 = k2; + k2 = tmp; + } else { + return A; + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( N, A, sa1, sa2, 0, k1, k2, inc, IPIV, incx, io ); +} + + +// EXPORTS // + +module.exports = slaswp; diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/package.json b/lib/node_modules/@stdlib/lapack/base/slaswp/package.json new file mode 100644 index 00000000000..70e530fba54 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/lapack/base/slaswp", + "version": "0.0.0", + "description": "Perform a series of row interchanges on an input matrix.", + "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", + "slaswp", + "interchange", + "swap", + "exchange", + "permute", + "permutedims", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float32", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_a_offset.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_a_offset.json new file mode 100644 index 00000000000..558c869d31e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_a_offset.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 2, + "A": [ 9999.0, 9999.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 9999.0, 9999.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 9999.0, 9999.0, 2.0, 1.0, 3.0, 5.0, 4.0, 6.0, 9999.0, 9999.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_a_strides.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_a_strides.json new file mode 100644 index 00000000000..2d1b409aebb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_a_strides.json @@ -0,0 +1,86 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": null, + "strideA1": 2, + "strideA2": 12, + "offsetA": 0, + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 4.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ + 2.0, + 9999.0, + 1.0, + 9999.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 5.0, + 9999.0, + 4.0, + 9999.0, + 6.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_complex_access_patterns.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_complex_access_patterns.json new file mode 100644 index 00000000000..715144fca75 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_complex_access_patterns.json @@ -0,0 +1,90 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": null, + "strideA1": -2, + "strideA2": 12, + "offsetA": 6, + "A": [ + 9999.0, + 9999.0, + 3.0, + 9999.0, + 2.0, + 9999.0, + 1.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 6.0, + 9999.0, + 5.0, + 9999.0, + 4.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 9999, 9999, 1, 9999, 0, 9999, 2, 9999, 9999 ], + "strideIPIV": -2, + "offsetIPIV": 6, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ + 9999.0, + 9999.0, + 3.0, + 9999.0, + 1.0, + 9999.0, + 2.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 6.0, + 9999.0, + 4.0, + 9999.0, + 5.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_ipiv_offset.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_ipiv_offset.json new file mode 100644 index 00000000000..d70d93b645c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_ipiv_offset.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 3, 4, 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 2, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_ipiv_stride_negative.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_ipiv_stride_negative.json new file mode 100644 index 00000000000..71ed2226640 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_ipiv_stride_negative.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 2, 999, 0, 999, 1, 999 ], + "strideIPIV": -2, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_ipiv_stride_positive.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_ipiv_stride_positive.json new file mode 100644 index 00000000000..272dd22d894 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_ipiv_stride_positive.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 999, 0, 999, 1, 999 ], + "strideIPIV": 2, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_k1.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_k1.json new file mode 100644 index 00000000000..5ebbd0dcb77 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_k1.json @@ -0,0 +1,42 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 7.0 ], + [ 2.0, 8.0 ], + [ 3.0, 9.0 ], + [ 4.0, 10.0 ], + [ 5.0, 11.0 ], + [ 6.0, 12.0 ] + ], + "N": 2, + "LDA": 6, + "strideA1": 1, + "strideA2": 6, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + + "k1": 3, + "k2": 5, + "incK": 1, + + "IPIV": [ 999, 999, 999, 2, 1, 0 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 3, 2 ], + [ 4, 1 ], + [ 5, 0 ] + ], + + "A_out_mat": [ + [ 6.0, 12.0 ], + [ 5.0, 11.0 ], + [ 4.0, 10.0 ], + [ 3.0, 9.0 ], + [ 2.0, 8.0 ], + [ 1.0, 7.0 ] + ], + "A_out": [ 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_lda.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_lda.json new file mode 100644 index 00000000000..bb3a7530612 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_lda.json @@ -0,0 +1,86 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 12, + "strideA1": 1, + "strideA2": 12, + "offsetA": 0, + "A": [ + 1.0, + 2.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 4.0, + 5.0, + 6.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ + 2.0, + 1.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 5.0, + 4.0, + 6.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_no_offsets.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_no_offsets.json new file mode 100644 index 00000000000..0ac37c157e6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_no_offsets.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_reverse_pivots.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_reverse_pivots.json new file mode 100644 index 00000000000..ccf8f229a3a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_reverse_pivots.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_reverse_pivots_ipiv_offset.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_reverse_pivots_ipiv_offset.json new file mode 100644 index 00000000000..c291ba59da4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_reverse_pivots_ipiv_offset.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 3, 4, 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 2, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_reverse_pivots_ipiv_stride.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_reverse_pivots_ipiv_stride.json new file mode 100644 index 00000000000..0bba7a549c4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/column_major_reverse_pivots_ipiv_stride.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 1, 0, 2 ], + "strideIPIV": -1, + "offsetIPIV": 2, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_a_offset.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_a_offset.json new file mode 100644 index 00000000000..89b034f623d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_a_offset.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 2, + "strideA2": 1, + "offsetA": 2, + "A": [ 9999.0, 9999.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 9999.0, 9999.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 9999.0, 9999.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0, 9999.0, 9999.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_a_strides.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_a_strides.json new file mode 100644 index 00000000000..6c3e4456b5b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_a_strides.json @@ -0,0 +1,74 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": null, + "strideA1": 6, + "strideA2": 2, + "offsetA": 0, + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 9999.0, + 9999.0, + 3.0, + 9999.0, + 4.0, + 9999.0, + 9999.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ + 3.0, + 9999.0, + 4.0, + 9999.0, + 9999.0, + 9999.0, + 1.0, + 9999.0, + 2.0, + 9999.0, + 9999.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_complex_access_patterns.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_complex_access_patterns.json new file mode 100644 index 00000000000..f1e828d5905 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_complex_access_patterns.json @@ -0,0 +1,74 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": null, + "strideA1": 6, + "strideA2": -2, + "offsetA": 3, + "A": [ + 9999.0, + 2.0, + 9999.0, + 1.0, + 9999.0, + 9999.0, + 9999.0, + 4.0, + 9999.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 6.0, + 9999.0, + 5.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 9999, 1, 9999, 0, 9999, 2, 9999 ], + "strideIPIV": -2, + "offsetIPIV": 5, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ + 9999.0, + 4.0, + 9999.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 2.0, + 9999.0, + 1.0, + 9999.0, + 9999.0, + 9999.0, + 6.0, + 9999.0, + 5.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_ipiv_offset.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_ipiv_offset.json new file mode 100644 index 00000000000..3df42215585 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_ipiv_offset.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 3, 4, 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 2, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_ipiv_stride_negative.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_ipiv_stride_negative.json new file mode 100644 index 00000000000..468991b43e7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_ipiv_stride_negative.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ], + [ 7.0, 8.0, 9.0 ] + ], + "N": 3, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 2, 9999, 0, 9999, 1, 9999 ], + "strideIPIV": -2, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 4.0, 5.0, 6.0 ], + [ 1.0, 2.0, 3.0 ], + [ 7.0, 8.0, 9.0 ] + ], + "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_ipiv_stride_positive.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_ipiv_stride_positive.json new file mode 100644 index 00000000000..1e4f74382c6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_ipiv_stride_positive.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ], + [ 7.0, 8.0, 9.0 ] + ], + "N": 3, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 9999, 0, 9999, 1, 9999 ], + "strideIPIV": 2, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 4.0, 5.0, 6.0 ], + [ 1.0, 2.0, 3.0 ], + [ 7.0, 8.0, 9.0 ] + ], + "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_k1.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_k1.json new file mode 100644 index 00000000000..c9af6921d63 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_k1.json @@ -0,0 +1,42 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ], + [ 9.0, 10.0 ], + [ 11.0, 12.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + + "k1": 3, + "k2": 5, + "incK": 1, + + "IPIV": [ 999, 999, 999, 2, 1, 0 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 3, 2 ], + [ 4, 1 ], + [ 5, 0 ] + ], + + "A_out_mat": [ + [ 11.0, 12.0 ], + [ 9.0, 10.0 ], + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ], + "A_out": [ 11.0, 12.0, 9.0, 10.0, 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_lda.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_lda.json new file mode 100644 index 00000000000..5b5bd174764 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_lda.json @@ -0,0 +1,62 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 0, + "A": [ + 1.0, + 2.0, + 9999.0, + 9999.0, + 3.0, + 4.0, + 9999.0, + 9999.0, + 5.0, + 6.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ + 3.0, + 4.0, + 9999.0, + 9999.0, + 1.0, + 2.0, + 9999.0, + 9999.0, + 5.0, + 6.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_no_offsets.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_no_offsets.json new file mode 100644 index 00000000000..4969a8828be --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_no_offsets.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_reverse_pivots.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_reverse_pivots.json new file mode 100644 index 00000000000..e5c56ff4872 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_reverse_pivots.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_reverse_pivots_ipiv_offset.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_reverse_pivots_ipiv_offset.json new file mode 100644 index 00000000000..b588ff9d00d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_reverse_pivots_ipiv_offset.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 3, 4, 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 2, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_reverse_pivots_ipiv_stride.json b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_reverse_pivots_ipiv_stride.json new file mode 100644 index 00000000000..74b8e66dd1d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/fixtures/row_major_reverse_pivots_ipiv_stride.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 1, 0, 2 ], + "strideIPIV": -1, + "offsetIPIV": 2, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/test.js b/lib/node_modules/@stdlib/lapack/base/slaswp/test/test.js new file mode 100644 index 00000000000..f74473ccd3a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/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 slaswp = 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 slaswp, '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 slaswp.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 slaswp = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( slaswp, 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 slaswp; + var main; + + main = require( './../lib/slaswp.js' ); + + slaswp = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( slaswp, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/slaswp/test/test.ndarray.js new file mode 100644 index 00000000000..f257d53b99b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/test.ndarray.js @@ -0,0 +1,577 @@ +/** +* @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 Int32Array = require( '@stdlib/array/int32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var oneTo = require( '@stdlib/array/one-to' ); +var flatten = require( '@stdlib/array/base/flatten' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var slaswp = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var COL_MAJOR = require( './fixtures/column_major_no_offsets.json' ); +var COL_MAJOR_IPIV_STRIDE_POS = require( './fixtures/column_major_ipiv_stride_positive.json' ); +var COL_MAJOR_IPIV_OFFSET = require( './fixtures/column_major_ipiv_offset.json' ); +var COL_MAJOR_A_STRIDES = require( './fixtures/column_major_a_strides.json' ); +var COL_MAJOR_A_OFFSET = require( './fixtures/column_major_a_offset.json' ); +var COL_MAJOR_CMPLX_ACCESS = require( './fixtures/column_major_complex_access_patterns.json' ); +var COL_MAJOR_REV_PIVOTS = require( './fixtures/column_major_reverse_pivots.json' ); +var COL_MAJOR_REV_PIVOTS_IPIV_STRIDE = require( './fixtures/column_major_reverse_pivots_ipiv_stride.json' ); // eslint-disable-line id-length +var COL_MAJOR_REV_PIVOTS_IPIV_OFFSET = require( './fixtures/column_major_reverse_pivots_ipiv_offset.json' ); // eslint-disable-line id-length +var COL_MAJOR_K1 = require( './fixtures/column_major_k1.json' ); + +var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); +var ROW_MAJOR_IPIV_STRIDE_POS = require( './fixtures/row_major_ipiv_stride_positive.json' ); +var ROW_MAJOR_IPIV_OFFSET = require( './fixtures/row_major_ipiv_offset.json' ); +var ROW_MAJOR_A_STRIDES = require( './fixtures/row_major_a_strides.json' ); +var ROW_MAJOR_A_OFFSET = require( './fixtures/row_major_a_offset.json' ); +var ROW_MAJOR_CMPLX_ACCESS = require( './fixtures/row_major_complex_access_patterns.json' ); +var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); +var ROW_MAJOR_REV_PIVOTS_IPIV_STRIDE = require( './fixtures/row_major_reverse_pivots_ipiv_stride.json' ); // eslint-disable-line id-length +var ROW_MAJOR_REV_PIVOTS_IPIV_OFFSET = require( './fixtures/row_major_reverse_pivots_ipiv_offset.json' ); // eslint-disable-line id-length +var ROW_MAJOR_K1 = require( './fixtures/row_major_k1.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof slaswp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( slaswp.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs a series of row interchanges (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges (column-major, k1 > 0)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_K1; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports applying pivots in reverse order (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_REV_PIVOTS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `IPIV` stride (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_IPIV_STRIDE_POS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `IPIV` stride (reverse pivots, column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_REV_PIVOTS_IPIV_STRIDE; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `IPIV` offset (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_IPIV_OFFSET; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `IPIV` offset (reverse pivots, column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_REV_PIVOTS_IPIV_OFFSET; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports `A` strides (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_A_STRIDES; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `A` offset (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_A_OFFSET; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_CMPLX_ACCESS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function efficiently handles large datasets (column-major)', function test( t ) { + var expected; + var IPIV; + var buf; + var mat; + var out; + var ord; + var sh; + var st; + var A; + var o; + + ord = 'column-major'; + sh = [ 5, 100 ]; + st = shape2strides( sh, ord ); + o = 0; + + // Define a linear buffer: + buf = oneTo( numel( sh ), 'generic' ); + + // Convert to a nested array: + mat = ndarray2array( buf, sh, st, o, ord ); + + // Define an input matrix in linear storage: + A = new Float32Array( buf ); + + // Create an array of pivot indices: + IPIV = new Int32Array( [ 9999, 9999, 9999, 1, 0 ] ); + + // Define the expected output array: + expected = reverse( mat.slice() ); + expected = new Float32Array( flatten( expected, sh, true ) ); + + // Interchange rows: + out = slaswp( sh[1], A, st[0], st[1], o, 3, 4, 1, IPIV, 1, 0 ); + + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges (row-major, k1 > 0)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_K1; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports applying pivots in reverse order (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_REV_PIVOTS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `IPIV` stride (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_IPIV_STRIDE_POS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `IPIV` stride (reverse pivots, row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_REV_PIVOTS_IPIV_STRIDE; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `IPIV` offset (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_IPIV_OFFSET; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `IPIV` offset (reverse pivots, row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_REV_PIVOTS_IPIV_OFFSET; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports `A` strides (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_A_STRIDES; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `A` offset (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_A_OFFSET; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_CMPLX_ACCESS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function efficiently handles large datasets (row-major)', function test( t ) { + var expected; + var IPIV; + var buf; + var mat; + var out; + var ord; + var sh; + var st; + var A; + var o; + + ord = 'row-major'; + sh = [ 5, 100 ]; + st = shape2strides( sh, ord ); + o = 0; + + // Define a linear buffer: + buf = oneTo( numel( sh ), 'generic' ); + + // Convert to a nested array: + mat = ndarray2array( buf, sh, st, o, ord ); + + // Define an input matrix in linear storage: + A = new Float32Array( buf ); + + // Create an array of pivot indices: + IPIV = new Int32Array( [ 9999, 9999, 9999, 1, 0 ] ); + + // Define the expected output array: + expected = reverse( mat.slice() ); + expected = new Float32Array( flatten( expected, sh, false ) ); + + // Interchange rows: + out = slaswp( sh[1], A, st[0], st[1], o, 3, 4, 1, IPIV, 1, 0 ); + + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/slaswp/test/test.slaswp.js b/lib/node_modules/@stdlib/lapack/base/slaswp/test/test.slaswp.js new file mode 100644 index 00000000000..047218f4bfb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/slaswp/test/test.slaswp.js @@ -0,0 +1,502 @@ +/** +* @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 Int32Array = require( '@stdlib/array/int32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var oneTo = require( '@stdlib/array/one-to' ); +var flatten = require( '@stdlib/array/base/flatten' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var slaswp = require( './../lib/slaswp.js' ); + + +// FIXTURES // + +var COL_MAJOR = require( './fixtures/column_major_no_offsets.json' ); +var COL_MAJOR_IPIV_STRIDE_POS = require( './fixtures/column_major_ipiv_stride_positive.json' ); +var COL_MAJOR_IPIV_STRIDE_NEG = require( './fixtures/column_major_ipiv_stride_negative.json' ); +var COL_MAJOR_LDA = require( './fixtures/column_major_lda.json' ); +var COL_MAJOR_REV_PIVOTS = require( './fixtures/column_major_reverse_pivots.json' ); +var COL_MAJOR_K1 = require( './fixtures/column_major_k1.json' ); + +var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); +var ROW_MAJOR_IPIV_STRIDE_POS = require( './fixtures/row_major_ipiv_stride_positive.json' ); +var ROW_MAJOR_IPIV_STRIDE_NEG = require( './fixtures/row_major_ipiv_stride_negative.json' ); +var ROW_MAJOR_LDA = require( './fixtures/row_major_lda.json' ); +var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); +var ROW_MAJOR_K1 = require( './fixtures/row_major_k1.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof slaswp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( slaswp.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { + var values; + var data; + var i; + + data = COL_MAJOR; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + 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() { + slaswp( value, data.N, data.A, data.LDA, data.k1, data.k2, data.IPIV, data.strideIPIV ); + }; + } +}); + +tape( 'the function throws an error if provided a fourth argument which is not a valid `LDA` value (row-major)', function test( t ) { + var values; + var data; + var i; + + data = ROW_MAJOR; + + values = [ + 0, + 1 + ]; + + 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() { + slaswp( data.order, data.N, data.A, value, data.k1, data.k2, data.IPIV, data.strideIPIV ); + }; + } +}); + +tape( 'the function performs a series of row interchanges (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges (column-major, k1 > 0)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_K1; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports applying pivots in reverse order (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_REV_PIVOTS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `LDA` parameter for operating on sub-matrices (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_LDA; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a positive increment between successive values of `IPIV` (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_IPIV_STRIDE_POS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative increment between successive values of `IPIV` (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_IPIV_STRIDE_NEG; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an increment between successive values of `IPIV` equal to `0`, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, 0 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function efficiently handles large datasets (column-major)', function test( t ) { + var expected; + var IPIV; + var buf; + var mat; + var out; + var ord; + var sh; + var st; + var A; + var o; + + ord = 'column-major'; + sh = [ 5, 100 ]; + st = shape2strides( sh, ord ); + o = 0; + + // Define a linear buffer: + buf = oneTo( numel( sh ), 'generic' ); + + // Convert to a nested array: + mat = ndarray2array( buf, sh, st, o, ord ); + + // Define an input matrix in linear storage: + A = new Float32Array( buf ); + + // Create an array of pivot indices: + IPIV = new Int32Array( [ 9999, 9999, 9999, 1, 0 ] ); + + // Define the expected output array: + expected = reverse( mat.slice() ); + expected = new Float32Array( flatten( expected, sh, true ) ); + + // Interchange rows: + out = slaswp( ord, sh[1], A, sh[0], 3, 4, IPIV, 1 ); + + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges (row-major, k1 > 0)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_K1; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports applying pivots in reverse order (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_REV_PIVOTS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `LDA` parameter for operating on sub-matrices (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_LDA; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a positive increment between successive values of `IPIV` (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_IPIV_STRIDE_POS; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative increment between successive values of `IPIV` (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_IPIV_STRIDE_NEG; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A_out ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an increment between successive values of `IPIV` equal to `0`, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR; + + A = new Float32Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float32Array( data.A ); + + out = slaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, 0 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function efficiently handles large datasets (row-major)', function test( t ) { + var expected; + var IPIV; + var buf; + var mat; + var out; + var ord; + var sh; + var st; + var A; + var o; + + ord = 'row-major'; + sh = [ 5, 100 ]; + st = shape2strides( sh, ord ); + o = 0; + + // Define a linear buffer: + buf = oneTo( numel( sh ), 'generic' ); + + // Convert to a nested array: + mat = ndarray2array( buf, sh, st, o, ord ); + + // Define an input matrix in linear storage: + A = new Float32Array( buf ); + + // Create an array of pivot indices: + IPIV = new Int32Array( [ 9999, 9999, 9999, 1, 0 ] ); + + // Define the expected output array: + expected = reverse( mat.slice() ); + expected = new Float32Array( flatten( expected, sh, false ) ); + + // Interchange rows: + out = slaswp( ord, sh[1], A, sh[1], 3, 4, IPIV, 1 ); + + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +});