Skip to content

Commit d1c59df

Browse files
committed
fix: apply suggestions from code review
--- 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: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - 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: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent 014e2a8 commit d1c59df

23 files changed

Lines changed: 709 additions & 356 deletions

lib/node_modules/@stdlib/blas/ext/base/svander/README.md

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,55 @@ The function has the following parameters:
5454

5555
- **order**: row-major (C-style) or column-major (Fortran-style) order.
5656
- **mode**: mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers.
57-
- **M**: number of rows in `out` and number of indexed elements in `x`.
57+
- **M**: number of rows in `out`.
5858
- **N**: number of columns in `out`.
5959
- **x**: input [`Float32Array`][@stdlib/array/float32].
6060
- **strideX**: stride length for `x`.
6161
- **out**: output matrix stored in linear memory as a [`Float32Array`][@stdlib/array/float32].
62-
- **ldo**: stride of the first dimension of `out` (a.k.a., leading dimension of the matrix `out`).
62+
- **ldo**: stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`).
63+
64+
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
65+
66+
<!-- eslint-disable stdlib/capitalized-comments, max-len -->
67+
68+
```javascript
69+
var Float32Array = require( '@stdlib/array/float32' );
70+
71+
// Initial arrays:
72+
var x0 = new Float32Array( [ 999.0, 1.0, 2.0, 3.0 ] );
73+
var out0 = new Float32Array( 10 );
74+
75+
// Create offset views:
76+
var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
77+
var out1 = new Float32Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
78+
79+
svander( 'row-major', 1, 3, 3, x1, 1, out1, 3 );
80+
// out0 => <Float32Array>[ 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 1.0, 3.0, 9.0 ]
81+
```
82+
83+
When the mode is positive, the matrix is generated such that
84+
85+
```text
86+
[
87+
1 x_0^1 x_0^2 ... x_0^(N-1)
88+
1 x_1^1 x_1^2 ... x_1^(N-1)
89+
...
90+
]
91+
```
92+
93+
with increasing powers along the rows.
94+
95+
When the mode is negative, the matrix is generated such that
96+
97+
```text
98+
[
99+
x_0^(N-1) ... x_0^2 x_0^1 1
100+
x_1^(N-1) ... x_1^2 x_1^1 1
101+
...
102+
]
103+
```
104+
105+
with decreasing powers along the rows.
63106

64107
<!-- lint disable maximum-heading-length -->
65108

@@ -86,16 +129,16 @@ The function has the following additional parameters:
86129
- **strideOut2**: stride length for the second dimension of `out`.
87130
- **offsetOut**: starting index for `out`.
88131

89-
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,
132+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, to use every other element from the input array starting from the second element:
90133

91134
```javascript
92135
var Float32Array = require( '@stdlib/array/float32' );
93136

94-
var x = new Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] );
137+
var x = new Float32Array( [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ] );
95138
var out = new Float32Array( 9 );
96139

97-
svander.ndarray( -1, 3, 3, x, 1, 1, out, 3, 1, 0 );
98-
// out => <Float32Array>[ 1.0, 1.0, 1.0, 4.0, 2.0, 1.0, 9.0, 3.0, 1.0 ]
140+
svander.ndarray( 1, 3, 3, x, 2, 1, out, 3, 1, 0 );
141+
// out => <Float32Array>[ 1.0, 1.0, 1.0, 1.0, 2.0, 4.0, 1.0, 3.0, 9.0 ]
99142
```
100143

101144
</section>
@@ -106,7 +149,7 @@ svander.ndarray( -1, 3, 3, x, 1, 1, out, 3, 1, 0 );
106149

107150
## Notes
108151

109-
- If `M <= 0` or `N <= 0`, both functions return `out` unchanged.
152+
- If `M <= 0` or `N <= 0`, both functions return the output matrix unchanged.
110153

111154
</section>
112155

@@ -133,10 +176,6 @@ var out = new Float32Array( M*N );
133176

134177
svander( 'row-major', -1, M, N, x, 1, out, N );
135178
console.log( out );
136-
137-
out = new Float32Array( M*N );
138-
svander.ndarray( -1, M, N, x, 1, 0, out, N, 1, 0 );
139-
console.log( out );
140179
```
141180

