Skip to content

Commit 0750c9d

Browse files
committed
Auto-generated commit
1 parent d43013c commit 0750c9d

25 files changed

Lines changed: 3537 additions & 18 deletions

.editorconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@ indent_size = 2
148148
indent_style = space
149149
indent_size = 2
150150

151-
# Set properties for `tslint.json` files:
152-
[tslint.json]
153-
indent_style = space
154-
indent_size = 2
155-
156151
# Set properties for `tsconfig.json` files:
157152
[tsconfig.json]
158153
indent_style = space

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ jobs:
119119
# For all dependencies, check in all *.js files if they are still used; if not, remove them:
120120
jq -r '.dependencies | keys[]' ./package.json | while read -r dep; do
121121
dep=$(echo "$dep" | xargs)
122-
if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
122+
if ! find lib -name "*.js" -exec grep -q "$dep" {} + && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
123123
jq --indent 2 "del(.dependencies[\"$dep\"])" ./package.json > ./package.json.tmp
124124
mv ./package.json.tmp ./package.json
125125
fi
@@ -129,7 +129,7 @@ jobs:
129129
continue
130130
fi
131131
dep=$(echo "$dep" | xargs)
132-
if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
132+
if ! find lib -name "*.js" -exec grep -q "$dep" {} + && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
133133
jq --indent 2 "del(.devDependencies[\"$dep\"])" ./package.json > ./package.json.tmp
134134
mv ./package.json.tmp ./package.json
135135
fi

CONTRIBUTORS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Brendan Graetz <bguiz@users.noreply.github.com>
99
Bruno Fenzl <brunofenzl@gmail.com>
1010
Christopher Dambamuromo <chridam@gmail.com>
1111
Dan Rose <danoftheroses@gmail.com>
12+
Daniel Killenberger <daniel.killenberger@gmail.com>
1213
Dominik Moritz <domoritz@gmail.com>
1314
Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
1415
Frank Kovacs <fran70kk@gmail.com>
@@ -29,6 +30,7 @@ Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
2930
Philipp Burckhardt <pburckhardt@outlook.com>
3031
Pranav Goswami <goswami.4@iitj.ac.in>
3132
Ricky Reusser <rsreusser@gmail.com>
33+
Robert Gislason <gztown2216@yahoo.com>
3234
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
3335
Ryan Seal <splrk@users.noreply.github.com>
3436
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
@@ -37,4 +39,3 @@ Stephannie Jiménez Gacha <steff456@hotmail.com>
3739
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>
3840
orimiles5 <97595296+orimiles5@users.noreply.github.com>
3941
rei2hu <reimu@reimu.ws>
40-
Robert Gislason <gztown2216@yahoo.com>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ The constructor accepts the following `options`:
110110
The constructor supports the following `modes`:
111111

112112
- **throw**: specifies that an `ndarray` instance should throw an error when an index exceeds array dimensions.
113+
- **normalize**: specifies that an `ndarray` instance should normalize negative indices and throw an error when an index exceeds array dimensions.
113114
- **wrap**: specifies that an `ndarray` instance should wrap around an index exceeding array dimensions using modulo arithmetic.
114115
- **clamp**: specifies that an `ndarray` instance should set an index exceeding array dimensions to either `0` (minimum index) or the maximum index.
115116

benchmark/benchmark.get.js

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,45 @@ bench( pkg+'::1d:get:mode=clamp', function benchmark( b ) {
139139
b.end();
140140
});
141141

