Skip to content

Commit d8fe0d8

Browse files
committed
bench: update value generation and update examples
--- 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: na - 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: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 9b0d852 commit d8fe0d8

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

lib/node_modules/@stdlib/ndarray/base/unary-loop-interchange-order/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,16 @@ For all returned arrays, the first element corresponds to the innermost loop, an
100100

101101
```javascript
102102
var array = require( '@stdlib/ndarray/array' );
103-
var loopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' );
103+
var getShape = require( '@stdlib/ndarray/shape' );
104+
var getStrides = require( '@stdlib/ndarray/strides' );
105+
var unaryLoopOrder = require( '@stdlib/ndarray/base/unary-loop-interchange-order' );
104106

105107
// Create ndarrays:
106108
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
107109
var y = array( [ [ 0, 0 ], [ 0, 0 ] ] );
108110

109111
// Resolve loop interchange data:
110-
var o = loopOrder( x.shape, x.strides, y.strides );
112+
var o = unaryLoopOrder( getShape( x ), getStrides( x ), getStrides( y ) );
111113
// returns {...}
112114

113115
console.log( o );

lib/node_modules/@stdlib/ndarray/base/unary-loop-interchange-order/benchmark/benchmark.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var randu = require( '@stdlib/random/base/randu' );
2524
var isArray = require( '@stdlib/assert/is-array' );
2625
var shape2strides = require( '@stdlib/ndarray/base/shape2strides' );
2726
var pkg = require( './../package.json' ).name;
@@ -32,16 +31,21 @@ var loopOrder = require( './../lib' );
3231

3332
bench( pkg+'::row-major', function benchmark( b ) {
3433
var strides;
34+
var factors;
3535
var shape;
3636
var out;
3737
var i;
3838

3939
shape = [ 10, 10, 10 ];
4040
strides = shape2strides( shape, 'row-major' );
41+
factors = [
42+
-1,
43+
1
44+
];
4145

4246
b.tic();
4347
for ( i = 0; i < b.iterations; i++ ) {
44-
strides[ i%shape.length ] *= ( randu() < 0.5 ) ? -1 : 1;
48+
strides[ i%shape.length ] *= factors[ i%factors.length ];
4549
out = loopOrder( shape, strides, strides );
4650
if ( typeof out !== 'object' ) {
4751
b.fail( 'should return an object' );
@@ -57,16 +61,21 @@ bench( pkg+'::row-major', function benchmark( b ) {
5761

5862
bench( pkg+'::column-major', function benchmark( b ) {
5963
var strides;
64+
var factors;
6065
var shape;
6166
var out;
6267
var i;
6368

6469
shape = [ 10, 10, 10 ];
6570
strides = shape2strides( shape, 'column-major' );
71+
factors = [
72+
-1,
73+
1
74+
];
6675

6776
b.tic();
6877
for ( i = 0; i < b.iterations; i++ ) {
69-
strides[ i%shape.length ] *= ( randu() < 0.5 ) ? -1 : 1;
78+
strides[ i%shape.length ] *= factors[ i%factors.length ];
7079
out = loopOrder( shape, strides, strides );
7180
if ( typeof out !== 'object' ) {
7281
b.fail( 'should return an object' );

lib/node_modules/@stdlib/ndarray/base/unary-loop-interchange-order/examples/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@
1919
'use strict';
2020

2121
var array = require( '@stdlib/ndarray/array' );
22-
var loopOrder = require( './../lib' );
22+
var getShape = require( '@stdlib/ndarray/shape' );
23+
var getStrides = require( '@stdlib/ndarray/strides' );
24+
var unaryLoopOrder = require( './../lib' );
2325

2426
// Create ndarrays:
2527
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
2628
var y = array( [ [ 0, 0 ], [ 0, 0 ] ] );
2729

2830
// Resolve loop interchange data:
29-
var o = loopOrder( x.shape, x.strides, y.strides );
31+
var o = unaryLoopOrder( getShape( x ), getStrides( x ), getStrides( y ) );
3032
// returns {...}
3133

3234
console.log( o );

lib/node_modules/@stdlib/ndarray/base/unary-loop-interchange-order/test/test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222

2323
var tape = require( 'tape' );
2424
var isArray = require( '@stdlib/assert/is-array' );
25-
var loopOrder = require( './../lib' );
25+
var unaryLoopOrder = require( './../lib' );
2626

2727

2828
// TESTS //
2929

3030
tape( 'main export is a function', function test( t ) {
3131
t.ok( true, __filename );
32-
t.strictEqual( typeof loopOrder, 'function', 'main export is a function' );
32+
t.strictEqual( typeof unaryLoopOrder, 'function', 'main export is a function' );
3333
t.end();
3434
});
3535

@@ -43,7 +43,7 @@ tape( 'the function returns loop interchange data (row-major)', function test( t
4343
sx = [ 4, -2, 1 ];
4444
sy = [ -4, 2, 1 ];
4545

46-
o = loopOrder( sh, sx, sy );
46+
o = unaryLoopOrder( sh, sx, sy );
4747

4848
t.notEqual( o.sh, sh, 'returns new array' );
4949
t.strictEqual( isArray( o.sh ), true, 'returns expected value' );
@@ -73,7 +73,7 @@ tape( 'the function returns loop interchange data (column-major)', function test
7373
sx = [ 1, -4, 8 ];
7474
sy = [ -1, 4, 8 ];
7575

76-
o = loopOrder( sh, sx, sy );
76+
o = unaryLoopOrder( sh, sx, sy );
7777

7878
t.notEqual( o.sh, sh, 'returns new array' );
7979
t.strictEqual( isArray( o.sh ), true, 'returns expected value' );
@@ -103,7 +103,7 @@ tape( 'the function returns loop interchange data (mixed order)', function test(
103103
sx = [ 4, -2, 1 ];
104104
sy = [ 1, -4, -8 ];
105105

106-
o = loopOrder( sh, sx, sy );
106+
o = unaryLoopOrder( sh, sx, sy );
107107

108108
t.notEqual( o.sh, sh, 'returns new array' );
109109
t.strictEqual( isArray( o.sh ), true, 'returns expected value' );
@@ -124,7 +124,7 @@ tape( 'the function returns loop interchange data (mixed order)', function test(
124124
});
125125

126126
tape( 'if provided empty arrays, the function returns empty arrays', function test( t ) {
127-
var o = loopOrder( [], [], [] );
127+
var o = unaryLoopOrder( [], [], [] );
128128
t.deepEqual( o.sh, [], 'returns expected value' );
129129
t.deepEqual( o.sx, [], 'returns expected value' );
130130
t.deepEqual( o.sy, [], 'returns expected value' );

0 commit comments

Comments
 (0)