Skip to content

Commit a458ee9

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: na - 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 0140996 commit a458ee9

20 files changed

Lines changed: 614 additions & 295 deletions

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,36 @@ 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 [`Float64Array`][@stdlib/array/float64].
6060
- **strideX**: stride length for `x`.
6161
- **out**: output matrix stored in linear memory as a [`Float64Array`][@stdlib/array/float64].
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+
When the mode is positive, the matrix is generated such that
65+
66+
```text
67+
[
68+
1 x_0^1 x_0^2 ... x_0^(N-1)
69+
1 x_1^1 x_1^2 ... x_1^(N-1)
70+
...
71+
]
72+
```
73+
74+
with increasing powers along the rows.
75+
76+
When the mode is negative, the matrix is generated such that
77+
78+
```text
79+
[
80+
x_0^(N-1) ... x_0^2 x_0^1 1
81+
x_1^(N-1) ... x_1^2 x_1^1 1
82+
...
83+
]
84+
```
85+
86+
with decreasing powers along the rows.
6387

6488
<!-- lint disable maximum-heading-length -->
6589

@@ -170,12 +194,12 @@ The function accepts the following arguments:
170194
171195
- **order**: `[in] CBLAS_LAYOUT` storage layout.
172196
- **mode**: `[in] double` mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers.
173-
- **M**: `[in] CBLAS_INT` number of rows in `Out` and number of indexed elements in `X`.
197+
- **M**: `[in] CBLAS_INT` number of rows in `Out`.
174198
- **N**: `[in] CBLAS_INT` number of columns in `Out`.
175199
- **X**: `[in] double*` input array.
176200
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
177201
- **Out**: `[out] double*` output matrix.
178-
- **LDO**: `[in] CBLAS_INT` stride of the first dimension of `Out` (a.k.a., leading dimension of the matrix `Out`).
202+
- **LDO**: `[in] CBLAS_INT` stride between successive contiguous vectors of the matrix `Out` (a.k.a., leading dimension of the matrix `Out`).
179203
180204
```c
181205
void API_SUFFIX(stdlib_strided_dvander)( const CBLAS_LAYOUT order, const double mode, const CBLAS_INT M, const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT LDO );
@@ -201,7 +225,7 @@ stdlib_strided_dvander_ndarray( -1.0, 3, 3, x, 1, 0, Out, 3, 1, 0 );
201225
The function accepts the following arguments:
202226
203227
- **mode**: `[in] double` mode. If `mode < 0`, the function generates decreasing powers. If `mode > 0`, the function generates increasing powers.
204-
- **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`.
205229
- **N**: `[in] CBLAS_INT` number of columns in `Out`.
206230
- **X**: `[in] double*` input array.
207231
- **strideX**: `[in] CBLAS_INT` stride length for `X`.

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

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var uniform = require( '@stdlib/random/array/uniform' );
25-
var zeros = require( '@stdlib/array/zeros' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var pow = require( '@stdlib/math/base/special/pow' );
28-
var floor = require( '@stdlib/math/base/special/floor' );
27+
var zeros = require( '@stdlib/array/zeros' );
2928
var format = require( '@stdlib/string/format' );
3029
var pkg = require( './../package.json' ).name;
3130
var dvander = require( './../lib/dvander.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, 'float64' );
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 = dvander( 'row-major', -1, N, N, x, 1, out, N );
71-
if ( isnan( z[ i%z.length ] ) ) {
66+
x[ 0 ] += 0.1;
67+
v = dvander( 'row-major', 1, len, len, x, 1, out, len );
68+
if ( isnan( v[ i%v.length ] ) ) {
7269
b.fail( 'should not return NaN' );
7370
}
7471
}
7572
b.toc();
76-
if ( isnan( z[ i%z.length ] ) ) {
73+
if ( isnan( 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/dvander/benchmark/benchmark.native.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var uniform = require( '@stdlib/random/array/uniform' );
26-
var zeros = require( '@stdlib/array/zeros' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var pow = require( '@stdlib/math/base/special/pow' );
29-
var floor = require( '@stdlib/math/base/special/floor' );
28+
var zeros = require( '@stdlib/array/zeros' );
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, 'float64' );
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 = dvander( 'row-major', -1, N, N, x, 1, out, N );
76-
if ( isnan( z[ i%z.length ] ) ) {
71+
x[ 0 ] += 0.1;
72+
v = dvander( 'row-major', 1, len, len, x, 1, out, len );
73+
if ( isnan( v[ i%v.length ] ) ) {
7774
b.fail( 'should not return NaN' );
7875
}
7976
}
8077
b.toc();
81-
if ( isnan( z[ i%z.length ] ) ) {
78+
if ( isnan( 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/dvander/benchmark/benchmark.ndarray.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var uniform = require( '@stdlib/random/array/uniform' );
25-
var zeros = require( '@stdlib/array/zeros' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var pow = require( '@stdlib/math/base/special/pow' );
28-
var floor = require( '@stdlib/math/base/special/floor' );
27+
var zeros = require( '@stdlib/array/zeros' );
2928
var format = require( '@stdlib/string/format' );
3029
var pkg = require( './../package.json' ).name;
3130
var dvander = 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, 'float64' );
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 = dvander( -1, N, N, x, 1, 0, out, N, 1, 0 );
71-
if ( isnan( z[ i%z.length ] ) ) {
66+
x[ 0 ] += 0.1;
67+
v = dvander( 1, len, len, x, 1, 0, out, len, 1, 0 );
68+
if ( isnan( v[ i%v.length ] ) ) {
7269
b.fail( 'should not return NaN' );
7370
}
7471
}
7572
b.toc();
76-
if ( isnan( z[ i%z.length ] ) ) {
73+
if ( isnan( 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/dvander/benchmark/benchmark.ndarray.native.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var uniform = require( '@stdlib/random/array/uniform' );
26-
var zeros = require( '@stdlib/array/zeros' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var pow = require( '@stdlib/math/base/special/pow' );
29-
var floor = require( '@stdlib/math/base/special/floor' );
28+
var zeros = require( '@stdlib/array/zeros' );
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, 'float64' );
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 = dvander( -1, N, N, x, 1, 0, out, N, 1, 0 );
76-
if ( isnan( z[ i%z.length ] ) ) {
71+
x[ 0 ] += 0.1;
72+
v = dvander( 1, len, len, x, 1, 0, out, len, 1, 0 );
73+
if ( isnan( v[ i%v.length ] ) ) {
7774
b.fail( 'should not return NaN' );
7875
}
7976
}
8077
b.toc();
81-
if ( isnan( z[ i%z.length ] ) ) {
78+
if ( isnan( 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

lib/node_modules/@stdlib/blas/ext/base/dvander/benchmark/c/benchmark.length.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static double benchmark1( int iterations, int len ) {
110110
t = tic();
111111
for ( i = 0; i < iterations; i++ ) {
112112
// cppcheck-suppress uninitvar
113-
stdlib_strided_dvander( CblasRowMajor, -1.0, len, len, x, 1, out, len );
113+
stdlib_strided_dvander( CblasRowMajor, 1.0, len, len, x, 1, out, len );
114114
if ( out[ 0 ] != out[ 0 ] ) {
115115
printf( "should not return NaN\n" );
116116
break;
@@ -147,7 +147,7 @@ static double benchmark2( int iterations, int len ) {
147147
t = tic();
148148
for ( i = 0; i < iterations; i++ ) {
149149
// cppcheck-suppress uninitvar
150-
stdlib_strided_dvander_ndarray( -1.0, len, len, x, 1, 0, out, len, 1, 0 );
150+
stdlib_strided_dvander_ndarray( 1.0, len, len, x, 1, 0, out, len, 1, 0 );
151151
if ( out[ 0 ] != out[ 0 ] ) {
152152
printf( "should not return NaN\n" );
153153
break;
@@ -179,7 +179,7 @@ int main( void ) {
179179
print_version();
180180
count = 0;
181181
for ( i = MIN; i <= MAX; i++ ) {
182-
len = (int)sqrt( pow( 10, i ) );
182+
len = (int)floor( pow( pow( 10, i ), 1.0/2.0 ) );
183183
iter = ITERATIONS / pow( 10, i-1 );
184184
for ( j = 0; j < REPEATS; j++ ) {
185185
count += 1;
@@ -190,7 +190,7 @@ int main( void ) {
190190
}
191191
}
192192
for ( i = MIN; i <= MAX; i++ ) {
193-
len = (int)sqrt( pow( 10, i ) );
193+
len = (int)floor( pow( pow( 10, i ), 1.0/2.0 ) );
194194
iter = ITERATIONS / pow( 10, i-1 );
195195
for ( j = 0; j < REPEATS; j++ ) {
196196
count += 1;

0 commit comments

Comments
 (0)