From a20a5437b930725cc76e28e664551b762f649726 Mon Sep 17 00:00:00 2001 From: iampratik13 Date: Sat, 30 May 2026 13:50:10 +0530 Subject: [PATCH] feat: add lapack/base/dlapmr --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/lapack/base/dlapmr/README.md | 264 ++++++++++ .../lapack/base/dlapmr/benchmark/benchmark.js | 123 +++++ .../dlapmr/benchmark/benchmark.ndarray.js | 134 +++++ .../@stdlib/lapack/base/dlapmr/docs/repl.txt | 117 +++++ .../lapack/base/dlapmr/docs/types/index.d.ts | 120 +++++ .../lapack/base/dlapmr/docs/types/test.ts | 190 +++++++ .../lapack/base/dlapmr/examples/index.js | 43 ++ .../@stdlib/lapack/base/dlapmr/lib/base.js | 128 +++++ .../@stdlib/lapack/base/dlapmr/lib/dlapmr.js | 83 +++ .../@stdlib/lapack/base/dlapmr/lib/index.js | 72 +++ .../@stdlib/lapack/base/dlapmr/lib/main.js | 35 ++ .../@stdlib/lapack/base/dlapmr/lib/ndarray.js | 60 +++ .../@stdlib/lapack/base/dlapmr/package.json | 72 +++ .../test/fixtures/column_major_backward.json | 28 ++ .../test/fixtures/column_major_forward.json | 28 ++ .../large_strides/column_major_backward.json | 75 +++ .../large_strides/column_major_forward.json | 75 +++ .../large_strides/row_major_backward.json | 75 +++ .../row_major_backward_large.json | 117 +++++ .../large_strides/row_major_forward.json | 75 +++ .../row_major_forward_large.json | 117 +++++ .../mixed_strides/column_major_backward.json | 60 +++ .../mixed_strides/column_major_forward.json | 60 +++ .../mixed_strides/row_major_backward.json | 60 +++ .../row_major_backward_large.json | 89 ++++ .../mixed_strides/row_major_forward.json | 60 +++ .../row_major_forward_large.json | 89 ++++ .../column_major_backward.json | 60 +++ .../column_major_forward.json | 60 +++ .../negative_strides/row_major_backward.json | 60 +++ .../row_major_backward_large.json | 89 ++++ .../negative_strides/row_major_forward.json | 60 +++ .../row_major_forward_large.json | 89 ++++ .../offsets/column_major_backward.json | 63 +++ .../offsets/column_major_forward.json | 63 +++ .../fixtures/offsets/row_major_backward.json | 63 +++ .../offsets/row_major_backward_large.json | 92 ++++ .../fixtures/offsets/row_major_forward.json | 63 +++ .../offsets/row_major_forward_large.json | 92 ++++ .../test/fixtures/row_major_backward.json | 28 ++ .../fixtures/row_major_backward_large.json | 30 ++ .../test/fixtures/row_major_forward.json | 28 ++ .../fixtures/row_major_forward_large.json | 30 ++ .../lapack/base/dlapmr/test/test.dlapmr.js | 308 ++++++++++++ .../@stdlib/lapack/base/dlapmr/test/test.js | 92 ++++ .../lapack/base/dlapmr/test/test.ndarray.js | 474 ++++++++++++++++++ 46 files changed, 4293 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/lib/dlapmr.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/package.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/column_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/column_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/column_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/column_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_backward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_forward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/column_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/column_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_backward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_forward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/column_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/column_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_backward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_forward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/column_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/column_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_backward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_forward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_backward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_backward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_forward.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_forward_large.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.dlapmr.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/README.md b/lib/node_modules/@stdlib/lapack/base/dlapmr/README.md new file mode 100644 index 000000000000..82e3efaf1fca --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/README.md @@ -0,0 +1,264 @@ + + +# dlapmr + +> Rearrange the rows of a matrix as specified by a permutation vector. + +
+ +## Usage + +```javascript +var dlapmr = require( '@stdlib/lapack/base/dlapmr' ); +``` + +#### dlapmr( order, forwrd, M, N, X, LDX, K, strideK ) + +Rearranges the rows of an `M` by `N` matrix `X` as specified by a permutation vector `K`. + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var X = new Float64Array( [ 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 K = new Int32Array( [ 2, 0, 1 ] ); + +dlapmr( 'row-major', true, 3, 2, X, 2, K, 1 ); +// X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **forwrd**: boolean indicating whether to apply a forward or backward permutation. If `true`, forward permutation: `X(K(I),*)` is moved to `X(I,*)`. If `false`, backward permutation: `X(I,*)` is moved to `X(K(I),*)`. +- **M**: number of rows of `X`. +- **N**: number of columns of `X`. +- **X**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **LDX**: stride of the first dimension of `X` (a.k.a., leading dimension of the matrix `X`). +- **K**: permutation vector as an [`Int32Array`][mdn-int32array]. +- **strideK**: stride length of `K`. + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var X0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var K0 = new Int32Array( [ 0, 2, 0, 1 ] ); + +// Create offset views... +var X1 = new Float64Array( X0.buffer, X0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var K1 = new Int32Array( K0.buffer, K0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlapmr( 'row-major', true, 3, 2, X1, 2, K1, 1 ); +// X0 => [ 0.0, 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +``` + +#### dlapmr.ndarray( forwrd, M, N, X, sx1, sx2, ox, K, sk, ok ) + +Rearranges the rows of an `M` by `N` matrix `X` as specified by a permutation vector `K` using alternative indexing semantics. + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var X = new Float64Array( [ 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 K = new Int32Array( [ 2, 0, 1 ] ); + +dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, K, 1, 0 ); +// X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +``` + +The function has the following parameters: + +- **forwrd**: boolean indicating whether to apply a forward or backward permutation. +- **M**: number of rows of `X`. +- **N**: number of columns of `X`. +- **X**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **sx1**: stride of the first dimension of `X`. +- **sx2**: stride of the second dimension of `X`. +- **ox**: starting index for `X`. +- **K**: permutation vector as an [`Int32Array`][mdn-int32array]. +- **sk**: stride length of `K`. +- **ok**: starting index for `K`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var X = new Float64Array( [ 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var K = new Int32Array( [ 0, 0, 2, 0, 1 ] ); + +dlapmr.ndarray( true, 3, 2, X, 2, 1, 2, K, 1, 2 ); +// X => [ 0.0, 0.0, 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +``` + +
+ + + +
+ +## Notes + +- `dlapmr()` corresponds to the [LAPACK][LAPACK] function [`dlapmr`][lapack-dlapmr]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dlapmr = require( '@stdlib/lapack/base/dlapmr' ); + +// Specify matrix meta data: +var shape = [ 4, 2 ]; +var order = 'row-major'; +var strides = [ 2, 1 ]; +var offset = 0; + +// Create a matrix stored in linear memory: +var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +console.log( ndarray2array( X, shape, strides, offset, order ) ); + +// Define a permutation vector: +var K = new Int32Array( [ 1, 3, 0, 2 ] ); + +// Rearrange rows: +dlapmr( order, true, shape[ 0 ], shape[ 1 ], X, strides[ 0 ], K, 1 ); +console.log( ndarray2array( X, 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/dlapmr/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/benchmark/benchmark.js new file mode 100644 index 000000000000..a1dad2484234 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/benchmark/benchmark.js @@ -0,0 +1,123 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Int32Array = require( '@stdlib/array/int32' ); +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dlapmr = require( './../lib/dlapmr.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 +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var K; + var X; + var i; + + // Create an identity permutation to avoid corrupting data across iterations: + K = new Int32Array( N ); + for ( i = 0; i < N; i++ ) { + K[ i ] = i; + } + X = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + 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 = dlapmr( order, true, N, N, X, N, K, 1 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + 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 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..0c1e421556e0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/benchmark/benchmark.ndarray.js @@ -0,0 +1,134 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Int32Array = require( '@stdlib/array/int32' ); +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var dlapmr = 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 +* @returns {Function} benchmark function +*/ +function createBenchmark( order, N ) { + var sx1; + var sx2; + var K; + var X; + var i; + + if ( isColumnMajor( order ) ) { + sx1 = 1; + sx2 = N; + } else { // order === 'row-major' + sx1 = N; + sx2 = 1; + } + + // Create identity permutation to avoid corrupting data across iterations: + K = new Int32Array( N ); + for ( i = 0; i < N; i++ ) { + K[ i ] = i; + } + X = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); + 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 = dlapmr( true, N, N, X, sx1, sx2, 0, K, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var ord; + var N; + var f; + var i; + 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 ) ); + f = createBenchmark( ord, N ); + bench( format( '%s::square_matrix:ndarray:order=%s,size=%d', pkg, ord, N*N ), f ); + } + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlapmr/docs/repl.txt new file mode 100644 index 000000000000..fdc19c2d474d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/docs/repl.txt @@ -0,0 +1,117 @@ + +{{alias}}( order, forwrd, M, N, X, LDX, K, strideK ) + Rearranges the rows of an `M` by `N` matrix `X` as specified by a + permutation vector `K`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + The permutation vector `K` is modified during execution but restored to its + original state on exit. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + forwrd: boolean + Boolean indicating whether to apply a forward or backward permutation. + If true, rows are rearranged as X(K(I),*) -> X(I,*). If false, rows are + rearranged as X(I,*) -> X(K(I),*). + + M: integer + Number of rows in `X`. + + N: integer + Number of columns in `X`. + + X: Float64Array + Input matrix. + + LDX: integer + Stride of the first dimension of `X` (a.k.a., leading dimension of the + matrix `X`). + + K: Int32Array + Permutation vector. + + strideK: integer + Stride length of `K`. + + Returns + ------- + X: Float64Array + Mutated input matrix. + + Examples + -------- + > var K = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); + > var X = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}( 'row-major', true, 3, 2, X, 2, K, 1 ) + [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] + + // Using typed array views: + > var K0 = new {{alias:@stdlib/array/int32}}( [ 0, 2, 0, 1 ] ); + > var X0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > K = new Int32Array( K0.buffer, K0.BYTES_PER_ELEMENT*1 ); + > X = new Float64Array( X0.buffer, X0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 'row-major', true, 3, 2, X, 2, K, 1 ); + > X0 + [ 0.0, 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] + + +{{alias}}.ndarray( forwrd, M, N, X, sx1, sx2, ox, K, sk, ok ) + Rearranges the rows of an `M` by `N` matrix `X` as specified by a + permutation vector `K` using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + forwrd: boolean + Boolean indicating whether to apply a forward or backward permutation. + + M: integer + Number of rows in `X`. + + N: integer + Number of columns in `X`. + + X: Float64Array + Input matrix. + + sx1: integer + Stride of the first dimension of `X`. + + sx2: integer + Stride of the second dimension of `X`. + + ox: integer + Index offset for `X`. + + K: Int32Array + Permutation vector. + + sk: integer + Stride length of `K`. + + ok: integer + Index offset for `K`. + + Returns + ------- + X: Float64Array + Mutated input matrix. + + Examples + -------- + > var K = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); + > var X = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}.ndarray( true, 3, 2, X, 2, 1, 0, K, 1, 0 ) + [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlapmr/docs/types/index.d.ts new file mode 100644 index 000000000000..b15894cf1c27 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/docs/types/index.d.ts @@ -0,0 +1,120 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 `dlapmr`. +*/ +interface Routine { + /** + * Rearranges the rows of an `M` by `N` matrix `X` as specified by a permutation vector `K`. + * + * @param order - storage layout + * @param forwrd - boolean indicating whether to apply a forward permutation + * @param M - number of rows of `X` + * @param N - number of columns of `X` + * @param X - input matrix + * @param LDX - leading dimension of `X` + * @param K - permutation vector + * @param strideK - stride length of `K` + * @returns permuted matrix `X` + * + * @example + * var Int32Array = require( '@stdlib/array/int32' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var K = new Int32Array( [ 2, 0, 1 ] ); + * + * dlapmr( 'row-major', true, 3, 2, X, 2, K, 1 ); + * // X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] + */ + ( order: Layout, forwrd: boolean, M: number, N: number, X: Float64Array, LDX: number, K: Int32Array, strideK: number ): Float64Array; + + /** + * Rearranges the rows of an `M` by `N` matrix `X` as specified by a permutation vector `K` using alternative indexing semantics. + * + * @param forwrd - boolean indicating whether to apply a forward permutation + * @param M - number of rows of `X` + * @param N - number of columns of `X` + * @param X - input matrix + * @param strideX1 - stride of the first dimension of `X` + * @param strideX2 - stride of the second dimension of `X` + * @param offsetX - starting index for `X` + * @param K - permutation vector + * @param strideK - stride length of `K` + * @param offsetK - starting index for `K` + * @returns permuted matrix `X` + * + * @example + * var Int32Array = require( '@stdlib/array/int32' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var K = new Int32Array( [ 2, 0, 1 ] ); + * + * dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, K, 1, 0 ); + * // X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] + */ + ndarray( forwrd: boolean, M: number, N: number, X: Float64Array, strideX1: number, strideX2: number, offsetX: number, K: Int32Array, strideK: number, offsetK: number ): Float64Array; +} + +/** +* Rearranges the rows of an `M` by `N` matrix `X` as specified by a permutation vector `K`. +* +* @param order - storage layout +* @param forwrd - boolean indicating whether to apply a forward permutation +* @param M - number of rows of `X` +* @param N - number of columns of `X` +* @param X - input matrix +* @param LDX - leading dimension of `X` +* @param K - permutation vector +* @param strideK - stride length of `K` +* @returns permuted matrix `X` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var K = new Int32Array( [ 2, 0, 1 ] ); +* +* dlapmr( 'row-major', true, 3, 2, X, 2, K, 1 ); +* // X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var K = new Int32Array( [ 2, 0, 1 ] ); +* +* dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, K, 1, 0 ); +* // X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +*/ +declare var dlapmr: Routine; + + +// EXPORTS // + +export = dlapmr; diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlapmr/docs/types/test.ts new file mode 100644 index 000000000000..f1553167da95 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/docs/types/test.ts @@ -0,0 +1,190 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 dlapmr = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const X = new Float64Array( 6 ); + const K = new Int32Array( 3 ); + + dlapmr( 'row-major', true, 3, 2, X, 2, K, 1 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const X = new Float64Array( 6 ); + const K = new Int32Array( 3 ); + + dlapmr( 5, true, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( true, true, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( false, true, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( null, true, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( void 0, true, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( [], true, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( {}, true, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( ( x: number ): number => x, true, 3, 2, X, 2, K, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a boolean... +{ + const X = new Float64Array( 6 ); + const K = new Int32Array( 3 ); + + dlapmr( 'row-major', '5', 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', 5, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', null, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', void 0, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', [], 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', {}, 3, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', ( x: number ): number => x, 3, 2, X, 2, K, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const X = new Float64Array( 6 ); + const K = new Int32Array( 3 ); + + dlapmr( 'row-major', true, '5', 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, true, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, false, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, null, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, void 0, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, [], 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, {}, 2, X, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, ( x: number ): number => x, 2, X, 2, K, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const K = new Int32Array( 3 ); + + dlapmr( 'row-major', true, 3, 2, '5', 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, 5, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, true, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, false, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, null, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, void 0, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, [], 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, {}, 2, K, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, ( x: number ): number => x, 2, K, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not an Int32Array... +{ + const X = new Float64Array( 6 ); + + dlapmr( 'row-major', true, 3, 2, X, 2, '5', 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, 5, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, true, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, false, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, null, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, void 0, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, [], 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, {}, 1 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const X = new Float64Array( 6 ); + const K = new Int32Array( 3 ); + + dlapmr(); // $ExpectError + dlapmr( 'row-major' ); // $ExpectError + dlapmr( 'row-major', true ); // $ExpectError + dlapmr( 'row-major', true, 3 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2 ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, K ); // $ExpectError + dlapmr( 'row-major', true, 3, 2, X, 2, K, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const X = new Float64Array( 6 ); + const K = new Int32Array( 3 ); + + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, K, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a boolean... +{ + const X = new Float64Array( 6 ); + const K = new Int32Array( 3 ); + + dlapmr.ndarray( '5', 3, 2, X, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( 5, 3, 2, X, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( null, 3, 2, X, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( void 0, 3, 2, X, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( [], 3, 2, X, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( {}, 3, 2, X, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( ( x: number ): number => x, 3, 2, X, 2, 1, 0, K, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a Float64Array... +{ + const K = new Int32Array( 3 ); + + dlapmr.ndarray( true, 3, 2, '5', 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, 5, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, true, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, false, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, null, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, void 0, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, [], 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, {}, 2, 1, 0, K, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, ( x: number ): number => x, 2, 1, 0, K, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not an Int32Array... +{ + const X = new Float64Array( 6 ); + + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, '5', 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, 5, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, true, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, false, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, null, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, void 0, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, [], 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, {}, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const X = new Float64Array( 6 ); + const K = new Int32Array( 3 ); + + dlapmr.ndarray(); // $ExpectError + dlapmr.ndarray( true ); // $ExpectError + dlapmr.ndarray( true, 3 ); // $ExpectError + dlapmr.ndarray( true, 3, 2 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, K ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, K, 1 ); // $ExpectError + dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, K, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/examples/index.js new file mode 100644 index 000000000000..c3f8f396a9e8 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var dlapmr = require( './../lib' ); + +// Specify matrix meta data: +var shape = [ 4, 2 ]; +var strides = [ 2, 1 ]; +var offset = 0; +var order = 'row-major'; + +// Create a matrix stored in linear memory: +var X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +console.log( ndarray2array( X, shape, strides, offset, order ) ); +// => [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ], [ 7.0, 8.0 ] ] + +// Define a permutation vector: +var K = new Int32Array( [ 1, 3, 0, 2 ] ); + +// Rearrange rows (forward permutation): +dlapmr( order, true, shape[ 0 ], shape[ 1 ], X, strides[ 0 ], K, 1 ); +console.log( ndarray2array( X, shape, strides, offset, order ) ); +// => [ [ 3.0, 4.0 ], [ 7.0, 8.0 ], [ 1.0, 2.0 ], [ 5.0, 6.0 ] ] diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/base.js new file mode 100644 index 000000000000..835095e9918f --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/base.js @@ -0,0 +1,128 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 dswap = require( '@stdlib/blas/base/dswap' ).ndarray; + + +// MAIN // + +/** +* Rearranges the rows of an `M` by `N` matrix `X` as specified by a permutation vector `K`. +* +* @private +* @param {boolean} forwrd - boolean indicating whether to apply a forward permutation +* @param {NonNegativeInteger} M - number of rows of `X` +* @param {NonNegativeInteger} N - number of columns of `X` +* @param {Float64Array} X - input matrix +* @param {integer} strideX1 - stride of the first dimension of `X` +* @param {integer} strideX2 - stride of the second dimension of `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Int32Array} K - permutation vector +* @param {integer} strideK - stride length of `K` +* @param {NonNegativeInteger} offsetK - starting index for `K` +* @returns {Float64Array} permuted matrix `X` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( [ 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 K = new Int32Array( [ 2, 0, 1 ] ); +* +* dlapmr( true, 3, 2, X, 2, 1, 0, K, 1, 0 ); +* // X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +*/ +function dlapmr( forwrd, M, N, X, strideX1, strideX2, offsetX, K, strideK, offsetK ) { + var temp; + var ik; + var ii; + var j; + var i; + + if ( M <= 1 ) { + return X; + } + // Negate all entries of K to mark them as unprocessed... + ik = offsetK; + for ( i = 0; i < M; i++ ) { + K[ ik ] = -K[ ik ] - 1; + ik += strideK; + } + if ( forwrd ) { + // Forward permutation... + for ( i = 0; i < M; i++ ) { + ik = offsetK + ( i * strideK ); + if ( K[ ik ] >= 0 ) { + continue; + } + j = i; + K[ ik ] = -K[ ik ] - 1; + ii = K[ ik ]; // `ii` is the source row index + + while ( true ) { + ik = offsetK + ( ii * strideK ); + if ( K[ ik ] >= 0 ) { + break; + } + // Swap row `j` and row `ii`... + dswap( N, X, strideX2, offsetX + ( j * strideX1 ), X, strideX2, offsetX + ( ii * strideX1 ) ); + + K[ ik ] = -K[ ik ] - 1; + temp = j; + j = ii; + ii = K[ ik ]; + + // Prevent infinite loop for identity permutations: + if ( ii === temp ) { + break; + } + } + } + } else { + // Backward permutation... + for ( i = 0; i < M; i++ ) { + ik = offsetK + ( i * strideK ); + if ( K[ ik ] >= 0 ) { + continue; + } + K[ ik ] = -K[ ik ] - 1; + j = K[ ik ]; + + while ( j !== i ) { + // Swap row `i` and row `j`... + dswap( N, X, strideX2, offsetX + ( i * strideX1 ), X, strideX2, offsetX + ( j * strideX1 ) ); + + ik = offsetK + ( j * strideK ); + K[ ik ] = -K[ ik ] - 1; + j = K[ ik ]; + } + } + } + return X; +} + + +// EXPORTS // + +module.exports = dlapmr; diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/dlapmr.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/dlapmr.js new file mode 100644 index 000000000000..3e7ba032ca9a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/dlapmr.js @@ -0,0 +1,83 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var max = require( '@stdlib/math/base/special/max' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Rearranges the rows of an `M` by `N` matrix `X` as specified by a permutation vector `K`. +* +* @param {string} order - storage layout +* @param {boolean} forwrd - boolean indicating whether to apply a forward permutation +* @param {NonNegativeInteger} M - number of rows of `X` +* @param {NonNegativeInteger} N - number of columns of `X` +* @param {Float64Array} X - input matrix +* @param {PositiveInteger} LDX - leading dimension of `X` +* @param {Int32Array} K - permutation vector +* @param {integer} strideK - stride length of `K` +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} sixth argument must be greater than or equal to max(1,N) +* @throws {RangeError} eighth argument must be a non-zero integer +* @returns {Float64Array} permuted matrix `X` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( [ 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 K = new Int32Array( [ 2, 0, 1 ] ); +* +* dlapmr( 'row-major', true, 3, 2, X, 2, K, 1 ); +* // X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +*/ +function dlapmr( order, forwrd, M, N, X, LDX, K, strideK ) { + var sx1; + var sx2; + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( isColumnMajor( order ) ) { + sx1 = 1; + sx2 = LDX; + } else { // order === 'row-major' + if ( LDX < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDX ) ); + } + sx1 = LDX; + sx2 = 1; + } + if ( strideK === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be a non-zero integer. Value: `%d`.', strideK ) ); + } + return base( forwrd, M, N, X, sx1, sx2, 0, K, strideK, 0 ); +} + + +// EXPORTS // + +module.exports = dlapmr; diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/index.js new file mode 100644 index 000000000000..60487f341c2d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/index.js @@ -0,0 +1,72 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 rearrange the rows of a matrix as specified by a permutation vector. +* +* @module @stdlib/lapack/base/dlapmr +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlapmr = require( '@stdlib/lapack/base/dlapmr' ); +* +* var X = new Float64Array( [ 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 K = new Int32Array( [ 2, 0, 1 ] ); +* +* dlapmr( 'row-major', true, 3, 2, X, 2, K, 1 ); +* // X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlapmr = require( '@stdlib/lapack/base/dlapmr' ); +* +* var X = new Float64Array( [ 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 K = new Int32Array( [ 2, 0, 1 ] ); +* +* dlapmr.ndarray( true, 3, 2, X, 2, 1, 0, K, 1, 0 ); +* // X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var dlapmr; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlapmr = main; +} else { + dlapmr = tmp; +} + + +// EXPORTS // + +module.exports = dlapmr; + +// exports: { "ndarray": "dlapmr.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/main.js new file mode 100644 index 000000000000..009c9555f652 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 dlapmr = require( './dlapmr.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlapmr, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlapmr; diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/ndarray.js new file mode 100644 index 000000000000..4f04f87a2a81 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/lib/ndarray.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 // + +/** +* Rearranges the rows of an `M` by `N` matrix `X` as specified by a permutation vector `K` using alternative indexing semantics. +* +* @param {boolean} forwrd - boolean indicating whether to apply a forward permutation +* @param {NonNegativeInteger} M - number of rows of `X` +* @param {NonNegativeInteger} N - number of columns of `X` +* @param {Float64Array} X - input matrix +* @param {integer} strideX1 - stride of the first dimension of `X` +* @param {integer} strideX2 - stride of the second dimension of `X` +* @param {NonNegativeInteger} offsetX - starting index for `X` +* @param {Int32Array} K - permutation vector +* @param {integer} strideK - stride length of `K` +* @param {NonNegativeInteger} offsetK - starting index for `K` +* @returns {Float64Array} permuted matrix `X` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var X = new Float64Array( [ 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 K = new Int32Array( [ 2, 0, 1 ] ); +* +* dlapmr( true, 3, 2, X, 2, 1, 0, K, 1, 0 ); +* // X => [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +*/ +function dlapmr( forwrd, M, N, X, strideX1, strideX2, offsetX, K, strideK, offsetK ) { // eslint-disable-line max-len + return base( forwrd, M, N, X, strideX1, strideX2, offsetX, K, strideK, offsetK ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dlapmr; diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/package.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/package.json new file mode 100644 index 000000000000..d57f1f6aff4e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/lapack/base/dlapmr", + "version": "0.0.0", + "description": "Rearrange the rows of a matrix as specified by a permutation vector.", + "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", + "dlapmr", + "permute", + "permutation", + "rearrange", + "rows", + "matrix", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/column_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/column_major_backward.json new file mode 100644 index 000000000000..23ddb41553f5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/column_major_backward.json @@ -0,0 +1,28 @@ +{ + "order": "column-major", + "forwrd": false, + + "M": 3, + "N": 2, + + "X_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "X": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "strideX1": 1, + "strideX2": 3, + "offsetX": 0, + + "K": [ 2, 0, 1 ], + "strideK": 1, + "offsetK": 0, + + "X_out_mat": [ + [ 2.0, 5.0 ], + [ 3.0, 6.0 ], + [ 1.0, 4.0 ] + ], + "X_out": [ 2.0, 3.0, 1.0, 5.0, 6.0, 4.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/column_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/column_major_forward.json new file mode 100644 index 000000000000..d8fe843d0a28 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/column_major_forward.json @@ -0,0 +1,28 @@ +{ + "order": "column-major", + "forwrd": true, + + "M": 3, + "N": 2, + + "X_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "X": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "strideX1": 1, + "strideX2": 3, + "offsetX": 0, + + "K": [ 2, 0, 1 ], + "strideK": 1, + "offsetK": 0, + + "X_out_mat": [ + [ 3.0, 6.0 ], + [ 1.0, 4.0 ], + [ 2.0, 5.0 ] + ], + "X_out": [ 3.0, 1.0, 2.0, 6.0, 4.0, 5.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/column_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/column_major_backward.json new file mode 100644 index 000000000000..b445339fb615 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/column_major_backward.json @@ -0,0 +1,75 @@ +{ + "order": "column-major", + "forwrd": false, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 4 + ], + [ + 2, + 5 + ], + [ + 3, + 6 + ] + ], + "X": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999 + ], + "strideX1": 2, + "strideX2": 6, + "offsetX": 0, + "K": [ + 2, + 9999, + 0, + 9999, + 1, + 9999 + ], + "strideK": 2, + "offsetK": 0, + "X_out_mat": [ + [ + 2, + 5 + ], + [ + 3, + 6 + ], + [ + 1, + 4 + ] + ], + "X_out": [ + 2, + 9999, + 3, + 9999, + 1, + 9999, + 5, + 9999, + 6, + 9999, + 4, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/column_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/column_major_forward.json new file mode 100644 index 000000000000..b089559b5843 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/column_major_forward.json @@ -0,0 +1,75 @@ +{ + "order": "column-major", + "forwrd": true, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 4 + ], + [ + 2, + 5 + ], + [ + 3, + 6 + ] + ], + "X": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999 + ], + "strideX1": 2, + "strideX2": 6, + "offsetX": 0, + "K": [ + 2, + 9999, + 0, + 9999, + 1, + 9999 + ], + "strideK": 2, + "offsetK": 0, + "X_out_mat": [ + [ + 3, + 6 + ], + [ + 1, + 4 + ], + [ + 2, + 5 + ] + ], + "X_out": [ + 3, + 9999, + 1, + 9999, + 2, + 9999, + 6, + 9999, + 4, + 9999, + 5, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_backward.json new file mode 100644 index 000000000000..35dc8444315d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_backward.json @@ -0,0 +1,75 @@ +{ + "order": "row-major", + "forwrd": false, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], + "X": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999 + ], + "strideX1": 4, + "strideX2": 2, + "offsetX": 0, + "K": [ + 2, + 9999, + 0, + 9999, + 1, + 9999 + ], + "strideK": 2, + "offsetK": 0, + "X_out_mat": [ + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ], + "X_out": [ + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999, + 1, + 9999, + 2, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_backward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_backward_large.json new file mode 100644 index 000000000000..5d9a1e0063f5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_backward_large.json @@ -0,0 +1,117 @@ +{ + "order": "row-major", + "forwrd": false, + "M": 4, + "N": 3, + "X_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ], + [ + 10, + 11, + 12 + ] + ], + "X": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999, + 7, + 9999, + 8, + 9999, + 9, + 9999, + 10, + 9999, + 11, + 9999, + 12, + 9999 + ], + "strideX1": 6, + "strideX2": 2, + "offsetX": 0, + "K": [ + 1, + 9999, + 3, + 9999, + 0, + 9999, + 2, + 9999 + ], + "strideK": 2, + "offsetK": 0, + "X_out_mat": [ + [ + 7, + 8, + 9 + ], + [ + 1, + 2, + 3 + ], + [ + 10, + 11, + 12 + ], + [ + 4, + 5, + 6 + ] + ], + "X_out": [ + 7, + 9999, + 8, + 9999, + 9, + 9999, + 1, + 9999, + 2, + 9999, + 3, + 9999, + 10, + 9999, + 11, + 9999, + 12, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_forward.json new file mode 100644 index 000000000000..9ce0471a4223 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_forward.json @@ -0,0 +1,75 @@ +{ + "order": "row-major", + "forwrd": true, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], + "X": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999 + ], + "strideX1": 4, + "strideX2": 2, + "offsetX": 0, + "K": [ + 2, + 9999, + 0, + 9999, + 1, + 9999 + ], + "strideK": 2, + "offsetK": 0, + "X_out_mat": [ + [ + 5, + 6 + ], + [ + 1, + 2 + ], + [ + 3, + 4 + ] + ], + "X_out": [ + 5, + 9999, + 6, + 9999, + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_forward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_forward_large.json new file mode 100644 index 000000000000..77f2f1b70d0c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/large_strides/row_major_forward_large.json @@ -0,0 +1,117 @@ +{ + "order": "row-major", + "forwrd": true, + "M": 4, + "N": 3, + "X_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ], + [ + 10, + 11, + 12 + ] + ], + "X": [ + 1, + 9999, + 2, + 9999, + 3, + 9999, + 4, + 9999, + 5, + 9999, + 6, + 9999, + 7, + 9999, + 8, + 9999, + 9, + 9999, + 10, + 9999, + 11, + 9999, + 12, + 9999 + ], + "strideX1": 6, + "strideX2": 2, + "offsetX": 0, + "K": [ + 1, + 9999, + 3, + 9999, + 0, + 9999, + 2, + 9999 + ], + "strideK": 2, + "offsetK": 0, + "X_out_mat": [ + [ + 4, + 5, + 6 + ], + [ + 10, + 11, + 12 + ], + [ + 1, + 2, + 3 + ], + [ + 7, + 8, + 9 + ] + ], + "X_out": [ + 4, + 9999, + 5, + 9999, + 6, + 9999, + 10, + 9999, + 11, + 9999, + 12, + 9999, + 1, + 9999, + 2, + 9999, + 3, + 9999, + 7, + 9999, + 8, + 9999, + 9, + 9999 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/column_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/column_major_backward.json new file mode 100644 index 000000000000..845838560302 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/column_major_backward.json @@ -0,0 +1,60 @@ +{ + "order": "column-major", + "forwrd": false, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 4 + ], + [ + 2, + 5 + ], + [ + 3, + 6 + ] + ], + "X": [ + 4, + 5, + 6, + 1, + 2, + 3 + ], + "strideX1": 1, + "strideX2": -3, + "offsetX": 3, + "K": [ + 2, + 0, + 1 + ], + "strideK": 1, + "offsetK": 0, + "X_out_mat": [ + [ + 2, + 5 + ], + [ + 3, + 6 + ], + [ + 1, + 4 + ] + ], + "X_out": [ + 5, + 6, + 4, + 2, + 3, + 1 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/column_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/column_major_forward.json new file mode 100644 index 000000000000..127452daa662 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/column_major_forward.json @@ -0,0 +1,60 @@ +{ + "order": "column-major", + "forwrd": true, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 4 + ], + [ + 2, + 5 + ], + [ + 3, + 6 + ] + ], + "X": [ + 4, + 5, + 6, + 1, + 2, + 3 + ], + "strideX1": 1, + "strideX2": -3, + "offsetX": 3, + "K": [ + 2, + 0, + 1 + ], + "strideK": 1, + "offsetK": 0, + "X_out_mat": [ + [ + 3, + 6 + ], + [ + 1, + 4 + ], + [ + 2, + 5 + ] + ], + "X_out": [ + 6, + 4, + 5, + 3, + 1, + 2 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_backward.json new file mode 100644 index 000000000000..f21ecd78e90a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_backward.json @@ -0,0 +1,60 @@ +{ + "order": "row-major", + "forwrd": false, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], + "X": [ + 5, + 6, + 3, + 4, + 1, + 2 + ], + "strideX1": -2, + "strideX2": 1, + "offsetX": 4, + "K": [ + 2, + 0, + 1 + ], + "strideK": 1, + "offsetK": 0, + "X_out_mat": [ + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ], + "X_out": [ + 1, + 2, + 5, + 6, + 3, + 4 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_backward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_backward_large.json new file mode 100644 index 000000000000..7f3620ce7c59 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_backward_large.json @@ -0,0 +1,89 @@ +{ + "order": "row-major", + "forwrd": false, + "M": 4, + "N": 3, + "X_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ], + [ + 10, + 11, + 12 + ] + ], + "X": [ + 10, + 11, + 12, + 7, + 8, + 9, + 4, + 5, + 6, + 1, + 2, + 3 + ], + "strideX1": -3, + "strideX2": 1, + "offsetX": 9, + "K": [ + 1, + 3, + 0, + 2 + ], + "strideK": 1, + "offsetK": 0, + "X_out_mat": [ + [ + 7, + 8, + 9 + ], + [ + 1, + 2, + 3 + ], + [ + 10, + 11, + 12 + ], + [ + 4, + 5, + 6 + ] + ], + "X_out": [ + 4, + 5, + 6, + 10, + 11, + 12, + 1, + 2, + 3, + 7, + 8, + 9 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_forward.json new file mode 100644 index 000000000000..5806865b29da --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_forward.json @@ -0,0 +1,60 @@ +{ + "order": "row-major", + "forwrd": true, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], + "X": [ + 5, + 6, + 3, + 4, + 1, + 2 + ], + "strideX1": -2, + "strideX2": 1, + "offsetX": 4, + "K": [ + 2, + 0, + 1 + ], + "strideK": 1, + "offsetK": 0, + "X_out_mat": [ + [ + 5, + 6 + ], + [ + 1, + 2 + ], + [ + 3, + 4 + ] + ], + "X_out": [ + 3, + 4, + 1, + 2, + 5, + 6 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_forward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_forward_large.json new file mode 100644 index 000000000000..1a0819559585 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/mixed_strides/row_major_forward_large.json @@ -0,0 +1,89 @@ +{ + "order": "row-major", + "forwrd": true, + "M": 4, + "N": 3, + "X_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ], + [ + 10, + 11, + 12 + ] + ], + "X": [ + 10, + 11, + 12, + 7, + 8, + 9, + 4, + 5, + 6, + 1, + 2, + 3 + ], + "strideX1": -3, + "strideX2": 1, + "offsetX": 9, + "K": [ + 1, + 3, + 0, + 2 + ], + "strideK": 1, + "offsetK": 0, + "X_out_mat": [ + [ + 4, + 5, + 6 + ], + [ + 10, + 11, + 12 + ], + [ + 1, + 2, + 3 + ], + [ + 7, + 8, + 9 + ] + ], + "X_out": [ + 7, + 8, + 9, + 1, + 2, + 3, + 10, + 11, + 12, + 4, + 5, + 6 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/column_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/column_major_backward.json new file mode 100644 index 000000000000..642e1e8972c6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/column_major_backward.json @@ -0,0 +1,60 @@ +{ + "order": "column-major", + "forwrd": false, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 4 + ], + [ + 2, + 5 + ], + [ + 3, + 6 + ] + ], + "X": [ + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideX1": -1, + "strideX2": -3, + "offsetX": 5, + "K": [ + 1, + 0, + 2 + ], + "strideK": -1, + "offsetK": 2, + "X_out_mat": [ + [ + 2, + 5 + ], + [ + 3, + 6 + ], + [ + 1, + 4 + ] + ], + "X_out": [ + 4, + 6, + 5, + 1, + 3, + 2 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/column_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/column_major_forward.json new file mode 100644 index 000000000000..c2716c7ca07a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/column_major_forward.json @@ -0,0 +1,60 @@ +{ + "order": "column-major", + "forwrd": true, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 4 + ], + [ + 2, + 5 + ], + [ + 3, + 6 + ] + ], + "X": [ + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideX1": -1, + "strideX2": -3, + "offsetX": 5, + "K": [ + 1, + 0, + 2 + ], + "strideK": -1, + "offsetK": 2, + "X_out_mat": [ + [ + 3, + 6 + ], + [ + 1, + 4 + ], + [ + 2, + 5 + ] + ], + "X_out": [ + 5, + 4, + 6, + 2, + 1, + 3 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_backward.json new file mode 100644 index 000000000000..5bac6c05c6e3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_backward.json @@ -0,0 +1,60 @@ +{ + "order": "row-major", + "forwrd": false, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], + "X": [ + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideX1": -2, + "strideX2": -1, + "offsetX": 5, + "K": [ + 1, + 0, + 2 + ], + "strideK": -1, + "offsetK": 2, + "X_out_mat": [ + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ], + "X_out": [ + 2, + 1, + 6, + 5, + 4, + 3 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_backward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_backward_large.json new file mode 100644 index 000000000000..2aa26f463068 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_backward_large.json @@ -0,0 +1,89 @@ +{ + "order": "row-major", + "forwrd": false, + "M": 4, + "N": 3, + "X_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ], + [ + 10, + 11, + 12 + ] + ], + "X": [ + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideX1": -3, + "strideX2": -1, + "offsetX": 11, + "K": [ + 2, + 0, + 3, + 1 + ], + "strideK": -1, + "offsetK": 3, + "X_out_mat": [ + [ + 7, + 8, + 9 + ], + [ + 1, + 2, + 3 + ], + [ + 10, + 11, + 12 + ], + [ + 4, + 5, + 6 + ] + ], + "X_out": [ + 6, + 5, + 4, + 12, + 11, + 10, + 3, + 2, + 1, + 9, + 8, + 7 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_forward.json new file mode 100644 index 000000000000..db187d745366 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_forward.json @@ -0,0 +1,60 @@ +{ + "order": "row-major", + "forwrd": true, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], + "X": [ + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideX1": -2, + "strideX2": -1, + "offsetX": 5, + "K": [ + 1, + 0, + 2 + ], + "strideK": -1, + "offsetK": 2, + "X_out_mat": [ + [ + 5, + 6 + ], + [ + 1, + 2 + ], + [ + 3, + 4 + ] + ], + "X_out": [ + 4, + 3, + 2, + 1, + 6, + 5 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_forward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_forward_large.json new file mode 100644 index 000000000000..c532d9bcd0c6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/negative_strides/row_major_forward_large.json @@ -0,0 +1,89 @@ +{ + "order": "row-major", + "forwrd": true, + "M": 4, + "N": 3, + "X_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ], + [ + 10, + 11, + 12 + ] + ], + "X": [ + 12, + 11, + 10, + 9, + 8, + 7, + 6, + 5, + 4, + 3, + 2, + 1 + ], + "strideX1": -3, + "strideX2": -1, + "offsetX": 11, + "K": [ + 2, + 0, + 3, + 1 + ], + "strideK": -1, + "offsetK": 3, + "X_out_mat": [ + [ + 4, + 5, + 6 + ], + [ + 10, + 11, + 12 + ], + [ + 1, + 2, + 3 + ], + [ + 7, + 8, + 9 + ] + ], + "X_out": [ + 9, + 8, + 7, + 3, + 2, + 1, + 12, + 11, + 10, + 6, + 5, + 4 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/column_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/column_major_backward.json new file mode 100644 index 000000000000..5be3bea2ca73 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/column_major_backward.json @@ -0,0 +1,63 @@ +{ + "order": "column-major", + "forwrd": false, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 4 + ], + [ + 2, + 5 + ], + [ + 3, + 6 + ] + ], + "X": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "strideX1": 1, + "strideX2": 3, + "offsetX": 1, + "K": [ + 9999, + 2, + 0, + 1 + ], + "strideK": 1, + "offsetK": 1, + "X_out_mat": [ + [ + 2, + 5 + ], + [ + 3, + 6 + ], + [ + 1, + 4 + ] + ], + "X_out": [ + 9999, + 2, + 3, + 1, + 5, + 6, + 4 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/column_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/column_major_forward.json new file mode 100644 index 000000000000..03991a5ce35d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/column_major_forward.json @@ -0,0 +1,63 @@ +{ + "order": "column-major", + "forwrd": true, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 4 + ], + [ + 2, + 5 + ], + [ + 3, + 6 + ] + ], + "X": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "strideX1": 1, + "strideX2": 3, + "offsetX": 1, + "K": [ + 9999, + 2, + 0, + 1 + ], + "strideK": 1, + "offsetK": 1, + "X_out_mat": [ + [ + 3, + 6 + ], + [ + 1, + 4 + ], + [ + 2, + 5 + ] + ], + "X_out": [ + 9999, + 3, + 1, + 2, + 6, + 4, + 5 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_backward.json new file mode 100644 index 000000000000..e79acd8917c9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_backward.json @@ -0,0 +1,63 @@ +{ + "order": "row-major", + "forwrd": false, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], + "X": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "strideX1": 2, + "strideX2": 1, + "offsetX": 1, + "K": [ + 9999, + 2, + 0, + 1 + ], + "strideK": 1, + "offsetK": 1, + "X_out_mat": [ + [ + 3, + 4 + ], + [ + 5, + 6 + ], + [ + 1, + 2 + ] + ], + "X_out": [ + 9999, + 3, + 4, + 5, + 6, + 1, + 2 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_backward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_backward_large.json new file mode 100644 index 000000000000..ded03b2894db --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_backward_large.json @@ -0,0 +1,92 @@ +{ + "order": "row-major", + "forwrd": false, + "M": 4, + "N": 3, + "X_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ], + [ + 10, + 11, + 12 + ] + ], + "X": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + ], + "strideX1": 3, + "strideX2": 1, + "offsetX": 1, + "K": [ + 9999, + 1, + 3, + 0, + 2 + ], + "strideK": 1, + "offsetK": 1, + "X_out_mat": [ + [ + 7, + 8, + 9 + ], + [ + 1, + 2, + 3 + ], + [ + 10, + 11, + 12 + ], + [ + 4, + 5, + 6 + ] + ], + "X_out": [ + 9999, + 7, + 8, + 9, + 1, + 2, + 3, + 10, + 11, + 12, + 4, + 5, + 6 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_forward.json new file mode 100644 index 000000000000..8d613ce8a07e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_forward.json @@ -0,0 +1,63 @@ +{ + "order": "row-major", + "forwrd": true, + "M": 3, + "N": 2, + "X_mat": [ + [ + 1, + 2 + ], + [ + 3, + 4 + ], + [ + 5, + 6 + ] + ], + "X": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6 + ], + "strideX1": 2, + "strideX2": 1, + "offsetX": 1, + "K": [ + 9999, + 2, + 0, + 1 + ], + "strideK": 1, + "offsetK": 1, + "X_out_mat": [ + [ + 5, + 6 + ], + [ + 1, + 2 + ], + [ + 3, + 4 + ] + ], + "X_out": [ + 9999, + 5, + 6, + 1, + 2, + 3, + 4 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_forward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_forward_large.json new file mode 100644 index 000000000000..f22c118f3010 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/offsets/row_major_forward_large.json @@ -0,0 +1,92 @@ +{ + "order": "row-major", + "forwrd": true, + "M": 4, + "N": 3, + "X_mat": [ + [ + 1, + 2, + 3 + ], + [ + 4, + 5, + 6 + ], + [ + 7, + 8, + 9 + ], + [ + 10, + 11, + 12 + ] + ], + "X": [ + 9999, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12 + ], + "strideX1": 3, + "strideX2": 1, + "offsetX": 1, + "K": [ + 9999, + 1, + 3, + 0, + 2 + ], + "strideK": 1, + "offsetK": 1, + "X_out_mat": [ + [ + 4, + 5, + 6 + ], + [ + 10, + 11, + 12 + ], + [ + 1, + 2, + 3 + ], + [ + 7, + 8, + 9 + ] + ], + "X_out": [ + 9999, + 4, + 5, + 6, + 10, + 11, + 12, + 1, + 2, + 3, + 7, + 8, + 9 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_backward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_backward.json new file mode 100644 index 000000000000..2b761177d033 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_backward.json @@ -0,0 +1,28 @@ +{ + "order": "row-major", + "forwrd": false, + + "M": 3, + "N": 2, + + "X_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "X": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "strideX1": 2, + "strideX2": 1, + "offsetX": 0, + + "K": [ 2, 0, 1 ], + "strideK": 1, + "offsetK": 0, + + "X_out_mat": [ + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 1.0, 2.0 ] + ], + "X_out": [ 3.0, 4.0, 5.0, 6.0, 1.0, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_backward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_backward_large.json new file mode 100644 index 000000000000..02a075cb2c8a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_backward_large.json @@ -0,0 +1,30 @@ +{ + "order": "row-major", + "forwrd": false, + + "M": 4, + "N": 3, + + "X_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 ] + ], + "X": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + "strideX1": 3, + "strideX2": 1, + "offsetX": 0, + + "K": [ 1, 3, 0, 2 ], + "strideK": 1, + "offsetK": 0, + + "X_out_mat": [ + [ 7.0, 8.0, 9.0 ], + [ 1.0, 2.0, 3.0 ], + [ 10.0, 11.0, 12.0 ], + [ 4.0, 5.0, 6.0 ] + ], + "X_out": [ 7.0, 8.0, 9.0, 1.0, 2.0, 3.0, 10.0, 11.0, 12.0, 4.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_forward.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_forward.json new file mode 100644 index 000000000000..2f03101b6400 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_forward.json @@ -0,0 +1,28 @@ +{ + "order": "row-major", + "forwrd": true, + + "M": 3, + "N": 2, + + "X_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "X": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "strideX1": 2, + "strideX2": 1, + "offsetX": 0, + + "K": [ 2, 0, 1 ], + "strideK": 1, + "offsetK": 0, + + "X_out_mat": [ + [ 5.0, 6.0 ], + [ 1.0, 2.0 ], + [ 3.0, 4.0 ] + ], + "X_out": [ 5.0, 6.0, 1.0, 2.0, 3.0, 4.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_forward_large.json b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_forward_large.json new file mode 100644 index 000000000000..3c4fa7c33eb4 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/fixtures/row_major_forward_large.json @@ -0,0 +1,30 @@ +{ + "order": "row-major", + "forwrd": true, + + "M": 4, + "N": 3, + + "X_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 ] + ], + "X": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + "strideX1": 3, + "strideX2": 1, + "offsetX": 0, + + "K": [ 1, 3, 0, 2 ], + "strideK": 1, + "offsetK": 0, + + "X_out_mat": [ + [ 4.0, 5.0, 6.0 ], + [ 10.0, 11.0, 12.0 ], + [ 1.0, 2.0, 3.0 ], + [ 7.0, 8.0, 9.0 ] + ], + "X_out": [ 4.0, 5.0, 6.0, 10.0, 11.0, 12.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.dlapmr.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.dlapmr.js new file mode 100644 index 000000000000..d8b21de4fbc9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.dlapmr.js @@ -0,0 +1,308 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dlapmr = require( './../lib/dlapmr.js' ); + + +// FIXTURES // + +var ROW_MAJOR_FWD = require( './fixtures/row_major_forward.json' ); +var ROW_MAJOR_BWD = require( './fixtures/row_major_backward.json' ); +var ROW_MAJOR_FWD_LARGE = require( './fixtures/row_major_forward_large.json' ); +var ROW_MAJOR_BWD_LARGE = require( './fixtures/row_major_backward_large.json' ); +var COL_MAJOR_FWD = require( './fixtures/column_major_forward.json' ); +var COL_MAJOR_BWD = require( './fixtures/column_major_backward.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlapmr, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dlapmr.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 K; + var X; + var i; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 2, 0, 1 ] ); + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + 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() { + dlapmr( value, true, 3, 2, X, 2, K, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument (row-major)', function test( t ) { + var values; + var K; + var X; + var i; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 2, 0, 1 ] ); + + 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() { + dlapmr( 'row-major', true, 3, 2, X, value, K, 1 ); + }; + } +}); + +tape( 'the function throws an error if provided a stride of zero for K', function test( t ) { + var K; + var X; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 2, 0, 1 ] ); + + t.throws( badValue, RangeError, 'throws an error when strideK is 0' ); + t.end(); + + function badValue() { + dlapmr( 'row-major', true, 3, 2, X, 2, K, 0 ); + } +}); + +tape( 'the function returns the matrix unchanged when M is 0', function test( t ) { + var expected; + var out; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + K = new Int32Array( 0 ); + expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + out = dlapmr( 'row-major', true, 0, 3, X, 3, K, 1 ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the matrix unchanged when M is 1', function test( t ) { + var expected; + var out; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + K = new Int32Array( [ 0 ] ); + expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + out = dlapmr( 'row-major', true, 1, 3, X, 3, K, 1 ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a forward permutation (row-major)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_FWD; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.order, data.forwrd, data.M, data.N, X, data.strideX1, K, data.strideK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a backward permutation (row-major)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_BWD; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.order, data.forwrd, data.M, data.N, X, data.strideX1, K, data.strideK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a forward permutation (row-major, larger matrix)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_FWD_LARGE; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.order, data.forwrd, data.M, data.N, X, data.strideX1, K, data.strideK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a backward permutation (row-major, larger matrix)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_BWD_LARGE; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.order, data.forwrd, data.M, data.N, X, data.strideX1, K, data.strideK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a forward permutation (column-major)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = COL_MAJOR_FWD; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.order, data.forwrd, data.M, data.N, X, data.strideX2, K, data.strideK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a backward permutation (column-major)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = COL_MAJOR_BWD; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.order, data.forwrd, data.M, data.N, X, data.strideX2, K, data.strideK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles identity permutation (row-major)', function test( t ) { + var expected; + var out; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 0, 1, 2 ] ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = dlapmr( 'row-major', true, 3, 2, X, 2, K, 1 ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function restores the permutation vector K after execution (forward)', function test( t ) { + var expectedK; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 2, 0, 1 ] ); + expectedK = new Int32Array( [ 2, 0, 1 ] ); + + dlapmr( 'row-major', true, 3, 2, X, 2, K, 1 ); + t.deepEqual( K, expectedK, 'K is restored to original values' ); + t.end(); +}); + +tape( 'the function restores the permutation vector K after execution (backward)', function test( t ) { + var expectedK; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 2, 0, 1 ] ); + expectedK = new Int32Array( [ 2, 0, 1 ] ); + + dlapmr( 'row-major', false, 3, 2, X, 2, K, 1 ); + t.deepEqual( K, expectedK, 'K is restored to original values' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.js new file mode 100644 index 000000000000..5781d0058751 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.js @@ -0,0 +1,92 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 dlapmr = 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 dlapmr, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dlapmr.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function has an `ndarray` method', function test( t ) { + t.strictEqual( typeof dlapmr.ndarray, 'function', 'has method' ); + t.end(); +}); + +tape( 'the `ndarray` method has an arity of 10', function test( t ) { + t.strictEqual( dlapmr.ndarray.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var dlapmr = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlapmr, 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 dlapmr; + var main; + + main = require( './../lib/main.js' ); + + dlapmr = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlapmr, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.ndarray.js new file mode 100644 index 000000000000..a266ab619581 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlapmr/test/test.ndarray.js @@ -0,0 +1,474 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dlapmr = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var ROW_MAJOR_FWD = require( './fixtures/row_major_forward.json' ); +var ROW_MAJOR_BWD = require( './fixtures/row_major_backward.json' ); +var ROW_MAJOR_FWD_LARGE = require( './fixtures/row_major_forward_large.json' ); +var ROW_MAJOR_BWD_LARGE = require( './fixtures/row_major_backward_large.json' ); +var COL_MAJOR_FWD = require( './fixtures/column_major_forward.json' ); +var COL_MAJOR_BWD = require( './fixtures/column_major_backward.json' ); +var ROW_MAJOR_FWD_OFFSETS = require( './fixtures/offsets/row_major_forward.json' ); +var ROW_MAJOR_BWD_OFFSETS = require( './fixtures/offsets/row_major_backward.json' ); +var COL_MAJOR_FWD_OFFSETS = require( './fixtures/offsets/column_major_forward.json' ); +var ROW_MAJOR_FWD_LARGE_STRIDES = require( './fixtures/large_strides/row_major_forward.json' ); +var ROW_MAJOR_BWD_LARGE_STRIDES = require( './fixtures/large_strides/row_major_backward.json' ); +var COL_MAJOR_FWD_LARGE_STRIDES = require( './fixtures/large_strides/column_major_forward.json' ); +var ROW_MAJOR_FWD_NEG_STRIDES = require( './fixtures/negative_strides/row_major_forward.json' ); +var ROW_MAJOR_BWD_NEG_STRIDES = require( './fixtures/negative_strides/row_major_backward.json' ); +var COL_MAJOR_FWD_NEG_STRIDES = require( './fixtures/negative_strides/column_major_forward.json' ); +var ROW_MAJOR_FWD_MIXED = require( './fixtures/mixed_strides/row_major_forward.json' ); +var ROW_MAJOR_BWD_MIXED = require( './fixtures/mixed_strides/row_major_backward.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlapmr, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dlapmr.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the matrix unchanged when M is 0', function test( t ) { + var expected; + var out; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + K = new Int32Array( 0 ); + expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + out = dlapmr( true, 0, 3, X, 3, 1, 0, K, 1, 0 ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the matrix unchanged when M is 1', function test( t ) { + var expected; + var out; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + K = new Int32Array( [ 0 ] ); + expected = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + + out = dlapmr( true, 1, 3, X, 3, 1, 0, K, 1, 0 ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a forward permutation (row-major)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_FWD; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a backward permutation (row-major)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_BWD; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a forward permutation (row-major, larger matrix)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_FWD_LARGE; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a backward permutation (row-major, larger matrix)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_BWD_LARGE; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a forward permutation (column-major)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = COL_MAJOR_FWD; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function applies a backward permutation (column-major)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = COL_MAJOR_BWD; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `X` offset (row-major, forward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_FWD_OFFSETS; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `X` offset (row-major, backward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_BWD_OFFSETS; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `X` offset (column-major, forward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = COL_MAJOR_FWD_OFFSETS; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports large strides (row-major, forward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_FWD_LARGE_STRIDES; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports large strides (row-major, backward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_BWD_LARGE_STRIDES; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports large strides (column-major, forward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = COL_MAJOR_FWD_LARGE_STRIDES; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides (row-major, forward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_FWD_NEG_STRIDES; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides (row-major, backward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_BWD_NEG_STRIDES; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides (column-major, forward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = COL_MAJOR_FWD_NEG_STRIDES; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports mixed strides (row-major, forward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_FWD_MIXED; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports mixed strides (row-major, backward)', function test( t ) { + var expected; + var data; + var out; + var X; + var K; + + data = ROW_MAJOR_BWD_MIXED; + + X = new Float64Array( data.X ); + K = new Int32Array( data.K ); + expected = new Float64Array( data.X_out ); + + out = dlapmr( data.forwrd, data.M, data.N, X, data.strideX1, data.strideX2, data.offsetX, K, data.strideK, data.offsetK ); + t.strictEqual( out, X, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles identity permutation', function test( t ) { + var expected; + var out; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 0, 1, 2 ] ); + expected = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + + out = dlapmr( true, 3, 2, X, 2, 1, 0, K, 1, 0 ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function handles a simple swap permutation', function test( t ) { + var expected; + var out; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 1, 0 ] ); + expected = new Float64Array( [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0 ] ); + + out = dlapmr( true, 2, 3, X, 3, 1, 0, K, 1, 0 ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function restores the permutation vector K after execution (forward)', function test( t ) { + var expectedK; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 2, 0, 1 ] ); + expectedK = new Int32Array( [ 2, 0, 1 ] ); + + dlapmr( true, 3, 2, X, 2, 1, 0, K, 1, 0 ); + t.deepEqual( K, expectedK, 'K is restored to original values' ); + t.end(); +}); + +tape( 'the function restores the permutation vector K after execution (backward)', function test( t ) { + var expectedK; + var X; + var K; + + X = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + K = new Int32Array( [ 2, 0, 1 ] ); + expectedK = new Int32Array( [ 2, 0, 1 ] ); + + dlapmr( false, 3, 2, X, 2, 1, 0, K, 1, 0 ); + t.deepEqual( K, expectedK, 'K is restored to original values' ); + t.end(); +});