Skip to content

Commit a31317e

Browse files
chore: add tests and minor bug fixes
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - 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: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 905427e commit a31317e

File tree

15 files changed

+957
-60
lines changed

15 files changed

+957
-60
lines changed

lib/node_modules/@stdlib/blas/ext/base/wasm/dapx/benchmark/benchmark.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,17 @@ function createBenchmark( len ) {
5959
* @param {Benchmark} b - benchmark instance
6060
*/
6161
function benchmark( b ) {
62-
var y;
6362
var i;
6463

6564
b.tic();
6665
for ( i = 0; i < b.iterations; i++ ) {
67-
y = dapx.main( x.length, 5.0, x, 1 );
68-
if ( isnan( y ) ) {
66+
dapx.main( x.length, 5.0, x, 1 );
67+
if ( isnan( x[ i%x.length ] ) ) {
6968
b.fail( 'should not return NaN' );
7069
}
7170
}
7271
b.toc();
73-
if ( isnan( y ) ) {
72+
if ( isnan( x[ i%x.length ] ) ) {
7473
b.fail( 'should not return NaN' );
7574
}
7675
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/blas/ext/base/wasm/dapx/benchmark/benchmark.module.main.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ function createBenchmark( len ) {
6060
* @param {Benchmark} b - benchmark instance
6161
*/
6262
function benchmark( b ) {
63+
var byteOffset;
64+
var view;
6365
var xptr;
6466
var mod;
6567
var mem;
6668
var nb;
67-
var y;
6869
var i;
6970

7071
// Create a new BLAS routine interface:
@@ -78,23 +79,27 @@ function createBenchmark( len ) {
7879

7980
// Reallocate the underlying memory to allow storing a vector:
8081
nb = bytesPerElement( options.dtype );
81-
mod.realloc( len*nb );
82+
mod.realloc( len*2*nb );
8283

8384
// Define a pointer (i.e., byte offset) to the first vector element:
8485
xptr = 0;
8586

8687
// Write random values to module memory:
8788
mod.write( xptr, uniform( len, -10.0, 10.0, options ) );
8889

90+
// Retrieve a DataView of module memory:
91+
view = mod.view;
92+
8993
b.tic();
9094
for ( i = 0; i < b.iterations; i++ ) {
91-
y = mod.main( len, 5.0, xptr, 1 );
92-
if ( isnan( y ) ) {
95+
mod.main( len, 5.0, xptr, 1 );
96+
byteOffset = xptr + ( (i%len)*nb );
97+
if ( isnan( view.getFloat64( byteOffset, true ) ) ) {
9398
b.fail( 'should not return NaN' );
9499
}
95100
}
96101
b.toc();
97-
if ( isnan( y ) ) {
102+
if ( isnan( view.getFloat64( byteOffset, true ) ) ) {
98103
b.fail( 'should not return NaN' );
99104
}
100105
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/blas/ext/base/wasm/dapx/benchmark/benchmark.module.ndarray.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@ function createBenchmark( len ) {
6060
* @param {Benchmark} b - benchmark instance
6161
*/
6262
function benchmark( b ) {
63+
var byteOffset;
64+
var view;
6365
var xptr;
6466
var mod;
6567
var mem;
6668
var nb;
67-
var y;
6869
var i;
6970

7071
// Create a new BLAS routine interface:
@@ -78,23 +79,27 @@ function createBenchmark( len ) {
7879

7980
// Reallocate the underlying memory to allow storing a vector:
8081
nb = bytesPerElement( options.dtype );
81-
mod.realloc( len*nb );
82+
mod.realloc( len*2*nb );
8283

8384
// Define a pointer (i.e., byte offset) to the first vector element:
8485
xptr = 0;
8586

8687
// Write random values to module memory:
8788
mod.write( xptr, uniform( len, -10.0, 10.0, options ) );
8889

90+
// Retrieve a DataView of module memory:
91+
view = mod.view;
92+
8993
b.tic();
9094
for ( i = 0; i < b.iterations; i++ ) {
91-
y = mod.ndarray( len, 5.0, xptr, 1, 0 );
92-
if ( isnan( y ) ) {
95+
mod.ndarray( len, 5.0, xptr, 1, 0 );
96+
byteOffset = xptr + ( (i%len)*nb );
97+
if ( isnan( view.getFloat64( byteOffset, true ) ) ) {
9398
b.fail( 'should not return NaN' );
9499
}
95100
}
96101
b.toc();
97-
if ( isnan( y ) ) {
102+
if ( isnan( view.getFloat64( byteOffset, true ) ) ) {
98103
b.fail( 'should not return NaN' );
99104
}
100105
b.pass( 'benchmark finished' );

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,17 @@ function createBenchmark( len ) {
5959
* @param {Benchmark} b - benchmark instance
6060
*/
6161
function benchmark( b ) {
62-
var y;
6362
var i;
6463

6564
b.tic();
6665
for ( i = 0; i < b.iterations; i++ ) {
67-
y = dapx.ndarray( x.length, 5.0, x, 1, 0 );
68-
if ( isnan( y ) ) {
66+
dapx.ndarray( x.length, 5.0, x, 1, 0 );
67+
if ( isnan( x[ i%x.length ] ) ) {
6968
b.fail( 'should not return NaN' );
7069
}
7170
}
7271
b.toc();
73-
if ( isnan( y ) ) {
72+
if ( isnan( x[ i%x.length ] ) ) {
7473
b.fail( 'should not return NaN' );
7574
}
7675
b.pass( 'benchmark finished' );

lib/node_modules/@stdlib/blas/ext/base/wasm/dapx/docs/repl.txt

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626

2727
Returns
2828
-------
29-
out: number
30-
Sum.
29+
x: Float64Array
30+
Input array.
3131

3232
Examples
3333
--------
@@ -46,8 +46,6 @@
4646
> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
4747
> {{alias}}.main( 3, 5.0, x1, 2 )
4848
<Float64Array>[ 3.0, 3.0, 1.0, 5.0, -1.0 ]
49-
> x0
50-
<Float64Array>[ 1.0, 3.0, 3.0, 1.0, 5.0, -1.0 ]
5149

5250

5351
{{alias}}.ndarray( N, alpha, x, strideX, offsetX )
@@ -77,8 +75,8 @@
7775

7876
Returns
7977
-------
80-
out: number
81-
Sum.
78+
x: Float64Array
79+
Input array.
8280

8381
Examples
8482
--------
@@ -425,8 +423,8 @@
425423

426424

427425
{{alias}}.Module.prototype.main( N, alpha, xp, sx )
428-
Adds a scalar constant to each double-precision floating-point strided array
429-
element and computes the sum using pairwise summation.
426+
Adds a scalar constant to each element in a double-precision floating-point
427+
strided array.
430428

431429
Parameters
432430
----------
@@ -444,8 +442,8 @@
444442

445443
Returns
446444
-------
447-
sum: number
448-
Sum.
445+
x: Float64Array
446+
Input array.
449447

450448
Examples
451449
--------
@@ -460,15 +458,16 @@
460458
> mod.write( xptr, {{alias:@stdlib/array/one-to}}( 3, 'float64' ) );
461459

462460
// Perform computation:
463-
> var s = mod.main( 3, 5.0, xptr, 1 )
464-
> s
461+
> mod.main( 3, 5.0, xptr, 1 );
462+
> var actual = new {{alias:@stdlib/array/float64}}( 3 );
463+
> mod.read( xptr, actual );
464+
> actual
465465
<Float64Array>[ 6.0, 7.0, 8.0 ]
466466

467467

468468
{{alias}}.Module.prototype.ndarray( N, alpha, xp, sx, ox )
469-
Adds a scalar constant to each double-precision floating-point strided
470-
array element and computes the sum using pairwise summation and alternative
471-
indexing semantics.
469+
Adds a scalar constant to each element in a double-precision floating-point
470+
strided array using alternative indexing semantics.
472471

473472
Parameters
474473
----------
@@ -489,8 +488,8 @@
489488

490489
Returns
491490
-------
492-
sum: number
493-
Sum.
491+
x: Float64Array
492+
Input array.
494493

495494
Examples
496495
--------
@@ -505,8 +504,10 @@
505504
> mod.write( xptr, {{alias:@stdlib/array/one-to}}( 3, 'float64' ) );
506505

507506
// Perform computation:
508-
> var s = mod.ndarray( 3, 5.0, xptr, 1, 0 )
509-
> s
507+
> mod.ndarray( 3, 5.0, xptr, 1, 0 );
508+
> var actual = new {{alias:@stdlib/array/float64}}( 3 );
509+
> mod.read( xptr, actual );
510+
> actual
510511
<Float64Array>[ 6.0, 7.0, 8.0 ]
511512

512513
See Also

lib/node_modules/@stdlib/blas/ext/base/wasm/dapx/docs/types/index.d.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ interface ModuleConstructor {
6262
* mod.write( xptr, oneTo( N, dtype ) );
6363
*
6464
* // Perform computation:
65-
* var out = mod.main( N, 5.0, xptr, 1 );
66-
* // out => <Float64Array>[ 6.0, 7.0, 8.0 ]
65+
* mod.main( N, 5.0, xptr, 1 );
66+
* // xptr => <Float64Array>[ 6.0, 7.0, 8.0 ]
6767
*/
6868
new( mem: Memory ): Module; // newable
6969

@@ -103,8 +103,8 @@ interface ModuleConstructor {
103103
* mod.write( xptr, oneTo( N, dtype ) );
104104
*
105105
* // Perform computation:
106-
* var out = mod.main( N, 5.0, xptr, 1 );
107-
* // out => <Float64Array>[ 6.0, 7.0, 8.0 ]
106+
* mod.main( N, 5.0, xptr, 1 );
107+
* // xptr => <Float64Array>[ 6.0, 7.0, 8.0 ]
108108
*/
109109
( mem: Memory ): Module; // callable
110110
}
@@ -114,7 +114,7 @@ interface ModuleConstructor {
114114
*/
115115
interface Module extends ModuleWrapper {
116116
/**
117-
* Adds a scalar constant to each double-precision floating-point strided array element.
117+
* Adds a scalar constant to each element in a double-precision floating-point strided array.
118118
*
119119
* @param N - number of indexed elements
120120
* @param alpha - scalar constant
@@ -152,8 +152,8 @@ interface Module extends ModuleWrapper {
152152
* mod.write( xptr, oneTo( N, dtype ) );
153153
*
154154
* // Perform computation:
155-
* var out = mod.main( N, 5.0, xptr, 1 );
156-
* // out => <Float64Array>[ 6.0, 7.0, 8.0 ]
155+
* mod.main( N, 5.0, xptr, 1 );
156+
* // xptr => <Float64Array>[ 6.0, 7.0, 8.0 ]
157157
*/
158158
main( N: number, alpha: number, xptr: number, strideX: number ): number;
159159

@@ -197,8 +197,8 @@ interface Module extends ModuleWrapper {
197197
* mod.write( xptr, oneTo( N, dtype ) );
198198
*
199199
* // Perform computation:
200-
* var out = mod.ndarray( N, 5.0, xptr, 1, 0 );
201-
* // out => <Float64Array>[ 6.0, 7.0, 8.0 ]
200+
* mod.ndarray( N, 5.0, xptr, 1, 0 );
201+
* // xptr => <Float64Array>[ 6.0, 7.0, 8.0 ]
202202
*/
203203
ndarray( N: number, alpha: number, xptr: number, strideX: number, offsetX: number ): number;
204204
}
@@ -241,8 +241,8 @@ interface Routine extends ModuleWrapper {
241241
*
242242
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
243243
*
244-
* var out = dapx.ndarray( 4, 5.0, x, 2, 1 );
245-
* // out => Float64Array[ 7.0, 6.0, 7.0, 3.0, 3.0, 7.0, 8.0, 9.0 ]
244+
* dapx.ndarray( 4, 5.0, x, 2, 1 );
245+
* // x => Float64Array[ 7.0, 6.0, 7.0, 3.0, 3.0, 7.0, 8.0, 9.0 ]
246246
*/
247247
ndarray( N: number, alpha: number, x: Float64Array, strideX: number, offsetX: number ): number;
248248

@@ -282,8 +282,8 @@ interface Routine extends ModuleWrapper {
282282
* mod.write( xptr, oneTo( N, dtype ) );
283283
*
284284
* // Perform computation:
285-
* var out = mod.main( N, 5.0, xptr, 1 );
286-
* // out => <Float64Array>[ 6.0, 7.0, 8.0 ]
285+
* mod.main( N, 5.0, xptr, 1 );
286+
* // xptr => <Float64Array>[ 6.0, 7.0, 8.0 ]
287287
*/
288288
Module: ModuleConstructor;
289289
}
@@ -302,16 +302,16 @@ interface Routine extends ModuleWrapper {
302302
*
303303
* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
304304
*
305-
* var out = dapx.main( 3, 5.0, x, 1 );
306-
* // out => Float64Array[ 6.0, 3.0, 7.0 ]
305+
* dapx.main( 3, 5.0, x, 1 );
306+
* // x => Float64Array[ 6.0, 3.0, 7.0 ]
307307
*
308308
* @example
309309
* var Float64Array = require( '@stdlib/array/float64' );
310310
*
311311
* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
312312
*
313-
* var out = dapx.ndarray( 4, 5.0, x, 2, 1 );
314-
* // out => Float64Array[ 7.0, 6.0, 7.0, 3.0, 3.0, 7.0, 8.0, 9.0 ]
313+
* dapx.ndarray( 4, 5.0, x, 2, 1 );
314+
* // x => Float64Array[ 7.0, 6.0, 7.0, 3.0, 3.0, 7.0, 8.0, 9.0 ]
315315
*/
316316
declare var dapx: Routine;
317317

lib/node_modules/@stdlib/blas/ext/base/wasm/dapx/examples/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,14 @@ function main() {
3030
// Specify a vector length:
3131
var N = 3;
3232

33-
// Create an input array:
3433
var x = oneTo( N, 'float64' );
3534

3635
// Perform computation:
3736
dapx.ndarray( N, 5.0, x, 1, 0 );
3837

3938
// Print the results:
4039
console.log( x );
41-
// => <Float64Array>[ 6.0, 7.0, 8.0 ]
40+
// => <Float64Array>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
4241
}
4342

4443
main();

lib/node_modules/@stdlib/blas/ext/base/wasm/dapx/examples/module.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' );
2222
var Memory = require( '@stdlib/wasm/memory' );
2323
var oneTo = require( '@stdlib/array/one-to' );
2424
var zeros = require( '@stdlib/array/zeros' );
25-
var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' );
2625
var dapx = require( './../lib' );
2726

2827
function main() {
@@ -49,20 +48,21 @@ function main() {
4948
// Specify a vector length:
5049
var N = 3;
5150

52-
// Define a pointer (i.e., byte offset) for storing the input vector:
53-
var xptr = N * bytesPerElement( dtype );
51+
// Define a pointer (i.e., byte offsets) for storing the input vector:
52+
var xptr = 0;
5453

5554
// Write vector values to module memory:
5655
mod.write( xptr, oneTo( N, dtype ) );
5756

5857
// Perform computation:
5958
mod.ndarray( N, 5.0, xptr, 1, 0 );
6059

61-
// Print the result:
60+
// Read out the results:
6261
var view = zeros( N, dtype );
6362
mod.read( xptr, view );
6463

6564
console.log( view );
65+
// => <Float64Array>[ 6.0, 7.0, 8.0, 9.0, 10.0 ]
6666
}
6767

6868
main();

0 commit comments

Comments
 (0)