Skip to content

Commit 812e033

Browse files
committed
feat!: remove order argument from ndarray method
This commit removes the `order` argument, as this argument is not necessary when providing multiple strides. The layout is conveyed by the strides, not the order string, and requiring that both strides and an order string be provided allows for the potential for conflicting information (e.g., an order string of "row-major", while the strides are in "column-major" order due to taking the transpose, etc). In short, the strides are the source of truth. BREAKING CHANGE: remove `order` argument from `ndarray` method To migrate, users should drop the `order` argument when invoking the `ndarray` method.
1 parent 9d0ce8b commit 812e033

File tree

9 files changed

+150
-215
lines changed

9 files changed

+150
-215
lines changed

lib/node_modules/@stdlib/lapack/base/dlaswp/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ dlaswp( 'row-major', 2, A1, 2, 0, 2, IPIV1, 1 );
102102
// A0 => <Float64Array>[ 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
103103
```
104104

105-
#### dlaswp.ndarray( order, N, A, sa1, sa2, oa, k1, k2, inck, IPIV, si, oi )
105+
#### dlaswp.ndarray( N, A, sa1, sa2, oa, k1, k2, inck, IPIV, si, oi )
106106

107107
Performs a series of row interchanges on the matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics.
108108

@@ -113,13 +113,12 @@ var Float64Array = require( '@stdlib/array/float64' );
113113
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 ] ]
114114
var IPIV = new Int32Array( [ 2, 0, 1 ] );
115115

116-
dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
116+
dlaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
117117
// A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
118118
```
119119

120120
The function has the following additional parameters:
121121

122-
- **order**: storage layout.
123122
- **N**: number of columns in `A`.
124123
- **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array].
125124
- **sa1**: stride of the first dimension of `A`.
@@ -143,7 +142,7 @@ var Float64Array = require( '@stdlib/array/float64' );
143142
var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
144143
var IPIV = new Int32Array( [ 0, 0, 2, 0, 1 ] );
145144

146-
dlaswp.ndarray( 'row-major', 2, A, 2, 1, 4, 0, 2, 1, IPIV, 1, 2 );
145+
dlaswp.ndarray( 2, A, 2, 1, 4, 0, 2, 1, IPIV, 1, 2 );
147146
// A => <Float64Array>[ 0.0, 0.0, 0.0, 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
148147
```
149148

lib/node_modules/@stdlib/lapack/base/dlaswp/benchmark/benchmark.ndarray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ function createBenchmark( order, N, nrows ) {
8282

8383
b.tic();
8484
for ( i = 0; i < b.iterations; i++ ) {
85-
z = dlaswp( order, N, A, sa1, sa2, 0, 0, nrows-1, 1, IPIV, 1, 0 );
85+
z = dlaswp( N, A, sa1, sa2, 0, 0, nrows-1, 1, IPIV, 1, 0 );
8686
if ( isnan( z[ i%z.length ] ) ) {
8787
b.fail( 'should not return NaN' );
8888
}

lib/node_modules/@stdlib/lapack/base/dlaswp/docs/repl.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<Float64Array>[ 0.0, 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
6060

6161

62-
{{alias}}.ndarray( order, N, A, sa1, sa2, oa, k1, k2, inck, IPIV, si, oi )
62+
{{alias}}.ndarray( N, A, sa1, sa2, oa, k1, k2, inck, IPIV, si, oi )
6363
Performs a series of row interchanges on the matrix `A` using pivot indices
6464
stored in `IPIV` and alternative indexing semantics.
6565

@@ -69,10 +69,6 @@
6969

7070
Parameters
7171
----------
72-
order: string
73-
Row-major (C-style) or column-major (Fortran-style) order. Must be
74-
either 'row-major' or 'column-major'.
75-
7672
N: integer
7773
Number of columns in `A`.
7874

@@ -116,8 +112,7 @@
116112
--------
117113
> var IPIV = new {{alias:@stdlib/array/int32}}( [ 2, 0, 1 ] );
118114
> var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
119-
> var ord = 'row-major';
120-
> {{alias}}.ndarray( ord, 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 )
115+
> {{alias}}.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 )
121116
<Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
122117

123118
See Also

lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/index.d.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ interface Routine {
5454
/**
5555
* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV` and alternative indexing semantics.
5656
*
57-
* @param order - storage layout
5857
* @param N - number of columns in `A`
5958
* @param A - input matrix
6059
* @param strideA1 - stride of the first dimension of `A`
@@ -75,10 +74,10 @@ interface Routine {
7574
* var IPIV = new Int32Array( [ 2, 0, 1 ] );
7675
* 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 ] ]
7776
*
78-
* dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
77+
* dlaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
7978
* // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
8079
*/
81-
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;
80+
ndarray( N: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number, k1: number, k2: number, inck: number, IPIV: Int32Array, strideIPIV: number, offsetIPIV: number ): Float64Array;
8281
}
8382

