Skip to content

Commit bd06c4d

Browse files
committed
refactor: resolve storage layout enumeration constants
1 parent df48448 commit bd06c4d

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

Diff for: lib/node_modules/@stdlib/blas/base/dger/lib/dger.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/**
2626
* Performs the rank 1 operation `A = alpha*x*y^T + A`.
2727
*
28-
* @param {string} order - storage layout
28+
* @param {*} order - storage layout
2929
* @param {NonNegativeInteger} M - number of rows in the matrix `A`
3030
* @param {NonNegativeInteger} N - number of columns in the matrix `A`
3131
* @param {number} alpha - scalar constant

Diff for: lib/node_modules/@stdlib/blas/base/dger/lib/dger.native.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
// MODULES //
2222

23+
var resolve = require( '@stdlib/blas/base/layout-resolve-enum' );
24+
var format = require( '@stdlib/string/format' );
2325
var addon = require( './../src/addon.node' );
2426

2527

@@ -28,7 +30,7 @@ var addon = require( './../src/addon.node' );
2830
/**
2931
* Performs the rank 1 operation `A = alpha*x*y^T + A`.
3032
*
31-
* @param {string} order - storage layout
33+
* @param {*} order - storage layout
3234
* @param {NonNegativeInteger} M - number of rows in the matrix `A`
3335
* @param {NonNegativeInteger} N - number of columns in the matrix `A`
3436
* @param {number} alpha - scalar constant
@@ -38,6 +40,7 @@ var addon = require( './../src/addon.node' );
3840
* @param {integer} strideY - `y` stride length
3941
* @param {Float64Array} A - matrix of coefficients
4042
* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
43+
* @throws {TypeError} first argument must be a supported BLAS memory layout
4144
* @returns {Float64Array} `A`
4245
*
4346
* @example
@@ -55,7 +58,11 @@ var addon = require( './../src/addon.node' );
5558
* // B => <Float64Array>[ 0.0, 1.0, 2.0, 3.0, 0.0, 4.0, 8.0, 12.0, 0.0, 0.0, 0.0, 0.0 ]
5659
*/
5760
function dger( order, M, N, alpha, x, strideX, y, strideY, A, LDA ) {
58-
addon( 101, M, N, alpha, x, strideX, y, strideY, A, LDA ); // FIXME: resolve order enum
61+
var ord = resolve( order );
62+
if ( ord === null ) {
63+
throw new TypeError( format( 'invalid argument. First argument must be a supported BLAS memory layout. Value: `%s`.', order ) );
64+
}
65+
addon( ord, M, N, alpha, x, strideX, y, strideY, A, LDA );
5966
return A;
6067
}
6168

Diff for: lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
/**
2626
* Performs the rank 1 operation `A = alpha*x*y^T + A`.
2727
*
28-
* @param {string} order - storage layout
28+
* @param {*} order - storage layout
2929
* @param {NonNegativeInteger} M - number of rows in the matrix `A`
3030
* @param {NonNegativeInteger} N - number of columns in the matrix `A`
3131
* @param {number} alpha - scalar constant

Diff for: lib/node_modules/@stdlib/blas/base/dger/lib/ndarray.native.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' );
2424
var offsetView = require( '@stdlib/strided/base/offset-view' );
25+
var resolve = require( '@stdlib/blas/base/layout-resolve-enum' );
26+
var format = require( '@stdlib/string/format' );
2527
var addon = require( './dger.native.js' );
2628

2729

@@ -30,7 +32,7 @@ var addon = require( './dger.native.js' );
3032
/**
3133
* Performs the rank 1 operation `A = alpha*x*y^T + A`.
3234
*
33-
* @param {string} order - storage layout
35+
* @param {*} order - storage layout
3436
* @param {NonNegativeInteger} M - number of rows in the matrix `A`
3537
* @param {NonNegativeInteger} N - number of columns in the matrix `A`
3638
* @param {number} alpha - scalar constant
@@ -42,6 +44,7 @@ var addon = require( './dger.native.js' );
4244
* @param {NonNegativeInteger} offsetY - starting `y` index
4345
* @param {Float64Array} A - matrix of coefficients
4446
* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
47+
* @throws {TypeError} first argument must be a supported BLAS memory layout
4548
* @returns {Float64Array} `A`
4649
*
4750
* @example
@@ -61,14 +64,19 @@ var addon = require( './dger.native.js' );
6164
function dger( order, M, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, LDA ) { // eslint-disable-line max-len, max-params
6265
var viewX;
6366
var viewY;
67+
var ord;
6468

69+
ord = resolve( order );
70+
if ( ord === null ) {
71+
throw new TypeError( format( 'invalid argument. First argument must be a supported BLAS memory layout. Value: `%s`.', order ) );
72+
}
6573
offsetX = minViewBufferIndex( N, strideX, offsetX );
6674
offsetY = minViewBufferIndex( N, strideY, offsetY );
6775

6876
viewX = offsetView( x, offsetX );
6977
viewY = offsetView( y, offsetY );
7078

71-
addon( 101, M, N, alpha, viewX, strideX, viewY, strideY, A, LDA ); // FIXME: resolve order enum
79+
addon( ord, M, N, alpha, viewX, strideX, viewY, strideY, A, LDA );
7280
return A;
7381
}
7482

0 commit comments

Comments
 (0)