142+
bench( pkg+'::1d:get:mode=normalize', function benchmark( b ) {
143+
var strides;
144+
var buffer;
145+
var offset;
146+
var shape;
147+
var order;
148+
var opts;
149+
var out;
150+
var v;
151+
var i;
152+
153+
opts = {
154+
'mode': 'normalize'
155+
};
156+
157+
buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
158+
shape = [ 6 ];
159+
strides = [ 1 ];
160+
offset = 0;
161+
order = 'row-major';
162+
163+
out = ndarray( 'generic', buffer, shape, strides, offset, order, opts );
164+
165+
b.tic();
166+
for ( i = 0; i < b.iterations; i++ ) {
167+
buffer[ 1 ] = i;
168+
v = out.get( (i%12)-6 );
169+
if ( v !== v ) {
170+
b.fail( 'should not return NaN' );
171+
}
172+
}
173+
b.toc();
174+
if ( v !== v ) {
175+
b.fail( 'should not return NaN' );
176+
}
177+
b.pass( 'benchmark finished' );
178+
b.end();
179+
});
180+
142181
bench( pkg+'::2d:get', function benchmark( b ) {
143182
var strides;
144183
var buffer;
@@ -251,6 +290,45 @@ bench( pkg+'::2d:get:mode=clamp', function benchmark( b ) {
251290
b.end();
252291
});
253292

293+
bench( pkg+'::2d:get:mode=normalize', function benchmark( b ) {
294+
var strides;
295+
var buffer;
296+
var offset;
297+
var shape;
298+
var order;
299+
var opts;
300+
var out;
301+
var v;
302+
var i;
303+
304+
opts = {
305+
'mode': 'normalize'
306+
};
307+
308+
buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
309+
shape = [ 3, 2 ];
310+
strides = [ 2, 1 ];
311+
offset = 0;
312+
order = 'row-major';
313+
314+
out = ndarray( 'generic', buffer, shape, strides, offset, order, opts );
315+
316+
b.tic();
317+
for ( i = 0; i < b.iterations; i++ ) {
318+
buffer[ 1 ] = i;
319+
v = out.get( (i%6)-3, 1 );
320+
if ( v !== v ) {
321+
b.fail( 'should not return NaN' );
322+
}
323+
}
324+
b.toc();
325+
if ( v !== v ) {
326+
b.fail( 'should not return NaN' );
327+
}
328+
b.pass( 'benchmark finished' );
329+
b.end();
330+
});
331+
254332
bench( pkg+'::3d:get', function benchmark( b ) {
255333
var strides;
256334
var buffer;
@@ -363,6 +441,45 @@ bench( pkg+'::3d:get:mode=clamp', function benchmark( b ) {
363441
b.end();
364442
});
365443

444+
bench( pkg+'::3d:get:mode=normalize', function benchmark( b ) {
445+
var strides;
446+
var buffer;
447+
var offset;
448+
var shape;
449+
var order;
450+
var opts;
451+
var out;
452+
var v;
453+
var i;
454+
455+
opts = {
456+
'mode': 'normalize'
457+
};
458+
459+
buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
460+
shape = [ 1, 3, 2 ];
461+
strides = [ 6, 2, 1 ];
462+
offset = 0;
463+
order = 'row-major';
464+
465+
out = ndarray( 'generic', buffer, shape, strides, offset, order, opts );
466+
467+
b.tic();
468+
for ( i = 0; i < b.iterations; i++ ) {
469+
buffer[ 1 ] = i;
470+
v = out.get( 0, (i%6)-3, 1 );
471+
if ( v !== v ) {
472+
b.fail( 'should not return NaN' );
473+
}
474+
}
475+
b.toc();
476+
if ( v !== v ) {
477+
b.fail( 'should not return NaN' );
478+
}
479+
b.pass( 'benchmark finished' );
480+
b.end();
481+
});
482+
366483
bench( pkg+'::4d:get', function benchmark( b ) {
367484
var strides;
368485
var buffer;
@@ -475,6 +592,45 @@ bench( pkg+'::4d:get:mode=clamp', function benchmark( b ) {
475592
b.end();
476593
});
477594

595+
bench( pkg+'::4d:get:mode=normalize', function benchmark( b ) {
596+
var strides;
597+
var buffer;
598+
var offset;
599+
var shape;
600+
var order;
601+
var opts;
602+
var out;
603+
var v;
604+
var i;
605+
606+
opts = {
607+
'mode': 'normalize'
608+
};
609+
610+
buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
611+
shape = [ 1, 1, 3, 2 ];
612+
strides = [ 6, 6, 2, 1 ];
613+
offset = 0;
614+
order = 'row-major';
615+
616+
out = ndarray( 'generic', buffer, shape, strides, offset, order, opts );
617+
618+
b.tic();
619+
for ( i = 0; i < b.iterations; i++ ) {
620+
buffer[ 1 ] = i;
621+
v = out.get( 0, 0, (i%6)-3, 1 );
622+
if ( v !== v ) {
623+
b.fail( 'should not return NaN' );
624+
}
625+
}
626+
b.toc();
627+
if ( v !== v ) {
628+
b.fail( 'should not return NaN' );
629+
}
630+
b.pass( 'benchmark finished' );
631+
b.end();
632+
});
633+
478634
bench( pkg+'::5d:get', function benchmark( b ) {
479635
var strides;
480636
var buffer;
@@ -586,3 +742,42 @@ bench( pkg+'::5d:get:mode=clamp', function benchmark( b ) {
586742
b.pass( 'benchmark finished' );
587743
b.end();
588744
});
745+
746+
bench( pkg+'::5d:get:mode=normalize', function benchmark( b ) {
747+
var strides;
748+
var buffer;
749+
var offset;
750+
var shape;
751+
var order;
752+
var opts;
753+
var out;
754+
var v;
755+
var i;
756+
757+
opts = {
758+
'mode': 'normalize'
759+
};
760+
761+
buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
762+
shape = [ 1, 1, 1, 3, 2 ];
763+
strides = [ 6, 6, 6, 2, 1 ];
764+
offset = 0;
765+
order = 'row-major';
766+
767+
out = ndarray( 'generic', buffer, shape, strides, offset, order, opts );
768+
769+
b.tic();
770+
for ( i = 0; i < b.iterations; i++ ) {
771+
buffer[ 1 ] = i;
772+
v = out.get( 0, 0, 0, (i%6)-3, 1 );
773+
if ( v !== v ) {
774+
b.fail( 'should not return NaN' );
775+
}
776+
}
777+
b.toc();
778+
if ( v !== v ) {
779+
b.fail( 'should not return NaN' );
780+
}
781+
b.pass( 'benchmark finished' );
782+
b.end();
783+
});

benchmark/benchmark.iget.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,45 @@ bench( pkg+'::1d:iget:mode=clamp', function benchmark( b ) {
139139
b.end();
140140
});
141141

142+
bench( pkg+'::1d:iget:mode=normalize', function benchmark( b ) {
143+
var strides;
144+
var buffer;
145+
var offset;
146+
var shape;
147+
var order;
148+
var opts;
149+
var out;
150+
var v;
151+
var i;
152+
153+
opts = {
154+
'mode': 'normalize'
155+
};
156+
157+
buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
158+
shape = [ 6 ];
159+
strides = [ 1 ];
160+
offset = 0;
161+
order = 'row-major';
162+
163+
out = ndarray( 'generic', buffer, shape, strides, offset, order, opts );
164+
165+
b.tic();
166+
for ( i = 0; i < b.iterations; i++ ) {
167+
buffer[ 1 ] = i;
168+
v = out.iget( (i%12)-6 );
169+
if ( v !== v ) {
170+
b.fail( 'should not return NaN' );
171+
}
172+
}
173+
b.toc();
174+
if ( v !== v ) {
175+
b.fail( 'should not return NaN' );
176+
}
177+
b.pass( 'benchmark finished' );
178+
b.end();
179+
});
180+
142181
bench( pkg+'::2d,all_positive_strides:iget:order=row-major', function benchmark( b ) {
143182
var strides;
144183
var buffer;

benchmark/benchmark.iset.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,48 @@ bench( pkg+'::1d:iset:mode=clamp', function benchmark( b ) {
147147
b.end();
148148
});
149149

150+
bench( pkg+'::1d:iset:mode=normalize', function benchmark( b ) {
151+
var strides;
152+
var buffer;
153+
var offset;
154+
var shape;
155+
var order;
156+
var opts;
157+
var out;
158+
var tmp;
159+
var v;
160+
var i;
161+
var j;
162+
163+
opts = {
164+
'mode': 'normalize'
165+
};
166+
167+
buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];
168+
shape = [ 6 ];
169+
strides = [ 1 ];
170+
offset = 0;
171+
order = 'row-major';
172+
173+
out = ndarray( 'generic', buffer, shape, strides, offset, order, opts );
174+
175+
b.tic();
176+
for ( i = 0; i < b.iterations; i++ ) {
177+
v = i;
178+
j = (i%12) - 6;
179+
tmp = out.iset( j, v );
180+
if ( typeof tmp !== 'object' ) {
181+
b.fail( 'should return an object' );
182+
}
183+
}
184+
b.toc();
185+
if ( out.iget( j ) !== v ) {
186+
b.fail( 'should set value' );
187+
}
188+
b.pass( 'benchmark finished' );
189+
b.end();
190+
});
191+
150192
bench( pkg+'::2d,all_positive_strides:iset:order=row-major', function benchmark( b ) {
151193
var strides;
152194
var buffer;

0 commit comments

Comments
 (0)