8483
/**
@@ -111,7 +110,7 @@ interface Routine {
111110
* var IPIV = new Int32Array( [ 2, 0, 1 ] );
112111
* 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 ] ]
113112
*
114-
* dlaswp.ndarray( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
113+
* dlaswp.ndarray( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
115114
* // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
116115
*/
117116
declare var dlaswp: Routine;

lib/node_modules/@stdlib/lapack/base/dlaswp/docs/types/test.ts

Lines changed: 109 additions & 125 deletions
Large diffs are not rendered by default.

lib/node_modules/@stdlib/lapack/base/dlaswp/lib/base.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
// MODULES //
2222

23+
var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' );
2324
var floor = require( '@stdlib/math/base/special/floor' );
2425
var dswap = require( '@stdlib/blas/base/dswap' ).ndarray;
2526

@@ -35,7 +36,6 @@ var BLOCK_SIZE = 32;
3536
* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.
3637
*
3738
* @private
38-
* @param {string} order - storage layout
3939
* @param {PositiveInteger} N - number of columns in `A`
4040
* @param {Float64Array} A - input matrix
4141
* @param {integer} strideA1 - stride of the first dimension of `A`
@@ -56,10 +56,10 @@ var BLOCK_SIZE = 32;
5656
* var IPIV = new Int32Array( [ 2, 0, 1 ] );
5757
* 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 ] ]
5858
*
59-
* dlaswp( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
59+
* dlaswp( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
6060
* // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
6161
*/
62-
function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params
62+
function dlaswp( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params
6363
var nrows;
6464
var n32;
6565
var tmp;
@@ -82,7 +82,7 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s
8282
nrows += 1;
8383

8484
// If the order is row-major, we can delegate to the Level 1 routine `dswap` for interchanging rows...
85-
if ( order === 'row-major' ) {
85+
if ( isRowMajor( [ strideA1, strideA2 ] ) ) {
8686
ip = offsetIPIV;
8787
for ( i = 0, k = k1; i < nrows; i++, k += inck ) {
8888
row = IPIV[ ip ];

lib/node_modules/@stdlib/lapack/base/dlaswp/lib/dlaswp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function dlaswp( order, N, A, LDA, k1, k2, IPIV, incx ) {
8484
sa1 = LDA;
8585
sa2 = 1;
8686
}
87-
return base( order, N, A, sa1, sa2, 0, k1, k2, inc, IPIV, incx, io );
87+
return base( N, A, sa1, sa2, 0, k1, k2, inc, IPIV, incx, io );
8888
}
8989

9090

lib/node_modules/@stdlib/lapack/base/dlaswp/lib/ndarray.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
// MODULES //
2222

23-
var isLayout = require( '@stdlib/blas/base/assert/is-layout' );
24-
var format = require( '@stdlib/string/format' );
2523
var base = require( './base.js' );
2624

2725

@@ -30,7 +28,6 @@ var base = require( './base.js' );
3028
/**
3129
* Performs a series of row interchanges on a matrix `A` using pivot indices stored in `IPIV`.
3230
*
33-
* @param {string} order - storage layout
3431
* @param {PositiveInteger} N - number of columns in `A`
3532
* @param {Float64Array} A - input matrix
3633
* @param {integer} strideA1 - stride of the first dimension of `A`
@@ -42,7 +39,6 @@ var base = require( './base.js' );
4239
* @param {Int32Array} IPIV - vector of pivot indices
4340
* @param {integer} strideIPIV - `IPIV` stride length
4441
* @param {NonNegativeInteger} offsetIPIV - index offset for `IPIV`
45-
* @throws {TypeError} first argument must be a valid order
4642
* @returns {Float64Array} permuted matrix `A`
4743
*
4844
* @example
@@ -52,14 +48,11 @@ var base = require( './base.js' );
5248
* var IPIV = new Int32Array( [ 2, 0, 1 ] );
5349
* 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 ] ]
5450
*
55-
* dlaswp( 'row-major', 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
51+
* dlaswp( 2, A, 2, 1, 0, 0, 2, 1, IPIV, 1, 0 );
5652
* // A => <Float64Array>[ 3.0, 4.0, 1.0, 2.0, 5.0, 6.0 ]
5753
*/
58-
function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params
54+
function dlaswp( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ) { // eslint-disable-line max-len, max-params
5955
var tmp;
60-
if ( !isLayout( order ) ) {
61-
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
62-
}
6356
if ( inck < 0 ) {
6457
offsetIPIV += k2 * strideIPIV;
6558
strideIPIV *= -1;
@@ -71,7 +64,7 @@ function dlaswp( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, s
7164
offsetIPIV += k1 * strideIPIV;
7265
inck = 1;
7366
}
74-
return base( order, N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len
67+
return base( N, A, strideA1, strideA2, offsetA, k1, k2, inck, IPIV, strideIPIV, offsetIPIV ); // eslint-disable-line max-len
7568
}
7669

7770

0 commit comments

Comments
 (0)