142181
</section>
@@ -186,12 +225,12 @@ The function accepts the following arguments:
186225
187226
- **order**: `[in] CBLAS_LAYOUT` storage layout.
188227
- **mode**: `[in] float` mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers.
189-
- **M**: `[in] CBLAS_INT` number of rows in `Out` and number of indexed elements in `X`.
228+
- **M**: `[in] CBLAS_INT` number of rows in `Out`.
190229
- **N**: `[in] CBLAS_INT` number of columns in `Out`.
191230
- **X**: `[in] float*` input array.
192231
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
193232
- **Out**: `[out] float*` output matrix.
194-
- **LDO**: `[in] CBLAS_INT` stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`).
233+
- **LDO**: `[in] CBLAS_INT` stride between successive contiguous vectors of the matrix `Out` (a.k.a., leading dimension of the matrix `Out`).
195234
196235
```c
197236
void API_SUFFIX(stdlib_strided_svander)( const CBLAS_LAYOUT order, const float mode, const CBLAS_INT M, const CBLAS_INT N, const float *X, const CBLAS_INT strideX, float *Out, const CBLAS_INT LDO );
@@ -217,7 +256,7 @@ stdlib_strided_svander_ndarray( -1.0f, 3, 3, x, 1, 0, Out, 3, 1, 0 );
217256
The function accepts the following arguments:
218257
219258
- **mode**: `[in] float` mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers.
220-
- **M**: `[in] CBLAS_INT` number of rows in `Out` and number of indexed elements in `X`.
259+
- **M**: `[in] CBLAS_INT` number of rows in `Out`.
221260
- **N**: `[in] CBLAS_INT` number of columns in `Out`.
222261
- **X**: `[in] float*` input array.
223262
- **strideX**: `[in] CBLAS_INT` stride length for `X`.

lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ var uniform = require( '@stdlib/random/array/uniform' );
2525
var zeros = require( '@stdlib/array/zeros' );
2626
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var pow = require( '@stdlib/math/base/special/pow' );
28-
var floor = require( '@stdlib/math/base/special/floor' );
2928
var format = require( '@stdlib/string/format' );
3029
var pkg = require( './../package.json' ).name;
3130
var svander = require( './../lib/svander.js' );
@@ -44,15 +43,12 @@ var options = {
4443
* Creates a benchmark function.
4544
*
4645
* @private
47-
* @param {PositiveInteger} N - array dimension size
46+
* @param {PositiveInteger} len - array length
4847
* @returns {Function} benchmark function
4948
*/
50-
function createBenchmark( N ) {
51-
var out;
52-
var x;
53-
54-
x = uniform( N, -10.0, 10.0, options );
55-
out = zeros( N*N, 'float32' );
49+
function createBenchmark( len ) {
50+
var out = zeros( len * len, options.dtype );
51+
var x = uniform( len, -10, 10, options );
5652
return benchmark;
5753

5854
/**
@@ -62,18 +58,19 @@ function createBenchmark( N ) {
6258
* @param {Benchmark} b - benchmark instance
6359
*/
6460
function benchmark( b ) {
65-
var z;
61+
var v;
6662
var i;
6763

6864
b.tic();
6965
for ( i = 0; i < b.iterations; i++ ) {
70-
z = svander( 'row-major', -1, N, N, x, 1, out, N );
71-
if ( isnanf( z[ i%z.length ] ) ) {
66+
x[ 0 ] += 0.1;
67+
v = svander( 'row-major', 1, len, len, x, 1, out, len );
68+
if ( isnanf( v[ i%v.length ] ) ) {
7269
b.fail( 'should not return NaN' );
7370
}
7471
}
7572
b.toc();
76-
if ( isnanf( z[ i%z.length ] ) ) {
73+
if ( isnanf( v[ i%v.length ] ) ) {
7774
b.fail( 'should not return NaN' );
7875
}
7976
b.pass( 'benchmark finished' );
@@ -97,12 +94,12 @@ function main() {
9794
var i;
9895

9996
min = 1; // 10^min
100-
max = 6; // 10^max
97+
max = 3; // 10^max
10198

10299
for ( i = min; i <= max; i++ ) {
103-
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
100+
len = pow( 10, i );
104101
f = createBenchmark( len );
105-
bench( format( '%s:size=%d', pkg, len*len ), f );
102+
bench( format( '%s:len=%d', pkg, len ), f );
106103
}
107104
}
108105

lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.native.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ var uniform = require( '@stdlib/random/array/uniform' );
2626
var zeros = require( '@stdlib/array/zeros' );
2727
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2828
var pow = require( '@stdlib/math/base/special/pow' );
29-
var floor = require( '@stdlib/math/base/special/floor' );
3029
var tryRequire = require( '@stdlib/utils/try-require' );
3130
var format = require( '@stdlib/string/format' );
3231
var pkg = require( './../package.json' ).name;
@@ -49,15 +48,12 @@ var options = {
4948
* Creates a benchmark function.
5049
*
5150
* @private
52-
* @param {PositiveInteger} N - array dimension size
51+
* @param {PositiveInteger} len - array length
5352
* @returns {Function} benchmark function
5453
*/
55-
function createBenchmark( N ) {
56-
var out;
57-
var x;
58-
59-
x = uniform( N, -10.0, 10.0, options );
60-
out = zeros( N*N, 'float32' );
54+
function createBenchmark( len ) {
55+
var out = zeros( len * len, options.dtype );
56+
var x = uniform( len, -10, 10, options );
6157
return benchmark;
6258

6359
/**
@@ -67,18 +63,19 @@ function createBenchmark( N ) {
6763
* @param {Benchmark} b - benchmark instance
6864
*/
6965
function benchmark( b ) {
70-
var z;
66+
var v;
7167
var i;
7268

7369
b.tic();
7470
for ( i = 0; i < b.iterations; i++ ) {
75-
z = svander( 'row-major', -1, N, N, x, 1, out, N );
76-
if ( isnanf( z[ i%z.length ] ) ) {
71+
x[ 0 ] += 0.1;
72+
v = svander( 'row-major', 1, len, len, x, 1, out, len );
73+
if ( isnanf( v[ i%v.length ] ) ) {
7774
b.fail( 'should not return NaN' );
7875
}
7976
}
8077
b.toc();
81-
if ( isnanf( z[ i%z.length ] ) ) {
78+
if ( isnanf( v[ i%v.length ] ) ) {
8279
b.fail( 'should not return NaN' );
8380
}
8481
b.pass( 'benchmark finished' );
@@ -102,12 +99,12 @@ function main() {
10299
var i;
103100

104101
min = 1; // 10^min
105-
max = 6; // 10^max
102+
max = 3; // 10^max
106103

107104
for ( i = min; i <= max; i++ ) {
108-
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
105+
len = pow( 10, i );
109106
f = createBenchmark( len );
110-
bench( format( '%s::native:size=%d', pkg, len*len ), opts, f );
107+
bench( format( '%s::native:len=%d', pkg, len ), opts, f );
111108
}
112109
}
113110

lib/node_modules/@stdlib/blas/ext/base/svander/benchmark/benchmark.ndarray.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ var uniform = require( '@stdlib/random/array/uniform' );
2525
var zeros = require( '@stdlib/array/zeros' );
2626
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2727
var pow = require( '@stdlib/math/base/special/pow' );
28-
var floor = require( '@stdlib/math/base/special/floor' );
2928
var format = require( '@stdlib/string/format' );
3029
var pkg = require( './../package.json' ).name;
3130
var svander = require( './../lib/ndarray.js' );
@@ -44,15 +43,12 @@ var options = {
4443
* Creates a benchmark function.
4544
*
4645
* @private
47-
* @param {PositiveInteger} N - array dimension size
46+
* @param {PositiveInteger} len - array length
4847
* @returns {Function} benchmark function
4948
*/
50-
function createBenchmark( N ) {
51-
var out;
52-
var x;
53-
54-
x = uniform( N, -10.0, 10.0, options );
55-
out = zeros( N*N, 'float32' );
49+
function createBenchmark( len ) {
50+
var out = zeros( len * len, options.dtype );
51+
var x = uniform( len, -10, 10, options );
5652
return benchmark;
5753

5854
/**
@@ -62,18 +58,19 @@ function createBenchmark( N ) {
6258
* @param {Benchmark} b - benchmark instance
6359
*/
6460
function benchmark( b ) {
65-
var z;
61+
var v;
6662
var i;
6763

6864
b.tic();
6965
for ( i = 0; i < b.iterations; i++ ) {
70-
z = svander( -1, N, N, x, 1, 0, out, N, 1, 0 );
71-
if ( isnanf( z[ i%z.length ] ) ) {
66+
x[ 0 ] += 0.1;
67+
v = svander( 1, len, len, x, 1, 0, out, len, 1, 0 );
68+
if ( isnanf( v[ i%v.length ] ) ) {
7269
b.fail( 'should not return NaN' );
7370
}
7471
}
7572
b.toc();
76-
if ( isnanf( z[ i%z.length ] ) ) {
73+
if ( isnanf( v[ i%v.length ] ) ) {
7774
b.fail( 'should not return NaN' );
7875
}
7976
b.pass( 'benchmark finished' );
@@ -97,12 +94,12 @@ function main() {
9794
var i;
9895

9996
min = 1; // 10^min
100-
max = 6; // 10^max
97+
max = 3; // 10^max
10198

10299
for ( i = min; i <= max; i++ ) {
103-
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
100+
len = pow( 10, i );
104101
f = createBenchmark( len );
105-
bench( format( '%s:ndarray:size=%d', pkg, len*len ), f );
102+
bench( format( '%s:ndarray:len=%d', pkg, len ), f );
106103
}
107104
}
108105

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

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ var uniform = require( '@stdlib/random/array/uniform' );
2626
var zeros = require( '@stdlib/array/zeros' );
2727
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
2828
var pow = require( '@stdlib/math/base/special/pow' );
29-
var floor = require( '@stdlib/math/base/special/floor' );
3029
var tryRequire = require( '@stdlib/utils/try-require' );
3130
var format = require( '@stdlib/string/format' );
3231
var pkg = require( './../package.json' ).name;
@@ -49,15 +48,12 @@ var options = {
4948
* Creates a benchmark function.
5049
*
5150
* @private
52-
* @param {PositiveInteger} N - array dimension size
51+
* @param {PositiveInteger} len - array length
5352
* @returns {Function} benchmark function
5453
*/
55-
function createBenchmark( N ) {
56-
var out;
57-
var x;
58-
59-
x = uniform( N, -10.0, 10.0, options );
60-
out = zeros( N*N, 'float32' );
54+
function createBenchmark( len ) {
55+
var out = zeros( len * len, options.dtype );
56+
var x = uniform( len, -10, 10, options );
6157
return benchmark;
6258

6359
/**
@@ -67,18 +63,19 @@ function createBenchmark( N ) {
6763
* @param {Benchmark} b - benchmark instance
6864
*/
6965
function benchmark( b ) {
70-
var z;
66+
var v;
7167
var i;
7268

7369
b.tic();
7470
for ( i = 0; i < b.iterations; i++ ) {
75-
z = svander( -1, N, N, x, 1, 0, out, N, 1, 0 );
76-
if ( isnanf( z[ i%z.length ] ) ) {
71+
x[ 0 ] += 0.1;
72+
v = svander( 1, len, len, x, 1, 0, out, len, 1, 0 );
73+
if ( isnanf( v[ i%v.length ] ) ) {
7774
b.fail( 'should not return NaN' );
7875
}
7976
}
8077
b.toc();
81-
if ( isnanf( z[ i%z.length ] ) ) {
78+
if ( isnanf( v[ i%v.length ] ) ) {
8279
b.fail( 'should not return NaN' );
8380
}
8481
b.pass( 'benchmark finished' );
@@ -102,12 +99,12 @@ function main() {
10299
var i;
103100

104101
min = 1; // 10^min
105-
max = 6; // 10^max
102+
max = 3; // 10^max
106103

107104
for ( i = min; i <= max; i++ ) {
108-
len = floor( pow( pow( 10, i ), 1.0/2.0 ) );
105+
len = pow( 10, i );
109106
f = createBenchmark( len );
110-
bench( format( '%s::native:ndarray:size=%d', pkg, len*len ), opts, f );
107+
bench( format( '%s::native:ndarray:len=%d', pkg, len ), opts, f );
111108
}
112109
}
113110

0 commit comments

Comments
 (0)