8000 Auto-generated commit · stdlib-js/ndarray-base-slice@17ae3e9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 17ae3e9

Browse files
committed
Auto-generated commit
1 parent 8f84ea6 commit 17ae3e9

File tree

15 files changed

+591
-300
lines changed

15 files changed

+591
-300
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ limitations under the License.
3333

3434
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
3535

36-
> Return a read-only view of an input ndarray.
36+
> Return a view of an input ndarray.
3737
3838
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
3939

@@ -71,9 +71,9 @@ The [branches.md][branches-url] file summarizes the available branches and displ
7171
var slice = require( '@stdlib/ndarray-base-slice' );
7272
```
7373

74-
#### slice( x, slice, strict )
74+
#### slice( x, slice, strict, mutable )
7575

76-
Returns a **read-only** view of an input ndarray.
76+
Returns a view of an input ndarray.
7777

7878
```javascript
7979
var Slice = require( '@stdlib/slice-ctor' );
@@ -100,7 +100,7 @@ var s1 = new Slice( null, null, -1 );
100100
var s = new MultiSlice( s0, s1 );
101101
// returns <MultiSlice>
102102

103-
var y = slice( x, s, false );
103+
var y = slice( x, s, false, false );
104104
// returns <ndarray>
105105

106106
sh = y.shape;
@@ -115,6 +115,7 @@ The function accepts the following arguments:
115115
- **x**: input ndarray.
116116
- **slice**: a [`MultiSlice`][@stdlib/slice/multi] instance.
117117
- **strict**: boolean indicating whether to enforce strict bounds checking.
118+
- **mutable**: boolean indicating whether a returned ndarray should be mutable.
118119

119120
</section>
120121

