From c92f72c1d463b59363f3958c52861bb1a7611679 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 09:23:12 +0530 Subject: [PATCH 01/60] feat: add initial implementation for lapack/base/dlaswp --- .../@stdlib/lapack/blas/dlaswp/lib/dlaswp.js | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js diff --git a/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js new file mode 100644 index 000000000000..a410d19e3908 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js @@ -0,0 +1,133 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); + + +// MAIN // + +/** +* Performs a series of row interchanges on the matrix `A`. +* +* @param {PositiveInteger} N - number of columns of `A` +* @param {Array} A - matrix +* @param {PositiveInteger} LDA - leading dimension of `A` +* @param {PositiveInteger} k1 - first element of `IPIV` for which a row interchange will be done +* @param {PositiveInteger} k2 - second element of `IPIV` for which a row interchange will be done +* @param {Array} IPIV - vector of pivot indices +* @param {PositiveInteger} incX - increment between successive values of `IPIV` +* @returns {Float64Array} permuted matrix `A` +* +* @example +* TODO: +*/ +function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { + var IPIV; + var incX; + var inc; + var ix0; + var LDA; + var n32; + var tmp; + var i2; + var ip; + var ix; + var k1; + var k2; + var i1; + var A; + var i; + var j; + var k; + var N; + + if ( !isLayout( order ) ) { + throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); + } + + // Interchange row I with IPIV( k1 + ( I - k1 ) * abs( incX ) ) for + // each rows k1 through k2. + if ( incX > 0 ) { + ix0 = k1; + i1 = k1; + i2 = k2; + inc = 1; + } else if ( incX < 0 ) { + ix0 = k1 + ( k1 - k2 ) * incX; + i1 = k2; + i2 = k1; + inc = -1; + } else { + return; + } + + n32 = ( N / 32 ) * 32; + if ( n32 != 0 ) { + for ( j = 0; j < n32; j += 32 ) { + ix = ix0; + for ( i = i1 - 1; i < i2; i += inc ) { + ip = IPIV[ ix - 1 ]; + if ( ip != i ) { + for ( k = j; k <= j + 31; k++ ) { + if ( order == 'row-major' ) { + tmp = A[ i * LDA + k ]; + A[ i * LDA + k ] = A[ ip * LDA + k ]; + A[ ip * LDA + k ] = tmp; + } else { + tmp = A[ k * LDA + i ]; + A[ k * LDA + i ] = A[ k * LDA + ip ]; + A[ k * LDA + ip ] = tmp; + } + } + } + ix += incX; + } + } + } + if ( n32 != N ) { + n32 += 1; + ix = ix0; + for ( i = i1 - 1; i < i2; i += inc ) { + ip = IPIV[ ix - 1 ]; + if ( ip != i ) { + for ( k = n32 - 1 ; k < N; k++ ) { + if ( order == 'row-major' ) { + tmp = A[ i * LDA + k ]; + A[ i * LDA + k ] = A[ ip * LDA + k ]; + A[ ip * LDA + k ] = tmp; + } else { + tmp = A[ k * LDA + i ]; + A[ k * LDA + i ] = A[ k * LDA + ip ]; + A[ k * LDA + ip ] = tmp; + } + } + } + ix += incX; + } + } + return A; +} + + +// EXPORTS // + +module.exports = dlaswp; From eece712c48a714eb80061b43997f9f6764d188e2 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 10:46:35 +0530 Subject: [PATCH 02/60] chore: update dlaswp.js --- .../@stdlib/lapack/blas/dlaswp/lib/dlaswp.js | 106 ++++++++++-------- 1 file changed, 62 insertions(+), 44 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js index a410d19e3908..4a954b81f211 100644 --- a/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js @@ -21,24 +21,34 @@ // MODULES // var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var dswap = require( '@stdlib/blas/base/dswap' ); // MAIN // /** -* Performs a series of row interchanges on the matrix `A`. +* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. * +* @param {string} order - storage layout * @param {PositiveInteger} N - number of columns of `A` -* @param {Array} A - matrix +* @param {Float64Array} A - matrix * @param {PositiveInteger} LDA - leading dimension of `A` -* @param {PositiveInteger} k1 - first element of `IPIV` for which a row interchange will be done -* @param {PositiveInteger} k2 - second element of `IPIV` for which a row interchange will be done -* @param {Array} IPIV - vector of pivot indices +* @param {PositiveInteger} k1 - index of first row to interchange +* @param {PositiveInteger} k2 - index of last row to interchange +* @param {Int32Array} IPIV - vector of pivot indices * @param {PositiveInteger} incX - increment between successive values of `IPIV` * @returns {Float64Array} permuted matrix `A` * * @example -* TODO: +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] */ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { var IPIV; @@ -64,8 +74,6 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); } - // Interchange row I with IPIV( k1 + ( I - k1 ) * abs( incX ) ) for - // each rows k1 through k2. if ( incX > 0 ) { ix0 = k1; i1 = k1; @@ -77,54 +85,64 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { i2 = k1; inc = -1; } else { - return; + return A; } - n32 = ( N / 32 ) * 32; - if ( n32 != 0 ) { - for ( j = 0; j < n32; j += 32 ) { - ix = ix0; - for ( i = i1 - 1; i < i2; i += inc ) { - ip = IPIV[ ix - 1 ]; - if ( ip != i ) { - for ( k = j; k <= j + 31; k++ ) { - if ( order == 'row-major' ) { - tmp = A[ i * LDA + k ]; - A[ i * LDA + k ] = A[ ip * LDA + k ]; - A[ ip * LDA + k ] = tmp; - } else { - tmp = A[ k * LDA + i ]; - A[ k * LDA + i ] = A[ k * LDA + ip ]; - A[ k * LDA + ip ] = tmp; + if ( order === 'row-major' ) { + ix = ix0; + if ( inc === 1 ) { + for ( i = i1; i <= i2; i++ ) { + ip = IPIV[ ix ]; + if ( ip !== i ) { + dswap( N, A, i * LDA, A, ip * LDA); + } + ix += incX; + } + return A; + } + for ( i = i1; i >= i2; i-- ) { + ip = IPIV[ ix ]; + if ( ip !== i ) { + dswap( N, A, i * LDA, A, ip * LDA); + } + ix += incX; + } + return A; + } else { + n32 = floor( N / 32 ) * 32; + if ( n32 !== 0 ) { + for ( j = 1; j < n32; j += 32 ) { + ix = ix0; + for ( i = i1; i < i2; i += inc ) { + ip = IPIV[ ix ]; + if ( ip !== i ) { + for ( k = j; k < j + 31; k++ ) { + tmp = A[ ( k - 1 ) * LDA + i ]; + A[ ( k - 1 ) * LDA + i ] = A[ ( k - 1 ) * LDA + ip ]; + A[ ( k - 1 ) * LDA + ip ] = tmp; } } + ix += incX; } - ix += incX; } } - } - if ( n32 != N ) { - n32 += 1; - ix = ix0; - for ( i = i1 - 1; i < i2; i += inc ) { - ip = IPIV[ ix - 1 ]; - if ( ip != i ) { - for ( k = n32 - 1 ; k < N; k++ ) { - if ( order == 'row-major' ) { - tmp = A[ i * LDA + k ]; - A[ i * LDA + k ] = A[ ip * LDA + k ]; - A[ ip * LDA + k ] = tmp; - } else { - tmp = A[ k * LDA + i ]; - A[ k * LDA + i ] = A[ k * LDA + ip ]; - A[ k * LDA + ip ] = tmp; + if ( n32 !== N ) { + n32 += 1; + ix = ix0; + for ( i = i1; i < i2; i += inc ) { + ip = IPIV[ ix ]; + if ( ip !== i ) { + for ( k = n32; k < N; k++ ) { + tmp = A[ ( k - 1 ) * LDA + i ]; + A[ ( k - 1 ) * LDA + i ] = A[ ( k - 1 ) * LDA + ip ]; + A[ ( k - 1 ) * LDA + ip ] = tmp; } } + ix += incX; } - ix += incX; } + return A; } - return A; } From b35d940af07b0a350c6c465f4ddcccd6926bccce Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:02:50 +0530 Subject: [PATCH 03/60] chore: update dlaswp.js --- .../@stdlib/lapack/blas/dlaswp/lib/dlaswp.js | 71 +++++++++---------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js index 4a954b81f211..efdc2dd5796e 100644 --- a/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js @@ -38,6 +38,7 @@ var dswap = require( '@stdlib/blas/base/dswap' ); * @param {PositiveInteger} k2 - index of last row to interchange * @param {Int32Array} IPIV - vector of pivot indices * @param {PositiveInteger} incX - increment between successive values of `IPIV` +* @throws {TypeError} first argument must be a valid order * @returns {Float64Array} permuted matrix `A` * * @example @@ -51,24 +52,17 @@ var dswap = require( '@stdlib/blas/base/dswap' ); * // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] */ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { - var IPIV; - var incX; var inc; var ix0; - var LDA; var n32; var tmp; var i2; var ip; var ix; - var k1; - var k2; var i1; - var A; var i; var j; var k; - var N; if ( !isLayout( order ) ) { throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); @@ -80,7 +74,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { i2 = k2; inc = 1; } else if ( incX < 0 ) { - ix0 = k1 + ( k1 - k2 ) * incX; + ix0 = k1 + ( ( k1 - k2 ) * incX ); i1 = k2; i2 = k1; inc = -1; @@ -91,58 +85,57 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { if ( order === 'row-major' ) { ix = ix0; if ( inc === 1 ) { - for ( i = i1; i <= i2; i++ ) { + for ( k = i1; k <= i2; k++ ) { ip = IPIV[ ix ]; - if ( ip !== i ) { - dswap( N, A, i * LDA, A, ip * LDA); + if ( ip !== k ) { + dswap( N, A, k * LDA, A, ip * LDA); } ix += incX; } return A; } - for ( i = i1; i >= i2; i-- ) { + for ( k = i1; k >= i2; k-- ) { ip = IPIV[ ix ]; - if ( ip !== i ) { - dswap( N, A, i * LDA, A, ip * LDA); + if ( ip !== k ) { + dswap( N, A, k * LDA, A, ip * LDA); } ix += incX; } return A; - } else { - n32 = floor( N / 32 ) * 32; - if ( n32 !== 0 ) { - for ( j = 1; j < n32; j += 32 ) { - ix = ix0; - for ( i = i1; i < i2; i += inc ) { - ip = IPIV[ ix ]; - if ( ip !== i ) { - for ( k = j; k < j + 31; k++ ) { - tmp = A[ ( k - 1 ) * LDA + i ]; - A[ ( k - 1 ) * LDA + i ] = A[ ( k - 1 ) * LDA + ip ]; - A[ ( k - 1 ) * LDA + ip ] = tmp; - } - } - ix += incX; - } - } - } - if ( n32 !== N ) { - n32 += 1; + } + n32 = floor( N / 32 ) * 32; + if ( n32 !== 0 ) { + for ( j = 1; j < n32; j += 32 ) { ix = ix0; for ( i = i1; i < i2; i += inc ) { ip = IPIV[ ix ]; if ( ip !== i ) { - for ( k = n32; k < N; k++ ) { - tmp = A[ ( k - 1 ) * LDA + i ]; - A[ ( k - 1 ) * LDA + i ] = A[ ( k - 1 ) * LDA + ip ]; - A[ ( k - 1 ) * LDA + ip ] = tmp; + for ( k = j; k < j + 31; k++ ) { + tmp = A[ ( ( k - 1 ) * LDA ) + i ]; + A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; + A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; } } ix += incX; } } - return A; } + if ( n32 !== N ) { + n32 += 1; + ix = ix0; + for ( i = i1; i < i2; i += inc ) { + ip = IPIV[ ix ]; + if ( ip !== i ) { + for ( k = n32; k < N; k++ ) { + tmp = A[ ( ( k - 1 ) * LDA ) + i ]; + A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; + A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; + } + } + ix += incX; + } + } + return A; } From 5f84f9930e546dd4c377f6722e2c37b913bbfa6c Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:03:11 +0530 Subject: [PATCH 04/60] chore: update dlaswp.js --- lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js index efdc2dd5796e..5645141e9bd7 100644 --- a/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js @@ -112,7 +112,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { if ( ip !== i ) { for ( k = j; k < j + 31; k++ ) { tmp = A[ ( ( k - 1 ) * LDA ) + i ]; - A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; + A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; } } @@ -128,7 +128,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { if ( ip !== i ) { for ( k = n32; k < N; k++ ) { tmp = A[ ( ( k - 1 ) * LDA ) + i ]; - A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; + A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; } } From 711aa9bded33e834037fea578d667ac809b6406b Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:12:28 +0530 Subject: [PATCH 05/60] chore: lib/index.js --- .../@stdlib/lapack/base/dlaswp/lib/index.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js new file mode 100644 index 000000000000..57ad490bf0d2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* LAPACK routine to perform a series of row interchanges on the matrix `A`. +* +* @module @stdlib/lapack/base/dlaswp +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var dlaswp; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlaswp = main; +} else { + dlaswp = tmp; +} + + +// EXPORTS // + +module.exports = dlaswp; From b0eec9af72dbae97266a86575cb4c78f483e43f0 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:12:49 +0530 Subject: [PATCH 06/60] chore: add dlaswp.js --- .../@stdlib/lapack/base/dlaswp/lib/dlaswp.js | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js new file mode 100644 index 000000000000..5645141e9bd7 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js @@ -0,0 +1,144 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var dswap = require( '@stdlib/blas/base/dswap' ); + + +// MAIN // + +/** +* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +* +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of columns of `A` +* @param {Float64Array} A - matrix +* @param {PositiveInteger} LDA - leading dimension of `A` +* @param {PositiveInteger} k1 - index of first row to interchange +* @param {PositiveInteger} k2 - index of last row to interchange +* @param {Int32Array} IPIV - vector of pivot indices +* @param {PositiveInteger} incX - increment between successive values of `IPIV` +* @throws {TypeError} first argument must be a valid order +* @returns {Float64Array} permuted matrix `A` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +*/ +function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { + var inc; + var ix0; + var n32; + var tmp; + var i2; + var ip; + var ix; + var i1; + var i; + var j; + var k; + + if ( !isLayout( order ) ) { + throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); + } + + if ( incX > 0 ) { + ix0 = k1; + i1 = k1; + i2 = k2; + inc = 1; + } else if ( incX < 0 ) { + ix0 = k1 + ( ( k1 - k2 ) * incX ); + i1 = k2; + i2 = k1; + inc = -1; + } else { + return A; + } + + if ( order === 'row-major' ) { + ix = ix0; + if ( inc === 1 ) { + for ( k = i1; k <= i2; k++ ) { + ip = IPIV[ ix ]; + if ( ip !== k ) { + dswap( N, A, k * LDA, A, ip * LDA); + } + ix += incX; + } + return A; + } + for ( k = i1; k >= i2; k-- ) { + ip = IPIV[ ix ]; + if ( ip !== k ) { + dswap( N, A, k * LDA, A, ip * LDA); + } + ix += incX; + } + return A; + } + n32 = floor( N / 32 ) * 32; + if ( n32 !== 0 ) { + for ( j = 1; j < n32; j += 32 ) { + ix = ix0; + for ( i = i1; i < i2; i += inc ) { + ip = IPIV[ ix ]; + if ( ip !== i ) { + for ( k = j; k < j + 31; k++ ) { + tmp = A[ ( ( k - 1 ) * LDA ) + i ]; + A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len + A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; + } + } + ix += incX; + } + } + } + if ( n32 !== N ) { + n32 += 1; + ix = ix0; + for ( i = i1; i < i2; i += inc ) { + ip = IPIV[ ix ]; + if ( ip !== i ) { + for ( k = n32; k < N; k++ ) { + tmp = A[ ( ( k - 1 ) * LDA ) + i ]; + A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len + A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; + } + } + ix += incX; + } + } + return A; +} + + +// EXPORTS // + +module.exports = dlaswp; From 4649c54c6c3e8b18f51bfa7908ea4cb6898a7af3 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:13:10 +0530 Subject: [PATCH 07/60] chore: add main.js --- .../@stdlib/lapack/base/dlaswp/lib/main.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/lib/main.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/main.js new file mode 100644 index 000000000000..1c7105f7000c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/main.js @@ -0,0 +1,28 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var dlaswp = require( './dlaswp.js' ); + + +// EXPORTS // + +module.exports = dlaswp; From 44075d2f0b6eacd896ba18794cbe66105f80f3f8 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:13:33 +0530 Subject: [PATCH 08/60] chore: delete lapack/blas/dlaswp.js --- .../@stdlib/lapack/blas/dlaswp/lib/dlaswp.js | 144 ------------------ 1 file changed, 144 deletions(-) delete mode 100644 lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js diff --git a/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js deleted file mode 100644 index 5645141e9bd7..000000000000 --- a/lib/node_modules/@stdlib/lapack/blas/dlaswp/lib/dlaswp.js +++ /dev/null @@ -1,144 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2024 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var dswap = require( '@stdlib/blas/base/dswap' ); - - -// MAIN // - -/** -* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. -* -* @param {string} order - storage layout -* @param {PositiveInteger} N - number of columns of `A` -* @param {Float64Array} A - matrix -* @param {PositiveInteger} LDA - leading dimension of `A` -* @param {PositiveInteger} k1 - index of first row to interchange -* @param {PositiveInteger} k2 - index of last row to interchange -* @param {Int32Array} IPIV - vector of pivot indices -* @param {PositiveInteger} incX - increment between successive values of `IPIV` -* @throws {TypeError} first argument must be a valid order -* @returns {Float64Array} permuted matrix `A` -* -* @example -* var Int32Array = require( '@stdlib/array/int32' ); -* var Float64Array = require( '@stdlib/array/float64' ); -* -* var IPIV = new Int32Array( [ 2, 0, 1 ] ); -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* -* dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); -* // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] -*/ -function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { - var inc; - var ix0; - var n32; - var tmp; - var i2; - var ip; - var ix; - var i1; - var i; - var j; - var k; - - if ( !isLayout( order ) ) { - throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); - } - - if ( incX > 0 ) { - ix0 = k1; - i1 = k1; - i2 = k2; - inc = 1; - } else if ( incX < 0 ) { - ix0 = k1 + ( ( k1 - k2 ) * incX ); - i1 = k2; - i2 = k1; - inc = -1; - } else { - return A; - } - - if ( order === 'row-major' ) { - ix = ix0; - if ( inc === 1 ) { - for ( k = i1; k <= i2; k++ ) { - ip = IPIV[ ix ]; - if ( ip !== k ) { - dswap( N, A, k * LDA, A, ip * LDA); - } - ix += incX; - } - return A; - } - for ( k = i1; k >= i2; k-- ) { - ip = IPIV[ ix ]; - if ( ip !== k ) { - dswap( N, A, k * LDA, A, ip * LDA); - } - ix += incX; - } - return A; - } - n32 = floor( N / 32 ) * 32; - if ( n32 !== 0 ) { - for ( j = 1; j < n32; j += 32 ) { - ix = ix0; - for ( i = i1; i < i2; i += inc ) { - ip = IPIV[ ix ]; - if ( ip !== i ) { - for ( k = j; k < j + 31; k++ ) { - tmp = A[ ( ( k - 1 ) * LDA ) + i ]; - A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len - A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; - } - } - ix += incX; - } - } - } - if ( n32 !== N ) { - n32 += 1; - ix = ix0; - for ( i = i1; i < i2; i += inc ) { - ip = IPIV[ ix ]; - if ( ip !== i ) { - for ( k = n32; k < N; k++ ) { - tmp = A[ ( ( k - 1 ) * LDA ) + i ]; - A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len - A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; - } - } - ix += incX; - } - } - return A; -} - - -// EXPORTS // - -module.exports = dlaswp; From dd393d492147db45f830a7df20bd94ce253dfda3 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:13:49 +0530 Subject: [PATCH 09/60] chore: add example --- .../lapack/base/dlaswp/examples/index.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js new file mode 100644 index 000000000000..ce1b2aac76a9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js @@ -0,0 +1,29 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dlaswp = require( './../lib' ); + +var IPIV = new Int32Array( [ 2, 0, 1 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +console.log( A ); From 40349ca411c75fa401d3c8f31620105fe786adf2 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:26:08 +0530 Subject: [PATCH 10/60] chore: add README.md --- .../@stdlib/lapack/base/dlaswp/README.md | 214 ++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/README.md diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md new file mode 100644 index 000000000000..3e61854225f3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -0,0 +1,214 @@ + + +# dsymv + +> Perform a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. + +
+ +## Usage + +```javascript +var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); +``` + +#### dlaswp( N, A, LDA, k1, k2, IPIV, incX ) + +Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var IPIV = new Int32Array( [ 2, 0, 1 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +// A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **N**: number of columns of `A`. +- **A**: input `Float64Array`. +- **LDA**: leading dimension of `A`. +- **k1**: index of first row to interchange. +- **k2**: index of last row to interchange. +- **IPIV**: vector of pivot indices. +- **incX**: increment between successive values of `IPIV`. + +The increment parameters determine how elements in the IPIV array are accessed at runtime. For example, to iterate over the elements of `IPIV` in reverse order, + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var IPIV = new Int32Array( [ 2, 0, 1 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +// A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var IPIV = new Int32Array( [ 2, 0, 1 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +// Create offset views... +var IPIV1 = new Int32Array( IPIV.buffer, IPIV.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var A1 = new Float64Array( A.buffer, A.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dlaswp( 'column-major', 3, A1, 2, 0, 2, IPIV1, 1 ); +// A => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] +``` + +
+ + + +
+ +## Notes + +- `dlaswp()` is a LAPACK routine. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); +var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); + +var IPIV = new Int32Array( [ 2, 0, 1 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +console.log( A ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + From e19ff82dcfecc2a5190cb6bcc735aa4d7aaa1e1b Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:27:54 +0530 Subject: [PATCH 11/60] chore: add package.json --- .../@stdlib/lapack/base/dlaswp/package.json | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/package.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json new file mode 100644 index 000000000000..a87b6f28f597 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/lapack/base/dlaswp", + "version": "0.0.0", + "description": "Perform a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`.", + "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", + "dlaswp", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} From 559824aa9cd50a0acca4164fa804650cbdc25fa9 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:28:39 +0530 Subject: [PATCH 12/60] chore: add README.md --- lib/node_modules/@stdlib/lapack/base/dlaswp/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 3e61854225f3..4c34d218c014 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -86,7 +86,7 @@ var IPIV1 = new Int32Array( IPIV.buffer, IPIV.BYTES_PER_ELEMENT*1 ); // start at var A1 = new Float64Array( A.buffer, A.BYTES_PER_ELEMENT*1 ); // start at 2nd element dlaswp( 'column-major', 3, A1, 2, 0, 2, IPIV1, 1 ); -// A => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] +// A1 => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] ``` From 9dcfa535ae50bfcddb78477e89714070cab8b7e0 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 11:49:25 +0530 Subject: [PATCH 13/60] chore: add repl.txt --- .../@stdlib/lapack/base/dlaswp/docs/repl.txt | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt new file mode 100644 index 000000000000..61fdf86d94c6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -0,0 +1,53 @@ + +{{alias}}( order, N, A, LDA, k1, k2, IPIV, incX ) + Perform a series of row interchanges on the matrix `A` using + pivot indices stored in `IPIV`. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is equal to `0`, the function returns `y` unchanged. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + N: integer + Number of columns of `A`. + + A: Float64Array + Matrix. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + k1: integer + Index of first row to interchange. + + k2: integer + Index of last row to interchange. + + IPIV: Int32Array + Array of pivot indices. + + incX: integer + Increment between pivot indices. + + Returns + ------- + A: Float64Array + Output vector. + + Examples + -------- + > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var ord = 'column-major'; + > {{alias}}( ord, 3, A, 2, 0, 2, IPIV, 1 ) + [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + + See Also + -------- From b76122543737a628fcb24699f1c42e88a782c0eb Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 12:02:59 +0530 Subject: [PATCH 14/60] chore: add test.ts --- .../lapack/base/dlaswp/docs/types/test.ts | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts new file mode 100644 index 000000000000..dba8b37d04fc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts @@ -0,0 +1,148 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import dlaswp = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp( 10, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( true, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( false, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( null, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( undefined, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( [], 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( {}, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( ( x: number ): number => x, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp( 'column-major', '3', A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', true, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', false, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', null, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', undefined, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', [ '1' ], A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', {}, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', ( x: number ): number => x, A, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const IPIV = new Int32Array( 3 ); + + dlaswp( 'row-major', 3, '10', 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, true, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, false, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, null, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, undefined, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, [ '1' ], 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, {}, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, ( x: number ): number => x, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp( 'column-major', 3, A, '2', 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, true, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, false, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, null, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, undefined, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, [], 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, {}, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, ( x: number ): number => x, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp( 'row-major', 3, A, 2, '0', 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, true, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, false, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, null, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, undefined, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, [], 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, {}, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, ( x: number ): number => x, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp( 'row-major', 3, A, 2, 0, '2', IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, true, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, false, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, null, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, undefined, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, [], IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, {}, IPIV, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, ( x: number ): number => x, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not an Int32Array... +{ + const A = new Float64Array( 6 ); + + dlaswp( 'row-major', 3, A, 2, 0, 2, 'IPIV', 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, true, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, false, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, null, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, undefined, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, [], 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, {}, 1 ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, '1' ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, true ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, false ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, null ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, undefined ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, [] ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, {} ); // $ExpectError + dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, ( x: number ): number => x ); // $ExpectError +} From d3f80692f1151ec878ac44e54aef22872e641308 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 12:04:30 +0530 Subject: [PATCH 15/60] chore: add index.d.ts --- .../lapack/base/dlaswp/docs/types/index.d.ts | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts new file mode 100644 index 000000000000..2c76b54c584a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts @@ -0,0 +1,83 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout } from '@stdlib/types/blas'; + +/** +* Interface describing `dlaswp`. +*/ +interface Routine { + /** + * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. + * + * @param order - storage layout + * @param N - number of columns of `A` + * @param A - matrix + * @param LDA - leading dimension of `A` + * @param k1 - index of first row to interchange + * @param k2 - index of last row to interchange + * @param IPIV - vector of pivot indices + * @param incX - increment between successive values of `IPIV` + * @returns `A` + * + * @example + * var Int32Array = require( '@stdlib/array/int32' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var IPIV = new Int32Array( [ 2, 0, 1 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); + * // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + */ + ( order: Layout, N: number, A: Float64Array, LDA: number, k1: number, k2: number, IPIV: Int32Array, incX: number ): Float64Array; +} + +/** +* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +* +* @param order - storage layout +* @param N - number of columns of `A` +* @param A - matrix +* @param LDA - leading dimension of `A` +* @param k1 - index of first row to interchange +* @param k2 - index of last row to interchange +* @param IPIV - vector of pivot indices +* @param incX - increment between successive values of `IPIV` +* @returns `A` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +*/ +declare var dlaswp: Routine; + + +// EXPORTS // + +export = dlaswp; From 15a6b5a6d1720384b4926014703f017a9555f7b2 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 12:10:38 +0530 Subject: [PATCH 16/60] chore: add benchmark --- .../lapack/base/dlaswp/benchmark/benchmark.js | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js new file mode 100644 index 000000000000..75d564b134d6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dlaswp = require( './../lib/dlaswp.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var IPIV = ones( N*N, 'int32' ); + var A = uniform( N, -10.0, 10.0, options ); + 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 = dlaswp( 'column-major', N, A, N, 1, 1, IPIV, 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 N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':size='+(N*N), f ); + } +} + +main(); From 6326803858aed7e68d406b31b4fe1ff20a0230cc Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 13:23:10 +0530 Subject: [PATCH 17/60] fix: row-major implementation --- lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js index 5645141e9bd7..f7ed53561be4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js @@ -22,7 +22,7 @@ var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var floor = require( '@stdlib/math/base/special/floor' ); -var dswap = require( '@stdlib/blas/base/dswap' ); +var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; // MAIN // @@ -88,7 +88,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { for ( k = i1; k <= i2; k++ ) { ip = IPIV[ ix ]; if ( ip !== k ) { - dswap( N, A, k * LDA, A, ip * LDA); + dswap( LDA, A, 1, k * LDA, A, 1, ip * LDA ); } ix += incX; } @@ -97,7 +97,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { for ( k = i1; k >= i2; k-- ) { ip = IPIV[ ix ]; if ( ip !== k ) { - dswap( N, A, k * LDA, A, ip * LDA); + dswap( LDA, A, 1, k * LDA, A, 1, ip * LDA ); } ix += incX; } From 682b172f3686d1f17c2706a25bc543fb6e47b73a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 13:24:48 +0530 Subject: [PATCH 18/60] test: add tests --- .../dlaswp/test/fixtures/column_major_ao.json | 11 + .../dlaswp/test/fixtures/column_major_at.json | 11 + .../dlaswp/test/fixtures/row_major_an.json | 11 + .../dlaswp/test/fixtures/row_major_ao.json | 11 + .../dlaswp/test/fixtures/row_major_aolt.json | 11 + .../lapack/base/dlaswp/test/test.dlaswp.js | 195 ++++++++++++++++++ .../@stdlib/lapack/base/dlaswp/test/test.js | 77 +++++++ 7 files changed, 327 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json new file mode 100644 index 000000000000..b89455d70ed3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json @@ -0,0 +1,11 @@ +{ + "order": "column-major", + "N": 3, + "k1": 0, + "k2": 2, + "IPIV": [ 2, 0, 1 ], + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_out": [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ], + "LDA": 2, + "incX": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json new file mode 100644 index 000000000000..7fd68f931b8e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json @@ -0,0 +1,11 @@ +{ + "order": "column-major", + "N": 3, + "k1": 0, + "k2": 2, + "IPIV": [ 2, 0, 1 ], + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_out": [ 3.0, 2.0, 5.0, 4.0, 1.0, 6.0 ], + "LDA": 2, + "incX": 2 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json new file mode 100644 index 000000000000..6fd84931f604 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json @@ -0,0 +1,11 @@ +{ + "order": "row-major", + "N": 3, + "k1": 0, + "k2": 2, + "IPIV": [ 2, 0, 1 ], + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], + "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], + "LDA": 3, + "incX": -1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json new file mode 100644 index 000000000000..209e17cc5762 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json @@ -0,0 +1,11 @@ +{ + "order": "row-major", + "N": 3, + "k1": 0, + "k2": 2, + "IPIV": [ 2, 0, 1 ], + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], + "LDA": 2, + "incX": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json new file mode 100644 index 000000000000..12642d08dead --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json @@ -0,0 +1,11 @@ +{ + "order": "row-major", + "N": 3, + "k1": 0, + "k2": 2, + "IPIV": [ 2, 0, 1 ], + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], + "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], + "LDA": 3, + "incX": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js new file mode 100644 index 000000000000..154e3c91870d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js @@ -0,0 +1,195 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlaswp = require( './../lib/dlaswp.js' ); + + +// FIXTURES // + +var cao = require( './fixtures/column_major_ao.json' ); +var cat = require( './fixtures/column_major_at.json' ); +var ran = require( './fixtures/row_major_an.json' ); +var rao = require( './fixtures/row_major_ao.json' ); +var raolt = require( './fixtures/row_major_aolt.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlaswp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dlaswp.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + 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() { + dlaswp( value, cao.N, cao.A, cao.LDA, cao.k1, cao.k2, cao.IPIV, cao.incX ); + }; + } +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, incX=1)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( cao.A ); + IPIV = new Int32Array( cao.IPIV ); + + expected = new Float64Array( cao.A_out ); + + out = dlaswp( 'column-major', cao.N, A, cao.LDA, cao.k1, cao.k2, IPIV, cao.incX ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, incX=2)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( cat.A ); + IPIV = new Int32Array( cat.IPIV ); + + expected = new Float64Array( cat.A_out ); + + out = dlaswp( 'column-major', cat.N, A, cat.LDA, cat.k1, cat.k2, IPIV, cat.incX ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, incX=1)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( rao.A ); + IPIV = new Int32Array( rao.IPIV ); + + expected = new Float64Array( rao.A_out ); + + out = dlaswp( 'row-major', rao.N, A, rao.LDA, rao.k1, rao.k2, IPIV, rao.incX ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, incX=1, LDA=2)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( raolt.A ); + IPIV = new Int32Array( raolt.IPIV ); + + expected = new Float64Array( raolt.A_out ); + + out = dlaswp( 'row-major', raolt.N, A, raolt.LDA, raolt.k1, raolt.k2, IPIV, raolt.incX ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, incX=-1)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( ran.A ); + IPIV = new Int32Array( ran.IPIV ); + + expected = new Float64Array( ran.A_out ); + + out = dlaswp( 'row-major', ran.N, A, ran.LDA, ran.k1, ran.k2, IPIV, ran.incX ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.js new file mode 100644 index 000000000000..1ec45c20ca39 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.js @@ -0,0 +1,77 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dlaswp = 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 dlaswp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var dlaswp = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaswp, 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 dlaswp; + var main; + + main = require( './../lib/dlaswp.js' ); + + dlaswp = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaswp, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); From dccfcf84bfedef845ee0171d408f64107a3d53cb Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 14:54:50 +0530 Subject: [PATCH 19/60] chore: apply suggestion and replace incX with strideIPIV --- .../@stdlib/lapack/base/dlaswp/README.md | 4 ++-- .../@stdlib/lapack/base/dlaswp/docs/repl.txt | 6 ++--- .../@stdlib/lapack/base/dlaswp/lib/dlaswp.js | 18 +++++++-------- .../dlaswp/test/fixtures/column_major_ao.json | 2 +- .../dlaswp/test/fixtures/column_major_at.json | 2 +- .../dlaswp/test/fixtures/row_major_an.json | 2 +- .../dlaswp/test/fixtures/row_major_ao.json | 2 +- .../dlaswp/test/fixtures/row_major_aolt.json | 2 +- .../lapack/base/dlaswp/test/test.dlaswp.js | 22 +++++++++---------- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 4c34d218c014..980e969cbfb4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -30,7 +30,7 @@ limitations under the License. var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); ``` -#### dlaswp( N, A, LDA, k1, k2, IPIV, incX ) +#### dlaswp( N, A, LDA, k1, k2, IPIV, strideIPIV ) Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. @@ -54,7 +54,7 @@ The function has the following parameters: - **k1**: index of first row to interchange. - **k2**: index of last row to interchange. - **IPIV**: vector of pivot indices. -- **incX**: increment between successive values of `IPIV`. +- **strideIPIV**: index increment for `IPIV`. The increment parameters determine how elements in the IPIV array are accessed at runtime. For example, to iterate over the elements of `IPIV` in reverse order, diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt index 61fdf86d94c6..dfbe7bebb4e5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( order, N, A, LDA, k1, k2, IPIV, incX ) +{{alias}}( order, N, A, LDA, k1, k2, IPIV, strideIPIV ) Perform a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. @@ -33,8 +33,8 @@ IPIV: Int32Array Array of pivot indices. - incX: integer - Increment between pivot indices. + strideIPIV: integer + Index increment for `IPIV`. Returns ------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js index f7ed53561be4..26c0a53cd053 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js @@ -37,7 +37,7 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * @param {PositiveInteger} k1 - index of first row to interchange * @param {PositiveInteger} k2 - index of last row to interchange * @param {Int32Array} IPIV - vector of pivot indices -* @param {PositiveInteger} incX - increment between successive values of `IPIV` +* @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` * @throws {TypeError} first argument must be a valid order * @returns {Float64Array} permuted matrix `A` * @@ -51,7 +51,7 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); * // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] */ -function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { +function dlaswp( order, N, A, LDA, k1, k2, IPIV, strideIPIV ) { var inc; var ix0; var n32; @@ -68,13 +68,13 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); } - if ( incX > 0 ) { + if ( strideIPIV > 0 ) { ix0 = k1; i1 = k1; i2 = k2; inc = 1; - } else if ( incX < 0 ) { - ix0 = k1 + ( ( k1 - k2 ) * incX ); + } else if ( strideIPIV < 0 ) { + ix0 = k1 + ( ( k1 - k2 ) * strideIPIV ); i1 = k2; i2 = k1; inc = -1; @@ -90,7 +90,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { if ( ip !== k ) { dswap( LDA, A, 1, k * LDA, A, 1, ip * LDA ); } - ix += incX; + ix += strideIPIV; } return A; } @@ -99,7 +99,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { if ( ip !== k ) { dswap( LDA, A, 1, k * LDA, A, 1, ip * LDA ); } - ix += incX; + ix += strideIPIV; } return A; } @@ -116,7 +116,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; } } - ix += incX; + ix += strideIPIV; } } } @@ -132,7 +132,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incX ) { A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; } } - ix += incX; + ix += strideIPIV; } } return A; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json index b89455d70ed3..ea8386848c2c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json @@ -7,5 +7,5 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "A_out": [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ], "LDA": 2, - "incX": 1 + "strideIPIV": 1 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json index 7fd68f931b8e..2f01b44d38f4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json @@ -7,5 +7,5 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "A_out": [ 3.0, 2.0, 5.0, 4.0, 1.0, 6.0 ], "LDA": 2, - "incX": 2 + "strideIPIV": 2 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json index 6fd84931f604..38915a6afaeb 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json @@ -7,5 +7,5 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], "LDA": 3, - "incX": -1 + "strideIPIV": -1 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json index 209e17cc5762..5cf807cb65e5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json @@ -7,5 +7,5 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], "LDA": 2, - "incX": 1 + "strideIPIV": 1 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json index 12642d08dead..f72b62f063df 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json @@ -7,5 +7,5 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], "LDA": 3, - "incX": 1 + "strideIPIV": 1 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js index 154e3c91870d..151faadb5c62 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js @@ -99,12 +99,12 @@ tape( 'the function throws an error if provided an invalid first argument', func function badValue( value ) { return function badValue() { - dlaswp( value, cao.N, cao.A, cao.LDA, cao.k1, cao.k2, cao.IPIV, cao.incX ); + dlaswp( value, cao.N, cao.A, cao.LDA, cao.k1, cao.k2, cao.IPIV, cao.strideIPIV ); }; } }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, incX=1)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, strideIPIV=1)', function test( t ) { var expected; var IPIV; var out; @@ -115,14 +115,14 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( cao.A_out ); - out = dlaswp( 'column-major', cao.N, A, cao.LDA, cao.k1, cao.k2, IPIV, cao.incX ); + out = dlaswp( 'column-major', cao.N, A, cao.LDA, cao.k1, cao.k2, IPIV, cao.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, incX=2)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, strideIPIV=2)', function test( t ) { var expected; var IPIV; var out; @@ -133,14 +133,14 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( cat.A_out ); - out = dlaswp( 'column-major', cat.N, A, cat.LDA, cat.k1, cat.k2, IPIV, cat.incX ); + out = dlaswp( 'column-major', cat.N, A, cat.LDA, cat.k1, cat.k2, IPIV, cat.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, incX=1)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1)', function test( t ) { var expected; var IPIV; var out; @@ -151,14 +151,14 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( rao.A_out ); - out = dlaswp( 'row-major', rao.N, A, rao.LDA, rao.k1, rao.k2, IPIV, rao.incX ); + out = dlaswp( 'row-major', rao.N, A, rao.LDA, rao.k1, rao.k2, IPIV, rao.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, incX=1, LDA=2)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1, LDA=2)', function test( t ) { var expected; var IPIV; var out; @@ -169,14 +169,14 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( raolt.A_out ); - out = dlaswp( 'row-major', raolt.N, A, raolt.LDA, raolt.k1, raolt.k2, IPIV, raolt.incX ); + out = dlaswp( 'row-major', raolt.N, A, raolt.LDA, raolt.k1, raolt.k2, IPIV, raolt.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, incX=-1)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=-1)', function test( t ) { var expected; var IPIV; var out; @@ -187,7 +187,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( ran.A_out ); - out = dlaswp( 'row-major', ran.N, A, ran.LDA, ran.k1, ran.k2, IPIV, ran.incX ); + out = dlaswp( 'row-major', ran.N, A, ran.LDA, ran.k1, ran.k2, IPIV, ran.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); From d88b69b7ecb9eac789681803418a0206528f4a64 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 14:55:20 +0530 Subject: [PATCH 20/60] chore: apply suggestion in index.d.ts --- .../@stdlib/lapack/base/dlaswp/docs/types/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts index 2c76b54c584a..3b5e2e9a9af0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts @@ -36,7 +36,7 @@ interface Routine { * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange * @param IPIV - vector of pivot indices - * @param incX - increment between successive values of `IPIV` + * @param strideIPIV - `IPIV` stride length * @returns `A` * * @example @@ -62,7 +62,7 @@ interface Routine { * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange * @param IPIV - vector of pivot indices -* @param incX - increment between successive values of `IPIV` +* @param strideIPIV - `IPIV` stride length * @returns `A` * * @example From 6514e1212e84fceaef46d5ea9a993950c9dfb67f Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 16:32:22 +0530 Subject: [PATCH 21/60] chore: add all files --- .../@stdlib/lapack/base/dlaswp/README.md | 34 +++ .../lapack/base/dlaswp/benchmark/benchmark.js | 2 +- .../dlaswp/benchmark/benchmark.ndarray.js | 105 ++++++++ .../@stdlib/lapack/base/dlaswp/docs/repl.txt | 79 +++++- .../lapack/base/dlaswp/docs/types/index.d.ts | 44 +++- .../lapack/base/dlaswp/docs/types/test.ts | 142 +++++++++++ .../lapack/base/dlaswp/examples/index.js | 2 +- .../@stdlib/lapack/base/dlaswp/lib/base.js | 139 +++++++++++ .../@stdlib/lapack/base/dlaswp/lib/dlaswp.js | 91 +------ .../@stdlib/lapack/base/dlaswp/lib/index.js | 4 +- .../@stdlib/lapack/base/dlaswp/lib/main.js | 7 + .../@stdlib/lapack/base/dlaswp/lib/ndarray.js | 64 +++++ .../dlaswp/test/fixtures/column_major_ao.json | 3 +- .../dlaswp/test/fixtures/column_major_at.json | 3 +- .../test/fixtures/column_major_oat.json | 12 + .../dlaswp/test/fixtures/row_major_an.json | 3 +- .../dlaswp/test/fixtures/row_major_ao.json | 3 +- .../dlaswp/test/fixtures/row_major_aolt.json | 3 +- .../dlaswp/test/fixtures/row_major_oat.json | 12 + .../@stdlib/lapack/base/dlaswp/test/test.js | 5 + .../lapack/base/dlaswp/test/test.ndarray.js | 233 ++++++++++++++++++ 21 files changed, 890 insertions(+), 100 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 980e969cbfb4..4d1b3189ba37 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -89,6 +89,40 @@ dlaswp( 'column-major', 3, A1, 2, 0, 2, IPIV1, 1 ); // A1 => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] ``` +#### dlaswp.ndarray( order, N, A, oa, LDA, k1, k2, IPIV, sipiv ) + +Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var IPIV = new Int32Array( [ 2, 0, 1 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + +dlaswp.ndarray( 'row-major', 3, A, 3, 2, 0, 2, IPIV, 1 ); +console.log( A ); +// A => [ 1.0, 2.0, 3.0, 6.0, 7.0, 4.0, 5.0, 8.0, 9.0 ] +``` + +The function has the following additional parameters: + +- **oa**: starting index for `A`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var Int32Array = require( '@stdlib/array/int32' ); + +var IPIV = new Int32Array( [ 2, 0, 1 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + +dlaswp.ndarray( 'column-major', 3, A, 2, 2, 0, 2, IPIV, 1 ); +console.log( A ); +// A => [ 1.0, 2.0, 4.0, 5.0, 6.0, 7.0, 3.0, 8.0, 9.0 ] +``` + diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js index 75d564b134d6..442c4bc378fa 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js @@ -47,7 +47,7 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( N ) { - var IPIV = ones( N*N, 'int32' ); + var IPIV = ones( N, 'int32' ); var A = uniform( N, -10.0, 10.0, options ); return benchmark; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..e16edf0078a2 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dlaswp = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var IPIV = ones( N, 'int32' ); + var A = uniform( N, -10.0, 10.0, options ); + 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 = dlaswp( 'column-major', N, A, 0, N, 1, 1, IPIV, 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 N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt index dfbe7bebb4e5..88a08c186ae4 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -39,15 +39,92 @@ Returns ------- A: Float64Array - Output vector. + Output array. Examples -------- + // Standard usage: > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var ord = 'column-major'; > {{alias}}( ord, 3, A, 2, 0, 2, IPIV, 1 ) [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + // Advanced indexing: + > IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}( ord, 3, A, 2, 0, 2, IPIV, 2 ) + [ 3.0, 2.0, 5.0, 4.0, 1.0, 6.0 ] + + // Using typed array views: + > var IPIV0 = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); + > var A0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > IPIV = new Int32Array( IPIV0.buffer, IPIV0.byteOffset, IPIV0.length ); + > A = new Float64Array( A0.buffer, A0.byteOffset, A0.length ); + > {{alias}}( ord, 3, A, 2, 0, 2, IPIV, 1 ); + > A0 + [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + + +{{alias}}.ndarray( order, N, A, oa, LDA, k1, k2, IPIV, sipiv ) + + Performs a series of row interchanges on the matrix `A` using + pivot indices stored in `IPIV` and alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + N: integer + Number of columns of `A`. + + A: Float64Array + Matrix. + + oa: integer + Index offset for `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + k1: integer + Index of first row to interchange. + + k2: integer + Index of last row to interchange. + + IPIV: Int32Array + Array of pivot indices. + + sipiv: integer + Index increment for `IPIV`. + + Returns + ------- + A: Float64Array + Output array. + + Examples + -------- + // Standard usage: + > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var ord = 'column-major'; + > {{alias}}.ndarray( ord, 3, A, 0, 2, 0, 2, IPIV, 1 ) + [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + + // Advanced indexing: + > IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}.ndarray( ord, 3, A, 2, 2, 0, 2, IPIV, 1 ) + [ 7.0, 8.0, 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + See Also -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts index 3b5e2e9a9af0..d4b4b4e03b31 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts @@ -46,10 +46,36 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * - * dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); - * // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + * dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); + * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ ( order: Layout, N: number, A: Float64Array, LDA: number, k1: number, k2: number, IPIV: Int32Array, incX: number ): Float64Array; + + /** + * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. + * + * @param order - storage layout + * @param N - number of columns of `A` + * @param A - matrix + * @param offsetA - starting index for `A` + * @param LDA - leading dimension of `A` + * @param k1 - index of first row to interchange + * @param k2 - index of last row to interchange + * @param IPIV - vector of pivot indices + * @param strideIPIV - increment between successive values of `IPIV` + * @returns `A` + * + * @example + * var Int32Array = require( '@stdlib/array/int32' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var IPIV = new Int32Array( [ 2, 0, 1 ] ); + * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); + * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] + */ + ndarray( order: Layout, N: number, A: Float64Array, offsetA: number, LDA: number, k1: number, k2: number, IPIV: Int32Array, strideIPIV: number ): Float64Array; } /** @@ -72,8 +98,18 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); -* // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +* dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ declare var dlaswp: Routine; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts index dba8b37d04fc..17f0789bad81 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts @@ -146,3 +146,145 @@ import dlaswp = require( './index' ); dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, {} ); // $ExpectError dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, ( x: number ): number => x ); // $ExpectError } + +// Attached to main export is an `ndarray` method which returns a Float64Array... + +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 10, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( true, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( false, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( null, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( void 0, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( [], 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( {}, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( ( x: number ): number => x, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'column-major', '3', A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', true, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', false, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', null, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', void 0, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', [], A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', {}, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', ( x: number ): number => x, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const IPIV = new Int32Array( 3 ); + + dlaswp.ndarray( 'column-major', 3, 10, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, true, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, false, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, null, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, void 0, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, [], 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, {}, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, ( x: number ): number => x, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not an integer... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'column-major', 3, A, '0', 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, true, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, false, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, null, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, void 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, [], 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, {}, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, ( x: number ): number => x, 2, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not an integer... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'column-major', 3, A, 0, '2', 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, true, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, false, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, null, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, void 0, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, [], 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, {}, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, ( x: number ): number => x, 0, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not an integer... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'column-major', 3, A, 0, 2, '0', 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, true, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, false, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, null, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, void 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, [], 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, {}, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, ( x: number ): number => x, 2, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not an integer... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, '2', IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, true, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, false, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, null, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, void 0, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, [], IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, {}, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, ( x: number ): number => x, IPIV, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not an Int32Array... +{ + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, 'IPIV', 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, true, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, false, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, null, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, void 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, [], 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, {}, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, '1' ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, true ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, false ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, null ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, void 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, [] ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, {} ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, ( x: number ): number => x ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js index ce1b2aac76a9..ee94df4b08c0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js @@ -25,5 +25,5 @@ var dlaswp = require( './../lib' ); var IPIV = new Int32Array( [ 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); console.log( A ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js new file mode 100644 index 000000000000..886fad91859c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js @@ -0,0 +1,139 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var floor = require( '@stdlib/math/base/special/floor' ); +var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; + + +// MAIN // + +/** +* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +* +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of columns of `A` +* @param {Float64Array} A - matrix +* @param {PositiveInteger} offsetA - index offset for `A` +* @param {PositiveInteger} LDA - leading dimension of `A` +* @param {PositiveInteger} k1 - index of first row to interchange +* @param {PositiveInteger} k2 - index of last row to interchange +* @param {Int32Array} IPIV - vector of pivot indices +* @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` +* @returns {Float64Array} permuted matrix `A` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dlaswp( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +*/ +function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, strideIPIV ) { + var inc; + var ix0; + var n32; + var tmp; + var i2; + var ip; + var ix; + var i1; + var i; + var j; + var k; + + if ( strideIPIV > 0 ) { + ix0 = k1; + i1 = k1; + i2 = k2; + inc = 1; + } else if ( strideIPIV < 0 ) { + ix0 = k1 + ( ( k1 - k2 ) * strideIPIV ); + i1 = k2; + i2 = k1; + inc = -1; + } else { + return A; + } + + if ( order === 'row-major' ) { + ix = ix0; + if ( inc === 1 ) { + for ( k = i1; k <= i2; k++ ) { + ip = IPIV[ ix ]; + if ( ip !== k ) { + dswap( LDA, A, 1, offsetA + ( k * LDA ), A, 1, offsetA + ( ip * LDA ) ); // eslint-disable-line max-len + } + ix += strideIPIV; + } + return A; + } + for ( k = i1; k >= i2; k-- ) { + ip = IPIV[ ix ]; + if ( ip !== k ) { + dswap( LDA, A, 1, offsetA + ( k * LDA ), A, 1, offsetA + ( ip * LDA ) ); // eslint-disable-line max-len + } + ix += strideIPIV; + } + return A; + } + n32 = floor( N / 32 ) * 32; + if ( n32 !== 0 ) { + for ( j = 1; j < n32; j += 32 ) { + ix = ix0; + for ( i = i1; i < i2; i += inc ) { + ip = IPIV[ ix ]; + if ( ip !== i ) { + for ( k = j; k < j + 31; k++ ) { + tmp = A[ offsetA + ( ( k - 1 ) * LDA ) + i ]; + A[ offsetA + ( ( k - 1 ) * LDA ) + i ] = A[ offsetA + ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len + A[ offsetA + ( ( k - 1 ) * LDA ) + ip ] = tmp; + } + } + ix += strideIPIV; + } + } + } + if ( n32 !== N ) { + n32 += 1; + ix = ix0; + for ( i = i1; i < i2; i += inc ) { + ip = IPIV[ ix ]; + if ( ip !== i ) { + for ( k = n32; k < N; k++ ) { + tmp = A[ offsetA + ( ( k - 1 ) * LDA ) + i ]; + A[ offsetA + ( ( k - 1 ) * LDA ) + i ] = A[ offsetA + ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len + A[ offsetA + ( ( k - 1 ) * LDA ) + ip ] = tmp; + } + } + ix += strideIPIV; + } + } + return A; +} + + +// EXPORTS // + +module.exports = dlaswp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js index 26c0a53cd053..caf58419a784 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js @@ -21,8 +21,7 @@ // MODULES // var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); -var floor = require( '@stdlib/math/base/special/floor' ); -var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; +var base = require( './base.js' ); // MAIN // @@ -48,94 +47,14 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); -* // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +* dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ function dlaswp( order, N, A, LDA, k1, k2, IPIV, strideIPIV ) { - var inc; - var ix0; - var n32; - var tmp; - var i2; - var ip; - var ix; - var i1; - var i; - var j; - var k; - if ( !isLayout( order ) ) { - throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); - } - - if ( strideIPIV > 0 ) { - ix0 = k1; - i1 = k1; - i2 = k2; - inc = 1; - } else if ( strideIPIV < 0 ) { - ix0 = k1 + ( ( k1 - k2 ) * strideIPIV ); - i1 = k2; - i2 = k1; - inc = -1; - } else { - return A; - } - - if ( order === 'row-major' ) { - ix = ix0; - if ( inc === 1 ) { - for ( k = i1; k <= i2; k++ ) { - ip = IPIV[ ix ]; - if ( ip !== k ) { - dswap( LDA, A, 1, k * LDA, A, 1, ip * LDA ); - } - ix += strideIPIV; - } - return A; - } - for ( k = i1; k >= i2; k-- ) { - ip = IPIV[ ix ]; - if ( ip !== k ) { - dswap( LDA, A, 1, k * LDA, A, 1, ip * LDA ); - } - ix += strideIPIV; - } - return A; - } - n32 = floor( N / 32 ) * 32; - if ( n32 !== 0 ) { - for ( j = 1; j < n32; j += 32 ) { - ix = ix0; - for ( i = i1; i < i2; i += inc ) { - ip = IPIV[ ix ]; - if ( ip !== i ) { - for ( k = j; k < j + 31; k++ ) { - tmp = A[ ( ( k - 1 ) * LDA ) + i ]; - A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len - A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; - } - } - ix += strideIPIV; - } - } - } - if ( n32 !== N ) { - n32 += 1; - ix = ix0; - for ( i = i1; i < i2; i += inc ) { - ip = IPIV[ ix ]; - if ( ip !== i ) { - for ( k = n32; k < N; k++ ) { - tmp = A[ ( ( k - 1 ) * LDA ) + i ]; - A[ ( ( k - 1 ) * LDA ) + i ] = A[ ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len - A[ ( ( k - 1 ) * LDA ) + ip ] = tmp; - } - } - ix += strideIPIV; - } + throw new TypeError( 'invalid argument. Order argument must be a string indicating whether an array is row-major (i.e., order is `row-major`) or column-major (i.e., order is `column-major`).' ); } - return A; + return base( order, N, A, 0, LDA, k1, k2, IPIV, strideIPIV ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js index 57ad490bf0d2..4abd7195b1b5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js @@ -31,8 +31,8 @@ * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); -* // A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +* dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/main.js index 1c7105f7000c..9242b977d178 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/main.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/main.js @@ -20,7 +20,14 @@ // MODULES // +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); var dlaswp = require( './dlaswp.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlaswp, 'ndarray', ndarray ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js new file mode 100644 index 000000000000..f59c44dc4c80 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js @@ -0,0 +1,64 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +* +* @param {string} order - storage layout +* @param {PositiveInteger} N - number of columns of `A` +* @param {Float64Array} A - matrix +* @param {PositiveInteger} offsetA - index offset for `A` +* @param {PositiveInteger} LDA - leading dimension of `A` +* @param {PositiveInteger} k1 - index of first row to interchange +* @param {PositiveInteger} k2 - index of last row to interchange +* @param {Int32Array} IPIV - vector of pivot indices +* @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` +* @throws {TypeError} first argument must be a valid order +* @returns {Float64Array} permuted matrix `A` +* +* @example +* var Int32Array = require( '@stdlib/array/int32' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var IPIV = new Int32Array( [ 2, 0, 1 ] ); +* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* +* dlaswp( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); +* // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +*/ +function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, strideIPIV ) { + if ( !isLayout( order ) ) { + throw new TypeError( 'invalid argument. Order argument must be a string indicating whether an array is row-major (i.e., order is `row-major`) or column-major (i.e., order is `column-major`).' ); + } + return base( order, N, A, offsetA, LDA, k1, k2, IPIV, strideIPIV ); +} + + +// EXPORTS // + +module.exports = dlaswp; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json index ea8386848c2c..74d9a298fc83 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json @@ -7,5 +7,6 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "A_out": [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ], "LDA": 2, - "strideIPIV": 1 + "strideIPIV": 1, + "offsetA": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json index 2f01b44d38f4..d31dd9728a74 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json @@ -7,5 +7,6 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "A_out": [ 3.0, 2.0, 5.0, 4.0, 1.0, 6.0 ], "LDA": 2, - "strideIPIV": 2 + "strideIPIV": 2, + "offsetA": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json new file mode 100644 index 000000000000..64515e48bd08 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json @@ -0,0 +1,12 @@ +{ + "order": "column-major", + "N": 3, + "k1": 0, + "k2": 2, + "IPIV": [ 2, 0, 1 ], + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], + "A_out": [ 1.0, 2.0, 4.0, 5.0, 6.0, 7.0, 3.0, 8.0 ], + "LDA": 2, + "strideIPIV": 1, + "offsetA": 2 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json index 38915a6afaeb..8ac1b0031ea0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json @@ -7,5 +7,6 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], "LDA": 3, - "strideIPIV": -1 + "strideIPIV": -1, + "offsetA": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json index 5cf807cb65e5..a8234a0150ab 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json @@ -7,5 +7,6 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], "LDA": 2, - "strideIPIV": 1 + "strideIPIV": 1, + "offsetA": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json index f72b62f063df..39951bed8a4e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json @@ -7,5 +7,6 @@ "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], "LDA": 3, - "strideIPIV": 1 + "strideIPIV": 1, + "offsetA": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json new file mode 100644 index 000000000000..090bacd54738 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json @@ -0,0 +1,12 @@ +{ + "order": "row-major", + "N": 3, + "k1": 0, + "k2": 2, + "IPIV": [ 2, 0, 1 ], + "A": [ 7.0, 8.0, 9.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_out": [ 7.0, 8.0, 9.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], + "LDA": 2, + "strideIPIV": 1, + "offsetA": 3 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.js index 1ec45c20ca39..a4f921c14c58 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.js @@ -41,6 +41,11 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof dlaswp.ndarray, 'function', 'method is a function' ); + t.end(); +}); + tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { var dlaswp = proxyquire( './../lib', { '@stdlib/utils/try-require': tryRequire diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js new file mode 100644 index 000000000000..f8f14b363732 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -0,0 +1,233 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlaswp = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var cao = require( './fixtures/column_major_ao.json' ); +var cat = require( './fixtures/column_major_at.json' ); +var coat = require( './fixtures/column_major_oat.json' ); +var ran = require( './fixtures/row_major_an.json' ); +var rao = require( './fixtures/row_major_ao.json' ); +var roat = require( './fixtures/row_major_oat.json' ); +var raolt = require( './fixtures/row_major_aolt.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dlaswp, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( dlaswp.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + 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() { + dlaswp( value, cao.N, cao.A, cao.offsetA, cao.LDA, cao.k1, cao.k2, cao.IPIV, cao.strideIPIV ); + }; + } +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, strideIPIV=1)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( cao.A ); + IPIV = new Int32Array( cao.IPIV ); + + expected = new Float64Array( cao.A_out ); + + out = dlaswp( cao.order, cao.N, A, cao.offsetA, cao.LDA, cao.k1, cao.k2, IPIV, cao.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, strideIPIV=2)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( cat.A ); + IPIV = new Int32Array( cat.IPIV ); + + expected = new Float64Array( cat.A_out ); + + out = dlaswp( cat.order, cat.N, A, cat.offsetA, cat.LDA, cat.k1, cat.k2, IPIV, cat.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( rao.A ); + IPIV = new Int32Array( rao.IPIV ); + + expected = new Float64Array( rao.A_out ); + + out = dlaswp( rao.order, rao.N, A, rao.offsetA, rao.LDA, rao.k1, rao.k2, IPIV, rao.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1, LDA=2)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( raolt.A ); + IPIV = new Int32Array( raolt.IPIV ); + + expected = new Float64Array( raolt.A_out ); + + out = dlaswp( raolt.order, raolt.N, A, raolt.offsetA, raolt.LDA, raolt.k1, raolt.k2, IPIV, raolt.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=-1)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( ran.A ); + IPIV = new Int32Array( ran.IPIV ); + + expected = new Float64Array( ran.A_out ); + + out = dlaswp( ran.order, ran.N, A, ran.offsetA, ran.LDA, ran.k1, ran.k2, IPIV, ran.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1, offsetA=3)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( roat.A ); + IPIV = new Int32Array( roat.IPIV ); + + expected = new Float64Array( roat.A_out ); + + out = dlaswp( roat.order, roat.N, A, roat.offsetA, roat.LDA, roat.k1, roat.k2, IPIV, roat.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (column-major, strideIPIV=1, offsetA=2)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( coat.A ); + IPIV = new Int32Array( coat.IPIV ); + + expected = new Float64Array( coat.A_out ); + + out = dlaswp( coat.order, coat.N, A, coat.offsetA, coat.LDA, coat.k1, coat.k2, IPIV, coat.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); From 486985fc09c06132c676ea5484e2dd88d5271569 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 16:35:29 +0530 Subject: [PATCH 22/60] chore: show sipiv instead of strideIPIV in readme and repl --- lib/node_modules/@stdlib/lapack/base/dlaswp/README.md | 4 ++-- lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 4d1b3189ba37..69a9b9ca45d3 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -30,7 +30,7 @@ limitations under the License. var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); ``` -#### dlaswp( N, A, LDA, k1, k2, IPIV, strideIPIV ) +#### dlaswp( N, A, LDA, k1, k2, IPIV, sipiv ) Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. @@ -54,7 +54,7 @@ The function has the following parameters: - **k1**: index of first row to interchange. - **k2**: index of last row to interchange. - **IPIV**: vector of pivot indices. -- **strideIPIV**: index increment for `IPIV`. +- **sipiv**: index increment for `IPIV`. The increment parameters determine how elements in the IPIV array are accessed at runtime. For example, to iterate over the elements of `IPIV` in reverse order, diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt index 88a08c186ae4..7f9d99c230f0 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( order, N, A, LDA, k1, k2, IPIV, strideIPIV ) +{{alias}}( order, N, A, LDA, k1, k2, IPIV, sipiv ) Perform a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. @@ -33,7 +33,7 @@ IPIV: Int32Array Array of pivot indices. - strideIPIV: integer + sipiv: integer Index increment for `IPIV`. Returns From 01237eb72596b3f706581232c808335c5a7f72fa Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Mon, 1 Jul 2024 16:39:29 +0530 Subject: [PATCH 23/60] chore: apply code review --- lib/node_modules/@stdlib/lapack/base/dlaswp/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 69a9b9ca45d3..b198246e32af 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -65,8 +65,8 @@ var Float64Array = require( '@stdlib/array/float64' ); var IPIV = new Int32Array( [ 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); -// A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 2 ); +// A => [ 3.0, 2.0, 5.0, 4.0, 1.0, 6.0 ] ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. From 2a0cf83223c8a8f084f29dbb0a961317cb9e4228 Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:53:38 +0530 Subject: [PATCH 24/60] chore: apply code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- .../@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js index e16edf0078a2..98ff94574ee2 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js @@ -98,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); f = createBenchmark( N ); - bench( pkg+':size='+(N*N), f ); + bench( pkg+':ndarray:size='+(N*N), f ); } } From 1cb1206aa271412c1db64d56bed4822e4b9afcab Mon Sep 17 00:00:00 2001 From: Pranav <85227306+Pranavchiku@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:55:11 +0530 Subject: [PATCH 25/60] chore: apply suggestions from code review Signed-off-by: Pranav <85227306+Pranavchiku@users.noreply.github.com> --- lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt | 5 ++--- .../@stdlib/lapack/base/dlaswp/docs/types/index.d.ts | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt index 7f9d99c230f0..8052cc9bd6f2 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -1,12 +1,12 @@ {{alias}}( order, N, A, LDA, k1, k2, IPIV, sipiv ) - Perform a series of row interchanges on the matrix `A` using + Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. Indexing is relative to the first index. To introduce an offset, use typed array views. - If `N` is equal to `0`, the function returns `y` unchanged. + If `N` is equal to `0`, the function returns `A` unchanged. Parameters ---------- @@ -67,7 +67,6 @@ {{alias}}.ndarray( order, N, A, oa, LDA, k1, k2, IPIV, sipiv ) - Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts index d4b4b4e03b31..5654babdce6d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts @@ -72,7 +72,7 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * - * dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); + * dlaswp.ndarray( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ ndarray( order: Layout, N: number, A: Float64Array, offsetA: number, LDA: number, k1: number, k2: number, IPIV: Int32Array, strideIPIV: number ): Float64Array; @@ -108,7 +108,7 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); +* dlaswp.ndarray( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ declare var dlaswp: Routine; From 3a6dc5c67e22b03dad399e21c8f303a6f2ea48df Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 09:15:29 +0530 Subject: [PATCH 26/60] test: update incorrect description --- .../@stdlib/lapack/base/dlaswp/test/test.dlaswp.js | 10 +++++----- .../lapack/base/dlaswp/test/test.ndarray.js | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js index 151faadb5c62..e47d6023ef3d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js @@ -104,7 +104,7 @@ tape( 'the function throws an error if provided an invalid first argument', func } }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, strideIPIV=1)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=1)', function test( t ) { var expected; var IPIV; var out; @@ -122,7 +122,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, strideIPIV=2)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=2)', function test( t ) { var expected; var IPIV; var out; @@ -140,7 +140,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1)', function test( t ) { var expected; var IPIV; var out; @@ -158,7 +158,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1, LDA=2)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1, LDA=2)', function test( t ) { var expected; var IPIV; var out; @@ -176,7 +176,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=-1)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=-1)', function test( t ) { var expected; var IPIV; var out; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index f8f14b363732..822aacec72ca 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -106,7 +106,7 @@ tape( 'the function throws an error if provided an invalid first argument', func } }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, strideIPIV=1)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=1)', function test( t ) { var expected; var IPIV; var out; @@ -124,7 +124,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix supplied in packed form (column-major, strideIPIV=2)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=2)', function test( t ) { var expected; var IPIV; var out; @@ -142,7 +142,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1)', function test( t ) { var expected; var IPIV; var out; @@ -160,7 +160,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1, LDA=2)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1, LDA=2)', function test( t ) { var expected; var IPIV; var out; @@ -178,7 +178,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=-1)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=-1)', function test( t ) { var expected; var IPIV; var out; @@ -196,7 +196,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (row-major, strideIPIV=1, offsetA=3)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1, offsetA=3)', function test( t ) { var expected; var IPIV; var out; @@ -214,7 +214,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix supplied in packed form (column-major, strideIPIV=1, offsetA=2)', function test( t ) { +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (column-major, strideIPIV=1, offsetA=2)', function test( t ) { var expected; var IPIV; var out; From 62e1af997af8c5d46d6d92a85ff937996c2a309f Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 09:17:19 +0530 Subject: [PATCH 27/60] chore: update base.js description --- lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js index 886fad91859c..acd1a0e0d785 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js @@ -98,6 +98,7 @@ function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, strideIPIV ) { } return A; } + // order === 'column-major' n32 = floor( N / 32 ) * 32; if ( n32 !== 0 ) { for ( j = 1; j < n32; j += 32 ) { From 1a9131408f5ee11bbbb83b846cba583f2440efa5 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 09:20:03 +0530 Subject: [PATCH 28/60] chore: link to LAPACK doc in readme --- lib/node_modules/@stdlib/lapack/base/dlaswp/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index b198246e32af..4e3f2cf3c0c5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -131,7 +131,7 @@ console.log( A ); ## Notes -- `dlaswp()` is a LAPACK routine. +- `dlaswp()` is a [LAPACK][lapack] routine. @@ -241,6 +241,8 @@ TODO From 8610f1a124595d62dcb9bc9c658ad386eb508511 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 09:21:19 +0530 Subject: [PATCH 29/60] chore: update package level description --- lib/node_modules/@stdlib/lapack/base/dlaswp/README.md | 4 ++-- lib/node_modules/@stdlib/lapack/base/dlaswp/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 4e3f2cf3c0c5..1b6b5a63848b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -20,7 +20,7 @@ limitations under the License. # dsymv -> Perform a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +> Perform a series of row interchanges on an input matrix.
@@ -32,7 +32,7 @@ var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); #### dlaswp( N, A, LDA, k1, k2, IPIV, sipiv ) -Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +Perform a series of row interchanges on an input matrix. ```javascript var Int32Array = require( '@stdlib/array/int32' ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json index a87b6f28f597..20a1a70a0331 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/lapack/base/dlaswp", "version": "0.0.0", - "description": "Perform a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`.", + "description": "Perform a series of row interchanges on an input matrix.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From a336167b716251a23812e2614f7165ef38b63293 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 2 Jul 2024 09:50:08 +0530 Subject: [PATCH 30/60] chore: introduce offsetIPIV and consequent changes --- .../@stdlib/lapack/base/dlaswp/README.md | 9 +- .../dlaswp/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/lapack/base/dlaswp/docs/repl.txt | 9 +- .../lapack/base/dlaswp/docs/types/index.d.ts | 8 +- .../lapack/base/dlaswp/docs/types/test.ts | 161 ++++++++++-------- .../@stdlib/lapack/base/dlaswp/lib/base.js | 9 +- .../@stdlib/lapack/base/dlaswp/lib/dlaswp.js | 2 +- .../@stdlib/lapack/base/dlaswp/lib/ndarray.js | 7 +- .../dlaswp/test/fixtures/column_major_ao.json | 3 +- .../test/fixtures/column_major_aoit.json | 13 ++ .../dlaswp/test/fixtures/column_major_at.json | 3 +- .../test/fixtures/column_major_oat.json | 3 +- .../dlaswp/test/fixtures/row_major_an.json | 3 +- .../dlaswp/test/fixtures/row_major_ao.json | 3 +- .../dlaswp/test/fixtures/row_major_aoio.json | 13 ++ .../dlaswp/test/fixtures/row_major_aolt.json | 3 +- .../dlaswp/test/fixtures/row_major_oat.json | 3 +- .../lapack/base/dlaswp/test/test.ndarray.js | 58 +++++-- 18 files changed, 203 insertions(+), 109 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_aoit.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aoio.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 1b6b5a63848b..7a1be166772d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -89,7 +89,7 @@ dlaswp( 'column-major', 3, A1, 2, 0, 2, IPIV1, 1 ); // A1 => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] ``` -#### dlaswp.ndarray( order, N, A, oa, LDA, k1, k2, IPIV, sipiv ) +#### dlaswp.ndarray( order, N, A, oa, LDA, k1, k2, IPIV, oipiv, sipiv ) Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. @@ -100,7 +100,7 @@ var Int32Array = require( '@stdlib/array/int32' ); var IPIV = new Int32Array( [ 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); -dlaswp.ndarray( 'row-major', 3, A, 3, 2, 0, 2, IPIV, 1 ); +dlaswp.ndarray( 'row-major', 3, A, 3, 2, 0, 2, IPIV, 0, 1 ); console.log( A ); // A => [ 1.0, 2.0, 3.0, 6.0, 7.0, 4.0, 5.0, 8.0, 9.0 ] ``` @@ -108,6 +108,7 @@ console.log( A ); The function has the following additional parameters: - **oa**: starting index for `A`. +- **oipiv**: starting index for `IPIV`. While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, @@ -115,10 +116,10 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); -var IPIV = new Int32Array( [ 2, 0, 1 ] ); +var IPIV = new Int32Array( [ 1, 0, 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); -dlaswp.ndarray( 'column-major', 3, A, 2, 2, 0, 2, IPIV, 1 ); +dlaswp.ndarray( 'column-major', 3, A, 2, 2, 0, 2, IPIV, 2, 1 ); console.log( A ); // A => [ 1.0, 2.0, 4.0, 5.0, 6.0, 7.0, 3.0, 8.0, 9.0 ] ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js index 98ff94574ee2..ef625167c98e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js @@ -63,7 +63,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, 0, N, 1, 1, IPIV, 1 ); + z = dlaswp( 'column-major', N, A, 0, N, 1, 1, IPIV, 0, 1 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt index 8052cc9bd6f2..f02d64de042c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -66,7 +66,7 @@ [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] -{{alias}}.ndarray( order, N, A, oa, LDA, k1, k2, IPIV, sipiv ) +{{alias}}.ndarray( order, N, A, oa, LDA, k1, k2, IPIV, oipiv, sipiv ) Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. @@ -102,6 +102,9 @@ IPIV: Int32Array Array of pivot indices. + oipiv: integer + Index offset for `IPIV`. + sipiv: integer Index increment for `IPIV`. @@ -116,13 +119,13 @@ > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var ord = 'column-major'; - > {{alias}}.ndarray( ord, 3, A, 0, 2, 0, 2, IPIV, 1 ) + > {{alias}}.ndarray( ord, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ) [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] // Advanced indexing: > IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); > A = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}.ndarray( ord, 3, A, 2, 2, 0, 2, IPIV, 1 ) + > {{alias}}.ndarray( ord, 3, A, 2, 2, 0, 2, IPIV, 0, 1 ) [ 7.0, 8.0, 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] See Also diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts index 5654babdce6d..9885a62f2d4f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts @@ -62,6 +62,7 @@ interface Routine { * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange * @param IPIV - vector of pivot indices + * @param offsetIPIV - starting index for `IPIV` * @param strideIPIV - increment between successive values of `IPIV` * @returns `A` * @@ -72,10 +73,10 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * - * dlaswp.ndarray( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); + * dlaswp.ndarray( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ - ndarray( order: Layout, N: number, A: Float64Array, offsetA: number, LDA: number, k1: number, k2: number, IPIV: Int32Array, strideIPIV: number ): Float64Array; + ndarray( order: Layout, N: number, A: Float64Array, offsetA: number, LDA: number, k1: number, k2: number, IPIV: Int32Array, offsetIPIV: number, strideIPIV: number ): Float64Array; } /** @@ -88,6 +89,7 @@ interface Routine { * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange * @param IPIV - vector of pivot indices +* @param offsetIPIV - starting index for `IPIV` * @param strideIPIV - `IPIV` stride length * @returns `A` * @@ -108,7 +110,7 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* dlaswp.ndarray( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); +* dlaswp.ndarray( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ declare var dlaswp: Routine; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts index 17f0789bad81..7c820a9de0ca 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts @@ -153,7 +153,7 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectType Float64Array + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectType Float64Array } // The compiler throws an error if the function is provided a first argument which is not a string... @@ -161,14 +161,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 10, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( true, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( false, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( null, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( void 0, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( [], 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( {}, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( ( x: number ): number => x, 3, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 10, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( true, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( false, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( null, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( void 0, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( [], 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( {}, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( ( x: number ): number => x, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -176,28 +176,28 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', '3', A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', true, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', false, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', null, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', void 0, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', [], A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', {}, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', ( x: number ): number => x, A, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', '3', A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', true, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', false, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', null, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', void 0, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', [], A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', {}, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', ( x: number ): number => x, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... { const IPIV = new Int32Array( 3 ); - dlaswp.ndarray( 'column-major', 3, 10, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, true, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, false, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, null, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, void 0, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, [], 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, {}, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, ( x: number ): number => x, 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, 10, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, true, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, false, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, null, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, void 0, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, [], 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, {}, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, ( x: number ): number => x, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not an integer... @@ -205,14 +205,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, '0', 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, true, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, false, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, null, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, void 0, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, [], 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, {}, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, ( x: number ): number => x, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, '0', 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, true, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, false, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, null, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, void 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, [], 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, {}, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, ( x: number ): number => x, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not an integer... @@ -220,14 +220,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, '2', 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, true, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, false, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, null, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, void 0, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, [], 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, {}, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, ( x: number ): number => x, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, '2', 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, true, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, false, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, null, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, void 0, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, [], 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, {}, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, ( x: number ): number => x, 0, 2, IPIV, 0, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not an integer... @@ -235,14 +235,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, '0', 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, true, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, false, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, null, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, void 0, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, [], 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, {}, 2, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, ( x: number ): number => x, 2, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, '0', 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, true, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, false, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, null, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, void 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, [], 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, {}, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, ( x: number ): number => x, 2, IPIV, 0, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not an integer... @@ -250,28 +250,28 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, '2', IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, true, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, false, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, null, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, void 0, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, [], IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, {}, IPIV, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, ( x: number ): number => x, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, '2', IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, true, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, false, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, null, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, void 0, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, [], IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, {}, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, ( x: number ): number => x, IPIV, 0, 1 ); // $ExpectError } // The compiler throws an error if the function is provided an eighth argument which is not an Int32Array... { const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, 'IPIV', 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, true, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, false, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, null, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, void 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, [], 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, {}, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, ( x: number ): number => x, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, 'IPIV', 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, true, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, false, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, null, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, void 0, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, [], 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, {}, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, ( x: number ): number => x, 0, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a ninth argument which is not a number... @@ -279,12 +279,27 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, '1' ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, true ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, false ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, null ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, void 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, [] ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, {} ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, ( x: number ): number => x ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, '1', 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, true, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, false, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, null, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, void 0, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, [], 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, {}, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, '1' ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, true ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, false ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, null ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, void 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, [] ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, {} ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, ( x: number ): number => x ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js index acd1a0e0d785..9abfb8900a9d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js @@ -37,6 +37,7 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * @param {PositiveInteger} k1 - index of first row to interchange * @param {PositiveInteger} k2 - index of last row to interchange * @param {Int32Array} IPIV - vector of pivot indices +* @param {PositiveInteger} offsetIPIV - index offset for `IPIV` * @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` * @returns {Float64Array} permuted matrix `A` * @@ -47,10 +48,10 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* dlaswp( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); +* dlaswp( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ -function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, strideIPIV ) { +function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, offsetIPIV, strideIPIV ) { // eslint-disable-line max-len var inc; var ix0; var n32; @@ -64,12 +65,12 @@ function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, strideIPIV ) { var k; if ( strideIPIV > 0 ) { - ix0 = k1; + ix0 = k1 + offsetIPIV; i1 = k1; i2 = k2; inc = 1; } else if ( strideIPIV < 0 ) { - ix0 = k1 + ( ( k1 - k2 ) * strideIPIV ); + ix0 = k1 + ( ( k1 - k2 ) * strideIPIV ) + offsetIPIV; i1 = k2; i2 = k1; inc = -1; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js index caf58419a784..2a06fd788770 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js @@ -54,7 +54,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, strideIPIV ) { if ( !isLayout( order ) ) { throw new TypeError( 'invalid argument. Order argument must be a string indicating whether an array is row-major (i.e., order is `row-major`) or column-major (i.e., order is `column-major`).' ); } - return base( order, N, A, 0, LDA, k1, k2, IPIV, strideIPIV ); + return base( order, N, A, 0, LDA, k1, k2, IPIV, 0, strideIPIV ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js index f59c44dc4c80..20a2417f132f 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js @@ -37,6 +37,7 @@ var base = require( './base.js' ); * @param {PositiveInteger} k1 - index of first row to interchange * @param {PositiveInteger} k2 - index of last row to interchange * @param {Int32Array} IPIV - vector of pivot indices +* @param {PositiveInteger} offsetIPIV - index offset for `IPIV` * @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` * @throws {TypeError} first argument must be a valid order * @returns {Float64Array} permuted matrix `A` @@ -48,14 +49,14 @@ var base = require( './base.js' ); * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* dlaswp( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 1 ); +* dlaswp( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ -function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, strideIPIV ) { +function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, offsetIPIV, strideIPIV ) { // eslint-disable-line max-len if ( !isLayout( order ) ) { throw new TypeError( 'invalid argument. Order argument must be a string indicating whether an array is row-major (i.e., order is `row-major`) or column-major (i.e., order is `column-major`).' ); } - return base( order, N, A, offsetA, LDA, k1, k2, IPIV, strideIPIV ); + return base( order, N, A, offsetA, LDA, k1, k2, IPIV, offsetIPIV, strideIPIV ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json index 74d9a298fc83..59cf8bdb1cc1 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json @@ -8,5 +8,6 @@ "A_out": [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ], "LDA": 2, "strideIPIV": 1, - "offsetA": 0 + "offsetA": 0, + "offsetIPIV": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_aoit.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_aoit.json new file mode 100644 index 000000000000..da4de0126156 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_aoit.json @@ -0,0 +1,13 @@ +{ + "order": "column-major", + "N": 3, + "k1": 0, + "k2": 2, + "IPIV": [ 3, 4, 2, 0, 1 ], + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_out": [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ], + "LDA": 2, + "strideIPIV": 1, + "offsetA": 0, + "offsetIPIV": 2 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json index d31dd9728a74..b2782b315bbb 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json @@ -8,5 +8,6 @@ "A_out": [ 3.0, 2.0, 5.0, 4.0, 1.0, 6.0 ], "LDA": 2, "strideIPIV": 2, - "offsetA": 0 + "offsetA": 0, + "offsetIPIV": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json index 64515e48bd08..fcba5c3f8c28 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json @@ -8,5 +8,6 @@ "A_out": [ 1.0, 2.0, 4.0, 5.0, 6.0, 7.0, 3.0, 8.0 ], "LDA": 2, "strideIPIV": 1, - "offsetA": 2 + "offsetA": 2, + "offsetIPIV": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json index 8ac1b0031ea0..6e264b252787 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json @@ -8,5 +8,6 @@ "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], "LDA": 3, "strideIPIV": -1, - "offsetA": 0 + "offsetA": 0, + "offsetIPIV": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json index a8234a0150ab..51a78f79b50b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json @@ -8,5 +8,6 @@ "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], "LDA": 2, "strideIPIV": 1, - "offsetA": 0 + "offsetA": 0, + "offsetIPIV": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aoio.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aoio.json new file mode 100644 index 000000000000..3020f2384c16 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aoio.json @@ -0,0 +1,13 @@ +{ + "order": "row-major", + "N": 3, + "k1": 0, + "k2": 2, + "IPIV": [ 3, 2, 0, 1 ], + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], + "LDA": 2, + "strideIPIV": 1, + "offsetA": 0, + "offsetIPIV": 1 +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json index 39951bed8a4e..2d0256eed93c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json @@ -8,5 +8,6 @@ "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], "LDA": 3, "strideIPIV": 1, - "offsetA": 0 + "offsetA": 0, + "offsetIPIV": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json index 090bacd54738..78f686ebad24 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json @@ -8,5 +8,6 @@ "A_out": [ 7.0, 8.0, 9.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], "LDA": 2, "strideIPIV": 1, - "offsetA": 3 + "offsetA": 3, + "offsetIPIV": 0 } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index 822aacec72ca..8bd186ca27fe 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -35,10 +35,12 @@ var dlaswp = require( './../lib/ndarray.js' ); var cao = require( './fixtures/column_major_ao.json' ); var cat = require( './fixtures/column_major_at.json' ); var coat = require( './fixtures/column_major_oat.json' ); +var caoit = require( './fixtures/column_major_aoit.json' ); var ran = require( './fixtures/row_major_an.json' ); var rao = require( './fixtures/row_major_ao.json' ); var roat = require( './fixtures/row_major_oat.json' ); var raolt = require( './fixtures/row_major_aolt.json' ); +var raoio = require( './fixtures/row_major_aoio.json' ); // FUNCTIONS // @@ -78,8 +80,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 9', function test( t ) { - t.strictEqual( dlaswp.length, 9, 'returns expected value' ); +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dlaswp.length, 10, 'returns expected value' ); t.end(); }); @@ -101,7 +103,7 @@ tape( 'the function throws an error if provided an invalid first argument', func function badValue( value ) { return function badValue() { - dlaswp( value, cao.N, cao.A, cao.offsetA, cao.LDA, cao.k1, cao.k2, cao.IPIV, cao.strideIPIV ); + dlaswp( value, cao.N, cao.A, cao.offsetA, cao.LDA, cao.k1, cao.k2, cao.IPIV, cao.offsetIPIV, cao.strideIPIV ); }; } }); @@ -117,7 +119,25 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( cao.A_out ); - out = dlaswp( cao.order, cao.N, A, cao.offsetA, cao.LDA, cao.k1, cao.k2, IPIV, cao.strideIPIV ); + out = dlaswp( cao.order, cao.N, A, cao.offsetA, cao.LDA, cao.k1, cao.k2, IPIV, cao.offsetIPIV, cao.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=1, offsetIPIV=2)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( caoit.A ); + IPIV = new Int32Array( caoit.IPIV ); + + expected = new Float64Array( caoit.A_out ); + + out = dlaswp( caoit.order, caoit.N, A, caoit.offsetA, caoit.LDA, caoit.k1, caoit.k2, IPIV, caoit.offsetIPIV, caoit.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -135,7 +155,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( cat.A_out ); - out = dlaswp( cat.order, cat.N, A, cat.offsetA, cat.LDA, cat.k1, cat.k2, IPIV, cat.strideIPIV ); + out = dlaswp( cat.order, cat.N, A, cat.offsetA, cat.LDA, cat.k1, cat.k2, IPIV, cat.offsetIPIV, cat.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -153,7 +173,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( rao.A_out ); - out = dlaswp( rao.order, rao.N, A, rao.offsetA, rao.LDA, rao.k1, rao.k2, IPIV, rao.strideIPIV ); + out = dlaswp( rao.order, rao.N, A, rao.offsetA, rao.LDA, rao.k1, rao.k2, IPIV, rao.offsetIPIV, rao.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -171,7 +191,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( raolt.A_out ); - out = dlaswp( raolt.order, raolt.N, A, raolt.offsetA, raolt.LDA, raolt.k1, raolt.k2, IPIV, raolt.strideIPIV ); + out = dlaswp( raolt.order, raolt.N, A, raolt.offsetA, raolt.LDA, raolt.k1, raolt.k2, IPIV, raolt.offsetIPIV, raolt.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -189,7 +209,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( ran.A_out ); - out = dlaswp( ran.order, ran.N, A, ran.offsetA, ran.LDA, ran.k1, ran.k2, IPIV, ran.strideIPIV ); + out = dlaswp( ran.order, ran.N, A, ran.offsetA, ran.LDA, ran.k1, ran.k2, IPIV, ran.offsetIPIV, ran.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -207,7 +227,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( roat.A_out ); - out = dlaswp( roat.order, roat.N, A, roat.offsetA, roat.LDA, roat.k1, roat.k2, IPIV, roat.strideIPIV ); + out = dlaswp( roat.order, roat.N, A, roat.offsetA, roat.LDA, roat.k1, roat.k2, IPIV, roat.offsetIPIV, roat.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -225,7 +245,25 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( coat.A_out ); - out = dlaswp( coat.order, coat.N, A, coat.offsetA, coat.LDA, coat.k1, coat.k2, IPIV, coat.strideIPIV ); + out = dlaswp( coat.order, coat.N, A, coat.offsetA, coat.LDA, coat.k1, coat.k2, IPIV, coat.offsetIPIV, coat.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1, offsetIPIV=1)', function test( t ) { + var expected; + var IPIV; + var out; + var A; + + A = new Float64Array( raoio.A ); + IPIV = new Int32Array( raoio.IPIV ); + + expected = new Float64Array( raoio.A_out ); + + out = dlaswp( raoio.order, raoio.N, A, raoio.offsetA, raoio.LDA, raoio.k1, raoio.k2, IPIV, raoio.offsetIPIV, raoio.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); From d2507ac45127c5bf125f1a7d47753551c0748c91 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 3 Jul 2024 02:06:04 -0700 Subject: [PATCH 31/60] bench: update data generation --- .../lapack/base/dlaswp/benchmark/benchmark.js | 24 +++++++++---------- .../dlaswp/benchmark/benchmark.ndarray.js | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js index 442c4bc378fa..22929031719b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js @@ -22,21 +22,14 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var ones = require( '@stdlib/array/ones' ); var pow = require( '@stdlib/math/base/special/pow' ); var floor = require( '@stdlib/math/base/special/floor' ); var pkg = require( './../package.json' ).name; var dlaswp = require( './../lib/dlaswp.js' ); -// VARIABLES // - -var options = { - 'dtype': 'float64' -}; - - // FUNCTIONS // /** @@ -47,8 +40,15 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( N ) { - var IPIV = ones( N, 'int32' ); - var A = uniform( N, -10.0, 10.0, options ); + var IPIV; + var A; + + IPIV = discreteUniform( 5, 0, N-1, { + 'dtype': 'int32' + }); + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); return benchmark; /** @@ -63,7 +63,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, N, 1, 1, IPIV, 1 ); + z = dlaswp( 'column-major', N, A, N, 0, IPIV.length-1, IPIV, 1 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } @@ -98,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); f = createBenchmark( N ); - bench( pkg+':size='+(N*N), f ); + bench( pkg+':order=column-major,size='+(N*N), f ); } } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js index ef625167c98e..919d23aee4af 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js @@ -22,21 +22,14 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var ones = require( '@stdlib/array/ones' ); var pow = require( '@stdlib/math/base/special/pow' ); var floor = require( '@stdlib/math/base/special/floor' ); var pkg = require( './../package.json' ).name; var dlaswp = require( './../lib/ndarray.js' ); -// VARIABLES // - -var options = { - 'dtype': 'float64' -}; - - // FUNCTIONS // /** @@ -47,8 +40,15 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( N ) { - var IPIV = ones( N, 'int32' ); - var A = uniform( N, -10.0, 10.0, options ); + var IPIV; + var A; + + IPIV = discreteUniform( 5, 0, N-1, { + 'dtype': 'int32' + }); + A = uniform( N*N, -10.0, 10.0, { + 'dtype': 'float64' + }); return benchmark; /** @@ -63,7 +63,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, 0, N, 1, 1, IPIV, 0, 1 ); + z = dlaswp( 'column-major', N, A, N, 0, 0, IPIV.length-1, IPIV, 0, 1 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } @@ -98,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); f = createBenchmark( N ); - bench( pkg+':ndarray:size='+(N*N), f ); + bench( pkg+':ndarray:order=column-major,size='+(N*N), f ); } } From b4364022b6755dcb22a32ac3d098bd5edaef528a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Jul 2024 02:42:08 -0700 Subject: [PATCH 32/60] refactor: reorder parameters --- .../dlaswp/benchmark/benchmark.ndarray.js | 2 +- .../lapack/base/dlaswp/docs/types/index.d.ts | 31 +++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js index 919d23aee4af..c37f5111613c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js @@ -63,7 +63,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, N, 0, 0, IPIV.length-1, IPIV, 0, 1 ); + z = dlaswp( 'column-major', N, A, N, 0, 0, IPIV.length-1, IPIV, 1, 0 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts index 9885a62f2d4f..b84489163ffb 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts @@ -30,9 +30,9 @@ interface Routine { * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. * * @param order - storage layout - * @param N - number of columns of `A` + * @param N - number of columns in `A` * @param A - matrix - * @param LDA - leading dimension of `A` + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange * @param IPIV - vector of pivot indices @@ -44,7 +44,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * * var IPIV = new Int32Array( [ 2, 0, 1 ] ); - * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var A = 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 ] ] * * dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] @@ -52,18 +52,18 @@ interface Routine { ( order: Layout, N: number, A: Float64Array, LDA: number, k1: number, k2: number, IPIV: Int32Array, incX: number ): Float64Array; /** - * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. + * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. * * @param order - storage layout - * @param N - number of columns of `A` + * @param N - number of columns in `A` * @param A - matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param offsetA - starting index for `A` - * @param LDA - leading dimension of `A` * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange * @param IPIV - vector of pivot indices - * @param offsetIPIV - starting index for `IPIV` * @param strideIPIV - increment between successive values of `IPIV` + * @param offsetIPIV - starting index for `IPIV` * @returns `A` * * @example @@ -71,25 +71,24 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * * var IPIV = new Int32Array( [ 2, 0, 1 ] ); - * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var A = 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 ] ] * - * dlaswp.ndarray( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); + * dlaswp.ndarray( 'row-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ - ndarray( order: Layout, N: number, A: Float64Array, offsetA: number, LDA: number, k1: number, k2: number, IPIV: Int32Array, offsetIPIV: number, strideIPIV: number ): Float64Array; + ndarray( order: Layout, N: number, A: Float64Array, LDA: number, offsetA: number, k1: number, k2: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number ): Float64Array; } /** * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. * * @param order - storage layout -* @param N - number of columns of `A` +* @param N - number of columns in `A` * @param A - matrix -* @param LDA - leading dimension of `A` +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange * @param IPIV - vector of pivot indices -* @param offsetIPIV - starting index for `IPIV` * @param strideIPIV - `IPIV` stride length * @returns `A` * @@ -98,7 +97,7 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * * var IPIV = new Int32Array( [ 2, 0, 1 ] ); -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var A = 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 ] ] * * dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] @@ -108,9 +107,9 @@ interface Routine { * var Float64Array = require( '@stdlib/array/float64' ); * * var IPIV = new Int32Array( [ 2, 0, 1 ] ); -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var A = 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 ] ] * -* dlaswp.ndarray( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); +* dlaswp.ndarray( 'row-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ declare var dlaswp: Routine; From 6001634228489df92ebe0f5ae66f2a0bf9cc7aaf Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Jul 2024 02:44:29 -0700 Subject: [PATCH 33/60] test: reorder parameters --- .../lapack/base/dlaswp/docs/types/test.ts | 162 +++++++++--------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts index 7c820a9de0ca..0141f989035a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts @@ -153,7 +153,7 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectType Float64Array + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectType Float64Array } // The compiler throws an error if the function is provided a first argument which is not a string... @@ -161,14 +161,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 10, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( true, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( false, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( null, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( void 0, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( [], 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( {}, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( ( x: number ): number => x, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 10, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( true, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( false, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( null, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( void 0, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( [], 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( {}, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( ( x: number ): number => x, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -176,28 +176,28 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', '3', A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', true, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', false, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', null, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', void 0, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', [], A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', {}, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', ( x: number ): number => x, A, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', '3', A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', true, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', false, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', null, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', void 0, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', [], A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', {}, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', ( x: number ): number => x, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... { const IPIV = new Int32Array( 3 ); - dlaswp.ndarray( 'column-major', 3, 10, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, true, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, false, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, null, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, void 0, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, [], 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, {}, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, ( x: number ): number => x, 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, 10, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, true, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, false, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, null, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, void 0, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, [], 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, {}, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, ( x: number ): number => x, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not an integer... @@ -205,14 +205,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, '0', 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, true, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, false, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, null, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, void 0, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, [], 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, {}, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, ( x: number ): number => x, 2, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, '0', 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, true, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, false, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, null, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, void 0, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, [], 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, {}, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, ( x: number ): number => x, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not an integer... @@ -220,14 +220,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, '2', 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, true, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, false, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, null, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, void 0, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, [], 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, {}, 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, ( x: number ): number => x, 0, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, '2', 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, true, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, false, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, null, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, void 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, [], 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, {}, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, ( x: number ): number => x, 0, 2, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not an integer... @@ -235,14 +235,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, '0', 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, true, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, false, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, null, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, void 0, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, [], 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, {}, 2, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, ( x: number ): number => x, 2, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, '0', 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, true, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, false, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, null, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, void 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, [], 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, {}, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, ( x: number ): number => x, 2, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not an integer... @@ -250,28 +250,28 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, '2', IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, true, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, false, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, null, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, void 0, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, [], IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, {}, IPIV, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, ( x: number ): number => x, IPIV, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, '2', IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, true, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, false, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, null, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, void 0, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, [], IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, {}, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, ( x: number ): number => x, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided an eighth argument which is not an Int32Array... { const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, 'IPIV', 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, true, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, false, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, null, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, void 0, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, [], 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, {}, 0, 1 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, ( x: number ): number => x, 0, 1 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, 'IPIV', 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, true, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, false, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, null, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, void 0, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, [], 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, {}, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a ninth argument which is not a number... @@ -279,14 +279,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, '1', 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, true, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, false, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, null, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, void 0, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, [], 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, {}, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, ( x: number ): number => x, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, '1', 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, true, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, false, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, null, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, void 0, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, [], 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, {}, 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a tenth argument which is not a number... @@ -294,12 +294,12 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, '1' ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, true ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, false ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, null ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, void 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, [] ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, {} ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 0, 2, 0, 2, IPIV, 0, ( x: number ): number => x ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, '1' ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, true ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, false ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, null ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, void 0 ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, [] ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, {} ); // $ExpectError + dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, ( x: number ): number => x ); // $ExpectError } From db68b19dcd1837b3bd3a9cc66d573e1415ad3d38 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Fri, 5 Jul 2024 09:32:35 +0530 Subject: [PATCH 34/60] chore: consequent changes of parameter reorder --- .../@stdlib/lapack/base/dlaswp/README.md | 10 ++++----- .../@stdlib/lapack/base/dlaswp/docs/repl.txt | 22 +++++++++---------- .../@stdlib/lapack/base/dlaswp/lib/base.js | 10 ++++----- .../@stdlib/lapack/base/dlaswp/lib/dlaswp.js | 6 ++--- .../@stdlib/lapack/base/dlaswp/lib/ndarray.js | 12 +++++----- .../lapack/base/dlaswp/test/test.ndarray.js | 20 ++++++++--------- 6 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 7a1be166772d..8596d1e70b0a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -48,9 +48,9 @@ dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); The function has the following parameters: - **order**: storage layout. -- **N**: number of columns of `A`. +- **N**: number of columns in `A`. - **A**: input `Float64Array`. -- **LDA**: leading dimension of `A`. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **k1**: index of first row to interchange. - **k2**: index of last row to interchange. - **IPIV**: vector of pivot indices. @@ -89,7 +89,7 @@ dlaswp( 'column-major', 3, A1, 2, 0, 2, IPIV1, 1 ); // A1 => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] ``` -#### dlaswp.ndarray( order, N, A, oa, LDA, k1, k2, IPIV, oipiv, sipiv ) +#### dlaswp.ndarray( order, N, A, LDA, oa, k1, k2, IPIV, sipiv, oipiv ) Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. @@ -100,7 +100,7 @@ var Int32Array = require( '@stdlib/array/int32' ); var IPIV = new Int32Array( [ 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); -dlaswp.ndarray( 'row-major', 3, A, 3, 2, 0, 2, IPIV, 0, 1 ); +dlaswp.ndarray( 'row-major', 3, A, 2, 3, 0, 2, IPIV, 1, 0 ); console.log( A ); // A => [ 1.0, 2.0, 3.0, 6.0, 7.0, 4.0, 5.0, 8.0, 9.0 ] ``` @@ -119,7 +119,7 @@ var Int32Array = require( '@stdlib/array/int32' ); var IPIV = new Int32Array( [ 1, 0, 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); -dlaswp.ndarray( 'column-major', 3, A, 2, 2, 0, 2, IPIV, 2, 1 ); +dlaswp.ndarray( 'column-major', 3, A, 2, 2, 0, 2, IPIV, 1, 2 ); console.log( A ); // A => [ 1.0, 2.0, 4.0, 5.0, 6.0, 7.0, 3.0, 8.0, 9.0 ] ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt index f02d64de042c..7b365f2b9775 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -15,7 +15,7 @@ either 'row-major' or 'column-major'. N: integer - Number of columns of `A`. + Number of columns in `A`. A: Float64Array Matrix. @@ -66,7 +66,7 @@ [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] -{{alias}}.ndarray( order, N, A, oa, LDA, k1, k2, IPIV, oipiv, sipiv ) +{{alias}}.ndarray( order, N, A, LDA, oa, k1, k2, IPIV, sipiv, oipiv ) Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. @@ -81,18 +81,18 @@ either 'row-major' or 'column-major'. N: integer - Number of columns of `A`. + Number of columns in `A`. A: Float64Array Matrix. - oa: integer - Index offset for `A`. - LDA: integer Stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + oa: integer + Index offset for `A`. + k1: integer Index of first row to interchange. @@ -102,12 +102,12 @@ IPIV: Int32Array Array of pivot indices. - oipiv: integer - Index offset for `IPIV`. - sipiv: integer Index increment for `IPIV`. + oipiv: integer + Index offset for `IPIV`. + Returns ------- A: Float64Array @@ -119,13 +119,13 @@ > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var ord = 'column-major'; - > {{alias}}.ndarray( ord, 3, A, 0, 2, 0, 2, IPIV, 0, 1 ) + > {{alias}}.ndarray( ord, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ) [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] // Advanced indexing: > IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); > A = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}.ndarray( ord, 3, A, 2, 2, 0, 2, IPIV, 0, 1 ) + > {{alias}}.ndarray( ord, 3, A, 2, 2, 0, 2, IPIV, 1, 0 ) [ 7.0, 8.0, 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] See Also diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js index 9abfb8900a9d..fd5e3a00d80d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js @@ -30,15 +30,15 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. * * @param {string} order - storage layout -* @param {PositiveInteger} N - number of columns of `A` +* @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {PositiveInteger} offsetA - index offset for `A` -* @param {PositiveInteger} LDA - leading dimension of `A` * @param {PositiveInteger} k1 - index of first row to interchange * @param {PositiveInteger} k2 - index of last row to interchange * @param {Int32Array} IPIV - vector of pivot indices -* @param {PositiveInteger} offsetIPIV - index offset for `IPIV` * @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` +* @param {PositiveInteger} offsetIPIV - index offset for `IPIV` * @returns {Float64Array} permuted matrix `A` * * @example @@ -48,10 +48,10 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* dlaswp( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); +* dlaswp( 'row-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ -function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, offsetIPIV, strideIPIV ) { // eslint-disable-line max-len +function dlaswp( order, N, A, LDA, offsetA, k1, k2, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len var inc; var ix0; var n32; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js index 2a06fd788770..d8d79b1a7a90 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js @@ -30,9 +30,9 @@ var base = require( './base.js' ); * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. * * @param {string} order - storage layout -* @param {PositiveInteger} N - number of columns of `A` +* @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - matrix -* @param {PositiveInteger} LDA - leading dimension of `A` +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {PositiveInteger} k1 - index of first row to interchange * @param {PositiveInteger} k2 - index of last row to interchange * @param {Int32Array} IPIV - vector of pivot indices @@ -54,7 +54,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, strideIPIV ) { if ( !isLayout( order ) ) { throw new TypeError( 'invalid argument. Order argument must be a string indicating whether an array is row-major (i.e., order is `row-major`) or column-major (i.e., order is `column-major`).' ); } - return base( order, N, A, 0, LDA, k1, k2, IPIV, 0, strideIPIV ); + return base( order, N, A, LDA, 0, k1, k2, IPIV, strideIPIV, 0 ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js index 20a2417f132f..e07040ce8f68 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js @@ -30,15 +30,15 @@ var base = require( './base.js' ); * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. * * @param {string} order - storage layout -* @param {PositiveInteger} N - number of columns of `A` +* @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {PositiveInteger} offsetA - index offset for `A` -* @param {PositiveInteger} LDA - leading dimension of `A` * @param {PositiveInteger} k1 - index of first row to interchange * @param {PositiveInteger} k2 - index of last row to interchange * @param {Int32Array} IPIV - vector of pivot indices -* @param {PositiveInteger} offsetIPIV - index offset for `IPIV` * @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` +* @param {PositiveInteger} offsetIPIV - index offset for `IPIV` * @throws {TypeError} first argument must be a valid order * @returns {Float64Array} permuted matrix `A` * @@ -49,14 +49,14 @@ var base = require( './base.js' ); * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * -* dlaswp( 'row-major', 3, A, 0, 2, 0, 2, IPIV, 0, 1 ); +* dlaswp( 'row-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ -function dlaswp( order, N, A, offsetA, LDA, k1, k2, IPIV, offsetIPIV, strideIPIV ) { // eslint-disable-line max-len +function dlaswp( order, N, A, LDA, offsetA, k1, k2, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len if ( !isLayout( order ) ) { throw new TypeError( 'invalid argument. Order argument must be a string indicating whether an array is row-major (i.e., order is `row-major`) or column-major (i.e., order is `column-major`).' ); } - return base( order, N, A, offsetA, LDA, k1, k2, IPIV, offsetIPIV, strideIPIV ); // eslint-disable-line max-len + return base( order, N, A, LDA, offsetA, k1, k2, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index 8bd186ca27fe..a1ae44dfc875 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -103,7 +103,7 @@ tape( 'the function throws an error if provided an invalid first argument', func function badValue( value ) { return function badValue() { - dlaswp( value, cao.N, cao.A, cao.offsetA, cao.LDA, cao.k1, cao.k2, cao.IPIV, cao.offsetIPIV, cao.strideIPIV ); + dlaswp( value, cao.N, cao.A, cao.LDA, cao.offsetA, cao.k1, cao.k2, cao.IPIV, cao.strideIPIV, cao.offsetIPIV ); }; } }); @@ -119,7 +119,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( cao.A_out ); - out = dlaswp( cao.order, cao.N, A, cao.offsetA, cao.LDA, cao.k1, cao.k2, IPIV, cao.offsetIPIV, cao.strideIPIV ); + out = dlaswp( cao.order, cao.N, A, cao.LDA, cao.offsetA, cao.k1, cao.k2, IPIV, cao.strideIPIV, cao.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -137,7 +137,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( caoit.A_out ); - out = dlaswp( caoit.order, caoit.N, A, caoit.offsetA, caoit.LDA, caoit.k1, caoit.k2, IPIV, caoit.offsetIPIV, caoit.strideIPIV ); + out = dlaswp( caoit.order, caoit.N, A, caoit.LDA, caoit.offsetA, caoit.k1, caoit.k2, IPIV, caoit.strideIPIV, caoit.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -155,7 +155,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( cat.A_out ); - out = dlaswp( cat.order, cat.N, A, cat.offsetA, cat.LDA, cat.k1, cat.k2, IPIV, cat.offsetIPIV, cat.strideIPIV ); + out = dlaswp( cat.order, cat.N, A, cat.LDA, cat.offsetA, cat.k1, cat.k2, IPIV, cat.strideIPIV, cat.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -173,7 +173,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( rao.A_out ); - out = dlaswp( rao.order, rao.N, A, rao.offsetA, rao.LDA, rao.k1, rao.k2, IPIV, rao.offsetIPIV, rao.strideIPIV ); + out = dlaswp( rao.order, rao.N, A, rao.LDA, rao.offsetA, rao.k1, rao.k2, IPIV, rao.strideIPIV, rao.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -191,7 +191,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( raolt.A_out ); - out = dlaswp( raolt.order, raolt.N, A, raolt.offsetA, raolt.LDA, raolt.k1, raolt.k2, IPIV, raolt.offsetIPIV, raolt.strideIPIV ); + out = dlaswp( raolt.order, raolt.N, A, raolt.LDA, raolt.offsetA, raolt.k1, raolt.k2, IPIV, raolt.strideIPIV, raolt.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -209,7 +209,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( ran.A_out ); - out = dlaswp( ran.order, ran.N, A, ran.offsetA, ran.LDA, ran.k1, ran.k2, IPIV, ran.offsetIPIV, ran.strideIPIV ); + out = dlaswp( ran.order, ran.N, A, ran.LDA, ran.offsetA, ran.k1, ran.k2, IPIV, ran.strideIPIV, ran.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -227,7 +227,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( roat.A_out ); - out = dlaswp( roat.order, roat.N, A, roat.offsetA, roat.LDA, roat.k1, roat.k2, IPIV, roat.offsetIPIV, roat.strideIPIV ); + out = dlaswp( roat.order, roat.N, A, roat.LDA, roat.offsetA, roat.k1, roat.k2, IPIV, roat.strideIPIV, roat.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -245,7 +245,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( coat.A_out ); - out = dlaswp( coat.order, coat.N, A, coat.offsetA, coat.LDA, coat.k1, coat.k2, IPIV, coat.offsetIPIV, coat.strideIPIV ); + out = dlaswp( coat.order, coat.N, A, coat.LDA, coat.offsetA, coat.k1, coat.k2, IPIV, coat.strideIPIV, coat.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -263,7 +263,7 @@ tape( 'the function performs a series of row interchanges on the matrix `A`, whe expected = new Float64Array( raoio.A_out ); - out = dlaswp( raoio.order, raoio.N, A, raoio.offsetA, raoio.LDA, raoio.k1, raoio.k2, IPIV, raoio.offsetIPIV, raoio.strideIPIV ); + out = dlaswp( raoio.order, raoio.N, A, raoio.LDA, raoio.offsetA, raoio.k1, raoio.k2, IPIV, raoio.strideIPIV, raoio.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); From c5f42cdcab57e268b752f4b1d60735dc1caa46ba Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 10 Jul 2024 21:46:46 -0700 Subject: [PATCH 35/60] temp: save snapshot --- .../@stdlib/lapack/base/dlaswp/lib/base.js | 116 +++++++++--------- .../@stdlib/lapack/base/dlaswp/lib/dlaswp.js | 41 +++++-- .../@stdlib/lapack/base/dlaswp/lib/index.js | 4 +- .../@stdlib/lapack/base/dlaswp/lib/ndarray.js | 34 +++-- 4 files changed, 114 insertions(+), 81 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js index fd5e3a00d80d..0794910f61cc 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js @@ -27,18 +27,21 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; // MAIN // /** -* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. * +* @private * @param {string} order - storage layout * @param {PositiveInteger} N - number of columns in `A` -* @param {Float64Array} A - matrix -* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param {PositiveInteger} offsetA - index offset for `A` -* @param {PositiveInteger} k1 - index of first row to interchange -* @param {PositiveInteger} k2 - index of last row to interchange +* @param {Float64Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeinteger} offsetA - index offset for `A` +* @param {NonNegativeInteger} k1 - index of first row to interchange +* @param {NonNegativeInteger} k2 - index of last row to interchange +* @param {integer} inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order) * @param {Int32Array} IPIV - vector of pivot indices -* @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` -* @param {PositiveInteger} offsetIPIV - index offset for `IPIV` +* @param {integer} strideIPIV - `IPIV` stride length +* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV` * @returns {Float64Array} permuted matrix `A` * * @example @@ -46,71 +49,68 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * var Float64Array = require( '@stdlib/array/float64' ); * * var IPIV = new Int32Array( [ 2, 0, 1 ] ); -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var A = 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 ] ] * -* dlaswp( 'row-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); +* dlaswp( 'row-major', 2, A, 2, 1, 0, 0, 2, IPIV, 1, 0 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ -function dlaswp( order, N, A, LDA, offsetA, k1, k2, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len - var inc; - var ix0; +function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len var n32; var tmp; + var row; + var i1; var i2; var ip; - var ix; - var i1; + var ip; + var ia; var i; var j; var k; - if ( strideIPIV > 0 ) { - ix0 = k1 + offsetIPIV; - i1 = k1; - i2 = k2; - inc = 1; - } else if ( strideIPIV < 0 ) { - ix0 = k1 + ( ( k1 - k2 ) * strideIPIV ) + offsetIPIV; - i1 = k2; - i2 = k1; - inc = -1; - } else { - return A; - } - + nrows = k2 - k1 + 1; if ( order === 'row-major' ) { - ix = ix0; - if ( inc === 1 ) { - for ( k = i1; k <= i2; k++ ) { - ip = IPIV[ ix ]; - if ( ip !== k ) { - dswap( LDA, A, 1, offsetA + ( k * LDA ), A, 1, offsetA + ( ip * LDA ) ); // eslint-disable-line max-len - } - ix += strideIPIV; + ip = offsetIPIV + ( k1*strideIPIV ); + for ( i = 0, k = k1; i < nrows; i++, k += inck ) { + row = IPIV[ ip ]; + if ( row !== k ) { + dswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); } - return A; - } - for ( k = i1; k >= i2; k-- ) { - ip = IPIV[ ix ]; - if ( ip !== k ) { - dswap( LDA, A, 1, offsetA + ( k * LDA ), A, 1, offsetA + ( ip * LDA ) ); // eslint-disable-line max-len - } - ix += strideIPIV; + ip += strideIPIV; } return A; + + // if ( inck > 0 ) { + // for ( k = k1; k <= k2; k += inck ) { + // row = IPIV[ ip ]; + // if ( row !== k ) { + // dswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); + // } + // ip += strideIPIV; + // } + // return A; + // } + // for ( k = k1; k >= k2; k += inck ) { + // row = IPIV[ ip ]; + // if ( row !== k ) { + // dswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); + // } + // ip += strideIPIV; + // } + // return A; } // order === 'column-major' - n32 = floor( N / 32 ) * 32; + n32 = floor( N/32 ) * 32; if ( n32 !== 0 ) { - for ( j = 1; j < n32; j += 32 ) { - ix = ix0; - for ( i = i1; i < i2; i += inc ) { + for ( j = 0; j < n32; j += 32 ) { + ix = ix0 + offsetIPIV; + for ( i = i1; i <= i2; i += inc ) { ip = IPIV[ ix ]; if ( ip !== i ) { for ( k = j; k < j + 31; k++ ) { - tmp = A[ offsetA + ( ( k - 1 ) * LDA ) + i ]; - A[ offsetA + ( ( k - 1 ) * LDA ) + i ] = A[ offsetA + ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len - A[ offsetA + ( ( k - 1 ) * LDA ) + ip ] = tmp; + ia = offsetA + ( (k-1)*LDA ); + tmp = A[ ia+i ]; + A[ ia+i ] = A[ ia+ip ]; + A[ ia+ip ] = tmp; } } ix += strideIPIV; @@ -118,15 +118,15 @@ function dlaswp( order, N, A, LDA, offsetA, k1, k2, IPIV, strideIPIV, offsetIPIV } } if ( n32 !== N ) { - n32 += 1; - ix = ix0; - for ( i = i1; i < i2; i += inc ) { + ix = ix0 + offsetIPIV; + for ( i = i1; i <= i2; i += inc ) { ip = IPIV[ ix ]; if ( ip !== i ) { for ( k = n32; k < N; k++ ) { - tmp = A[ offsetA + ( ( k - 1 ) * LDA ) + i ]; - A[ offsetA + ( ( k - 1 ) * LDA ) + i ] = A[ offsetA + ( ( k - 1 ) * LDA ) + ip ]; // eslint-disable-line max-len - A[ offsetA + ( ( k - 1 ) * LDA ) + ip ] = tmp; + ia = offsetA + ( (k-1)*LDA ); + tmp = A[ ia+i ]; + A[ ia+i ] = A[ ia+ip ]; + A[ ia+ip ] = tmp; } } ix += strideIPIV; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js index d8d79b1a7a90..0c0d1f335c0a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js @@ -21,23 +21,26 @@ // MODULES // var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var max = require( '@stdlib/math/base/special/max' ); +var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); // MAIN // /** -* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. * * @param {string} order - storage layout * @param {PositiveInteger} N - number of columns in `A` -* @param {Float64Array} A - matrix +* @param {Float64Array} A - input matrix * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param {PositiveInteger} k1 - index of first row to interchange -* @param {PositiveInteger} k2 - index of last row to interchange +* @param {NonNegativeInteger} k1 - index of first row to interchange +* @param {NonNegativeInteger} k2 - index of last row to interchange * @param {Int32Array} IPIV - vector of pivot indices -* @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` +* @param {integer} incx - increment between successive values of `IPIV` * @throws {TypeError} first argument must be a valid order +* @throws {RangeError} fourth argument must be greater than or equal to max(1,N) * @returns {Float64Array} permuted matrix `A` * * @example @@ -45,16 +48,34 @@ var base = require( './base.js' ); * var Float64Array = require( '@stdlib/array/float64' ); * * var IPIV = new Int32Array( [ 2, 0, 1 ] ); -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var A = 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 ] ] * -* dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); +* dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ -function dlaswp( order, N, A, LDA, k1, k2, IPIV, strideIPIV ) { +function dlaswp( order, N, A, LDA, k1, k2, IPIV, incx ) { + var tmp; + var inc; + var io; if ( !isLayout( order ) ) { - throw new TypeError( 'invalid argument. Order argument must be a string indicating whether an array is row-major (i.e., order is `row-major`) or column-major (i.e., order is `column-major`).' ); + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } - return base( order, N, A, LDA, 0, k1, k2, IPIV, strideIPIV, 0 ); + if ( order === 'row-major' && LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Fourth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + if ( incx > 0 ) { + inc = 1; + io = 0; + } else if ( incx < 0 ) { + inc = -1; + io = k1 + ( (k1-k2) * incx ); + tmp = k1; + k1 = k2; + k2 = tmp; + } else { + return A; + } + return base( order, N, A, LDA, 1, 0, k1, k2, inc, IPIV, 1, io ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js index 4abd7195b1b5..460ed29888ea 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* LAPACK routine to perform a series of row interchanges on the matrix `A`. +* LAPACK routine to perform a series of row interchanges on an input matrix. * * @module @stdlib/lapack/base/dlaswp * @@ -29,7 +29,7 @@ * var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); * * var IPIV = new Int32Array( [ 2, 0, 1 ] ); -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var A = 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 ] ] * * dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js index e07040ce8f68..2fe0b066acd7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js @@ -21,25 +21,29 @@ // MODULES // var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var max = require( '@stdlib/math/base/special/max' ); +var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); // MAIN // /** -* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. * * @param {string} order - storage layout * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - matrix * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) -* @param {PositiveInteger} offsetA - index offset for `A` -* @param {PositiveInteger} k1 - index of first row to interchange -* @param {PositiveInteger} k2 - index of last row to interchange +* @param {NonNegativeInteger} offsetA - index offset for `A` +* @param {NonNegativeInteger} k1 - index of first row to interchange +* @param {NonNegativeInteger} k2 - index of last row to interchange * @param {Int32Array} IPIV - vector of pivot indices -* @param {PositiveInteger} strideIPIV - increment between successive values of `IPIV` -* @param {PositiveInteger} offsetIPIV - index offset for `IPIV` +* @param {integer} strideIPIV - `IPIV` stride length +* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV` +* @param {integer} incx - increment between successive values of `IPIV` * @throws {TypeError} first argument must be a valid order +* @throws {RangeError} fourth argument must be greater than or equal to max(1,N) * @returns {Float64Array} permuted matrix `A` * * @example @@ -47,16 +51,24 @@ var base = require( './base.js' ); * var Float64Array = require( '@stdlib/array/float64' ); * * var IPIV = new Int32Array( [ 2, 0, 1 ] ); -* var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var A = 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 ] ] * -* dlaswp( 'row-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); +* dlaswp( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0, 1, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ -function dlaswp( order, N, A, LDA, offsetA, k1, k2, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len +function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len + var tmp; if ( !isLayout( order ) ) { - throw new TypeError( 'invalid argument. Order argument must be a string indicating whether an array is row-major (i.e., order is `row-major`) or column-major (i.e., order is `column-major`).' ); + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } - return base( order, N, A, LDA, offsetA, k1, k2, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len + if ( inck < 0 ) { + offsetIPIV += ( k2-k1 ) * strideIPIV; + strideIPIV *= -1; + tmp = k1; + k1 = k2; + k2 = tmp; + } + return base( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len } From fee1ce6af6614d0cd4434589ddafec21c142167d Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 02:26:43 -0700 Subject: [PATCH 36/60] refactor: update to support matrix strides --- .../@stdlib/lapack/base/dlaswp/lib/base.js | 94 +++++++++---------- 1 file changed, 44 insertions(+), 50 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js index 0794910f61cc..b36021292cc6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js @@ -24,6 +24,11 @@ var floor = require( '@stdlib/math/base/special/floor' ); var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; +// VARIABLES // + +var BLOCK_SIZE = 32; + + // MAIN // /** @@ -35,7 +40,7 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * @param {Float64Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` -* @param {NonNegativeinteger} offsetA - index offset for `A` +* @param {NonNegativeInteger} offsetA - index offset for `A` * @param {NonNegativeInteger} k1 - index of first row to interchange * @param {NonNegativeInteger} k2 - index of last row to interchange * @param {integer} inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order) @@ -51,85 +56,74 @@ var dswap = require( '@stdlib/blas/base/dswap' ).ndarray; * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = 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 ] ] * -* dlaswp( 'row-major', 2, A, 2, 1, 0, 0, 2, IPIV, 1, 0 ); +* dlaswp( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ -function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len +function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params + var nrows; var n32; var tmp; var row; - var i1; - var i2; + var ia1; + var ia2; var ip; - var ip; - var ia; var i; var j; var k; + var n; + var o; + // Compute the number of rows to be interchanged: nrows = k2 - k1 + 1; + + // If the order is row-major, we can delegate to the Level 1 routine `dswap` for interchanging rows... if ( order === 'row-major' ) { ip = offsetIPIV + ( k1*strideIPIV ); for ( i = 0, k = k1; i < nrows; i++, k += inck ) { row = IPIV[ ip ]; if ( row !== k ) { - dswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); + dswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); // eslint-disable-line max-len } ip += strideIPIV; } return A; - - // if ( inck > 0 ) { - // for ( k = k1; k <= k2; k += inck ) { - // row = IPIV[ ip ]; - // if ( row !== k ) { - // dswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); - // } - // ip += strideIPIV; - // } - // return A; - // } - // for ( k = k1; k >= k2; k += inck ) { - // row = IPIV[ ip ]; - // if ( row !== k ) { - // dswap( N, A, strideA2, offsetA+(k*strideA1), A, strideA2, offsetA+(row*strideA1) ); - // } - // ip += strideIPIV; - // } - // return A; } - // order === 'column-major' - n32 = floor( N/32 ) * 32; + // If the order is column-major, we need to use loop tiling to ensure efficient cache access when accessing matrix elements... + n32 = floor( N/BLOCK_SIZE ) * BLOCK_SIZE; if ( n32 !== 0 ) { - for ( j = 0; j < n32; j += 32 ) { - ix = ix0 + offsetIPIV; - for ( i = i1; i <= i2; i += inc ) { - ip = IPIV[ ix ]; - if ( ip !== i ) { - for ( k = j; k < j + 31; k++ ) { - ia = offsetA + ( (k-1)*LDA ); - tmp = A[ ia+i ]; - A[ ia+i ] = A[ ia+ip ]; - A[ ia+ip ] = tmp; + for ( j = 0; j < n32; j += BLOCK_SIZE ) { + ip = offsetIPIV + ( k1*strideIPIV ); + for ( i = 0, k = k1; i < nrows; i++, k += inck ) { + row = IPIV[ ip ]; + if ( row !== i ) { + ia1 = offsetA + ( k*strideA1 ); + ia2 = offsetA + ( row*strideA1 ); + for ( n = j; n < j+BLOCK_SIZE; n++ ) { + o = n * strideA2; + tmp = A[ ia1+o ]; + A[ ia1+o ] = A[ ia2+o ]; + A[ ia2+o ] = tmp; } } - ix += strideIPIV; + ip += strideIPIV; } } } if ( n32 !== N ) { - ix = ix0 + offsetIPIV; - for ( i = i1; i <= i2; i += inc ) { - ip = IPIV[ ix ]; - if ( ip !== i ) { - for ( k = n32; k < N; k++ ) { - ia = offsetA + ( (k-1)*LDA ); - tmp = A[ ia+i ]; - A[ ia+i ] = A[ ia+ip ]; - A[ ia+ip ] = tmp; + ip = offsetIPIV + ( k1*strideIPIV ); + for ( i = 0, k = k1; i < nrows; i++, k += inck ) { + row = IPIV[ ip ]; + if ( row !== i ) { + ia1 = offsetA + ( k*strideA1 ); + ia2 = offsetA + ( row*strideA1 ); + for ( n = n32; n < N; n++ ) { + o = n * strideA2; + tmp = A[ ia1+o ]; + A[ ia1+o ] = A[ ia2+o ]; + A[ ia2+o ] = tmp; } } - ix += strideIPIV; + ip += strideIPIV; } } return A; From f317d4511d904e396d9f7ebb1170799947128b82 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 02:27:53 -0700 Subject: [PATCH 37/60] test: rename fixtures and update ndarray tests --- .../test/fixtures/column_major_a_offset.json | 36 ++ .../test/fixtures/column_major_a_strides.json | 86 +++++ .../dlaswp/test/fixtures/column_major_ao.json | 13 - .../test/fixtures/column_major_aoit.json | 13 - .../dlaswp/test/fixtures/column_major_at.json | 13 - .../column_major_complex_access_patterns.json | 90 +++++ .../fixtures/column_major_ipiv_offset.json | 36 ++ .../fixtures/column_major_ipiv_stride.json | 36 ++ .../fixtures/column_major_no_offsets.json | 36 ++ .../test/fixtures/column_major_oat.json | 13 - .../test/fixtures/row_major_a_offset.json | 36 ++ .../test/fixtures/row_major_a_strides.json | 74 ++++ .../dlaswp/test/fixtures/row_major_an.json | 13 - .../dlaswp/test/fixtures/row_major_ao.json | 13 - .../dlaswp/test/fixtures/row_major_aoio.json | 13 - .../dlaswp/test/fixtures/row_major_aolt.json | 13 - .../row_major_complex_access_patterns.json | 74 ++++ .../test/fixtures/row_major_ipiv_offset.json | 36 ++ .../test/fixtures/row_major_ipiv_stride.json | 36 ++ .../test/fixtures/row_major_no_offsets.json | 36 ++ .../dlaswp/test/fixtures/row_major_oat.json | 13 - .../lapack/base/dlaswp/test/test.ndarray.js | 348 +++++++++++++----- 22 files changed, 864 insertions(+), 213 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_a_offset.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_a_strides.json delete mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json delete mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_aoit.json delete mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_complex_access_patterns.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_offset.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_no_offsets.json delete mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_a_offset.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_a_strides.json delete mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json delete mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json delete mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aoio.json delete mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_complex_access_patterns.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_offset.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_no_offsets.json delete mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_a_offset.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_a_offset.json new file mode 100644 index 000000000000..558c869d31ec --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_a_offset.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 2, + "A": [ 9999.0, 9999.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 9999.0, 9999.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 9999.0, 9999.0, 2.0, 1.0, 3.0, 5.0, 4.0, 6.0, 9999.0, 9999.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_a_strides.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_a_strides.json new file mode 100644 index 000000000000..2d1b409aebbb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_a_strides.json @@ -0,0 +1,86 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": null, + "strideA1": 2, + "strideA2": 12, + "offsetA": 0, + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 4.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ + 2.0, + 9999.0, + 1.0, + 9999.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 5.0, + 9999.0, + 4.0, + 9999.0, + 6.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json deleted file mode 100644 index 59cf8bdb1cc1..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ao.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "order": "column-major", - "N": 3, - "k1": 0, - "k2": 2, - "IPIV": [ 2, 0, 1 ], - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], - "A_out": [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ], - "LDA": 2, - "strideIPIV": 1, - "offsetA": 0, - "offsetIPIV": 0 -} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_aoit.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_aoit.json deleted file mode 100644 index da4de0126156..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_aoit.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "order": "column-major", - "N": 3, - "k1": 0, - "k2": 2, - "IPIV": [ 3, 4, 2, 0, 1 ], - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], - "A_out": [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ], - "LDA": 2, - "strideIPIV": 1, - "offsetA": 0, - "offsetIPIV": 2 -} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json deleted file mode 100644 index b2782b315bbb..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_at.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "order": "column-major", - "N": 3, - "k1": 0, - "k2": 2, - "IPIV": [ 2, 0, 1 ], - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], - "A_out": [ 3.0, 2.0, 5.0, 4.0, 1.0, 6.0 ], - "LDA": 2, - "strideIPIV": 2, - "offsetA": 0, - "offsetIPIV": 0 -} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_complex_access_patterns.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_complex_access_patterns.json new file mode 100644 index 000000000000..715144fca754 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_complex_access_patterns.json @@ -0,0 +1,90 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": null, + "strideA1": -2, + "strideA2": 12, + "offsetA": 6, + "A": [ + 9999.0, + 9999.0, + 3.0, + 9999.0, + 2.0, + 9999.0, + 1.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 6.0, + 9999.0, + 5.0, + 9999.0, + 4.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 9999, 9999, 1, 9999, 0, 9999, 2, 9999, 9999 ], + "strideIPIV": -2, + "offsetIPIV": 6, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ + 9999.0, + 9999.0, + 3.0, + 9999.0, + 1.0, + 9999.0, + 2.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 6.0, + 9999.0, + 4.0, + 9999.0, + 5.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_offset.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_offset.json new file mode 100644 index 000000000000..d70d93b645c9 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_offset.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 3, 4, 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 2, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride.json new file mode 100644 index 000000000000..0b68c30522c1 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 9999, 0, 9999, 1, 9999 ], + "strideIPIV": 2, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_no_offsets.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_no_offsets.json new file mode 100644 index 000000000000..0ac37c157e66 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_no_offsets.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json deleted file mode 100644 index fcba5c3f8c28..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_oat.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "order": "column-major", - "N": 3, - "k1": 0, - "k2": 2, - "IPIV": [ 2, 0, 1 ], - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ], - "A_out": [ 1.0, 2.0, 4.0, 5.0, 6.0, 7.0, 3.0, 8.0 ], - "LDA": 2, - "strideIPIV": 1, - "offsetA": 2, - "offsetIPIV": 0 -} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_a_offset.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_a_offset.json new file mode 100644 index 000000000000..89b034f623d3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_a_offset.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 2, + "strideA2": 1, + "offsetA": 2, + "A": [ 9999.0, 9999.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 9999.0, 9999.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 9999.0, 9999.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0, 9999.0, 9999.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_a_strides.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_a_strides.json new file mode 100644 index 000000000000..6c3e4456b5be --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_a_strides.json @@ -0,0 +1,74 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": null, + "strideA1": 6, + "strideA2": 2, + "offsetA": 0, + "A": [ + 1.0, + 9999.0, + 2.0, + 9999.0, + 9999.0, + 9999.0, + 3.0, + 9999.0, + 4.0, + 9999.0, + 9999.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ + 3.0, + 9999.0, + 4.0, + 9999.0, + 9999.0, + 9999.0, + 1.0, + 9999.0, + 2.0, + 9999.0, + 9999.0, + 9999.0, + 5.0, + 9999.0, + 6.0, + 9999.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json deleted file mode 100644 index 6e264b252787..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_an.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "order": "row-major", - "N": 3, - "k1": 0, - "k2": 2, - "IPIV": [ 2, 0, 1 ], - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], - "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], - "LDA": 3, - "strideIPIV": -1, - "offsetA": 0, - "offsetIPIV": 0 -} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json deleted file mode 100644 index 51a78f79b50b..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ao.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "order": "row-major", - "N": 3, - "k1": 0, - "k2": 2, - "IPIV": [ 2, 0, 1 ], - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], - "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], - "LDA": 2, - "strideIPIV": 1, - "offsetA": 0, - "offsetIPIV": 0 -} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aoio.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aoio.json deleted file mode 100644 index 3020f2384c16..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aoio.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "order": "row-major", - "N": 3, - "k1": 0, - "k2": 2, - "IPIV": [ 3, 2, 0, 1 ], - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], - "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], - "LDA": 2, - "strideIPIV": 1, - "offsetA": 0, - "offsetIPIV": 1 -} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json deleted file mode 100644 index 2d0256eed93c..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_aolt.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "order": "row-major", - "N": 3, - "k1": 0, - "k2": 2, - "IPIV": [ 2, 0, 1 ], - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], - "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ], - "LDA": 3, - "strideIPIV": 1, - "offsetA": 0, - "offsetIPIV": 0 -} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_complex_access_patterns.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_complex_access_patterns.json new file mode 100644 index 000000000000..f1e828d59051 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_complex_access_patterns.json @@ -0,0 +1,74 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": null, + "strideA1": 6, + "strideA2": -2, + "offsetA": 3, + "A": [ + 9999.0, + 2.0, + 9999.0, + 1.0, + 9999.0, + 9999.0, + 9999.0, + 4.0, + 9999.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 6.0, + 9999.0, + 5.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 9999, 1, 9999, 0, 9999, 2, 9999 ], + "strideIPIV": -2, + "offsetIPIV": 5, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ + 9999.0, + 4.0, + 9999.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 2.0, + 9999.0, + 1.0, + 9999.0, + 9999.0, + 9999.0, + 6.0, + 9999.0, + 5.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_offset.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_offset.json new file mode 100644 index 000000000000..3df422155856 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_offset.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 3, 4, 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 2, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride.json new file mode 100644 index 000000000000..1e4f74382c6c --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ], + [ 7.0, 8.0, 9.0 ] + ], + "N": 3, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 9999, 0, 9999, 1, 9999 ], + "strideIPIV": 2, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 4.0, 5.0, 6.0 ], + [ 1.0, 2.0, 3.0 ], + [ 7.0, 8.0, 9.0 ] + ], + "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_no_offsets.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_no_offsets.json new file mode 100644 index 000000000000..4969a8828beb --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_no_offsets.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json deleted file mode 100644 index 78f686ebad24..000000000000 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_oat.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "order": "row-major", - "N": 3, - "k1": 0, - "k2": 2, - "IPIV": [ 2, 0, 1 ], - "A": [ 7.0, 8.0, 9.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], - "A_out": [ 7.0, 8.0, 9.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ], - "LDA": 2, - "strideIPIV": 1, - "offsetA": 3, - "offsetIPIV": 0 -} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index a1ae44dfc875..944beebeadd6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -25,51 +25,30 @@ var tape = require( 'tape' ); var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var oneTo = require( '@stdlib/array/one-to' ); +var flatten = require( '@stdlib/array/base/flatten' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); var dlaswp = require( './../lib/ndarray.js' ); // FIXTURES // -var cao = require( './fixtures/column_major_ao.json' ); -var cat = require( './fixtures/column_major_at.json' ); -var coat = require( './fixtures/column_major_oat.json' ); -var caoit = require( './fixtures/column_major_aoit.json' ); -var ran = require( './fixtures/row_major_an.json' ); -var rao = require( './fixtures/row_major_ao.json' ); -var roat = require( './fixtures/row_major_oat.json' ); -var raolt = require( './fixtures/row_major_aolt.json' ); -var raoio = require( './fixtures/row_major_aoio.json' ); +var COL_MAJOR = require( './fixtures/column_major_no_offsets.json' ); +var COL_MAJOR_IPIV_STRIDE = require( './fixtures/column_major_ipiv_stride.json' ); +var COL_MAJOR_IPIV_OFFSET = require( './fixtures/column_major_ipiv_offset.json' ); +var COL_MAJOR_A_STRIDES = require( './fixtures/column_major_a_strides.json' ); +var COL_MAJOR_A_OFFSET = require( './fixtures/column_major_a_offset.json' ); +var COL_MAJOR_CMPLX_ACCESS = require( './fixtures/column_major_complex_access_patterns.json' ); - -// FUNCTIONS // - -/** -* Tests for element-wise approximate equality. -* -* @private -* @param {Object} t - test object -* @param {Collection} actual - actual values -* @param {Collection} expected - expected values -* @param {number} rtol - relative tolerance -*/ -function isApprox( t, actual, expected, rtol ) { - var delta; - var tol; - var i; - - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - if ( actual[ i ] === expected[ i ] ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } else { - delta = abs( actual[ i ] - expected[ i ] ); - tol = rtol * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - } -} +var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); +var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); +var ROW_MAJOR_IPIV_OFFSET = require( './fixtures/row_major_ipiv_offset.json' ); +var ROW_MAJOR_A_STRIDES = require( './fixtures/row_major_a_strides.json' ); +var ROW_MAJOR_A_OFFSET = require( './fixtures/row_major_a_offset.json' ); +var ROW_MAJOR_CMPLX_ACCESS = require( './fixtures/row_major_complex_access_patterns.json' ); // TESTS // @@ -80,15 +59,18 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 10', function test( t ) { - t.strictEqual( dlaswp.length, 10, 'returns expected value' ); +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( dlaswp.length, 12, 'returns expected value' ); t.end(); }); tape( 'the function throws an error if provided an invalid first argument', function test( t ) { var values; + var data; var i; + data = COL_MAJOR; + values = [ 'foo', 'bar', @@ -103,169 +85,343 @@ tape( 'the function throws an error if provided an invalid first argument', func function badValue( value ) { return function badValue() { - dlaswp( value, cao.N, cao.A, cao.LDA, cao.offsetA, cao.k1, cao.k2, cao.IPIV, cao.strideIPIV, cao.offsetIPIV ); + dlaswp( value, data.N, data.A, data.LDA, data.offsetA, data.k1, data.k2, data.IPIV, data.strideIPIV, data.offsetIPIV ); }; } }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=1)', function test( t ) { +tape( 'the function performs a series of row interchanges (column-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( cao.A ); - IPIV = new Int32Array( cao.IPIV ); + data = COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `IPIV` stride (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_IPIV_STRIDE; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - expected = new Float64Array( cao.A_out ); + expected = new Float64Array( data.A_out ); - out = dlaswp( cao.order, cao.N, A, cao.LDA, cao.offsetA, cao.k1, cao.k2, IPIV, cao.strideIPIV, cao.offsetIPIV ); + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=1, offsetIPIV=2)', function test( t ) { +tape( 'the function supports an `IPIV` offset (column-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( caoit.A ); - IPIV = new Int32Array( caoit.IPIV ); + data = COL_MAJOR_IPIV_OFFSET; - expected = new Float64Array( caoit.A_out ); + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - out = dlaswp( caoit.order, caoit.N, A, caoit.LDA, caoit.offsetA, caoit.k1, caoit.k2, IPIV, caoit.strideIPIV, caoit.offsetIPIV ); + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=2)', function test( t ) { +tape( 'the function supports `A` strides (column-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( cat.A ); - IPIV = new Int32Array( cat.IPIV ); + data = COL_MAJOR_A_STRIDES; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - expected = new Float64Array( cat.A_out ); + expected = new Float64Array( data.A_out ); - out = dlaswp( cat.order, cat.N, A, cat.LDA, cat.offsetA, cat.k1, cat.k2, IPIV, cat.strideIPIV, cat.offsetIPIV ); + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1)', function test( t ) { +tape( 'the function supports an `A` offset (column-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( rao.A ); - IPIV = new Int32Array( rao.IPIV ); + data = COL_MAJOR_A_OFFSET; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - expected = new Float64Array( rao.A_out ); + expected = new Float64Array( data.A_out ); - out = dlaswp( rao.order, rao.N, A, rao.LDA, rao.offsetA, rao.k1, rao.k2, IPIV, rao.strideIPIV, rao.offsetIPIV ); + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1, LDA=2)', function test( t ) { +tape( 'the function supports complex access patterns (column-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( raolt.A ); - IPIV = new Int32Array( raolt.IPIV ); + data = COL_MAJOR_CMPLX_ACCESS; - expected = new Float64Array( raolt.A_out ); + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - out = dlaswp( raolt.order, raolt.N, A, raolt.LDA, raolt.offsetA, raolt.k1, raolt.k2, IPIV, raolt.strideIPIV, raolt.offsetIPIV ); + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=-1)', function test( t ) { +tape( 'the function efficiently handles large datasets (column-major)', function test( t ) { var expected; var IPIV; + var buf; + var mat; var out; + var ord; + var sh; + var st; var A; + var o; + + ord = 'column-major'; + sh = [ 5, 100 ]; + st = shape2strides( sh, ord ); + o = 0; + + // Define a linear buffer: + buf = oneTo( numel( sh ), 'generic' ); - A = new Float64Array( ran.A ); - IPIV = new Int32Array( ran.IPIV ); + // Convert to a nested array: + mat = ndarray2array( buf, sh, st, o, ord ); - expected = new Float64Array( ran.A_out ); + // Define an input matrix in linear storage: + A = new Float64Array( buf ); + + // Create an array of pivot indices: + IPIV = new Int32Array( [ 9999, 9999, 9999, 1, 0 ] ); + + // Define the expected output array: + expected = reverse( mat.slice() ); + expected = new Float64Array( flatten( expected, sh, true ) ); + + // Interchange rows: + out = dlaswp( ord, sh[1], A, st[0], st[1], o, 3, 4, 1, IPIV, 1, 0 ); - out = dlaswp( ran.order, ran.N, A, ran.LDA, ran.offsetA, ran.k1, ran.k2, IPIV, ran.strideIPIV, ran.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1, offsetA=3)', function test( t ) { +tape( 'the function performs a series of row interchanges (row-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( roat.A ); - IPIV = new Int32Array( roat.IPIV ); + data = ROW_MAJOR; - expected = new Float64Array( roat.A_out ); + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - out = dlaswp( roat.order, roat.N, A, roat.LDA, roat.offsetA, roat.k1, roat.k2, IPIV, roat.strideIPIV, roat.offsetIPIV ); + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (column-major, strideIPIV=1, offsetA=2)', function test( t ) { +tape( 'the function supports an `IPIV` stride (row-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( coat.A ); - IPIV = new Int32Array( coat.IPIV ); + data = ROW_MAJOR_IPIV_STRIDE; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - expected = new Float64Array( coat.A_out ); + expected = new Float64Array( data.A_out ); - out = dlaswp( coat.order, coat.N, A, coat.LDA, coat.offsetA, coat.k1, coat.k2, IPIV, coat.strideIPIV, coat.offsetIPIV ); + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1, offsetIPIV=1)', function test( t ) { +tape( 'the function supports an `IPIV` offset (row-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( raoio.A ); - IPIV = new Int32Array( raoio.IPIV ); + data = ROW_MAJOR_IPIV_OFFSET; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports `A` strides (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_A_STRIDES; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an `A` offset (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_A_OFFSET; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_CMPLX_ACCESS; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function efficiently handles large datasets (row-major)', function test( t ) { + var expected; + var IPIV; + var buf; + var mat; + var out; + var ord; + var sh; + var st; + var A; + var o; + + ord = 'row-major'; + sh = [ 5, 100 ]; + st = shape2strides( sh, ord ); + o = 0; + + // Define a linear buffer: + buf = oneTo( numel( sh ), 'generic' ); + + // Convert to a nested array: + mat = ndarray2array( buf, sh, st, o, ord ); + + // Define an input matrix in linear storage: + A = new Float64Array( buf ); + + // Create an array of pivot indices: + IPIV = new Int32Array( [ 9999, 9999, 9999, 1, 0 ] ); + + // Define the expected output array: + expected = reverse( mat.slice() ); + expected = new Float64Array( flatten( expected, sh, false ) ); - expected = new Float64Array( raoio.A_out ); + // Interchange rows: + out = dlaswp( ord, sh[1], A, st[0], st[1], o, 3, 4, 1, IPIV, 1, 0 ); - out = dlaswp( raoio.order, raoio.N, A, raoio.LDA, raoio.offsetA, raoio.k1, raoio.k2, IPIV, raoio.strideIPIV, raoio.offsetIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); From ddfd2c730ddcd3db27336e63e242d75e4004264d Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 03:22:28 -0700 Subject: [PATCH 38/60] fix: account for layout when passing stride arguments and update tests --- .../@stdlib/lapack/base/dlaswp/lib/dlaswp.js | 11 +- .../test/fixtures/column_major_lda.json | 86 +++++++ .../dlaswp/test/fixtures/row_major_lda.json | 62 +++++ .../lapack/base/dlaswp/test/test.dlaswp.js | 232 +++++++++++++----- 4 files changed, 324 insertions(+), 67 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_lda.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_lda.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js index 0c0d1f335c0a..d59258906ada 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js @@ -56,6 +56,8 @@ var base = require( './base.js' ); function dlaswp( order, N, A, LDA, k1, k2, IPIV, incx ) { var tmp; var inc; + var sa1; + var sa2; var io; if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); @@ -75,7 +77,14 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incx ) { } else { return A; } - return base( order, N, A, LDA, 1, 0, k1, k2, inc, IPIV, 1, io ); + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( order, N, A, sa1, sa2, 0, k1, k2, inc, IPIV, incx, io ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_lda.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_lda.json new file mode 100644 index 000000000000..bb3a75306122 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_lda.json @@ -0,0 +1,86 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 12, + "strideA1": 1, + "strideA2": 12, + "offsetA": 0, + "A": [ + 1.0, + 2.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 4.0, + 5.0, + 6.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ + 2.0, + 1.0, + 3.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 5.0, + 4.0, + 6.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_lda.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_lda.json new file mode 100644 index 000000000000..5b5bd1747642 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_lda.json @@ -0,0 +1,62 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 4, + "strideA1": 4, + "strideA2": 1, + "offsetA": 0, + "A": [ + 1.0, + 2.0, + 9999.0, + 9999.0, + 3.0, + 4.0, + 9999.0, + 9999.0, + 5.0, + 6.0, + 9999.0, + 9999.0 +], + + "k1": 0, + "k2": 2, + "incK": 1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 0, 2 ], + [ 1, 0 ], + [ 2, 1 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ + 3.0, + 4.0, + 9999.0, + 9999.0, + 1.0, + 2.0, + 9999.0, + 9999.0, + 5.0, + 6.0, + 9999.0, + 9999.0 + ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js index e47d6023ef3d..bd21ae305a73 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js @@ -25,47 +25,24 @@ var tape = require( 'tape' ); var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); -var EPS = require( '@stdlib/constants/float64/eps' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var oneTo = require( '@stdlib/array/one-to' ); +var flatten = require( '@stdlib/array/base/flatten' ); +var reverse = require( '@stdlib/array/base/reverse' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var numel = require( '@stdlib/ndarray/base/numel' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); var dlaswp = require( './../lib/dlaswp.js' ); // FIXTURES // -var cao = require( './fixtures/column_major_ao.json' ); -var cat = require( './fixtures/column_major_at.json' ); -var ran = require( './fixtures/row_major_an.json' ); -var rao = require( './fixtures/row_major_ao.json' ); -var raolt = require( './fixtures/row_major_aolt.json' ); +var COL_MAJOR = require( './fixtures/column_major_no_offsets.json' ); +var COL_MAJOR_IPIV_STRIDE = require( './fixtures/column_major_ipiv_stride.json' ); +var COL_MAJOR_LDA = require( './fixtures/column_major_lda.json' ); - -// FUNCTIONS // - -/** -* Tests for element-wise approximate equality. -* -* @private -* @param {Object} t - test object -* @param {Collection} actual - actual values -* @param {Collection} expected - expected values -* @param {number} rtol - relative tolerance -*/ -function isApprox( t, actual, expected, rtol ) { - var delta; - var tol; - var i; - - t.strictEqual( actual.length, expected.length, 'returns expected value' ); - for ( i = 0; i < expected.length; i++ ) { - if ( actual[ i ] === expected[ i ] ) { - t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); - } else { - delta = abs( actual[ i ] - expected[ i ] ); - tol = rtol * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); - } - } -} +var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); +var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); +var ROW_MAJOR_LDA = require( './fixtures/row_major_lda.json' ); // TESTS // @@ -83,8 +60,11 @@ tape( 'the function has an arity of 8', function test( t ) { tape( 'the function throws an error if provided an invalid first argument', function test( t ) { var values; + var data; var i; + data = COL_MAJOR; + values = [ 'foo', 'bar', @@ -99,97 +79,217 @@ tape( 'the function throws an error if provided an invalid first argument', func function badValue( value ) { return function badValue() { - dlaswp( value, cao.N, cao.A, cao.LDA, cao.k1, cao.k2, cao.IPIV, cao.strideIPIV ); + dlaswp( value, data.N, data.A, data.LDA, data.k1, data.k2, data.IPIV, data.strideIPIV ); }; } }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=1)', function test( t ) { +tape( 'the function performs a series of row interchanges (column-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( cao.A ); - IPIV = new Int32Array( cao.IPIV ); + data = COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - expected = new Float64Array( cao.A_out ); + expected = new Float64Array( data.A_out ); - out = dlaswp( 'column-major', cao.N, A, cao.LDA, cao.k1, cao.k2, IPIV, cao.strideIPIV ); + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `LDA` by `N` matrix (column-major, strideIPIV=2)', function test( t ) { +tape( 'the function supports specifying an `LDA` parameter for operating on sub-matrices (column-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( cat.A ); - IPIV = new Int32Array( cat.IPIV ); + data = COL_MAJOR_LDA; - expected = new Float64Array( cat.A_out ); + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - out = dlaswp( 'column-major', cat.N, A, cat.LDA, cat.k1, cat.k2, IPIV, cat.strideIPIV ); + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1)', function test( t ) { +tape( 'the function supports specifying an increment between successive values of `IPIV` (column-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( rao.A ); - IPIV = new Int32Array( rao.IPIV ); + data = COL_MAJOR_IPIV_STRIDE; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); - expected = new Float64Array( rao.A_out ); + expected = new Float64Array( data.A_out ); - out = dlaswp( 'row-major', rao.N, A, rao.LDA, rao.k1, rao.k2, IPIV, rao.strideIPIV ); + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=1, LDA=2)', function test( t ) { +tape( 'the function efficiently handles large datasets (column-major)', function test( t ) { var expected; var IPIV; + var buf; + var mat; var out; + var ord; + var sh; + var st; var A; + var o; + + ord = 'column-major'; + sh = [ 5, 100 ]; + st = shape2strides( sh, ord ); + o = 0; + + // Define a linear buffer: + buf = oneTo( numel( sh ), 'generic' ); + + // Convert to a nested array: + mat = ndarray2array( buf, sh, st, o, ord ); + + // Define an input matrix in linear storage: + A = new Float64Array( buf ); - A = new Float64Array( raolt.A ); - IPIV = new Int32Array( raolt.IPIV ); + // Create an array of pivot indices: + IPIV = new Int32Array( [ 9999, 9999, 9999, 1, 0 ] ); - expected = new Float64Array( raolt.A_out ); + // Define the expected output array: + expected = reverse( mat.slice() ); + expected = new Float64Array( flatten( expected, sh, true ) ); + + // Interchange rows: + out = dlaswp( ord, sh[1], A, sh[0], 3, 4, IPIV, 1 ); - out = dlaswp( 'row-major', raolt.N, A, raolt.LDA, raolt.k1, raolt.k2, IPIV, raolt.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function performs a series of row interchanges on the matrix `A`, where `A` is an `N` by `LDA` matrix (row-major, strideIPIV=-1)', function test( t ) { +tape( 'the function performs a series of row interchanges (row-major)', function test( t ) { var expected; var IPIV; + var data; var out; var A; - A = new Float64Array( ran.A ); - IPIV = new Int32Array( ran.IPIV ); + data = ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `LDA` parameter for operating on sub-matrices (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_LDA; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an increment between successive values of `IPIV` (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_IPIV_STRIDE; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function efficiently handles large datasets (row-major)', function test( t ) { + var expected; + var IPIV; + var buf; + var mat; + var out; + var ord; + var sh; + var st; + var A; + var o; + + ord = 'row-major'; + sh = [ 5, 100 ]; + st = shape2strides( sh, ord ); + o = 0; + + // Define a linear buffer: + buf = oneTo( numel( sh ), 'generic' ); + + // Convert to a nested array: + mat = ndarray2array( buf, sh, st, o, ord ); + + // Define an input matrix in linear storage: + A = new Float64Array( buf ); + + // Create an array of pivot indices: + IPIV = new Int32Array( [ 9999, 9999, 9999, 1, 0 ] ); + + // Define the expected output array: + expected = reverse( mat.slice() ); + expected = new Float64Array( flatten( expected, sh, false ) ); - expected = new Float64Array( ran.A_out ); + // Interchange rows: + out = dlaswp( ord, sh[1], A, sh[1], 3, 4, IPIV, 1 ); - out = dlaswp( 'row-major', ran.N, A, ran.LDA, ran.k1, ran.k2, IPIV, ran.strideIPIV ); t.strictEqual( out, A, 'returns expected value' ); - isApprox( t, A, expected, 2.0 ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); From 3e53660f82020943aa9eb6b4c368e6b4ddcc781e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 03:27:10 -0700 Subject: [PATCH 39/60] docs: fix parameters and resolve lint errors --- .../@stdlib/lapack/base/dlaswp/lib/ndarray.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js index 2fe0b066acd7..baa01645ec20 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js @@ -21,7 +21,6 @@ // MODULES // var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); -var max = require( '@stdlib/math/base/special/max' ); var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -34,16 +33,16 @@ var base = require( './base.js' ); * @param {string} order - storage layout * @param {PositiveInteger} N - number of columns in `A` * @param {Float64Array} A - matrix -* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` * @param {NonNegativeInteger} k1 - index of first row to interchange * @param {NonNegativeInteger} k2 - index of last row to interchange +* @param {integer} inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order) * @param {Int32Array} IPIV - vector of pivot indices * @param {integer} strideIPIV - `IPIV` stride length * @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV` -* @param {integer} incx - increment between successive values of `IPIV` * @throws {TypeError} first argument must be a valid order -* @throws {RangeError} fourth argument must be greater than or equal to max(1,N) * @returns {Float64Array} permuted matrix `A` * * @example @@ -53,10 +52,10 @@ var base = require( './base.js' ); * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = 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 ] ] * -* dlaswp( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0, 1, 1 ); +* dlaswp( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ -function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len +function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params var tmp; if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); From d668fe1156f81bf690b5212f80a181598892b6f2 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 03:28:45 -0700 Subject: [PATCH 40/60] docs: fix example --- lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js index 460ed29888ea..07a4a7919e83 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/index.js @@ -31,7 +31,7 @@ * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = 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 ] ] * -* dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); +* dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ From 5c29c0fce8fc5a06564b090b79c3e5e14aed9360 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 03:32:45 -0700 Subject: [PATCH 41/60] docs: update example --- lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js index ee94df4b08c0..ce1b2aac76a9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js @@ -25,5 +25,5 @@ var dlaswp = require( './../lib' ); var IPIV = new Int32Array( [ 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); +dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); console.log( A ); From 81b27acf90287161339a121658a2d2df935b3564 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Fri, 12 Jul 2024 00:13:00 +0530 Subject: [PATCH 42/60] chore: consequent changes --- .../@stdlib/lapack/base/dlaswp/README.md | 49 +-- .../lapack/base/dlaswp/benchmark/benchmark.js | 2 +- .../dlaswp/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/lapack/base/dlaswp/docs/repl.txt | 54 +-- .../lapack/base/dlaswp/docs/types/index.d.ts | 42 +-- .../lapack/base/dlaswp/docs/types/test.ts | 339 +++++++++++------- .../lapack/base/dlaswp/examples/index.js | 2 +- 7 files changed, 284 insertions(+), 206 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 8596d1e70b0a..8191cfbd9692 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -41,8 +41,8 @@ var Float64Array = require( '@stdlib/array/float64' ); var IPIV = new Int32Array( [ 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); -// A => [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] +dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] ``` The function has the following parameters: @@ -62,11 +62,11 @@ The increment parameters determine how elements in the IPIV array are accessed a var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); -var IPIV = new Int32Array( [ 2, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var IPIV = new Int32Array( [ 2, 0, 0, 0, 1 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); -dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 2 ); -// A => [ 3.0, 2.0, 5.0, 4.0, 1.0, 6.0 ] +dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 2 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -78,50 +78,51 @@ var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); // Initial arrays... -var IPIV = new Int32Array( [ 2, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var IPIV0 = new Int32Array( [ 0, 2, 0, 1] ); +var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); // Create offset views... -var IPIV1 = new Int32Array( IPIV.buffer, IPIV.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var A1 = new Float64Array( A.buffer, A.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var IPIV1 = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 1st element +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 1st element -dlaswp( 'column-major', 3, A1, 2, 0, 2, IPIV1, 1 ); -// A1 => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] +dlaswp( 'row-major', 2, A1, 2, 0, 2, IPIV1, 1 ); +// A0 => [ 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] ``` -#### dlaswp.ndarray( order, N, A, LDA, oa, k1, k2, IPIV, sipiv, oipiv ) +#### dlaswp.ndarray( order, N, A, sa1, sa2, oa, k1, k2, inck, IPIV, sipiv, oipiv ) Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. ```javascript -var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); var IPIV = new Int32Array( [ 2, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -dlaswp.ndarray( 'row-major', 3, A, 2, 3, 0, 2, IPIV, 1, 0 ); -console.log( A ); -// A => [ 1.0, 2.0, 3.0, 6.0, 7.0, 4.0, 5.0, 8.0, 9.0 ] +dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] ``` The function has the following additional parameters: +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. - **oa**: starting index for `A`. +- **inck**: direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order). - **oipiv**: starting index for `IPIV`. While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, ```javascript -var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); -var IPIV = new Int32Array( [ 1, 0, 2, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +var IPIV = new Int32Array( [ 2, 0, 1 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -dlaswp.ndarray( 'column-major', 3, A, 2, 2, 0, 2, IPIV, 1, 2 ); -console.log( A ); -// A => [ 1.0, 2.0, 4.0, 5.0, 6.0, 7.0, 3.0, 8.0, 9.0 ] +dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] ```
diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js index 22929031719b..f1b56a764e90 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js @@ -63,7 +63,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, N, 0, IPIV.length-1, IPIV, 1 ); + z = dlaswp( 'column-major', N, A, N, 0, 2, IPIV, 1 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js index c37f5111613c..a6cb4a023be9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js @@ -63,7 +63,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, N, 0, 0, IPIV.length-1, IPIV, 1, 0 ); + z = dlaswp( 'column-major', N, A, 1, 1, 0, 0, IPIV.length-1, 1, IPIV, 1, 0); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt index 7b365f2b9775..479460d900a9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -46,27 +46,27 @@ // Standard usage: > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > var ord = 'column-major'; - > {{alias}}( ord, 3, A, 2, 0, 2, IPIV, 1 ) - [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + > var ord = 'row-major'; + > {{alias}}( ord, 2, A, 2, 0, 2, IPIV, 1 ) + [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] // Advanced indexing: - > IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); - > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}( ord, 3, A, 2, 0, 2, IPIV, 2 ) - [ 3.0, 2.0, 5.0, 4.0, 1.0, 6.0 ] + > IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 0, 0, 1 ] ); + > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); + > {{alias}}( ord, 2, A, 2, 0, 2, IPIV, 2 ) + [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] // Using typed array views: - > var IPIV0 = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); - > var A0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > IPIV = new Int32Array( IPIV0.buffer, IPIV0.byteOffset, IPIV0.length ); - > A = new Float64Array( A0.buffer, A0.byteOffset, A0.length ); - > {{alias}}( ord, 3, A, 2, 0, 2, IPIV, 1 ); + > var IPIV0 = new {{alias:@stdlib/array/int32}}( [ 0, 2, 0, 1 ] ); + > var A0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > IPIV = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); + > A = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( ord, 2, A, 2, 0, 2, IPIV, 1 ); > A0 - [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + [ 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] -{{alias}}.ndarray( order, N, A, LDA, oa, k1, k2, IPIV, sipiv, oipiv ) +{{alias}}.ndarray( ord, N, A, sa1, sa2, oa, k1, k2, inck, IPIV, sipiv, oipiv ) Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. @@ -76,7 +76,7 @@ Parameters ---------- - order: string + ord: string Row-major (C-style) or column-major (Fortran-style) order. Must be either 'row-major' or 'column-major'. @@ -86,9 +86,11 @@ A: Float64Array Matrix. - LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. oa: integer Index offset for `A`. @@ -99,6 +101,10 @@ k2: integer Index of last row to interchange. + inck: integer + Direction in which to apply pivots (-1 to apply pivots in reverse + order; otherwise, apply in provided order). + IPIV: Int32Array Array of pivot indices. @@ -118,15 +124,15 @@ // Standard usage: > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > var ord = 'column-major'; - > {{alias}}.ndarray( ord, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ) - [ 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + > var ord = 'row-major'; + > {{alias}}.ndarray( ord, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ) + [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] // Advanced indexing: > IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); - > A = new {{alias:@stdlib/array/float64}}( [ 7.0, 8.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}.ndarray( ord, 3, A, 2, 2, 0, 2, IPIV, 1, 0 ) - [ 7.0, 8.0, 2.0, 3.0, 4.0, 5.0, 1.0, 6.0 ] + > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > {{alias}}.ndarray( ord, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ) + [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] See Also -------- diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts index b84489163ffb..0de74d669aa6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts @@ -27,17 +27,17 @@ import { Layout } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. + * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. * * @param order - storage layout * @param N - number of columns in `A` - * @param A - matrix + * @param A - input matrix * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange * @param IPIV - vector of pivot indices - * @param strideIPIV - `IPIV` stride length - * @returns `A` + * @param incx - increment between successive values of `IPIV` + * @returns permuted matrix `A` * * @example * var Int32Array = require( '@stdlib/array/int32' ); @@ -46,25 +46,27 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = 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 ] ] * - * dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); + * dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ - ( order: Layout, N: number, A: Float64Array, LDA: number, k1: number, k2: number, IPIV: Int32Array, incX: number ): Float64Array; + ( order: Layout, N: number, A: Float64Array, LDA: number, k1: number, k2: number, IPIV: Int32Array, incx: number ): Float64Array; /** - * Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. + * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. * * @param order - storage layout * @param N - number of columns in `A` * @param A - matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) - * @param offsetA - starting index for `A` + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - index offset for `A` * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange + * @param inck - direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order) * @param IPIV - vector of pivot indices - * @param strideIPIV - increment between successive values of `IPIV` - * @param offsetIPIV - starting index for `IPIV` - * @returns `A` + * @param strideIPIV - `IPIV` stride length + * @param offsetIPIV - index offset for `IPIV` + * @returns permuted matrix `A` * * @example * var Int32Array = require( '@stdlib/array/int32' ); @@ -73,24 +75,24 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = 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 ] ] * - * dlaswp.ndarray( 'row-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); + * dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ - ndarray( order: Layout, N: number, A: Float64Array, LDA: number, offsetA: number, k1: number, k2: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number ): Float64Array; + ndarray( order: Layout, N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, k1: number, k2: number, inck: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number ): Float64Array; } /** -* Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV`. +* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. * * @param order - storage layout * @param N - number of columns in `A` -* @param A - matrix +* @param A - input matrix * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param k1 - index of first row to interchange * @param k2 - index of last row to interchange * @param IPIV - vector of pivot indices -* @param strideIPIV - `IPIV` stride length -* @returns `A` +* @param incx - increment between successive values of `IPIV` +* @returns permuted matrix `A` * * @example * var Int32Array = require( '@stdlib/array/int32' ); @@ -99,7 +101,7 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = 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 ] ] * -* dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, 1 ); +* dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] * * @example @@ -109,7 +111,7 @@ interface Routine { * var IPIV = new Int32Array( [ 2, 0, 1 ] ); * var A = 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 ] ] * -* dlaswp.ndarray( 'row-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); +* dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); * // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] */ declare var dlaswp: Routine; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts index 0141f989035a..3ad73057ad3e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts @@ -34,11 +34,11 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp( 10, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 5, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( true, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( false, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( null, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( undefined, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( void 0, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( [], 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( {}, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( ( x: number ): number => x, 3, A, 2, 0, 2, IPIV, 1 ); // $ExpectError @@ -49,12 +49,12 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp( 'column-major', '3', A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', '5', A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', true, A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', false, A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', null, A, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'column-major', undefined, A, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'column-major', [ '1' ], A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', void 0, A, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', [], A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', {}, A, 2, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', ( x: number ): number => x, A, 2, 0, 2, IPIV, 1 ); // $ExpectError } @@ -63,14 +63,15 @@ import dlaswp = require( './index' ); { const IPIV = new Int32Array( 3 ); - dlaswp( 'row-major', 3, '10', 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, true, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, false, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, null, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, undefined, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, [ '1' ], 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, {}, 2, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, ( x: number ): number => x, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, '5', 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, 5, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, true, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, false, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, null, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, void 0, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, [], 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, {}, 2, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, ( x: number ): number => x, 2, 0, 2, IPIV, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -78,11 +79,11 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp( 'column-major', 3, A, '2', 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, '5', 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', 3, A, true, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', 3, A, false, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', 3, A, null, 0, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'column-major', 3, A, undefined, 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, void 0, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', 3, A, [], 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', 3, A, {}, 0, 2, IPIV, 1 ); // $ExpectError dlaswp( 'column-major', 3, A, ( x: number ): number => x, 0, 2, IPIV, 1 ); // $ExpectError @@ -93,14 +94,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp( 'row-major', 3, A, 2, '0', 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, true, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, false, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, null, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, undefined, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, [], 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, {}, 2, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, ( x: number ): number => x, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, '5', 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, true, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, false, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, null, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, void 0, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, [], 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, {}, 2, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, ( x: number ): number => x, 2, IPIV, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not a number... @@ -108,28 +109,29 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp( 'row-major', 3, A, 2, 0, '2', IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, true, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, false, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, null, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, undefined, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, [], IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, {}, IPIV, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, ( x: number ): number => x, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, '5', IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, true, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, false, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, null, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, void 0, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, [], IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, {}, IPIV, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, ( x: number ): number => x, IPIV, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not an Int32Array... { const A = new Float64Array( 6 ); - dlaswp( 'row-major', 3, A, 2, 0, 2, 'IPIV', 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, true, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, false, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, null, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, undefined, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, [], 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, {}, 1 ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, ( x: number ): number => x, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, '5', 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, 5, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, true, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, false, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, null, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, void 0, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, [], 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, {}, 1 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, ( x: number ): number => x, 1 ); // $ExpectError } // The compiler throws an error if the function is provided an eighth argument which is not a number... @@ -137,23 +139,38 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, '1' ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, true ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, false ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, null ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, undefined ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, [] ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, {} ); // $ExpectError - dlaswp( 'row-major', 3, A, 2, 0, 2, IPIV, ( x: number ): number => x ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, '5' ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, true ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, false ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, null ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, void 0 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, [] ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, {} ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, ( x: number ): number => x ); // $ExpectError } -// Attached to main export is an `ndarray` method which returns a Float64Array... +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + dlaswp(); // $ExpectError + dlaswp( 'column-major' ); // $ExpectError + dlaswp( 'column-major', 3 ); // $ExpectError + dlaswp( 'column-major', 3, A ); // $ExpectError + dlaswp( 'column-major', 3, A, 2 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2 ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV ); // $ExpectError + dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... { const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectType Float64Array + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectType Float64Array } // The compiler throws an error if the function is provided a first argument which is not a string... @@ -161,14 +178,14 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 10, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( true, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( false, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( null, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( void 0, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( [], 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( {}, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( ( x: number ): number => x, 3, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 5, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( true, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( false, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( null, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( void 0, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( [], 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( {}, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( ( x: number ): number => x, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... @@ -176,102 +193,104 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', '3', A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', true, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', false, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', null, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', void 0, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', [], A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', {}, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', ( x: number ): number => x, A, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', '5', A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', true, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', false, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', null, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', void 0, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', [], A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', {}, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', ( x: number ): number => x, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a Float64Array... { const IPIV = new Int32Array( 3 ); - dlaswp.ndarray( 'column-major', 3, 10, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, true, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, false, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, null, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, void 0, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, [], 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, {}, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, ( x: number ): number => x, 2, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, '5', 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, 5, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, true, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, false, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, null, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, void 0, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, [], 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, {}, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, ( x: number ): number => x, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fourth argument which is not an integer... +// The compiler throws an error if the function is provided a fourth argument which is not a number... { const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, '0', 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, true, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, false, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, null, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, void 0, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, [], 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, {}, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, ( x: number ): number => x, 0, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, '5', 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, true, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, false, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, null, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, void 0, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, [], 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, {}, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, ( x: number ): number => x, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fifth argument which is not an integer... +// The compiler throws an error if the function is provided a fifth argument which is not a number... { const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 2, '2', 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, true, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, false, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, null, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, void 0, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, [], 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, {}, 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, ( x: number ): number => x, 0, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, '5', 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, true, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, false, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, null, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, void 0, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, [], 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, {}, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, ( x: number ): number => x, 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a sixth argument which is not an integer... +// The compiler throws an error if the function is provided a sixth argument which is not a number... { const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 2, 0, '0', 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, true, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, false, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, null, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, void 0, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, [], 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, {}, 2, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, ( x: number ): number => x, 2, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, '5', 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, true, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, false, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, null, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, void 0, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, [], 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, {}, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, ( x: number ): number => x, 0, 2, 1, IPIV, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a seventh argument which is not an integer... +// The compiler throws an error if the function is provided a seventh argument which is not a number... { const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, '2', IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, true, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, false, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, null, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, void 0, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, [], IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, {}, IPIV, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, ( x: number ): number => x, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, '5', 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, true, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, false, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, null, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, void 0, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, [], 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, {}, 2, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, ( x: number ): number => x, 2, 1, IPIV, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided an eighth argument which is not an Int32Array... +// The compiler throws an error if the function is provided an eighth argument which is not a number... { + const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, 'IPIV', 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, true, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, false, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, null, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, void 0, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, [], 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, {}, 1, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, ( x: number ): number => x, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, '5', 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, true, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, false, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, null, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, void 0, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, [], 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, {}, 1, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, ( x: number ): number => x, 1, IPIV, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a ninth argument which is not a number... @@ -279,27 +298,77 @@ import dlaswp = require( './index' ); const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, '1', 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, true, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, false, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, null, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, void 0, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, [], 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, {}, 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, ( x: number ): number => x, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, '5', IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, true, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, false, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, null, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, void 0, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, [], IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, {}, IPIV, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, ( x: number ): number => x, IPIV, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not an Int32Array... +{ + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, '5', 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, 5, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, true, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, false, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, null, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, void 0, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, [], 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, {}, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, '5', 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, true, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, false, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, null, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, void 0, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, [], 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, {}, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const IPIV = new Int32Array( 3 ); + const A = new Float64Array( 6 ); + + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, '5' ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, true ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, false ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, null ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, void 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, [] ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, {} ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, ( x: number ): number => x ); // $ExpectError } -// The compiler throws an error if the function is provided a tenth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... { const IPIV = new Int32Array( 3 ); const A = new Float64Array( 6 ); - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, '1' ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, true ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, false ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, null ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, void 0 ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, [] ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, {} ); // $ExpectError - dlaswp.ndarray( 'column-major', 3, A, 2, 0, 0, 2, IPIV, 0, ( x: number ): number => x ); // $ExpectError + dlaswp.ndarray(); // $ExpectError + dlaswp.ndarray( 'row-major' ); // $ExpectError + dlaswp.ndarray( 'row-major', 2 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1 ); // $ExpectError + dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0, 10 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js index ce1b2aac76a9..50023e3d184a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js @@ -25,5 +25,5 @@ var dlaswp = require( './../lib' ); var IPIV = new Int32Array( [ 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +dlaswp( 'column-major', 2, A, 2, 0, 2, IPIV, 1 ); console.log( A ); From 4c663d39661f3ac7eaa79a765d2f6d68976e0394 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Fri, 12 Jul 2024 00:14:25 +0530 Subject: [PATCH 43/60] fix: incorrect readme example --- lib/node_modules/@stdlib/lapack/base/dlaswp/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 8191cfbd9692..c67eb4dc9abe 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -153,7 +153,7 @@ var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); var IPIV = new Int32Array( [ 2, 0, 1 ] ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -dlaswp( 'column-major', 3, A, 2, 0, 2, IPIV, 1 ); +dlaswp( 'column-major', 2, A, 2, 0, 2, IPIV, 1 ); console.log( A ); ``` From 5af48c0d0eed2e5154d66b3cad0d9aeb18e036fe Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 12:42:51 -0700 Subject: [PATCH 44/60] bench: add facet for the number of interchanged rows --- .../lapack/base/dlaswp/benchmark/benchmark.js | 16 +++++++++++----- .../base/dlaswp/benchmark/benchmark.ndarray.js | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js index f1b56a764e90..2bedc386513c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js @@ -37,13 +37,14 @@ var dlaswp = require( './../lib/dlaswp.js' ); * * @private * @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} nrows - number of rows to interchange * @returns {Function} benchmark function */ -function createBenchmark( N ) { +function createBenchmark( N, nrows ) { var IPIV; var A; - IPIV = discreteUniform( 5, 0, N-1, { + IPIV = discreteUniform( nrows, 0, N-1, { 'dtype': 'int32' }); A = uniform( N*N, -10.0, 10.0, { @@ -63,7 +64,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, N, 0, 2, IPIV, 1 ); + z = dlaswp( 'column-major', N, A, N, 0, nrows-1, IPIV, 1 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } @@ -91,14 +92,19 @@ function main() { var N; var f; var i; + var j; min = 1; // 10^min max = 6; // 10^max for ( i = min; i <= max; i++ ) { N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - f = createBenchmark( N ); - bench( pkg+':order=column-major,size='+(N*N), f ); + j = 1; + while ( j <= N ) { + f = createBenchmark( N, j ); + bench( pkg+'::square_matrix:order=column-major,nrows='+j+',size='+(N*N), f ); + j *= 2; + } } } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js index a6cb4a023be9..e50b1fd300db 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js @@ -37,13 +37,14 @@ var dlaswp = require( './../lib/ndarray.js' ); * * @private * @param {PositiveInteger} N - number of elements along each dimension +* @param {PositiveInteger} nrows - number of rows to interchange * @returns {Function} benchmark function */ -function createBenchmark( N ) { +function createBenchmark( N, nrows ) { var IPIV; var A; - IPIV = discreteUniform( 5, 0, N-1, { + IPIV = discreteUniform( nrows, 0, N-1, { 'dtype': 'int32' }); A = uniform( N*N, -10.0, 10.0, { @@ -63,7 +64,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, 1, 1, 0, 0, IPIV.length-1, 1, IPIV, 1, 0); + z = dlaswp( 'column-major', N, A, 1, N, 0, 0, nrows-1, 1, IPIV, 1, 0 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } @@ -91,14 +92,19 @@ function main() { var N; var f; var i; + var j; min = 1; // 10^min max = 6; // 10^max for ( i = min; i <= max; i++ ) { N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - f = createBenchmark( N ); - bench( pkg+':ndarray:order=column-major,size='+(N*N), f ); + j = 1; + while ( j <= N ) { + f = createBenchmark( N, j ); + bench( pkg+'::square_matrix:ndarray:order=column-major,nrows='+j+',size='+(N*N), f ); + j *= 2; + } } } From 254f41ff5636527fa78d4795d62a37607f33a339 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 12:53:44 -0700 Subject: [PATCH 45/60] bench: add facet for measuring performance for different layouts --- .../lapack/base/dlaswp/benchmark/benchmark.js | 32 +++++++++++---- .../dlaswp/benchmark/benchmark.ndarray.js | 41 +++++++++++++++---- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js index 2bedc386513c..4b356eade281 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.js @@ -30,17 +30,26 @@ var pkg = require( './../package.json' ).name; var dlaswp = require( './../lib/dlaswp.js' ); +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + // FUNCTIONS // /** * Creates a benchmark function. * * @private +* @param {string} order - storage layout * @param {PositiveInteger} N - number of elements along each dimension * @param {PositiveInteger} nrows - number of rows to interchange * @returns {Function} benchmark function */ -function createBenchmark( N, nrows ) { +function createBenchmark( order, N, nrows ) { var IPIV; var A; @@ -64,7 +73,7 @@ function createBenchmark( N, nrows ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, N, 0, nrows-1, IPIV, 1 ); + z = dlaswp( order, N, A, N, 0, nrows-1, IPIV, 1 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } @@ -89,21 +98,26 @@ function createBenchmark( N, nrows ) { function main() { var min; var max; + var ord; var N; var f; var i; var j; + var k; min = 1; // 10^min max = 6; // 10^max - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - j = 1; - while ( j <= N ) { - f = createBenchmark( N, j ); - bench( pkg+'::square_matrix:order=column-major,nrows='+j+',size='+(N*N), f ); - j *= 2; + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + j = 1; + while ( j <= N ) { + f = createBenchmark( ord, N, j ); + bench( pkg+'::square_matrix:order='+ord+',nrows='+j+',size='+(N*N), f ); + j *= 2; + } } } } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js index e50b1fd300db..898dd51e8cad 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js @@ -30,20 +30,38 @@ var pkg = require( './../package.json' ).name; var dlaswp = require( './../lib/ndarray.js' ); +// VARIABLES // + +var LAYOUTS = [ + 'row-major', + 'column-major' +]; + + // FUNCTIONS // /** * Creates a benchmark function. * * @private +* @param {string} order - storage layout * @param {PositiveInteger} N - number of elements along each dimension * @param {PositiveInteger} nrows - number of rows to interchange * @returns {Function} benchmark function */ -function createBenchmark( N, nrows ) { +function createBenchmark( order, N, nrows ) { var IPIV; + var sa1; + var sa2; var A; + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = N; + } else { // order === 'row-major' + sa1 = N; + sa2 = 1; + } IPIV = discreteUniform( nrows, 0, N-1, { 'dtype': 'int32' }); @@ -64,7 +82,7 @@ function createBenchmark( N, nrows ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaswp( 'column-major', N, A, 1, N, 0, 0, nrows-1, 1, IPIV, 1, 0 ); + z = dlaswp( order, N, A, sa1, sa2, 0, 0, nrows-1, 1, IPIV, 1, 0 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } @@ -89,21 +107,26 @@ function createBenchmark( N, nrows ) { function main() { var min; var max; + var ord; var N; var f; var i; var j; + var k; min = 1; // 10^min max = 6; // 10^max - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); - j = 1; - while ( j <= N ) { - f = createBenchmark( N, j ); - bench( pkg+'::square_matrix:ndarray:order=column-major,nrows='+j+',size='+(N*N), f ); - j *= 2; + for ( k = 0; k < LAYOUTS.length; k++ ) { + ord = LAYOUTS[ k ]; + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + j = 1; + while ( j <= N ) { + f = createBenchmark( ord, N, j ); + bench( pkg+'::square_matrix:ndarray:order='+ord+',nrows='+j+',size='+(N*N), f ); + j *= 2; + } } } } From 8c47131ba444b2ad6f27692b7627472d1677acd3 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 12:58:09 -0700 Subject: [PATCH 46/60] docs: update descriptions --- .../@stdlib/lapack/base/dlaswp/docs/types/index.d.ts | 4 ++-- lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts index 0de74d669aa6..dc77f72036a7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts @@ -52,11 +52,11 @@ interface Routine { ( order: Layout, N: number, A: Float64Array, LDA: number, k1: number, k2: number, IPIV: Int32Array, incx: number ): Float64Array; /** - * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`. + * Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. * * @param order - storage layout * @param N - number of columns in `A` - * @param A - matrix + * @param A - input matrix * @param strideA1 - stride of the first dimension of `A` * @param strideA2 - stride of the second dimension of `A` * @param offsetA - index offset for `A` diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js index baa01645ec20..a1777e581bd6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js @@ -32,7 +32,7 @@ var base = require( './base.js' ); * * @param {string} order - storage layout * @param {PositiveInteger} N - number of columns in `A` -* @param {Float64Array} A - matrix +* @param {Float64Array} A - input matrix * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - index offset for `A` From 0f69c0358e975a9a27c5fc391742377cf0185d7d Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 13:04:58 -0700 Subject: [PATCH 47/60] docs: update descriptions --- .../@stdlib/lapack/base/dlaswp/docs/repl.txt | 48 +++++++------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt index 479460d900a9..c0d9c61ace66 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -1,7 +1,7 @@ -{{alias}}( order, N, A, LDA, k1, k2, IPIV, sipiv ) - Performs a series of row interchanges on the matrix `A` using - pivot indices stored in `IPIV`. +{{alias}}( order, N, A, LDA, k1, k2, IPIV, incx ) + Performs a series of row interchanges on the matrix `A` using pivot indices + stored in `IPIV`. Indexing is relative to the first index. To introduce an offset, use typed array views. @@ -18,7 +18,7 @@ Number of columns in `A`. A: Float64Array - Matrix. + Input matrix. LDA: integer Stride of the first dimension of `A` (a.k.a., leading dimension of the @@ -33,29 +33,22 @@ IPIV: Int32Array Array of pivot indices. - sipiv: integer - Index increment for `IPIV`. + incx: integer + Increment between successive values of `IPIV`. Returns ------- A: Float64Array - Output array. + Mutated input matrix. Examples -------- - // Standard usage: > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var ord = 'row-major'; > {{alias}}( ord, 2, A, 2, 0, 2, IPIV, 1 ) [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] - // Advanced indexing: - > IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 0, 0, 1 ] ); - > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); - > {{alias}}( ord, 2, A, 2, 0, 2, IPIV, 2 ) - [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] - // Using typed array views: > var IPIV0 = new {{alias:@stdlib/array/int32}}( [ 0, 2, 0, 1 ] ); > var A0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); @@ -66,9 +59,9 @@ [ 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] -{{alias}}.ndarray( ord, N, A, sa1, sa2, oa, k1, k2, inck, IPIV, sipiv, oipiv ) - Performs a series of row interchanges on the matrix `A` using - pivot indices stored in `IPIV` and alternative indexing semantics. +{{alias}}.ndarray( order, N, A, sa1, sa2, oa, k1, k2, inck, IPIV, si, oi ) + Performs a series of row interchanges on the matrix `A` using pivot indices + stored in `IPIV` and alternative indexing semantics. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting @@ -76,7 +69,7 @@ Parameters ---------- - ord: string + order: string Row-major (C-style) or column-major (Fortran-style) order. Must be either 'row-major' or 'column-major'. @@ -84,7 +77,7 @@ Number of columns in `A`. A: Float64Array - Matrix. + Input matrix. sa1: integer Stride of the first dimension of `A`. @@ -102,37 +95,30 @@ Index of last row to interchange. inck: integer - Direction in which to apply pivots (-1 to apply pivots in reverse - order; otherwise, apply in provided order). + Direction in which to apply pivots (-1 to apply pivots in reverse order; + otherwise, apply in provided order). IPIV: Int32Array Array of pivot indices. - sipiv: integer + si: integer Index increment for `IPIV`. - oipiv: integer + oi: integer Index offset for `IPIV`. Returns ------- A: Float64Array - Output array. + Mutated input matrix. Examples -------- - // Standard usage: > var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); > var ord = 'row-major'; > {{alias}}.ndarray( ord, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ) [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] - // Advanced indexing: - > IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] ); - > A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - > {{alias}}.ndarray( ord, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ) - [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] - See Also -------- From 402d5c8a83343765286d15bc3d549fadaa25af03 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 13:15:45 -0700 Subject: [PATCH 48/60] docs: update example --- .../@stdlib/lapack/base/dlaswp/README.md | 20 +++++++++++++++---- .../lapack/base/dlaswp/examples/index.js | 20 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index c67eb4dc9abe..8e0d845701e5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -148,13 +148,25 @@ dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); ```javascript var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); -var IPIV = new Int32Array( [ 2, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +// Specify matrix meta data: +var shape = [ 4, 2 ]; +var strides = [ 1, 4 ]; +var offset = 0; +var order = 'column-major'; + +// Create a matrix stored in linear memory: +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +// Define a vector of pivot indices: +var IPIV = new Int32Array( [ 2, 0, 3, 1 ] ); -dlaswp( 'column-major', 2, A, 2, 0, 2, IPIV, 1 ); -console.log( A ); +// Interchange rows: +dlaswp( order, shape[ 1 ], A, strides[ 1 ], 0, shape[ 0 ]-1, IPIV, 1 ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js index 50023e3d184a..53e0ff443819 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/examples/index.js @@ -20,10 +20,22 @@ var Float64Array = require( '@stdlib/array/float64' ); var Int32Array = require( '@stdlib/array/int32' ); +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); var dlaswp = require( './../lib' ); -var IPIV = new Int32Array( [ 2, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +// Specify matrix meta data: +var shape = [ 4, 2 ]; +var strides = [ 1, 4 ]; +var offset = 0; +var order = 'column-major'; -dlaswp( 'column-major', 2, A, 2, 0, 2, IPIV, 1 ); -console.log( A ); +// Create a matrix stored in linear memory: +var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 ] ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); + +// Define a vector of pivot indices: +var IPIV = new Int32Array( [ 2, 0, 3, 1 ] ); + +// Interchange rows: +dlaswp( order, shape[ 1 ], A, strides[ 1 ], 0, shape[ 0 ]-1, IPIV, 1 ); +console.log( ndarray2array( A, shape, strides, offset, order ) ); From 70dc36f16d86aa95b60c2bbeee13d7f4ec8173d3 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 11 Jul 2024 13:17:00 -0700 Subject: [PATCH 49/60] chore: update keywords --- lib/node_modules/@stdlib/lapack/base/dlaswp/package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json index 20a1a70a0331..670119590fdf 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/package.json @@ -55,6 +55,11 @@ "math", "lapack", "dlaswp", + "interchange", + "swap", + "exchange", + "permute", + "permutedims", "linear", "algebra", "subroutines", From 03eed0f0e0468e1ca69d5cb0f87dc0677dab630e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 11:07:06 -0700 Subject: [PATCH 50/60] fix: ensure support for applying pivots in reverse --- .../@stdlib/lapack/base/dlaswp/README.md | 60 ++++++++++++------- .../@stdlib/lapack/base/dlaswp/lib/base.js | 20 +++++-- .../@stdlib/lapack/base/dlaswp/lib/dlaswp.js | 2 +- .../@stdlib/lapack/base/dlaswp/lib/ndarray.js | 4 +- .../fixtures/column_major_reverse_pivots.json | 36 +++++++++++ .../fixtures/row_major_reverse_pivots.json | 36 +++++++++++ .../lapack/base/dlaswp/test/test.dlaswp.js | 44 ++++++++++++++ .../lapack/base/dlaswp/test/test.ndarray.js | 44 ++++++++++++++ 8 files changed, 216 insertions(+), 30 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 8e0d845701e5..6084c32a48d8 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -18,7 +18,7 @@ limitations under the License. --> -# dsymv +# dlaswp > Perform a series of row interchanges on an input matrix. @@ -30,16 +30,16 @@ limitations under the License. var dlaswp = require( '@stdlib/lapack/base/dlaswp' ); ``` -#### dlaswp( N, A, LDA, k1, k2, IPIV, sipiv ) +#### dlaswp( N, A, LDA, k1, k2, IPIV, incx ) -Perform a series of row interchanges on an input matrix. +Perform a series of row interchanges on an input matrix `A` using pivot indices stored in `IPIV`. ```javascript var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); +var A = 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 IPIV = new Int32Array( [ 2, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 1 ); // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] @@ -49,24 +49,24 @@ The function has the following parameters: - **order**: storage layout. - **N**: number of columns in `A`. -- **A**: input `Float64Array`. +- **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. - **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **k1**: index of first row to interchange. - **k2**: index of last row to interchange. -- **IPIV**: vector of pivot indices. -- **sipiv**: index increment for `IPIV`. +- **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array]. Must contain at least `k1+(k2-k1)*abs(incx)` elements. Only the elements in positions `k1` through `k1+(k2-k1)*abs(incx)` are accessed. +- **incx**: increment between successive values of `IPIV`. Elements from `IPIV` are accessed according to `IPIV[k1+(k-k1)*abs(incx)] = j`, thus implying that rows `k` and `j` should be interchanged. If `incx` is negative, the pivots are applied in reverse order. -The increment parameters determine how elements in the IPIV array are accessed at runtime. For example, to iterate over the elements of `IPIV` in reverse order, +The increment parameter `incx` determines the order in which pivots are applied. For example, to apply pivots in reverse order, ```javascript var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); -var IPIV = new Int32Array( [ 2, 0, 0, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] ); +var A = 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 IPIV = new Int32Array( [ 2, 0, 1 ] ); -dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 2 ); -// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0, 7.0, 8.0, 9.0 ] +dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, -1 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -78,18 +78,18 @@ var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); // Initial arrays... -var IPIV0 = new Int32Array( [ 0, 2, 0, 1] ); var A0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var IPIV0 = new Int32Array( [ 0, 2, 0, 1] ); // Create offset views... -var IPIV1 = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 1st element var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 1st element +var IPIV1 = new Int32Array( IPIV0.buffer, IPIV0.BYTES_PER_ELEMENT*1 ); // start at 1st element dlaswp( 'row-major', 2, A1, 2, 0, 2, IPIV1, 1 ); // A0 => [ 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] ``` -#### dlaswp.ndarray( order, N, A, sa1, sa2, oa, k1, k2, inck, IPIV, sipiv, oipiv ) +#### dlaswp.ndarray( order, N, A, sa1, sa2, oa, k1, k2, inck, IPIV, si, oi ) Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics. @@ -97,8 +97,8 @@ Performs a series of row interchanges on the matrix `A` using pivot indices stor var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); +var A = 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 IPIV = new Int32Array( [ 2, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] @@ -106,23 +106,32 @@ dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); The function has the following additional parameters: +- **order**: storage layout. +- **N**: number of columns in `A`. +- **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. - **sa1**: stride of the first dimension of `A`. - **sa2**: stride of the second dimension of `A`. - **oa**: starting index for `A`. +- **k1**: index of first row to interchange. +- **k2**: index of last row to interchange. - **inck**: direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order). -- **oipiv**: starting index for `IPIV`. +- **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array]. +- **si**: index increment for `IPIV`. +- **oi**: starting index for `IPIV`. While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + ```javascript var Int32Array = require( '@stdlib/array/int32' ); var Float64Array = require( '@stdlib/array/float64' ); -var IPIV = new Int32Array( [ 2, 0, 1 ] ); -var A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var IPIV = new Int32Array( [ 0, 0, 2, 0, 1 ] ); -dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); -// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +dlaswp.ndarray( 'row-major', 2, A, 2, 1, 4, 0, 2, 1, IPIV, 1, 2 ); +// A => [ 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] ``` @@ -133,7 +142,8 @@ dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 ); ## Notes -- `dlaswp()` is a [LAPACK][lapack] routine. +- Both functions access `k2-k1+1` elements from `IPIV`. +- `dlaswp()` corresponds to the [LAPACK][LAPACK] level 1 function [`dlaswp`][dlaswp]. @@ -257,6 +267,12 @@ TODO [lapack]: https://www.netlib.org/lapack/explore-html/ +[dlaswp]: https://www.netlib.org/lapack/explore-html/d7/d6b/dlaswp_8f_source.html + +[mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array + +[mdn-int32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array + [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js index b36021292cc6..ea0462e78680 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js @@ -74,11 +74,17 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s var o; // Compute the number of rows to be interchanged: - nrows = k2 - k1 + 1; + if ( inck > 0 ) { + nrows = k2 - k1; + } else { + nrows = k1 - k2; + } + nrows += 1; // If the order is row-major, we can delegate to the Level 1 routine `dswap` for interchanging rows... if ( order === 'row-major' ) { - ip = offsetIPIV + ( k1*strideIPIV ); + // ip = offsetIPIV + ( k1*strideIPIV ); + ip = offsetIPIV; for ( i = 0, k = k1; i < nrows; i++, k += inck ) { row = IPIV[ ip ]; if ( row !== k ) { @@ -92,10 +98,11 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s n32 = floor( N/BLOCK_SIZE ) * BLOCK_SIZE; if ( n32 !== 0 ) { for ( j = 0; j < n32; j += BLOCK_SIZE ) { - ip = offsetIPIV + ( k1*strideIPIV ); + // ip = offsetIPIV + ( k1*strideIPIV ); + ip = offsetIPIV; for ( i = 0, k = k1; i < nrows; i++, k += inck ) { row = IPIV[ ip ]; - if ( row !== i ) { + if ( row !== k ) { ia1 = offsetA + ( k*strideA1 ); ia2 = offsetA + ( row*strideA1 ); for ( n = j; n < j+BLOCK_SIZE; n++ ) { @@ -110,10 +117,11 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s } } if ( n32 !== N ) { - ip = offsetIPIV + ( k1*strideIPIV ); + // ip = offsetIPIV + ( k1*strideIPIV ); + ip = offsetIPIV; for ( i = 0, k = k1; i < nrows; i++, k += inck ) { row = IPIV[ ip ]; - if ( row !== i ) { + if ( row !== k ) { ia1 = offsetA + ( k*strideA1 ); ia2 = offsetA + ( row*strideA1 ); for ( n = n32; n < N; n++ ) { diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js index d59258906ada..786cfe418b9a 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js @@ -67,7 +67,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incx ) { } if ( incx > 0 ) { inc = 1; - io = 0; + io = k1; } else if ( incx < 0 ) { inc = -1; io = k1 + ( (k1-k2) * incx ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js index a1777e581bd6..85aeed71f049 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js @@ -61,11 +61,13 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } if ( inck < 0 ) { - offsetIPIV += ( k2-k1 ) * strideIPIV; + offsetIPIV += k2 * strideIPIV; strideIPIV *= -1; tmp = k1; k1 = k2; k2 = tmp; + } else { + offsetIPIV += k1 * strideIPIV; } return base( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots.json new file mode 100644 index 000000000000..ccf8f229a3a5 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots.json new file mode 100644 index 000000000000..e5c56ff4872b --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js index bd21ae305a73..574ffb1dc0fd 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js @@ -39,10 +39,12 @@ var dlaswp = require( './../lib/dlaswp.js' ); var COL_MAJOR = require( './fixtures/column_major_no_offsets.json' ); var COL_MAJOR_IPIV_STRIDE = require( './fixtures/column_major_ipiv_stride.json' ); var COL_MAJOR_LDA = require( './fixtures/column_major_lda.json' ); +var COL_MAJOR_REV_PIVOTS = require( './fixtures/column_major_reverse_pivots.json' ); var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); var ROW_MAJOR_LDA = require( './fixtures/row_major_lda.json' ); +var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); // TESTS // @@ -105,6 +107,27 @@ tape( 'the function performs a series of row interchanges (column-major)', funct t.end(); }); +tape( 'the function supports applying pivots in reverse order (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_REV_PIVOTS; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports specifying an `LDA` parameter for operating on sub-matrices (column-major)', function test( t ) { var expected; var IPIV; @@ -210,6 +233,27 @@ tape( 'the function performs a series of row interchanges (row-major)', function t.end(); }); +tape( 'the function supports applying pivots in reverse order (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_REV_PIVOTS; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports specifying an `LDA` parameter for operating on sub-matrices (row-major)', function test( t ) { var expected; var IPIV; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index 944beebeadd6..4665d66ae151 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -42,6 +42,7 @@ var COL_MAJOR_IPIV_OFFSET = require( './fixtures/column_major_ipiv_offset.json' var COL_MAJOR_A_STRIDES = require( './fixtures/column_major_a_strides.json' ); var COL_MAJOR_A_OFFSET = require( './fixtures/column_major_a_offset.json' ); var COL_MAJOR_CMPLX_ACCESS = require( './fixtures/column_major_complex_access_patterns.json' ); +var COL_MAJOR_REV_PIVOTS = require( './fixtures/column_major_reverse_pivots.json' ); var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); @@ -49,6 +50,7 @@ var ROW_MAJOR_IPIV_OFFSET = require( './fixtures/row_major_ipiv_offset.json' ); var ROW_MAJOR_A_STRIDES = require( './fixtures/row_major_a_strides.json' ); var ROW_MAJOR_A_OFFSET = require( './fixtures/row_major_a_offset.json' ); var ROW_MAJOR_CMPLX_ACCESS = require( './fixtures/row_major_complex_access_patterns.json' ); +var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); // TESTS // @@ -111,6 +113,27 @@ tape( 'the function performs a series of row interchanges (column-major)', funct t.end(); }); +tape( 'the function supports applying pivots in reverse order (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_REV_PIVOTS; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports an `IPIV` stride (column-major)', function test( t ) { var expected; var IPIV; @@ -279,6 +302,27 @@ tape( 'the function performs a series of row interchanges (row-major)', function t.end(); }); +tape( 'the function supports applying pivots in reverse order (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_REV_PIVOTS; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports an `IPIV` stride (row-major)', function test( t ) { var expected; var IPIV; From 461749a8cabb4c17bf522b3421183e3c3caed2bb Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 11:08:04 -0700 Subject: [PATCH 51/60] refactor: remove comments --- lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js index ea0462e78680..c7b9fae2af45 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js @@ -83,7 +83,6 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s // If the order is row-major, we can delegate to the Level 1 routine `dswap` for interchanging rows... if ( order === 'row-major' ) { - // ip = offsetIPIV + ( k1*strideIPIV ); ip = offsetIPIV; for ( i = 0, k = k1; i < nrows; i++, k += inck ) { row = IPIV[ ip ]; @@ -98,7 +97,6 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s n32 = floor( N/BLOCK_SIZE ) * BLOCK_SIZE; if ( n32 !== 0 ) { for ( j = 0; j < n32; j += BLOCK_SIZE ) { - // ip = offsetIPIV + ( k1*strideIPIV ); ip = offsetIPIV; for ( i = 0, k = k1; i < nrows; i++, k += inck ) { row = IPIV[ ip ]; @@ -117,7 +115,6 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s } } if ( n32 !== N ) { - // ip = offsetIPIV + ( k1*strideIPIV ); ip = offsetIPIV; for ( i = 0, k = k1; i < nrows; i++, k += inck ) { row = IPIV[ ip ]; From 9b9dbce96c13e9fc0d9e93c04fba6c464f637265 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 11:13:15 -0700 Subject: [PATCH 52/60] test: add tests for applying pivots in reverse with an IPIV stride --- ...lumn_major_reverse_pivots_ipiv_stride.json | 36 +++++++++++++++ .../row_major_reverse_pivots_ipiv_stride.json | 36 +++++++++++++++ .../lapack/base/dlaswp/test/test.ndarray.js | 44 +++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots_ipiv_stride.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots_ipiv_stride.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots_ipiv_stride.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots_ipiv_stride.json new file mode 100644 index 000000000000..0bba7a549c41 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots_ipiv_stride.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 1, 0, 2 ], + "strideIPIV": -1, + "offsetIPIV": 2, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots_ipiv_stride.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots_ipiv_stride.json new file mode 100644 index 000000000000..74b8e66dd1d3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots_ipiv_stride.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 1, 0, 2 ], + "strideIPIV": -1, + "offsetIPIV": 2, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index 4665d66ae151..eab68a0d0fe5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -43,6 +43,7 @@ var COL_MAJOR_A_STRIDES = require( './fixtures/column_major_a_strides.json' ); var COL_MAJOR_A_OFFSET = require( './fixtures/column_major_a_offset.json' ); var COL_MAJOR_CMPLX_ACCESS = require( './fixtures/column_major_complex_access_patterns.json' ); var COL_MAJOR_REV_PIVOTS = require( './fixtures/column_major_reverse_pivots.json' ); +var COL_MAJOR_REV_PIVOTS_IPIV_STRIDE = require( './fixtures/column_major_reverse_pivots_ipiv_stride.json' ); // eslint-disable-line id-length var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); @@ -51,6 +52,7 @@ var ROW_MAJOR_A_STRIDES = require( './fixtures/row_major_a_strides.json' ); var ROW_MAJOR_A_OFFSET = require( './fixtures/row_major_a_offset.json' ); var ROW_MAJOR_CMPLX_ACCESS = require( './fixtures/row_major_complex_access_patterns.json' ); var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); +var ROW_MAJOR_REV_PIVOTS_IPIV_STRIDE = require( './fixtures/row_major_reverse_pivots_ipiv_stride.json' ); // eslint-disable-line id-length // TESTS // @@ -155,6 +157,27 @@ tape( 'the function supports an `IPIV` stride (column-major)', function test( t t.end(); }); +tape( 'the function supports an `IPIV` stride (reverse pivots, column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_REV_PIVOTS_IPIV_STRIDE; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports an `IPIV` offset (column-major)', function test( t ) { var expected; var IPIV; @@ -344,6 +367,27 @@ tape( 'the function supports an `IPIV` stride (row-major)', function test( t ) { t.end(); }); +tape( 'the function supports an `IPIV` stride (reverse pivots, row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_REV_PIVOTS_IPIV_STRIDE; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports an `IPIV` offset (row-major)', function test( t ) { var expected; var IPIV; From 45faccaedde554936985c5c98a71101b27fe15ed Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 11:16:36 -0700 Subject: [PATCH 53/60] test: add tests for appying pivots in reverse with an IPIV offset --- ...lumn_major_reverse_pivots_ipiv_offset.json | 36 +++++++++++++++ .../row_major_reverse_pivots_ipiv_offset.json | 36 +++++++++++++++ .../lapack/base/dlaswp/test/test.ndarray.js | 44 +++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots_ipiv_offset.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots_ipiv_offset.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots_ipiv_offset.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots_ipiv_offset.json new file mode 100644 index 000000000000..c291ba59da4e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_reverse_pivots_ipiv_offset.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 3, 4, 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 2, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots_ipiv_offset.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots_ipiv_offset.json new file mode 100644 index 000000000000..b588ff9d00db --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_reverse_pivots_ipiv_offset.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 3, 4, 2, 0, 1 ], + "strideIPIV": 1, + "offsetIPIV": 2, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 3.0, 4.0 ], + [ 1.0, 2.0 ], + [ 5.0, 6.0 ] + ], + "A_out": [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index eab68a0d0fe5..64851226a9c1 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -44,6 +44,7 @@ var COL_MAJOR_A_OFFSET = require( './fixtures/column_major_a_offset.json' ); var COL_MAJOR_CMPLX_ACCESS = require( './fixtures/column_major_complex_access_patterns.json' ); var COL_MAJOR_REV_PIVOTS = require( './fixtures/column_major_reverse_pivots.json' ); var COL_MAJOR_REV_PIVOTS_IPIV_STRIDE = require( './fixtures/column_major_reverse_pivots_ipiv_stride.json' ); // eslint-disable-line id-length +var COL_MAJOR_REV_PIVOTS_IPIV_OFFSET = require( './fixtures/column_major_reverse_pivots_ipiv_offset.json' ); // eslint-disable-line id-length var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); @@ -53,6 +54,7 @@ var ROW_MAJOR_A_OFFSET = require( './fixtures/row_major_a_offset.json' ); var ROW_MAJOR_CMPLX_ACCESS = require( './fixtures/row_major_complex_access_patterns.json' ); var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); var ROW_MAJOR_REV_PIVOTS_IPIV_STRIDE = require( './fixtures/row_major_reverse_pivots_ipiv_stride.json' ); // eslint-disable-line id-length +var ROW_MAJOR_REV_PIVOTS_IPIV_OFFSET = require( './fixtures/row_major_reverse_pivots_ipiv_offset.json' ); // eslint-disable-line id-length // TESTS // @@ -199,6 +201,27 @@ tape( 'the function supports an `IPIV` offset (column-major)', function test( t t.end(); }); +tape( 'the function supports an `IPIV` offset (reverse pivots, column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_REV_PIVOTS_IPIV_OFFSET; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports `A` strides (column-major)', function test( t ) { var expected; var IPIV; @@ -409,6 +432,27 @@ tape( 'the function supports an `IPIV` offset (row-major)', function test( t ) { t.end(); }); +tape( 'the function supports an `IPIV` offset (reverse pivots, row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_REV_PIVOTS_IPIV_OFFSET; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports `A` strides (row-major)', function test( t ) { var expected; var IPIV; From 1ec29ed2ec8bb3192fdca78f75ee38834775f2d6 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 11:27:33 -0700 Subject: [PATCH 54/60] test: add tests for positive `k1` value --- .../dlaswp/test/fixtures/column_major_k1.json | 42 ++++++++++++++++++ .../dlaswp/test/fixtures/row_major_k1.json | 42 ++++++++++++++++++ .../lapack/base/dlaswp/test/test.dlaswp.js | 44 +++++++++++++++++++ .../lapack/base/dlaswp/test/test.ndarray.js | 44 +++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_k1.json create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_k1.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_k1.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_k1.json new file mode 100644 index 000000000000..5ebbd0dcb774 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_k1.json @@ -0,0 +1,42 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 7.0 ], + [ 2.0, 8.0 ], + [ 3.0, 9.0 ], + [ 4.0, 10.0 ], + [ 5.0, 11.0 ], + [ 6.0, 12.0 ] + ], + "N": 2, + "LDA": 6, + "strideA1": 1, + "strideA2": 6, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + + "k1": 3, + "k2": 5, + "incK": 1, + + "IPIV": [ 999, 999, 999, 2, 1, 0 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 3, 2 ], + [ 4, 1 ], + [ 5, 0 ] + ], + + "A_out_mat": [ + [ 6.0, 12.0 ], + [ 5.0, 11.0 ], + [ 4.0, 10.0 ], + [ 3.0, 9.0 ], + [ 2.0, 8.0 ], + [ 1.0, 7.0 ] + ], + "A_out": [ 6.0, 5.0, 4.0, 3.0, 2.0, 1.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_k1.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_k1.json new file mode 100644 index 000000000000..c9af6921d632 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_k1.json @@ -0,0 +1,42 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0 ], + [ 3.0, 4.0 ], + [ 5.0, 6.0 ], + [ 7.0, 8.0 ], + [ 9.0, 10.0 ], + [ 11.0, 12.0 ] + ], + "N": 2, + "LDA": 2, + "strideA1": 2, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ], + + "k1": 3, + "k2": 5, + "incK": 1, + + "IPIV": [ 999, 999, 999, 2, 1, 0 ], + "strideIPIV": 1, + "offsetIPIV": 0, + + "interchanges": [ + [ 3, 2 ], + [ 4, 1 ], + [ 5, 0 ] + ], + + "A_out_mat": [ + [ 11.0, 12.0 ], + [ 9.0, 10.0 ], + [ 7.0, 8.0 ], + [ 5.0, 6.0 ], + [ 3.0, 4.0 ], + [ 1.0, 2.0 ] + ], + "A_out": [ 11.0, 12.0, 9.0, 10.0, 7.0, 8.0, 5.0, 6.0, 3.0, 4.0, 1.0, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js index 574ffb1dc0fd..e96846dc3d1e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js @@ -40,11 +40,13 @@ var COL_MAJOR = require( './fixtures/column_major_no_offsets.json' ); var COL_MAJOR_IPIV_STRIDE = require( './fixtures/column_major_ipiv_stride.json' ); var COL_MAJOR_LDA = require( './fixtures/column_major_lda.json' ); var COL_MAJOR_REV_PIVOTS = require( './fixtures/column_major_reverse_pivots.json' ); +var COL_MAJOR_K1 = require( './fixtures/column_major_k1.json' ); var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); var ROW_MAJOR_LDA = require( './fixtures/row_major_lda.json' ); var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); +var ROW_MAJOR_K1 = require( './fixtures/row_major_k1.json' ); // TESTS // @@ -107,6 +109,27 @@ tape( 'the function performs a series of row interchanges (column-major)', funct t.end(); }); +tape( 'the function performs a series of row interchanges (column-major, k1 > 0)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_K1; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports applying pivots in reverse order (column-major)', function test( t ) { var expected; var IPIV; @@ -233,6 +256,27 @@ tape( 'the function performs a series of row interchanges (row-major)', function t.end(); }); +tape( 'the function performs a series of row interchanges (row-major, k1 > 0)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_K1; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports applying pivots in reverse order (row-major)', function test( t ) { var expected; var IPIV; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index 64851226a9c1..00ba89e074e5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -45,6 +45,7 @@ var COL_MAJOR_CMPLX_ACCESS = require( './fixtures/column_major_complex_access_pa var COL_MAJOR_REV_PIVOTS = require( './fixtures/column_major_reverse_pivots.json' ); var COL_MAJOR_REV_PIVOTS_IPIV_STRIDE = require( './fixtures/column_major_reverse_pivots_ipiv_stride.json' ); // eslint-disable-line id-length var COL_MAJOR_REV_PIVOTS_IPIV_OFFSET = require( './fixtures/column_major_reverse_pivots_ipiv_offset.json' ); // eslint-disable-line id-length +var COL_MAJOR_K1 = require( './fixtures/column_major_k1.json' ); var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); @@ -55,6 +56,7 @@ var ROW_MAJOR_CMPLX_ACCESS = require( './fixtures/row_major_complex_access_patte var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); var ROW_MAJOR_REV_PIVOTS_IPIV_STRIDE = require( './fixtures/row_major_reverse_pivots_ipiv_stride.json' ); // eslint-disable-line id-length var ROW_MAJOR_REV_PIVOTS_IPIV_OFFSET = require( './fixtures/row_major_reverse_pivots_ipiv_offset.json' ); // eslint-disable-line id-length +var ROW_MAJOR_K1 = require( './fixtures/row_major_k1.json' ); // TESTS // @@ -117,6 +119,27 @@ tape( 'the function performs a series of row interchanges (column-major)', funct t.end(); }); +tape( 'the function performs a series of row interchanges (column-major, k1 > 0)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_K1; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports applying pivots in reverse order (column-major)', function test( t ) { var expected; var IPIV; @@ -348,6 +371,27 @@ tape( 'the function performs a series of row interchanges (row-major)', function t.end(); }); +tape( 'the function performs a series of row interchanges (row-major, k1 > 0)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_K1; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.strideA1, data.strideA2, data.offsetA, data.k1, data.k2, data.incK, IPIV, data.strideIPIV, data.offsetIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports applying pivots in reverse order (row-major)', function test( t ) { var expected; var IPIV; From 0a99eed4e2fe4816024863441accbaa458e5bc20 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 11:30:11 -0700 Subject: [PATCH 55/60] docs: update copy --- lib/node_modules/@stdlib/lapack/base/dlaswp/README.md | 2 +- lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 6084c32a48d8..782b46d508fe 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -56,7 +56,7 @@ The function has the following parameters: - **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array]. Must contain at least `k1+(k2-k1)*abs(incx)` elements. Only the elements in positions `k1` through `k1+(k2-k1)*abs(incx)` are accessed. - **incx**: increment between successive values of `IPIV`. Elements from `IPIV` are accessed according to `IPIV[k1+(k-k1)*abs(incx)] = j`, thus implying that rows `k` and `j` should be interchanged. If `incx` is negative, the pivots are applied in reverse order. -The increment parameter `incx` determines the order in which pivots are applied. For example, to apply pivots in reverse order, +The sign of the increment parameter `incx` determines the order in which pivots are applied. For example, to apply pivots in reverse order, ```javascript var Int32Array = require( '@stdlib/array/int32' ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js index e96846dc3d1e..e49782c34cc7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js @@ -48,6 +48,8 @@ var ROW_MAJOR_LDA = require( './fixtures/row_major_lda.json' ); var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); var ROW_MAJOR_K1 = require( './fixtures/row_major_k1.json' ); +// FIXME: `incx` tests (positive + negative) + // TESTS // From b50c74042ec5df6dd25ede42a757b71a96095b13 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 18:17:07 -0700 Subject: [PATCH 56/60] test: add stride tests --- .../@stdlib/lapack/base/dlaswp/lib/ndarray.js | 2 + .../column_major_ipiv_stride_negative.json | 36 ++++++++++++ ...=> column_major_ipiv_stride_positive.json} | 2 +- .../row_major_ipiv_stride_negative.json | 36 ++++++++++++ ...on => row_major_ipiv_stride_positive.json} | 0 .../lapack/base/dlaswp/test/test.dlaswp.js | 58 ++++++++++++++++--- .../lapack/base/dlaswp/test/test.ndarray.js | 8 +-- 7 files changed, 129 insertions(+), 13 deletions(-) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride_negative.json rename lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/{column_major_ipiv_stride.json => column_major_ipiv_stride_positive.json} (92%) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride_negative.json rename lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/{row_major_ipiv_stride.json => row_major_ipiv_stride_positive.json} (100%) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js index 85aeed71f049..ce367d98f4c7 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js @@ -66,8 +66,10 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s tmp = k1; k1 = k2; k2 = tmp; + inck = -1; } else { offsetIPIV += k1 * strideIPIV; + inck = 1; } return base( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride_negative.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride_negative.json new file mode 100644 index 000000000000..71ed22266403 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride_negative.json @@ -0,0 +1,36 @@ +{ + "order": "column-major", + + "A_mat": [ + [ 1.0, 4.0 ], + [ 2.0, 5.0 ], + [ 3.0, 6.0 ] + ], + "N": 2, + "LDA": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 2, 999, 0, 999, 1, 999 ], + "strideIPIV": -2, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 2.0, 5.0 ], + [ 1.0, 4.0 ], + [ 3.0, 6.0 ] + ], + "A_out": [ 2.0, 1.0, 3.0, 5.0, 4.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride_positive.json similarity index 92% rename from lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride.json rename to lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride_positive.json index 0b68c30522c1..272dd22d8944 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride.json +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/column_major_ipiv_stride_positive.json @@ -17,7 +17,7 @@ "k2": 2, "incK": 1, - "IPIV": [ 2, 9999, 0, 9999, 1, 9999 ], + "IPIV": [ 2, 999, 0, 999, 1, 999 ], "strideIPIV": 2, "offsetIPIV": 0, diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride_negative.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride_negative.json new file mode 100644 index 000000000000..468991b43e78 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride_negative.json @@ -0,0 +1,36 @@ +{ + "order": "row-major", + + "A_mat": [ + [ 1.0, 2.0, 3.0 ], + [ 4.0, 5.0, 6.0 ], + [ 7.0, 8.0, 9.0 ] + ], + "N": 3, + "LDA": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 ], + + "k1": 0, + "k2": 2, + "incK": -1, + + "IPIV": [ 2, 9999, 0, 9999, 1, 9999 ], + "strideIPIV": -2, + "offsetIPIV": 0, + + "interchanges": [ + [ 2, 1 ], + [ 1, 0 ], + [ 0, 2 ] + ], + + "A_out_mat": [ + [ 4.0, 5.0, 6.0 ], + [ 1.0, 2.0, 3.0 ], + [ 7.0, 8.0, 9.0 ] + ], + "A_out": [ 4.0, 5.0, 6.0, 1.0, 2.0, 3.0, 7.0, 8.0, 9.0 ] +} diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride.json b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride_positive.json similarity index 100% rename from lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride.json rename to lib/node_modules/@stdlib/lapack/base/dlaswp/test/fixtures/row_major_ipiv_stride_positive.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js index e49782c34cc7..ee76fa8327af 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js @@ -37,19 +37,19 @@ var dlaswp = require( './../lib/dlaswp.js' ); // FIXTURES // var COL_MAJOR = require( './fixtures/column_major_no_offsets.json' ); -var COL_MAJOR_IPIV_STRIDE = require( './fixtures/column_major_ipiv_stride.json' ); +var COL_MAJOR_IPIV_STRIDE_POS = require( './fixtures/column_major_ipiv_stride_positive.json' ); +var COL_MAJOR_IPIV_STRIDE_NEG = require( './fixtures/column_major_ipiv_stride_negative.json' ); var COL_MAJOR_LDA = require( './fixtures/column_major_lda.json' ); var COL_MAJOR_REV_PIVOTS = require( './fixtures/column_major_reverse_pivots.json' ); var COL_MAJOR_K1 = require( './fixtures/column_major_k1.json' ); var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); -var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); +var ROW_MAJOR_IPIV_STRIDE_POS = require( './fixtures/row_major_ipiv_stride_positive.json' ); +var ROW_MAJOR_IPIV_STRIDE_NEG = require( './fixtures/row_major_ipiv_stride_negative.json' ); var ROW_MAJOR_LDA = require( './fixtures/row_major_lda.json' ); var ROW_MAJOR_REV_PIVOTS = require( './fixtures/row_major_reverse_pivots.json' ); var ROW_MAJOR_K1 = require( './fixtures/row_major_k1.json' ); -// FIXME: `incx` tests (positive + negative) - // TESTS // @@ -174,14 +174,35 @@ tape( 'the function supports specifying an `LDA` parameter for operating on sub- t.end(); }); -tape( 'the function supports specifying an increment between successive values of `IPIV` (column-major)', function test( t ) { +tape( 'the function supports specifying a positive increment between successive values of `IPIV` (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR_IPIV_STRIDE_POS; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative increment between successive values of `IPIV` (column-major)', function test( t ) { var expected; var IPIV; var data; var out; var A; - data = COL_MAJOR_IPIV_STRIDE; + data = COL_MAJOR_IPIV_STRIDE_NEG; A = new Float64Array( data.A ); IPIV = new Int32Array( data.IPIV ); @@ -321,14 +342,35 @@ tape( 'the function supports specifying an `LDA` parameter for operating on sub- t.end(); }); -tape( 'the function supports specifying an increment between successive values of `IPIV` (row-major)', function test( t ) { +tape( 'the function supports specifying a positive increment between successive values of `IPIV` (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR_IPIV_STRIDE_POS; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A_out ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, data.strideIPIV ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a negative increment between successive values of `IPIV` (row-major)', function test( t ) { var expected; var IPIV; var data; var out; var A; - data = ROW_MAJOR_IPIV_STRIDE; + data = ROW_MAJOR_IPIV_STRIDE_NEG; A = new Float64Array( data.A ); IPIV = new Int32Array( data.IPIV ); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index 00ba89e074e5..6fa446937bf5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -37,7 +37,7 @@ var dlaswp = require( './../lib/ndarray.js' ); // FIXTURES // var COL_MAJOR = require( './fixtures/column_major_no_offsets.json' ); -var COL_MAJOR_IPIV_STRIDE = require( './fixtures/column_major_ipiv_stride.json' ); +var COL_MAJOR_IPIV_STRIDE_POS = require( './fixtures/column_major_ipiv_stride_positive.json' ); var COL_MAJOR_IPIV_OFFSET = require( './fixtures/column_major_ipiv_offset.json' ); var COL_MAJOR_A_STRIDES = require( './fixtures/column_major_a_strides.json' ); var COL_MAJOR_A_OFFSET = require( './fixtures/column_major_a_offset.json' ); @@ -48,7 +48,7 @@ var COL_MAJOR_REV_PIVOTS_IPIV_OFFSET = require( './fixtures/column_major_reverse var COL_MAJOR_K1 = require( './fixtures/column_major_k1.json' ); var ROW_MAJOR = require( './fixtures/row_major_no_offsets.json' ); -var ROW_MAJOR_IPIV_STRIDE = require( './fixtures/row_major_ipiv_stride.json' ); +var ROW_MAJOR_IPIV_STRIDE_POS = require( './fixtures/row_major_ipiv_stride_positive.json' ); var ROW_MAJOR_IPIV_OFFSET = require( './fixtures/row_major_ipiv_offset.json' ); var ROW_MAJOR_A_STRIDES = require( './fixtures/row_major_a_strides.json' ); var ROW_MAJOR_A_OFFSET = require( './fixtures/row_major_a_offset.json' ); @@ -168,7 +168,7 @@ tape( 'the function supports an `IPIV` stride (column-major)', function test( t var out; var A; - data = COL_MAJOR_IPIV_STRIDE; + data = COL_MAJOR_IPIV_STRIDE_POS; A = new Float64Array( data.A ); IPIV = new Int32Array( data.IPIV ); @@ -420,7 +420,7 @@ tape( 'the function supports an `IPIV` stride (row-major)', function test( t ) { var out; var A; - data = ROW_MAJOR_IPIV_STRIDE; + data = ROW_MAJOR_IPIV_STRIDE_POS; A = new Float64Array( data.A ); IPIV = new Int32Array( data.IPIV ); From be33a85095e9d1d4432c098d88b756ca9f5e7d02 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 18:24:29 -0700 Subject: [PATCH 57/60] test: add error handling tests --- .../lapack/base/dlaswp/test/test.dlaswp.js | 79 ++++++++++++++++++- .../lapack/base/dlaswp/test/test.ndarray.js | 13 ++- 2 files changed, 88 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js index ee76fa8327af..f2ce06b4c767 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.dlaswp.js @@ -64,7 +64,7 @@ tape( 'the function has an arity of 8', function test( t ) { t.end(); }); -tape( 'the function throws an error if provided an invalid first argument', function test( t ) { +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { var values; var data; var i; @@ -75,7 +75,16 @@ tape( 'the function throws an error if provided an invalid first argument', func 'foo', 'bar', 'beep', - 'boop' + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} ]; for ( i = 0; i < values.length; i++ ) { @@ -90,6 +99,30 @@ tape( 'the function throws an error if provided an invalid first argument', func } }); +tape( 'the function throws an error if provided a fourth argument which is not a valid `LDA` value (row-major)', function test( t ) { + var values; + var data; + var i; + + data = ROW_MAJOR; + + values = [ + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + dlaswp( data.order, data.N, data.A, value, data.k1, data.k2, data.IPIV, data.strideIPIV ); + }; + } +}); + tape( 'the function performs a series of row interchanges (column-major)', function test( t ) { var expected; var IPIV; @@ -216,6 +249,27 @@ tape( 'the function supports specifying a negative increment between successive t.end(); }); +tape( 'if provided an increment between successive values of `IPIV` equal to `0`, the function returns the input matrix unchanged (column-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = COL_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, 0 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function efficiently handles large datasets (column-major)', function test( t ) { var expected; var IPIV; @@ -384,6 +438,27 @@ tape( 'the function supports specifying a negative increment between successive t.end(); }); +tape( 'if provided an increment between successive values of `IPIV` equal to `0`, the function returns the input matrix unchanged (row-major)', function test( t ) { + var expected; + var IPIV; + var data; + var out; + var A; + + data = ROW_MAJOR; + + A = new Float64Array( data.A ); + IPIV = new Int32Array( data.IPIV ); + + expected = new Float64Array( data.A ); + + out = dlaswp( data.order, data.N, A, data.LDA, data.k1, data.k2, IPIV, 0 ); + t.strictEqual( out, A, 'returns expected value' ); + t.deepEqual( out, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function efficiently handles large datasets (row-major)', function test( t ) { var expected; var IPIV; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js index 6fa446937bf5..194b29404a36 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/test/test.ndarray.js @@ -72,7 +72,7 @@ tape( 'the function has an arity of 12', function test( t ) { t.end(); }); -tape( 'the function throws an error if provided an invalid first argument', function test( t ) { +tape( 'the function throws an error if provided a first argument which is not a valid order', function test( t ) { var values; var data; var i; @@ -83,7 +83,16 @@ tape( 'the function throws an error if provided an invalid first argument', func 'foo', 'bar', 'beep', - 'boop' + 'boop', + -5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} ]; for ( i = 0; i < values.length; i++ ) { From 6247f98fd7f8d9f958dded5b49005e985128dc4a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 18:31:24 -0700 Subject: [PATCH 58/60] docs: add example --- .../@stdlib/lapack/base/dlaswp/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 782b46d508fe..032034fc740e 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -69,6 +69,19 @@ dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, -1 ); // A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] ``` +To perform strided access over `IPIV`, provide an `abs(incx)` value greater than one. For example, to access every other element in `IPIV`, + +```javascript +var Int32Array = require( '@stdlib/array/int32' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var A = 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 IPIV = new Int32Array( [ 2, 999, 0, 999, 1 ] ); + +dlaswp( 'row-major', 2, A, 2, 0, 2, IPIV, 2 ); +// A => [ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ] +``` + Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. From 8dd21b61704d29539ac0eeb7cd68356944c8400b Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 18:38:50 -0700 Subject: [PATCH 59/60] docs: update copy --- lib/node_modules/@stdlib/lapack/base/dlaswp/README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md index 032034fc740e..20e786974dfa 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/README.md @@ -51,8 +51,8 @@ The function has the following parameters: - **N**: number of columns in `A`. - **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. - **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). -- **k1**: index of first row to interchange. -- **k2**: index of last row to interchange. +- **k1**: index of first row to interchange when `incx` is positive and the index of the last row to interchange when `incx` is negative. +- **k2**: index of last row to interchange when `incx` is positive and the index of the first row to interchange when `incx` is negative. - **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array]. Must contain at least `k1+(k2-k1)*abs(incx)` elements. Only the elements in positions `k1` through `k1+(k2-k1)*abs(incx)` are accessed. - **incx**: increment between successive values of `IPIV`. Elements from `IPIV` are accessed according to `IPIV[k1+(k-k1)*abs(incx)] = j`, thus implying that rows `k` and `j` should be interchanged. If `incx` is negative, the pivots are applied in reverse order. @@ -125,8 +125,8 @@ The function has the following additional parameters: - **sa1**: stride of the first dimension of `A`. - **sa2**: stride of the second dimension of `A`. - **oa**: starting index for `A`. -- **k1**: index of first row to interchange. -- **k2**: index of last row to interchange. +- **k1**: index of first row to interchange when `inck` is positive and the index of the last row to interchange when `inck` is negative. +- **k2**: index of last row to interchange when `inck` is positive and the index of the first row to interchange when `inck` is negative. - **inck**: direction in which to apply pivots (-1 to apply pivots in reverse order; otherwise, apply in provided order). - **IPIV**: vector of pivot indices as an [`Int32Array`][mdn-int32array]. - **si**: index increment for `IPIV`. @@ -156,6 +156,7 @@ dlaswp.ndarray( 'row-major', 2, A, 2, 1, 4, 0, 2, 1, IPIV, 1, 2 ); ## Notes - Both functions access `k2-k1+1` elements from `IPIV`. +- While `dlaswp` conflates the order in which pivots are applied with the order in which elements in `IPIV` are accessed, the `ndarray` method delineates control of those behaviors with separate parameters `inck` and `si`. - `dlaswp()` corresponds to the [LAPACK][LAPACK] level 1 function [`dlaswp`][dlaswp]. From 9019417c2b1436b27eb05d4f9d381e5d4042814f Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 12 Jul 2024 19:12:22 -0700 Subject: [PATCH 60/60] docs: fix note --- lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt index c0d9c61ace66..beaf39401754 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt @@ -6,7 +6,7 @@ Indexing is relative to the first index. To introduce an offset, use typed array views. - If `N` is equal to `0`, the function returns `A` unchanged. + If `incx` is equal to `0`, the function returns `A` unchanged. Parameters ----------