Skip to content

Commit 529687d

Browse files
committed
refactor: avoid duplicate computation
--- 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: na - 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: na - 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 b9e9eca commit 529687d

File tree

19 files changed

+77
-75
lines changed

19 files changed

+77
-75
lines changed

lib/node_modules/@stdlib/ndarray/base/map/lib/10d.js

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

2323
// MODULES //
2424

25-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
2625
var zeroTo = require( '@stdlib/array/base/zero-to' );
2726
var reverse = require( '@stdlib/array/base/reverse' );
2827
var take = require( '@stdlib/array/base/take-indexed' );
@@ -49,6 +48,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4948
* @param {IntegerArray} y.strides - stride lengths
5049
* @param {NonNegativeInteger} y.offset - index offset
5150
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
51+
* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order
5252
* @param {Callback} fcn - callback function
5353
* @param {*} thisArg - callback execution context
5454
* @returns {void}
@@ -95,12 +95,12 @@ var take = require( '@stdlib/array/base/take-indexed' );
9595
* };
9696
*
9797
* // Apply the map function:
98-
* map10d( x, y, scale, {} );
98+
* map10d( x, y, true, scale, {} );
9999
*
100100
* console.log( y.data );
101101
* // => <Float64Array>[ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ]
102102
*/
103-
function map10d( x, y, fcn, thisArg ) { // eslint-disable-line max-statements
103+
function map10d( x, y, isRowMajor, fcn, thisArg ) { // eslint-disable-line max-statements
104104
var xbuf;
105105
var ybuf;
106106
var dx0;
@@ -157,7 +157,7 @@ function map10d( x, y, fcn, thisArg ) { // eslint-disable-line max-statements
157157
sx = x.strides;
158158
sy = y.strides;
159159
idx = zeroTo( sh.length );
160-
if ( strides2order( sx ) === 1 ) {
160+
if ( isRowMajor ) {
161161
// For row-major ndarrays, the last dimensions have the fastest changing indices...
162162
S0 = sh[ 9 ];
163163
S1 = sh[ 8 ];

lib/node_modules/@stdlib/ndarray/base/map/lib/10d_accessors.js

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

2323
// MODULES //
2424

25-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
2625
var zeroTo = require( '@stdlib/array/base/zero-to' );
2726
var reverse = require( '@stdlib/array/base/reverse' );
2827
var take = require( '@stdlib/array/base/take-indexed' );
@@ -49,6 +48,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4948
* @param {IntegerArray} y.strides - stride lengths
5049
* @param {NonNegativeInteger} y.offset - index offset
5150
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
51+
* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order
5252
* @param {Callback} fcn - callback function
5353
* @param {*} thisArg - callback execution context
5454
* @returns {void}
@@ -109,7 +109,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
109109
* };
110110
*
111111
* // Apply the map function:
112-
* map10d( x, y, scale, {} );
112+
* map10d( x, y, true, scale, {} );
113113
*
114114
* var v = y.data.get( 0 );
115115
*
@@ -119,7 +119,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
119119
* var im = imagf( v );
120120
* // returns 20.0
121121
*/
122-
function map10d( x, y, fcn, thisArg ) { // eslint-disable-line max-statements
122+
function map10d( x, y, isRowMajor, fcn, thisArg ) { // eslint-disable-line max-statements
123123
var xbuf;
124124
var ybuf;
125125
var get;
@@ -178,7 +178,7 @@ function map10d( x, y, fcn, thisArg ) { // eslint-disable-line max-statements
178178
sx = x.strides;
179179
sy = y.strides;
180180
idx = zeroTo( sh.length );
181-
if ( strides2order( sx ) === 1 ) {
181+
if ( isRowMajor ) {
182182
// For row-major ndarrays, the last dimensions have the fastest changing indices...
183183
S0 = sh[ 9 ];
184184
S1 = sh[ 8 ];

lib/node_modules/@stdlib/ndarray/base/map/lib/2d.js

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

2121
// MODULES //
2222

23-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
2423
var zeroTo = require( '@stdlib/array/base/zero-to' );
2524
var reverse = require( '@stdlib/array/base/reverse' );
2625
var take = require( '@stdlib/array/base/take-indexed' );
@@ -47,6 +46,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4746
* @param {IntegerArray} y.strides - stride lengths
4847
* @param {NonNegativeInteger} y.offset - index offset
4948
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
49+
* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order
5050
* @param {Callback} fcn - callback function
5151
* @param {*} thisArg - callback execution context
5252
* @returns {void}
@@ -93,12 +93,12 @@ var take = require( '@stdlib/array/base/take-indexed' );
9393
* };
9494
*
9595
* // Apply the map function:
96-
* map2d( x, y, scale, {} );
96+
* map2d( x, y, true, scale, {} );
9797
*
9898
* console.log( y.data );
9999
* // => <Float64Array>[ 20.0, 30.0, 60.0, 70.0 ]
100100
*/
101-
function map2d( x, y, fcn, thisArg ) {
101+
function map2d( x, y, isRowMajor, fcn, thisArg ) {
102102
var xbuf;
103103
var ybuf;
104104
var dx0;
@@ -123,7 +123,7 @@ function map2d( x, y, fcn, thisArg ) {
123123
sx = x.strides;
124124
sy = y.strides;
125125
idx = zeroTo( sh.length );
126-
if ( strides2order( sx ) === 1 ) {
126+
if ( isRowMajor ) {
127127
// For row-major ndarrays, the last dimensions have the fastest changing indices...
128128
S0 = sh[ 1 ];
129129
S1 = sh[ 0 ];

lib/node_modules/@stdlib/ndarray/base/map/lib/2d_accessors.js

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

2121
// MODULES //
2222

23-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
2423
var zeroTo = require( '@stdlib/array/base/zero-to' );
2524
var reverse = require( '@stdlib/array/base/reverse' );
2625
var take = require( '@stdlib/array/base/take-indexed' );
@@ -47,6 +46,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4746
* @param {IntegerArray} y.strides - stride lengths
4847
* @param {NonNegativeInteger} y.offset - index offset
4948
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
49+
* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order
5050
* @param {Callback} fcn - callback function
5151
* @param {*} thisArg - callback execution context
5252
* @returns {void}
@@ -107,7 +107,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
107107
* };
108108
*
109109
* // Apply the map function:
110-
* map2d( x, y, scale, {} );
110+
* map2d( x, y, true, scale, {} );
111111
*
112112
* var v = y.data.get( 0 );
113113
*
@@ -117,7 +117,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
117117
* var im = imagf( v );
118118
* // returns 20.0
119119
*/
120-
function map2d( x, y, fcn, thisArg ) {
120+
function map2d( x, y, isRowMajor, fcn, thisArg ) {
121121
var xbuf;
122122
var ybuf;
123123
var get;
@@ -144,7 +144,7 @@ function map2d( x, y, fcn, thisArg ) {
144144
sx = x.strides;
145145
sy = y.strides;
146146
idx = zeroTo( sh.length );
147-
if ( strides2order( sx ) === 1 ) {
147+
if ( isRowMajor ) {
148148
// For row-major ndarrays, the last dimensions have the fastest changing indices...
149149
S0 = sh[ 1 ];
150150
S1 = sh[ 0 ];

lib/node_modules/@stdlib/ndarray/base/map/lib/3d.js

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

2121
// MODULES //
2222

23-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
2423
var zeroTo = require( '@stdlib/array/base/zero-to' );
2524
var reverse = require( '@stdlib/array/base/reverse' );
2625
var take = require( '@stdlib/array/base/take-indexed' );
@@ -47,6 +46,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4746
* @param {IntegerArray} y.strides - stride lengths
4847
* @param {NonNegativeInteger} y.offset - index offset
4948
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
49+
* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order
5050
* @param {Callback} fcn - callback function
5151
* @param {*} thisArg - callback execution context
5252
* @returns {void}
@@ -93,12 +93,12 @@ var take = require( '@stdlib/array/base/take-indexed' );
9393
* };
9494
*
9595
* // Apply the map function:
96-
* map3d( x, y, scale, {} );
96+
* map3d( x, y, true, scale, {} );
9797
*
9898
* console.log( y.data );
9999
* // => <Float64Array>[ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ]
100100
*/
101-
function map3d( x, y, fcn, thisArg ) {
101+
function map3d( x, y, isRowMajor, fcn, thisArg ) {
102102
var xbuf;
103103
var ybuf;
104104
var dx0;
@@ -127,7 +127,7 @@ function map3d( x, y, fcn, thisArg ) {
127127
sx = x.strides;
128128
sy = y.strides;
129129
idx = zeroTo( sh.length );
130-
if ( strides2order( sx ) === 1 ) {
130+
if ( isRowMajor ) {
131131
// For row-major ndarrays, the last dimensions have the fastest changing indices...
132132
S0 = sh[ 2 ];
133133
S1 = sh[ 1 ];

lib/node_modules/@stdlib/ndarray/base/map/lib/3d_accessors.js

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

2121
// MODULES //
2222

23-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
2423
var zeroTo = require( '@stdlib/array/base/zero-to' );
2524
var reverse = require( '@stdlib/array/base/reverse' );
2625
var take = require( '@stdlib/array/base/take-indexed' );
@@ -47,6 +46,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4746
* @param {IntegerArray} y.strides - stride lengths
4847
* @param {NonNegativeInteger} y.offset - index offset
4948
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
49+
* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order
5050
* @param {Callback} fcn - callback function
5151
* @param {*} thisArg - callback execution context
5252
* @returns {void}
@@ -107,7 +107,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
107107
* };
108108
*
109109
* // Apply the map function:
110-
* map3d( x, y, scale, {} );
110+
* map3d( x, y, true, scale, {} );
111111
*
112112
* var v = y.data.get( 0 );
113113
*
@@ -117,7 +117,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
117117
* var im = imagf( v );
118118
* // returns 20.0
119119
*/
120-
function map3d( x, y, fcn, thisArg ) {
120+
function map3d( x, y, isRowMajor, fcn, thisArg ) {
121121
var xbuf;
122122
var ybuf;
123123
var dx0;
@@ -148,7 +148,7 @@ function map3d( x, y, fcn, thisArg ) {
148148
sx = x.strides;
149149
sy = y.strides;
150150
idx = zeroTo( sh.length );
151-
if ( strides2order( sx ) === 1 ) {
151+
if ( isRowMajor ) {
152152
// For row-major ndarrays, the last dimensions have the fastest changing indices...
153153
S0 = sh[ 2 ];
154154
S1 = sh[ 1 ];

lib/node_modules/@stdlib/ndarray/base/map/lib/4d.js

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

2121
// MODULES //
2222

23-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
2423
var zeroTo = require( '@stdlib/array/base/zero-to' );
2524
var reverse = require( '@stdlib/array/base/reverse' );
2625
var take = require( '@stdlib/array/base/take-indexed' );
@@ -47,6 +46,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4746
* @param {IntegerArray} y.strides - stride lengths
4847
* @param {NonNegativeInteger} y.offset - index offset
4948
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
49+
* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order
5050
* @param {Callback} fcn - callback function
5151
* @param {*} thisArg - callback execution context
5252
* @returns {void}
@@ -93,12 +93,12 @@ var take = require( '@stdlib/array/base/take-indexed' );
9393
* };
9494
*
9595
* // Apply the map function:
96-
* map4d( x, y, scale, {} );
96+
* map4d( x, y, true, scale, {} );
9797
*
9898
* console.log( y.data );
9999
* // => <Float64Array>[ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ]
100100
*/
101-
function map4d( x, y, fcn, thisArg ) {
101+
function map4d( x, y, isRowMajor, fcn, thisArg ) {
102102
var xbuf;
103103
var ybuf;
104104
var dx0;
@@ -131,7 +131,7 @@ function map4d( x, y, fcn, thisArg ) {
131131
sx = x.strides;
132132
sy = y.strides;
133133
idx = zeroTo( sh.length );
134-
if ( strides2order( sx ) === 1 ) {
134+
if ( isRowMajor ) {
135135
// For row-major ndarrays, the last dimensions have the fastest changing indices...
136136
S0 = sh[ 3 ];
137137
S1 = sh[ 2 ];

lib/node_modules/@stdlib/ndarray/base/map/lib/4d_accessors.js

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

2121
// MODULES //
2222

23-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
2423
var zeroTo = require( '@stdlib/array/base/zero-to' );
2524
var reverse = require( '@stdlib/array/base/reverse' );
2625
var take = require( '@stdlib/array/base/take-indexed' );
@@ -47,6 +46,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4746
* @param {IntegerArray} y.strides - stride lengths
4847
* @param {NonNegativeInteger} y.offset - index offset
4948
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
49+
* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order
5050
* @param {Callback} fcn - callback function
5151
* @param {*} thisArg - callback execution context
5252
* @returns {void}
@@ -107,7 +107,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
107107
* };
108108
*
109109
* // Apply the map function:
110-
* map4d( x, y, scale, {} );
110+
* map4d( x, y, true, scale, {} );
111111
*
112112
* var v = y.data.get( 0 );
113113
*
@@ -117,7 +117,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
117117
* var im = imagf( v );
118118
* // returns 20.0
119119
*/
120-
function map4d( x, y, fcn, thisArg ) {
120+
function map4d( x, y, isRowMajor, fcn, thisArg ) {
121121
var xbuf;
122122
var ybuf;
123123
var get;
@@ -152,7 +152,7 @@ function map4d( x, y, fcn, thisArg ) {
152152
sx = x.strides;
153153
sy = y.strides;
154154
idx = zeroTo( sh.length );
155-
if ( strides2order( sx ) === 1 ) {
155+
if ( isRowMajor ) {
156156
// For row-major ndarrays, the last dimensions have the fastest changing indices...
157157
S0 = sh[ 3 ];
158158
S1 = sh[ 2 ];

lib/node_modules/@stdlib/ndarray/base/map/lib/5d.js

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

2121
// MODULES //
2222

23-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
2423
var zeroTo = require( '@stdlib/array/base/zero-to' );
2524
var reverse = require( '@stdlib/array/base/reverse' );
2625
var take = require( '@stdlib/array/base/take-indexed' );
@@ -47,6 +46,7 @@ var take = require( '@stdlib/array/base/take-indexed' );
4746
* @param {IntegerArray} y.strides - stride lengths
4847
* @param {NonNegativeInteger} y.offset - index offset
4948
* @param {string} y.order - specifies whether `y` is row-major (C-style) or column-major (Fortran-style)
49+
* @param {boolean} isRowMajor - boolean indicating if provided arrays are in row-major order
5050
* @param {Callback} fcn - callback function
5151
* @param {*} thisArg - callback execution context
5252
* @returns {void}
@@ -93,12 +93,12 @@ var take = require( '@stdlib/array/base/take-indexed' );
9393
* };
9494
*
9595
* // Apply the map function:
96-
* map5d( x, y, scale, {} );
96+
* map5d( x, y, true, scale, {} );
9797
*
9898
* console.log( y.data );
9999
* // => <Float64Array>[ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ]
100100
*/
101-
function map5d( x, y, fcn, thisArg ) {
101+
function map5d( x, y, isRowMajor, fcn, thisArg ) {
102102
var xbuf;
103103
var ybuf;
104104
var dx0;
@@ -135,7 +135,7 @@ function map5d( x, y, fcn, thisArg ) {
135135
sx = x.strides;
136136
sy = y.strides;
137137
idx = zeroTo( sh.length );
138-
if ( strides2order( sx ) === 1 ) {
138+
if ( isRowMajor ) {
139139
// For row-major ndarrays, the last dimensions have the fastest changing indices...
140140
S0 = sh[ 4 ];
141141
S1 = sh[ 3 ];

0 commit comments

Comments
 (0)