@@ -159,21 +160,21 @@ var x = array( buf, {
159160

160161
// Get each matrix...
161162
var s1 = E( 0, _, _ );
162-
var y1 = slice( x, s1, false );
163+
var y1 = slice( x, s1, false, false );
163164
// returns <ndarray>
164165

165166
var a1 = ndarray2array( y1 );
166167
// returns [ [ 0, 1, 2 ], [ 3, 4, 5 ], [ 6, 7, 8 ] ]
167168

168169
var s2 = E( 1, _, _ );
169-
var y2 = slice( x, s2, false );
170+
var y2 = slice( x, s2, false, false );
170171
// returns <ndarray>
171172

172173
var a2 = ndarray2array( y2 );
173174
// returns [ [ 9, 10, 11 ], [ 12, 13, 14 ], [ 15, 16, 17 ] ]
174175

175176
var s3 = E( 2, _, _ );
176-
var y3 = slice( x, s3, false );
177+
var y3 = slice( x, s3, false, false );
177178
// returns <ndarray>
178179

179180
var a3 = ndarray2array( y3 );
@@ -182,23 +183,23 @@ var a3 = ndarray2array( y3 );
182183
// Reverse all elements:
183184
var s = S( _, _, -1 );
184185
var s4 = E( s, s, s );
185-
var y4 = slice( x, s4, false );
186+
var y4 = slice( x, s4, false, false );
186187
// returns <ndarray>
187188

188189
var a4 = ndarray2array( y4 );
189190
// returns [...]
190191

191192
// Get the second rows from each matrix:
192193
var s5 = E( _, 1, _ );
193-
var y5 = slice( x, s5, false );
194+
var y5 = slice( x, s5, false, false );
194195
// returns <ndarray>
195196

196197
var a5 = ndarray2array( y5 );
197198
// returns [ [ 3, 4, 5 ], [ 12, 13, 14 ], [ 21, 22, 23 ] ]
198199

199200
// Get the second columns from each matrix:
200201
var s6 = E( _, _, 1 );
201-
var y6 = slice( x, s6, false );
202+
var y6 = slice( x, s6, false, false );
202203
// returns <ndarray>
203204

204205
var a6 = ndarray2array( y6 );

benchmark/benchmark.js

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bench( pkg+'::0d,base', function benchmark( b ) {
4949

5050
b.tic();
5151
for ( i = 0; i < b.iterations; i++ ) {
52-
v = slice( values[ i%values.length ], s, false );
52+
v = slice( values[ i%values.length ], s, false, false );
5353
if ( typeof v !== 'object' ) {
5454
b.fail( 'should return an ndarray' );
5555
}
@@ -84,7 +84,7 @@ bench( pkg+'::0d,non-base', function benchmark( b ) {
8484

8585
b.tic();
8686
for ( i = 0; i < b.iterations; i++ ) {
87-
v = slice( values[ i%values.length ], s, false );
87+
v = slice( values[ i%values.length ], s, false, false );
8888
if ( typeof v !== 'object' ) {
8989
b.fail( 'should return an ndarray' );
9090
}
@@ -114,7 +114,7 @@ bench( pkg+'::1d,base', function benchmark( b ) {
114114

115115
b.tic();
116116
for ( i = 0; i < b.iterations; i++ ) {
117-
v = slice( values[ i%values.length ], s, false );
117+
v = slice( values[ i%values.length ], s, false, false );
118118
if ( typeof v !== 'object' ) {
119119
b.fail( 'should return an ndarray' );
120120
}
@@ -149,7 +149,7 @@ bench( pkg+'::1d,non-base', function benchmark( b ) {
149149

150150
b.tic();
151151
for ( i = 0; i < b.iterations; i++ ) {
152-
v = slice( values[ i%values.length ], s, false );
152+
v = slice( values[ i%values.length ], s, false, false );
153153
if ( typeof v !== 'object' ) {
154154
b.fail( 'should return an ndarray' );
155155
}
@@ -179,7 +179,7 @@ bench( pkg+'::1d,base,reduced', function benchmark( b ) {
179179

180180
b.tic();
181181
for ( i = 0; i < b.iterations; i++ ) {
182-
v = slice( values[ i%values.length ], s, false );
182+
v = slice( values[ i%values.length ], s, false, false );
183183
if ( typeof v !== 'object' ) {
184184
b.fail( 'should return an ndarray' );
185185
}
@@ -214,7 +214,7 @@ bench( pkg+'::1d,non-base,reduced', function benchmark( b ) {
214214

215215
b.tic();
216216
for ( i = 0; i < b.iterations; i++ ) {
217-
v = slice( values[ i%values.length ], s, false );
217+
v = slice( values[ i%values.length ], s, false, false );
218218
if ( typeof v !== 'object' ) {
219219
b.fail( 'should return an ndarray' );
220220
}
@@ -244,7 +244,7 @@ bench( pkg+'::1d,base,out-of-bounds', function benchmark( b ) {
244244

245245
b.tic();
246246
for ( i = 0; i < b.iterations; i++ ) {
247-
v = slice( values[ i%values.length ], s, false );
247+
v = slice( values[ i%values.length ], s, false, false );
248248
if ( typeof v !== 'object' ) {
249249
b.fail( 'should return an ndarray' );
250250
}
@@ -279,7 +279,7 @@ bench( pkg+'::1d,non-base,out-of-bounds', function benchmark( b ) {
279279

280280
b.tic();
281281
for ( i = 0; i < b.iterations; i++ ) {
282-
v = slice( values[ i%values.length ], s, false );
282+
v = slice( values[ i%values.length ], s, false, false );
283283
if ( typeof v !== 'object' ) {
284284
b.fail( 'should return an ndarray' );
285285
}
@@ -309,7 +309,7 @@ bench( pkg+'::2d,base', function benchmark( b ) {
309309

310310
b.tic();
311311
for ( i = 0; i < b.iterations; i++ ) {
312-
v = slice( values[ i%values.length ], s, false );
312+
v = slice( values[ i%values.length ], s, false, false );
313313
if ( typeof v !== 'object' ) {
314314
b.fail( 'should return an ndarray' );
315315
}
@@ -344,7 +344,7 @@ bench( pkg+'::2d,non-base', function benchmark( b ) {
344344

345345
b.tic();
346346
for ( i = 0; i < b.iterations; i++ ) {
347-
v = slice( values[ i%values.length ], s, false );
347+
v = slice( values[ i%values.length ], s, false, false );
348348
if ( typeof v !== 'object' ) {
349349
b.fail( 'should return an ndarray' );
350350
}
@@ -374,7 +374,7 @@ bench( pkg+'::2d,base,reduced', function benchmark( b ) {
374374

375375
b.tic();
376376
for ( i = 0; i < b.iterations; i++ ) {
377-
v = slice( values[ i%values.length ], s, false );
377+
v = slice( values[ i%values.length ], s, false, false );
378378
if ( typeof v !== 'object' ) {
379379
b.fail( 'should return an ndarray' );
380380
}
@@ -409,7 +409,7 @@ bench( pkg+'::2d,non-base,reduced', function benchmark( b ) {
409409

410410
b.tic();
411411
for ( i = 0; i < b.iterations; i++ ) {
412-
v = slice( values[ i%values.length ], s, false );
412+
v = slice( values[ i%values.length ], s, false, false );
413413
if ( typeof v !== 'object' ) {
414414
b.fail( 'should return an ndarray' );
415415
}
@@ -439,7 +439,7 @@ bench( pkg+'::2d,base,out-of-bounds', function benchmark( b ) {
439439

440440
b.tic();
441441
for ( i = 0; i < b.iterations; i++ ) {
442-
v = slice( values[ i%values.length ], s, false );
442+
v = slice( values[ i%values.length ], s, false, false );
443443
if ( typeof v !== 'object' ) {
444444
b.fail( 'should return an ndarray' );
445445
}
@@ -474,7 +474,7 @@ bench( pkg+'::2d,non-base,out-of-bounds', function benchmark( b ) {
474474

475475
b.tic();
476476
for ( i = 0; i < b.iterations; i++ ) {
477-
v = slice( values[ i%values.length ], s, false );
477+
v = slice( values[ i%values.length ], s, false, false );
478478
if ( typeof v !== 'object' ) {
479479
b.fail( 'should return an ndarray' );
480480
}
@@ -504,7 +504,7 @@ bench( pkg+'::3d,base', function benchmark( b ) {
504504

505505
b.tic();
506506
for ( i = 0; i < b.iterations; i++ ) {
507-
v = slice( values[ i%values.length ], s, false );
507+
v = slice( values[ i%values.length ], s, false, false );
508508
if ( typeof v !== 'object' ) {
509509
b.fail( 'should return an ndarray' );
510510
}
@@ -539,7 +539,7 @@ bench( pkg+'::3d,non-base', function benchmark( b ) {
539539

540540
b.tic();
541541
for ( i = 0; i < b.iterations; i++ ) {
542-
v = slice( values[ i%values.length ], s, false );
542+
v = slice( values[ i%values.length ], s, false, false );
543543
if ( typeof v !== 'object' ) {
544544
b.fail( 'should return an ndarray' );
545545
}
@@ -569,7 +569,7 @@ bench( pkg+'::3d,base,reduced', function benchmark( b ) {
569569

570570
b.tic();
571571
for ( i = 0; i < b.iterations; i++ ) {
572-
v = slice( values[ i%values.length ], s, false );
572+
v = slice( values[ i%values.length ], s, false, false );
573573
if ( typeof v !== 'object' ) {
574574
b.fail( 'should return an ndarray' );
575575
}
@@ -604,7 +604,7 @@ bench( pkg+'::3d,non-base,reduced', function benchmark( b ) {
604604

605605
b.tic();
606606
for ( i = 0; i < b.iterations; i++ ) {
607-
v = slice( values[ i%values.length ], s, false );
607+
v = slice( values[ i%values.length ], s, false, false );
608608
if ( typeof v !== 'object' ) {
609609
b.fail( 'should return an ndarray' );
610610
}
@@ -634,7 +634,7 @@ bench( pkg+'::3d,base,out-of-bounds', function benchmark( b ) {
634634

635635
b.tic();
636636
for ( i = 0; i < b.iterations; i++ ) {
637-
v = slice( values[ i%values.length ], s, false );
637+
v = slice( values[ i%values.length ], s, false, false );
638638
if ( typeof v !== 'object' ) {
639639
b.fail( 'should return an ndarray' );
640640
}
@@ -669,7 +669,7 @@ bench( pkg+'::3d,non-base,out-of-bounds', function benchmark( b ) {
669669

670670
b.tic();
671671
for ( i = 0; i < b.iterations; i++ ) {
672-
v = slice( values[ i%values.length ], s, false );
672+
v = slice( values[ i%values.length ], s, false, false );
673673
if ( typeof v !== 'object' ) {
674674
b.fail( 'should return an ndarray' );
675675
}
@@ -699,7 +699,7 @@ bench( pkg+'::4d,base', function benchmark( b ) {
699699

700700
b.tic();
701701
for ( i = 0; i < b.iterations; i++ ) {
702-
v = slice( values[ i%values.length ], s, false );
702+
v = slice( values[ i%values.length ], s, false, false );
703703
if ( typeof v !== 'object' ) {
704704
b.fail( 'should return an ndarray' );
705705
}
@@ -734,7 +734,7 @@ bench( pkg+'::4d,non-base', function benchmark( b ) {
734734

735735
b.tic();
736736
for ( i = 0; i < b.iterations; i++ ) {
737-
v = slice( values[ i%values.length ], s, false );
737+
v = slice( values[ i%values.length ], s, false, false );
738738
if ( typeof v !== 'object' ) {
739739
b.fail( 'should return an ndarray' );
740740
}
@@ -764,7 +764,7 @@ bench( pkg+'::4d,base,reduced', function benchmark( b ) {
764764

765765
b.tic();
766766
for ( i = 0; i < b.iterations; i++ ) {
767-
v = slice( values[ i%values.length ], s, false );
767+
v = slice( values[ i%values.length ], s, false, false );
768768
if ( typeof v !== 'object' ) {
769769
b.fail( 'should return an ndarray' );
770770
}
@@ -799,7 +799,7 @@ bench( pkg+'::4d,non-base,reduced', function benchmark( b ) {
799799

800800
b.tic();
801801
for ( i = 0; i < b.iterations; i++ ) {
802-
v = slice( values[ i%values.length ], s, false );
802+
v = slice( values[ i%values.length ], s, false, false );
803803
if ( typeof v !== 'object' ) {
804804
b.fail( 'should return an ndarray' );
805805
}
@@ -829,7 +829,7 @@ bench( pkg+'::4d,base,out-of-bounds', function benchmark( b ) {
829829

830830
b.tic();
831831
for ( i = 0; i < b.iterations; i++ ) {
832-
v = slice( values[ i%values.length ], s, false );
832+
v = slice( values[ i%values.length ], s, false, false );
833833
if ( typeof v !== 'object' ) {
834834
b.fail( 'should return an ndarray' );
835835
}
@@ -864,7 +864,7 @@ bench( pkg+'::4d,non-base,out-of-bounds', function benchmark( b ) {
864864

865865
b.tic();
866866
for ( i = 0; i < b.iterations; i++ ) {
867-
v = slice( values[ i%values.length ], s, false );
867+
v = slice( values[ i%values.length ], s, false, false );
868868
if ( typeof v !== 'object' ) {
869869
b.fail( 'should return an ndarray' );
870870
}
@@ -894,7 +894,7 @@ bench( pkg+'::5d,base', function benchmark( b ) {
894894

895895
b.tic();
896896
for ( i = 0; i < b.iterations; i++ ) {
897-
v = slice( values[ i%values.length ], s, false );
897+
v = slice( values[ i%values.length ], s, false, false );
898898
if ( typeof v !== 'object' ) {
899899
b.fail( 'should return an ndarray' );
900900
}
@@ -929,7 +929,7 @@ bench( pkg+'::5d,non-base', function benchmark( b ) {
929929

930930
b.tic();
931931
for ( i = 0; i < b.iterations; i++ ) {
932-
v = slice( values[ i%values.length ], s, false );
932+
v = slice( values[ i%values.length ], s, false, false );
933933
if ( typeof v !== 'object' ) {
934934
b.fail( 'should return an ndarray' );
935935
}
@@ -959,7 +959,7 @@ bench( pkg+'::5d,base,reduced', function benchmark( b ) {
959959

960960
b.tic();
961961
for ( i = 0; i < b.iterations; i++ ) {
962-
v = slice( values[ i%values.length ], s, false );
962+
v = slice( values[ i%values.length ], s, false, false );
963963
if ( typeof v !== 'object' ) {
964964
b.fail( 'should return an ndarray' );
965965
}
@@ -994,7 +994,7 @@ bench( pkg+'::5d,non-base,reduced', function benchmark( b ) {
994994

995995
b.tic();
996996
for ( i = 0; i < b.iterations; i++ ) {
997-
v = slice( values[ i%values.length ], s, false );
997+
v = slice( values[ i%values.length ], s, false, false );
998998
if ( typeof v !== 'object' ) {
999999
b.fail( 'should return an ndarray' );
10001000
}
@@ -1024,7 +1024,7 @@ bench( pkg+'::5d,base,out-of-bounds', function benchmark( b ) {
10241024

10251025
b.tic();
10261026
for ( i = 0; i < b.iterations; i++ ) {
1027-
v = slice( values[ i%values.length ], s, false );
1027+
v = slice( values[ i%values.length ], s, false, false );
10281028
if ( typeof v !== 'object' ) {
10291029
b.fail( 'should return an ndarray' );
10301030
}
@@ -1059,7 +1059,7 @@ bench( pkg+'::5d,non-base,out-of-bounds', function benchmark( b ) {
10591059

10601060
b.tic();
10611061
for ( i = 0; i < b.iterations; i++ ) {
1062-
v = slice( values[ i%values.length ], s, false );
1062+
v = slice( values[ i%values.length ], s, false, false );
10631063
if ( typeof v !== 'object' ) {
10641064
b.fail( 'should return an ndarray' );
10651065
}

0 commit comments

Comments
 (0)
0