Skip to content

Commit 01de8bc

Browse files
committed
chore: update implementation
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 4e8ace2 commit 01de8bc

File tree

9 files changed

+104
-46
lines changed

9 files changed

+104
-46
lines changed

lib/node_modules/@stdlib/blas/base/dtrmv/README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,14 @@ void c_dtrmv_ndarray( const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const
275275
#include <stdio.h>
276276

277277
int main( void ) {
278-
// Create a strided array:
279-
const double A[] = { 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 };
280-
double x[] = { 1.0, 2.0, 3.0 };
278+
// Define a 3x3 matrix stored in row-major order:
279+
const double A[ 3*3 ] = {
280+
1.0, 0.0, 0.0,
281+
2.0, 1.0, 0.0,
282+
3.0, 2.0, 1.0
283+
};
284+
// Define `x` vector:
285+
double x[ 3 ] = { 1.0, 2.0, 3.0 };
281286

282287
// Specify the number of elements along each dimension of `A`:
283288
const int N = 3;

lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.native.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ var options = {
4747
* Creates a benchmark function.
4848
*
4949
* @private
50-
* @param {PositiveInteger} len - array length
50+
* @param {PositiveInteger} N - array length
5151
* @returns {Function} benchmark function
5252
*/
53-
function createBenchmark( len ) {
54-
var x = ones( len, options.dtype );
55-
var A = ones( len*len, options.dtype );
53+
function createBenchmark( N ) {
54+
var x = ones( N, options.dtype );
55+
var A = ones( N*N, options.dtype );
5656
return benchmark;
5757

5858
function benchmark( b ) {
@@ -61,7 +61,7 @@ function createBenchmark( len ) {
6161

6262
b.tic();
6363
for ( i = 0; i < b.iterations; i++ ) {
64-
z = dgemv( 'row-major', 'upper', 'transpose', 'non-unit', len, A, len, x, 1 );
64+
z = dgemv( 'row-major', 'upper', 'transpose', 'non-unit', N, A, N, x, 1 );
6565
if ( isnan( z ) ) {
6666
b.fail( 'should not return NaN' );
6767
}
@@ -86,17 +86,17 @@ function createBenchmark( len ) {
8686
function main() {
8787
var min;
8888
var max;
89-
var len;
89+
var N;
9090
var f;
9191
var i;
9292

9393
min = 1; // 10^min
9494
max = 6; // 10^max
9595

9696
for ( i = min; i <= max; i++ ) {
97-
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
98-
f = createBenchmark( len );
99-
bench( pkg+':size='+(len*len), opts, f );
97+
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
98+
f = createBenchmark( N );
99+
bench( pkg+'::native:size='+(N*N), opts, f );
100100
}
101101
}
102102

lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/benchmark.ndarray.native.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ var options = {
4747
* Creates a benchmark function.
4848
*
4949
* @private
50-
* @param {PositiveInteger} len - array length
50+
* @param {PositiveInteger} N - array length
5151
* @returns {Function} benchmark function
5252
*/
53-
function createBenchmark( len ) {
54-
var x = ones( len, options.dtype );
55-
var A = ones( len*len, options.dtype );
53+
function createBenchmark( N ) {
54+
var x = ones( N, options.dtype );
55+
var A = ones( N*N, options.dtype );
5656
return benchmark;
5757

5858
function benchmark( b ) {
@@ -61,7 +61,7 @@ function createBenchmark( len ) {
6161

6262
b.tic();
6363
for ( i = 0; i < b.iterations; i++ ) {
64-
z = dgemv( 'upper', 'transpose', 'non-unit', len, A, len, 1, 0, x, 1, 0 );
64+
z = dgemv( 'upper', 'transpose', 'non-unit', N, A, N, 1, 0, x, 1, 0 );
6565
if ( isnan( z ) ) {
6666
b.fail( 'should not return NaN' );
6767
}
@@ -86,17 +86,17 @@ function createBenchmark( len ) {
8686
function main() {
8787
var min;
8888
var max;
89-
var len;
89+
var N;
9090
var f;
9191
var i;
9292

9393
min = 1; // 10^min
9494
max = 6; // 10^max
9595

9696
for ( i = min; i <= max; i++ ) {
97-
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
98-
f = createBenchmark( len );
99-
bench( pkg+':size='+(len*len), opts, f );
97+
N = floor( pow( pow( 10, i ), 1.0/2.0 ) );
98+
f = createBenchmark( N );
99+
bench( pkg+'::native:ndarray:size='+(N*N), opts, f );
100100
}
101101
}
102102

lib/node_modules/@stdlib/blas/base/dtrmv/benchmark/c/benchmark.length.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,28 @@ static double tic( void ) {
8282
* Runs a benchmark.
8383
*
8484
* @param iterations number of iterations
85-
* @param len array length
85+
* @param N array dimension size
8686
* @return elapsed time in seconds
8787
*/
88-
static double benchmark1( int iterations, int len ) {
88+
static double benchmark1( int iterations, int N ) {
8989
double elapsed;
90-
double A[ len*len ];
91-
double x[ len ];
90+
double A[ N*N ];
91+
double x[ N ];
9292
double t;
9393
int i;
9494

95-
stdlib_strided_dfill( len, 1.0, x, 1 );
96-
stdlib_strided_dfill( len*len, 1.0, A, 1 );
95+
stdlib_strided_dfill( N, 1.0, x, 1 );
96+
stdlib_strided_dfill( N*N, 1.0, A, 1 );
9797
t = tic();
9898
for ( i = 0; i < iterations; i++ ) {
99-
c_dtrmv( CblasRowMajor, CblasUpper, CblasNoTrans, CblasNonUnit, len, A, len, x, 1 );
100-
if ( x[ 0 ] != x[ 0 ] ) {
99+
c_dtrmv( CblasRowMajor, CblasUpper, CblasNoTrans, CblasNonUnit, N, A, N, x, 1 );
100+
if ( x[ i%N ] != x[ i%N ] ) {
101101
printf( "should not return NaN\n" );
102102
break;
103103
}
104104
}
105105
elapsed = tic() - t;
106-
if ( x[ 0 ] != x[ 0 ] ) {
106+
if ( x[ i%N ] != x[ i%N ] ) {
107107
printf( "should not return NaN\n" );
108108
}
109109
return elapsed;
@@ -113,28 +113,28 @@ static double benchmark1( int iterations, int len ) {
113113
* Runs a benchmark.
114114
*
115115
* @param iterations number of iterations
116-
* @param len array length
116+
* @param N array dimension size
117117
* @return elapsed time in seconds
118118
*/
119-
static double benchmark2( int iterations, int len ) {
119+
static double benchmark2( int iterations, int N ) {
120120
double elapsed;
121-
double A[ len*len ];
122-
double x[ len ];
121+
double A[ N*N ];
122+
double x[ N ];
123123
double t;
124124
int i;
125125

126-
stdlib_strided_dfill( len, 1.0, x, 1 );
127-
stdlib_strided_dfill( len*len, 1.0, A, 1 );
126+
stdlib_strided_dfill( N, 1.0, x, 1 );
127+
stdlib_strided_dfill( N*N, 1.0, A, 1 );
128128
t = tic();
129129
for ( i = 0; i < iterations; i++ ) {
130-
c_dtrmv_ndarray( CblasUpper, CblasNoTrans, CblasNonUnit, len, A, len, 1, 0, x, 1, 0 );
131-
if ( x[ 0 ] != x[ 0 ] ) {
130+
c_dtrmv_ndarray( CblasUpper, CblasNoTrans, CblasNonUnit, N, A, N, 1, 0, x, 1, 0 );
131+
if ( x[ i%N ] != x[ i%N ] ) {
132132
printf( "should not return NaN\n" );
133133
break;
134134
}
135135
}
136136
elapsed = tic() - t;
137-
if ( x[ 0 ] != x[ 0 ] ) {
137+
if ( x[ i%N ] != x[ i%N ] ) {
138138
printf( "should not return NaN\n" );
139139
}
140140
return elapsed;

lib/node_modules/@stdlib/blas/base/dtrmv/docs/repl.txt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{alias}}( ord, uplo, trans, diag, N, A, lda, x, sx )
2+
{{alias}}( order, uplo, trans, diag, N, A, lda, x, sx )
33
Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`,
44
where `x` is an `N` element vector and `A` is an `N` by `N` unit, or
55
non-unit, upper or lower triangular matrix.
@@ -11,7 +11,7 @@
1111

1212
Parameters
1313
----------
14-
ord: string
14+
order: string
1515
Row-major (C-style) or column-major (Fortran-style) order. Must be
1616
either 'row-major' or 'column-major'.
1717

@@ -48,11 +48,25 @@
4848

4949
Examples
5050
--------
51+
// Standard usage:
5152
> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
5253
> var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 1.0 ] );
5354
> {{alias}}( 'row-major', 'upper', 'no-transpose', 'unit', 2, A, 2, x, 1 )
5455
<Float64Array>[ 3.0, 1.0 ]
5556

57+
// Advanced indexing:
58+
> x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] );
59+
> A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 1.0 ] );
60+
> {{alias}}( 'row-major', 'upper', 'no-transpose', 'unit', 2, A, 2, x, -1 )
61+
<Float64Array>[ 1.0, 3.0 ]
62+
63+
// Using typed array views:
64+
> var x0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 1.0, 1.0 ] );
65+
> A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 1.0 ] );
66+
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
67+
> {{alias}}( 'row-major', 'upper', 'no-transpose', 'unit', 2, A, 2, x1, 1 )
68+
<Float64Array>[ 3.0, 1.0 ]
69+
5670

5771
{{alias}}.ndarray( uplo, trans, diag, N, A, sa1, sa2, oa, x, sx, ox )
5872
Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`,

lib/node_modules/@stdlib/blas/base/dtrmv/include/stdlib/blas/base/dtrmv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C" {
3434
/**
3535
* Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix.
3636
*/
37-
void API_SUFFIX(c_dtrmv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *x, const CBLAS_INT strideX );
37+
void API_SUFFIX(c_dtrmv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *x, const CBLAS_INT strideX );
3838

3939
/**
4040
* Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x` using alternative indexing semantics, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix.

lib/node_modules/@stdlib/blas/base/dtrmv/include/stdlib/blas/base/dtrmv_cblas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C" {
3434
/**
3535
* Performs one of the matrix-vector operations `x = A*x` or `x = A^T*x`, where `x` is an `N` element vector and `A` is an `N` by `N` unit, or non-unit, upper or lower triangular matrix.
3636
*/
37-
void API_SUFFIX(cblas_dtrmv)( const CBLAS_LAYOUT order, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *x, const CBLAS_INT strideX );
37+
void API_SUFFIX(cblas_dtrmv)( const CBLAS_LAYOUT layout, const CBLAS_UPLO uplo, const CBLAS_TRANSPOSE trans, const CBLAS_DIAG diag, const CBLAS_INT N, const double *A, const CBLAS_INT LDA, double *x, const CBLAS_INT strideX );
3838

3939
#ifdef __cplusplus
4040
}

lib/node_modules/@stdlib/blas/base/dtrmv/lib/dtrmv.js

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

2121
// MODULES //
2222

23-
var max = require( '@stdlib/math/base/special/fast/max' );
23+
var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' );
2424
var isLayout = require( '@stdlib/blas/base/assert/is-layout' );
2525
var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' );
2626
var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' );
2727
var isDiagonal = require( '@stdlib/blas/base/assert/is-diagonal-type' );
28-
var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' );
2928
var stride2offset = require( '@stdlib/strided/base/stride2offset' );
29+
var max = require( '@stdlib/math/base/special/fast/max' );
3030
var format = require( '@stdlib/string/format' );
3131
var base = require( './base.js' );
3232

@@ -50,7 +50,7 @@ var base = require( './base.js' );
5050
* @throws {TypeError} third argument must be a valid transpose operation
5151
* @throws {TypeError} fourth argument must be a valid diagonal type
5252
* @throws {RangeError} fifth argument must be a nonnegative integer
53-
* @throws {RangeError} seventh argument must be greater than or equal to max(1,N)
53+
* @throws {RangeError} seventh argument must be a valid stride
5454
* @throws {RangeError} ninth argument must be non-zero
5555
* @returns {Float64Array} `x`
5656
*
@@ -89,6 +89,7 @@ function dtrmv( order, uplo, trans, diag, N, A, LDA, x, strideX ) {
8989
if ( strideX === 0 ) {
9090
throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) );
9191
}
92+
// Check if we can early return...
9293
if ( N === 0 ) {
9394
return x;
9495
}

lib/node_modules/@stdlib/blas/base/dtrmv/lib/dtrmv.native.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,16 @@
2020

2121
// MODULES //
2222

23+
var isLayout = require( '@stdlib/blas/base/assert/is-layout' );
24+
var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' );
25+
var isTransposeOperation = require( '@stdlib/blas/base/assert/is-transpose-operation' );
26+
var isDiagonal = require( '@stdlib/blas/base/assert/is-diagonal-type' );
2327
var resolveOrder = require( '@stdlib/blas/base/layout-resolve-enum' );
2428
var resolveUplo = require( '@stdlib/blas/base/matrix-triangle-resolve-enum' );
2529
var resolveTrans = require( '@stdlib/blas/base/transpose-operation-resolve-enum' );
2630
var resolveDiag = require( '@stdlib/blas/base/diagonal-type-resolve-enum' );
31+
var max = require( '@stdlib/math/base/special/fast/max' );
32+
var format = require( '@stdlib/string/format' );
2733
var addon = require( './../src/addon.node' );
2834

2935

@@ -41,6 +47,13 @@ var addon = require( './../src/addon.node' );
4147
* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`)
4248
* @param {Float64Array} x - input vector
4349
* @param {integer} strideX - `x` stride length
50+
* @throws {TypeError} first argument must be a valid order
51+
* @throws {TypeError} second argument must specify whether a lower or upper triangular matrix is supplied
52+
* @throws {TypeError} third argument must be a valid transpose operation
53+
* @throws {TypeError} fourth argument must be a valid diagonal type
54+
* @throws {RangeError} fifth argument must be a nonnegative integer
55+
* @throws {RangeError} seventh argument must be a valid stride
56+
* @throws {RangeError} ninth argument must be non-zero
4457
* @returns {Float64Array} `x`
4558
*
4659
* @example
@@ -53,6 +66,31 @@ var addon = require( './../src/addon.node' );
5366
* // x => <Float64Array>[ 14.0, 8.0, 3.0 ]
5467
*/
5568
function dtrmv( order, uplo, trans, diag, N, A, LDA, x, strideX ) {
69+
if ( !isLayout( order ) ) {
70+
throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) );
71+
}
72+
if ( !isMatrixTriangle( uplo ) ) {
73+
throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) );
74+
}
75+
if ( !isTransposeOperation( trans ) ) {
76+
throw new TypeError( format( 'invalid argument. Third argument must be a valid transpose operation. Value: `%s`.', trans ) );
77+
}
78+
if ( !isDiagonal( diag ) ) {
79+
throw new TypeError( format( 'invalid argument. Fourth argument must be a valid diagonal type. Value: `%s`.', diag ) );
80+
}
81+
if ( N < 0 ) {
82+
throw new RangeError( format( 'invalid argument. Fifth argument must be a nonnegative integer. Value: `%d`.', N ) );
83+
}
84+
if ( LDA < max( 1, N ) ) {
85+
throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) );
86+
}
87+
if ( strideX === 0 ) {
88+
throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) );
89+
}
90+
// Check if we can early return...
91+
if ( N === 0 ) {
92+
return x;
93+
}
5694
addon( resolveOrder( order ), resolveUplo( uplo ), resolveTrans( trans ), resolveDiag( diag ), N, A, LDA, x, strideX ); // eslint-disable-line max-len
5795
return x;
5896
}

0 commit comments

Comments
 (0)