@stdlib/ndarray-filter 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1478 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2024 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ // TypeScript Version: 4.1
20
+
21
+ /// <reference types="@stdlib/types"/>
22
+
23
+ /* eslint-disable max-lines */
24
+
25
+ import { typedndarray, DataType, Order, float64ndarray, float32ndarray, complex128ndarray, complex64ndarray, int32ndarray, int16ndarray, int8ndarray, uint32ndarray, uint16ndarray, uint8ndarray, uint8cndarray, boolndarray, genericndarray } from '@stdlib/types/ndarray';
26
+ import { Complex64, Complex128 } from '@stdlib/types/complex';
27
+
28
+ /**
29
+ * Returns a boolean indicating whether an element passes a test.
30
+ *
31
+ * @returns boolean indicating whether an element passes a test
32
+ */
33
+ type Nullary<V> = ( this: V ) => boolean;
34
+
35
+ /**
36
+ * Returns a boolean indicating whether an element passes a test.
37
+ *
38
+ * @param value - current array element
39
+ * @returns boolean indicating whether an element passes a test
40
+ */
41
+ type Unary<T, V> = ( this: V, value: T ) => boolean;
42
+
43
+ /**
44
+ * Returns a boolean indicating whether an element passes a test.
45
+ *
46
+ * @param value - current array element
47
+ * @param indices - current array element indices
48
+ * @returns boolean indicating whether an element passes a test
49
+ */
50
+ type Binary<T, V> = ( this: V, value: T, indices: Array<number> ) => boolean;
51
+
52
+ /**
53
+ * Returns a boolean indicating whether an element passes a test.
54
+ *
55
+ * @param value - current array element
56
+ * @param indices - current array element indices
57
+ * @param arr - input array
58
+ * @returns boolean indicating whether an element passes a test
59
+ */
60
+ type Ternary<T, V> = ( this: V, value: T, indices: Array<number>, arr: typedndarray<T> ) => boolean;
61
+
62
+ /**
63
+ * Returns a boolean indicating whether an element passes a test.
64
+ *
65
+ * @param value - current array element
66
+ * @param indices - current array element indices
67
+ * @param arr - input array
68
+ * @returns boolean indicating whether an element passes a test
69
+ */
70
+ type Predicate<T, V> = Nullary<V> | Unary<T, V> | Binary<T, V> | Ternary<T, V>;
71
+
72
+ /**
73
+ * Interface describing "base" function options.
74
+ */
75
+ interface BaseOptions {
76
+ /**
77
+ * Index iteration order.
78
+ *
79
+ * ## Notes
80
+ *
81
+ * - By default, the function iterates over elements according to the layout order of the provided ndarray. Accordingly, for row-major input ndarrays, the last dimension indices increment fastest. For column-major input ndarrays, the first dimension indices increment fastest. To override the inferred order and ensure that indices increment in a specific manner, regardless of the input ndarray's layout order, explicitly set the iteration order. Note, however, that iterating according to an order which does not match that of the input ndarray may, in some circumstances, result in performance degradation due to cache misses.
82
+ */
83
+ order?: Order;
84
+ }
85
+
86
+ /**
87
+ * Interface describing function options.
88
+ */
89
+ interface OrderOptions {
90
+ /**
91
+ * Index iteration order.
92
+ *
93
+ * ## Notes
94
+ *
95
+ * - By default, the function iterates over elements according to the layout order of the provided ndarray. Accordingly, for row-major input ndarrays, the last dimension indices increment fastest. For column-major input ndarrays, the first dimension indices increment fastest. To override the inferred order and ensure that indices increment in a specific manner, regardless of the input ndarray's layout order, explicitly set the iteration order. Note, however, that iterating according to an order which does not match that of the input ndarray may, in some circumstances, result in performance degradation due to cache misses.
96
+ */
97
+ order: Order;
98
+ }
99
+
100
+ /**
101
+ * Interface describing function options.
102
+ */
103
+ interface Options extends BaseOptions {
104
+ /**
105
+ * Output ndarray data type.
106
+ *
107
+ * ## Notes
108
+ *
109
+ * - This option overrides using the input ndarray's inferred data type.
110
+ */
111
+ dtype?: DataType;
112
+ }
113
+
114
+ /**
115
+ * Interface describing function options.
116
+ */
117
+ interface Float64Options extends Options {
118
+ /**
119
+ * Output ndarray data type.
120
+ *
121
+ * ## Notes
122
+ *
123
+ * - This option overrides using the input ndarray's inferred data type.
124
+ */
125
+ dtype?: 'float64';
126
+ }
127
+
128
+ /**
129
+ * Interface describing function options.
130
+ */
131
+ interface Float32Options extends Options {
132
+ /**
133
+ * Output ndarray data type.
134
+ *
135
+ * ## Notes
136
+ *
137
+ * - This option overrides using the input ndarray's inferred data type.
138
+ */
139
+ dtype?: 'float32';
140
+ }
141
+
142
+ /**
143
+ * Interface describing function options.
144
+ */
145
+ interface Complex128Options extends Options {
146
+ /**
147
+ * Output ndarray data type.
148
+ *
149
+ * ## Notes
150
+ *
151
+ * - This option overrides using the input ndarray's inferred data type.
152
+ */
153
+ dtype?: 'complex128';
154
+ }
155
+
156
+ /**
157
+ * Interface describing function options.
158
+ */
159
+ interface Complex64Options extends Options {
160
+ /**
161
+ * Output ndarray data type.
162
+ *
163
+ * ## Notes
164
+ *
165
+ * - This option overrides using the input ndarray's inferred data type.
166
+ */
167
+ dtype?: 'complex64';
168
+ }
169
+
170
+ /**
171
+ * Interface describing function options.
172
+ */
173
+ interface Int32Options extends Options {
174
+ /**
175
+ * Output ndarray data type.
176
+ *
177
+ * ## Notes
178
+ *
179
+ * - This option overrides using the input ndarray's inferred data type.
180
+ */
181
+ dtype?: 'int32';
182
+ }
183
+
184
+ /**
185
+ * Interface describing function options.
186
+ */
187
+ interface Int16Options extends Options {
188
+ /**
189
+ * Output ndarray data type.
190
+ *
191
+ * ## Notes
192
+ *
193
+ * - This option overrides using the input ndarray's inferred data type.
194
+ */
195
+ dtype?: 'int16';
196
+ }
197
+
198
+ /**
199
+ * Interface describing function options.
200
+ */
201
+ interface Int8Options extends Options {
202
+ /**
203
+ * Output ndarray data type.
204
+ *
205
+ * ## Notes
206
+ *
207
+ * - This option overrides using the input ndarray's inferred data type.
208
+ */
209
+ dtype?: 'int8';
210
+ }
211
+
212
+ /**
213
+ * Interface describing function options.
214
+ */
215
+ interface Uint32Options extends Options {
216
+ /**
217
+ * Output ndarray data type.
218
+ *
219
+ * ## Notes
220
+ *
221
+ * - This option overrides using the input ndarray's inferred data type.
222
+ */
223
+ dtype?: 'uint32';
224
+ }
225
+
226
+ /**
227
+ * Interface describing function options.
228
+ */
229
+ interface Uint16Options extends Options {
230
+ /**
231
+ * Output ndarray data type.
232
+ *
233
+ * ## Notes
234
+ *
235
+ * - This option overrides using the input ndarray's inferred data type.
236
+ */
237
+ dtype?: 'uint16';
238
+ }
239
+
240
+ /**
241
+ * Interface describing function options.
242
+ */
243
+ interface Uint8Options extends Options {
244
+ /**
245
+ * Output ndarray data type.
246
+ *
247
+ * ## Notes
248
+ *
249
+ * - This option overrides using the input ndarray's inferred data type.
250
+ */
251
+ dtype?: 'uint8';
252
+ }
253
+
254
+ /**
255
+ * Interface describing function options.
256
+ */
257
+ interface Uint8COptions extends Options {
258
+ /**
259
+ * Output ndarray data type.
260
+ *
261
+ * ## Notes
262
+ *
263
+ * - This option overrides using the input ndarray's inferred data type.
264
+ */
265
+ dtype?: 'uint8c';
266
+ }
267
+
268
+ /**
269
+ * Interface describing function options.
270
+ */
271
+ interface BoolOptions extends Options {
272
+ /**
273
+ * Output ndarray data type.
274
+ *
275
+ * ## Notes
276
+ *
277
+ * - This option overrides using the input ndarray's inferred data type.
278
+ */
279
+ dtype?: 'bool';
280
+ }
281
+
282
+ /**
283
+ * Interface describing function options.
284
+ */
285
+ interface GenericOptions extends Options {
286
+ /**
287
+ * Output ndarray data type.
288
+ *
289
+ * ## Notes
290
+ *
291
+ * - This option overrides using the input ndarray's inferred data type.
292
+ */
293
+ dtype?: 'generic';
294
+ }
295
+
296
+ /**
297
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
298
+ *
299
+ * @param x - input ndarray
300
+ * @param predicate - predicate function
301
+ * @param thisArg - predicate function execution context
302
+ * @returns output ndarray
303
+ *
304
+ * @example
305
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
306
+ * var Float64Array = require( '@stdlib/array-float64' );
307
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
308
+ *
309
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
310
+ * var shape = [ 2, 3 ];
311
+ * var strides = [ 6, 1 ];
312
+ * var offset = 1;
313
+ *
314
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
315
+ * // returns <ndarray>
316
+ *
317
+ * var y = filter( x, isEven );
318
+ * // returns <ndarray>[ 2.0, 4.0, 8.0, 10.0 ]
319
+ */
320
+ declare function filter<V = unknown>( x: float64ndarray, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): float64ndarray;
321
+
322
+ /**
323
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
324
+ *
325
+ * @param x - input ndarray
326
+ * @param predicate - predicate function
327
+ * @param thisArg - predicate function execution context
328
+ * @returns output ndarray
329
+ *
330
+ * @example
331
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
332
+ * var Float32Array = require( '@stdlib/array-float32' );
333
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
334
+ *
335
+ * var buffer = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
336
+ * var shape = [ 2, 3 ];
337
+ * var strides = [ 6, 1 ];
338
+ * var offset = 1;
339
+ *
340
+ * var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' );
341
+ * // returns <ndarray>
342
+ *
343
+ * var y = filter( x, isEven );
344
+ * // returns <ndarray>[ 2.0, 4.0, 8.0, 10.0 ]
345
+ */
346
+ declare function filter<V = unknown>( x: float32ndarray, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): float32ndarray;
347
+
348
+ /**
349
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
350
+ *
351
+ * @param x - input ndarray
352
+ * @param predicate - predicate function
353
+ * @param thisArg - predicate function execution context
354
+ * @returns output ndarray
355
+ *
356
+ * @example
357
+ * var Complex64Array = require( '@stdlib/array-complex64' );
358
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
359
+ *
360
+ * function predicate( z, idx ) {
361
+ * return idx[ 0 ] > 0;
362
+ * }
363
+ *
364
+ * var buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
365
+ * var shape = [ 2, 3 ];
366
+ * var strides = [ 3, 1 ];
367
+ * var offset = 0;
368
+ *
369
+ * var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' );
370
+ * // returns <ndarray>
371
+ *
372
+ * var y = filter( x, predicate );
373
+ * // returns <ndarray>
374
+ */
375
+ declare function filter<V = unknown>( x: complex64ndarray, predicate: Predicate<Complex64, V>, thisArg?: ThisParameterType<Predicate<Complex64, V>> ): complex64ndarray;
376
+
377
+ /**
378
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
379
+ *
380
+ * @param x - input ndarray
381
+ * @param predicate - predicate function
382
+ * @param thisArg - predicate function execution context
383
+ * @returns output ndarray
384
+ *
385
+ * @example
386
+ * var Complex128Array = require( '@stdlib/array-complex128' );
387
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
388
+ *
389
+ * function predicate( z, idx ) {
390
+ * return idx[ 0 ] > 0;
391
+ * }
392
+ *
393
+ * var buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
394
+ * var shape = [ 2, 3 ];
395
+ * var strides = [ 3, 1 ];
396
+ * var offset = 0;
397
+ *
398
+ * var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' );
399
+ * // returns <ndarray>
400
+ *
401
+ * var y = filter( x, predicate );
402
+ * // returns <ndarray>
403
+ */
404
+ declare function filter<V = unknown>( x: complex128ndarray, predicate: Predicate<Complex128, V>, thisArg?: ThisParameterType<Predicate<Complex128, V>> ): complex128ndarray;
405
+
406
+ /**
407
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
408
+ *
409
+ * @param x - input ndarray
410
+ * @param predicate - predicate function
411
+ * @param thisArg - predicate function execution context
412
+ * @returns output ndarray
413
+ *
414
+ * @example
415
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
416
+ * var Int32Array = require( '@stdlib/array-int32' );
417
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
418
+ *
419
+ * var buffer = new Int32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
420
+ * var shape = [ 2, 3 ];
421
+ * var strides = [ 6, 1 ];
422
+ * var offset = 1;
423
+ *
424
+ * var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' );
425
+ * // returns <ndarray>
426
+ *
427
+ * var y = filter( x, isEven );
428
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
429
+ */
430
+ declare function filter<V = unknown>( x: int32ndarray, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): int32ndarray;
431
+
432
+ /**
433
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
434
+ *
435
+ * @param x - input ndarray
436
+ * @param predicate - predicate function
437
+ * @param thisArg - predicate function execution context
438
+ * @returns output ndarray
439
+ *
440
+ * @example
441
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
442
+ * var Int16Array = require( '@stdlib/array-int16' );
443
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
444
+ *
445
+ * var buffer = new Int16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
446
+ * var shape = [ 2, 3 ];
447
+ * var strides = [ 6, 1 ];
448
+ * var offset = 1;
449
+ *
450
+ * var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' );
451
+ * // returns <ndarray>
452
+ *
453
+ * var y = filter( x, isEven );
454
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
455
+ */
456
+ declare function filter<V = unknown>( x: int16ndarray, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): int16ndarray;
457
+
458
+ /**
459
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
460
+ *
461
+ * @param x - input ndarray
462
+ * @param predicate - predicate function
463
+ * @param thisArg - predicate function execution context
464
+ * @returns output ndarray
465
+ *
466
+ * @example
467
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
468
+ * var Int8Array = require( '@stdlib/array-int8' );
469
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
470
+ *
471
+ * var buffer = new Int8Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
472
+ * var shape = [ 2, 3 ];
473
+ * var strides = [ 6, 1 ];
474
+ * var offset = 1;
475
+ *
476
+ * var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' );
477
+ * // returns <ndarray>
478
+ *
479
+ * var y = filter( x, isEven );
480
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
481
+ */
482
+ declare function filter<V = unknown>( x: int8ndarray, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): int8ndarray;
483
+
484
+ /**
485
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
486
+ *
487
+ * @param x - input ndarray
488
+ * @param predicate - predicate function
489
+ * @param thisArg - predicate function execution context
490
+ * @returns output ndarray
491
+ *
492
+ * @example
493
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
494
+ * var Uint32Array = require( '@stdlib/array-uint32' );
495
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
496
+ *
497
+ * var buffer = new Uint32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
498
+ * var shape = [ 2, 3 ];
499
+ * var strides = [ 6, 1 ];
500
+ * var offset = 1;
501
+ *
502
+ * var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' );
503
+ * // returns <ndarray>
504
+ *
505
+ * var y = filter( x, isEven );
506
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
507
+ */
508
+ declare function filter<V = unknown>( x: uint32ndarray, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): uint32ndarray;
509
+
510
+ /**
511
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
512
+ *
513
+ * @param x - input ndarray
514
+ * @param predicate - predicate function
515
+ * @param thisArg - predicate function execution context
516
+ * @returns output ndarray
517
+ *
518
+ * @example
519
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
520
+ * var Uint16Array = require( '@stdlib/array-uint16' );
521
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
522
+ *
523
+ * var buffer = new Uint16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
524
+ * var shape = [ 2, 3 ];
525
+ * var strides = [ 6, 1 ];
526
+ * var offset = 1;
527
+ *
528
+ * var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' );
529
+ * // returns <ndarray>
530
+ *
531
+ * var y = filter( x, isEven );
532
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
533
+ */
534
+ declare function filter<V = unknown>( x: uint16ndarray, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): uint16ndarray;
535
+
536
+ /**
537
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
538
+ *
539
+ * @param x - input ndarray
540
+ * @param predicate - predicate function
541
+ * @param thisArg - predicate function execution context
542
+ * @returns output ndarray
543
+ *
544
+ * @example
545
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
546
+ * var Uint8Array = require( '@stdlib/array-uint8' );
547
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
548
+ *
549
+ * var buffer = new Uint8Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
550
+ * var shape = [ 2, 3 ];
551
+ * var strides = [ 6, 1 ];
552
+ * var offset = 1;
553
+ *
554
+ * var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' );
555
+ * // returns <ndarray>
556
+ *
557
+ * var y = filter( x, isEven );
558
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
559
+ */
560
+ declare function filter<V = unknown>( x: uint8ndarray, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): uint8ndarray;
561
+
562
+ /**
563
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
564
+ *
565
+ * @param x - input ndarray
566
+ * @param predicate - predicate function
567
+ * @param thisArg - predicate function execution context
568
+ * @returns output ndarray
569
+ *
570
+ * @example
571
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
572
+ * var Uint8ClampedArray = require( '@stdlib/array-uint8c' );
573
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
574
+ *
575
+ * var buffer = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
576
+ * var shape = [ 2, 3 ];
577
+ * var strides = [ 6, 1 ];
578
+ * var offset = 1;
579
+ *
580
+ * var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' );
581
+ * // returns <ndarray>
582
+ *
583
+ * var y = filter( x, isEven );
584
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
585
+ */
586
+ declare function filter<V = unknown>( x: uint8cndarray, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): uint8cndarray;
587
+
588
+ /**
589
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
590
+ *
591
+ * @param x - input ndarray
592
+ * @param predicate - predicate function
593
+ * @param thisArg - predicate function execution context
594
+ * @returns output ndarray
595
+ *
596
+ * @example
597
+ * var BooleanArray = require( '@stdlib/array-bool' );
598
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
599
+ *
600
+ * function predicate( z ) {
601
+ * return z;
602
+ * }
603
+ *
604
+ * var buffer = new BooleanArray( [ false, true, false, true, false, true, false, true, false, true, false, true ] );
605
+ * var shape = [ 2, 3 ];
606
+ * var strides = [ 6, 1 ];
607
+ * var offset = 1;
608
+ *
609
+ * var x = ndarray( 'bool', buffer, shape, strides, offset, 'row-major' );
610
+ * // returns <ndarray>
611
+ *
612
+ * var y = filter( x, predicate );
613
+ * // returns <ndarray>[ true, true, true, true ]
614
+ */
615
+ declare function filter<V = unknown>( x: boolndarray, predicate: Predicate<boolean, V>, thisArg?: ThisParameterType<Predicate<boolean, V>> ): boolndarray;
616
+
617
+ /**
618
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
619
+ *
620
+ * @param x - input ndarray
621
+ * @param predicate - predicate function
622
+ * @param thisArg - predicate function execution context
623
+ * @returns output ndarray
624
+ *
625
+ * @example
626
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
627
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
628
+ *
629
+ * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ];
630
+ * var shape = [ 2, 3 ];
631
+ * var strides = [ 6, 1 ];
632
+ * var offset = 1;
633
+ *
634
+ * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
635
+ * // returns <ndarray>
636
+ *
637
+ * var y = filter( x, isEven );
638
+ * // returns <ndarray>[ 2.0, 4.0, 8.0, 10.0 ]
639
+ */
640
+ declare function filter<T = unknown, V = unknown>( x: genericndarray<T>, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): genericndarray<T>;
641
+
642
+ /**
643
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
644
+ *
645
+ * @param x - input ndarray
646
+ * @param options - function options
647
+ * @param options.order - iteration order
648
+ * @param predicate - predicate function
649
+ * @param thisArg - predicate function execution context
650
+ * @returns output ndarray
651
+ *
652
+ * @example
653
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
654
+ * var Float64Array = require( '@stdlib/array-float64' );
655
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
656
+ *
657
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
658
+ * var shape = [ 2, 3 ];
659
+ * var strides = [ 6, 1 ];
660
+ * var offset = 1;
661
+ *
662
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
663
+ * // returns <ndarray>
664
+ *
665
+ * var opts = {
666
+ * 'order': 'row-major'
667
+ * };
668
+ * var y = filter( x, opts, isEven );
669
+ * // returns <ndarray>[ 2.0, 4.0, 8.0, 10.0 ]
670
+ */
671
+ declare function filter<V = unknown>( x: float64ndarray, options: OrderOptions, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): float64ndarray;
672
+
673
+ /**
674
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
675
+ *
676
+ * @param x - input ndarray
677
+ * @param options - function options
678
+ * @param options.order - iteration order
679
+ * @param predicate - predicate function
680
+ * @param thisArg - predicate function execution context
681
+ * @returns output ndarray
682
+ *
683
+ * @example
684
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
685
+ * var Float32Array = require( '@stdlib/array-float32' );
686
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
687
+ *
688
+ * var buffer = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
689
+ * var shape = [ 2, 3 ];
690
+ * var strides = [ 6, 1 ];
691
+ * var offset = 1;
692
+ *
693
+ * var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' );
694
+ * // returns <ndarray>
695
+ *
696
+ * var opts = {
697
+ * 'order': 'row-major'
698
+ * };
699
+ * var y = filter( x, opts, isEven );
700
+ * // returns <ndarray>[ 2.0, 4.0, 8.0, 10.0 ]
701
+ */
702
+ declare function filter<V = unknown>( x: float32ndarray, options: OrderOptions, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): float32ndarray;
703
+
704
+ /**
705
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
706
+ *
707
+ * @param x - input ndarray
708
+ * @param options - function options
709
+ * @param options.order - iteration order
710
+ * @param predicate - predicate function
711
+ * @param thisArg - predicate function execution context
712
+ * @returns output ndarray
713
+ *
714
+ * @example
715
+ * var Complex64Array = require( '@stdlib/array-complex64' );
716
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
717
+ *
718
+ * function predicate( z, idx ) {
719
+ * return idx[ 0 ] > 0;
720
+ * }
721
+ *
722
+ * var buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
723
+ * var shape = [ 2, 3 ];
724
+ * var strides = [ 3, 1 ];
725
+ * var offset = 0;
726
+ *
727
+ * var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' );
728
+ * // returns <ndarray>
729
+ *
730
+ * var opts = {
731
+ * 'order': 'row-major'
732
+ * };
733
+ * var y = filter( x, opts, predicate );
734
+ * // returns <ndarray>
735
+ */
736
+ declare function filter<V = unknown>( x: complex64ndarray, options: OrderOptions, predicate: Predicate<Complex64, V>, thisArg?: ThisParameterType<Predicate<Complex64, V>> ): complex64ndarray;
737
+
738
+ /**
739
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
740
+ *
741
+ * @param x - input ndarray
742
+ * @param options - function options
743
+ * @param options.order - iteration order
744
+ * @param predicate - predicate function
745
+ * @param thisArg - predicate function execution context
746
+ * @returns output ndarray
747
+ *
748
+ * @example
749
+ * var Complex128Array = require( '@stdlib/array-complex128' );
750
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
751
+ *
752
+ * function predicate( z, idx ) {
753
+ * return idx[ 0 ] > 0;
754
+ * }
755
+ *
756
+ * var buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
757
+ * var shape = [ 2, 3 ];
758
+ * var strides = [ 3, 1 ];
759
+ * var offset = 0;
760
+ *
761
+ * var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' );
762
+ * // returns <ndarray>
763
+ *
764
+ * var opts = {
765
+ * 'order': 'row-major'
766
+ * };
767
+ * var y = filter( x, opts, predicate );
768
+ * // returns <ndarray>
769
+ */
770
+ declare function filter<V = unknown>( x: complex128ndarray, options: OrderOptions, predicate: Predicate<Complex128, V>, thisArg?: ThisParameterType<Predicate<Complex128, V>> ): complex128ndarray;
771
+
772
+ /**
773
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
774
+ *
775
+ * @param x - input ndarray
776
+ * @param options - function options
777
+ * @param options.order - iteration order
778
+ * @param predicate - predicate function
779
+ * @param thisArg - predicate function execution context
780
+ * @returns output ndarray
781
+ *
782
+ * @example
783
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
784
+ * var Int32Array = require( '@stdlib/array-int32' );
785
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
786
+ *
787
+ * var buffer = new Int32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
788
+ * var shape = [ 2, 3 ];
789
+ * var strides = [ 6, 1 ];
790
+ * var offset = 1;
791
+ *
792
+ * var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' );
793
+ * // returns <ndarray>
794
+ *
795
+ * var opts = {
796
+ * 'order': 'row-major'
797
+ * };
798
+ * var y = filter( x, opts, isEven );
799
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
800
+ */
801
+ declare function filter<V = unknown>( x: int32ndarray, options: OrderOptions, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): int32ndarray;
802
+
803
+ /**
804
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
805
+ *
806
+ * @param x - input ndarray
807
+ * @param options - function options
808
+ * @param options.order - iteration order
809
+ * @param predicate - predicate function
810
+ * @param thisArg - predicate function execution context
811
+ * @returns output ndarray
812
+ *
813
+ * @example
814
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
815
+ * var Int16Array = require( '@stdlib/array-int16' );
816
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
817
+ *
818
+ * var buffer = new Int16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
819
+ * var shape = [ 2, 3 ];
820
+ * var strides = [ 6, 1 ];
821
+ * var offset = 1;
822
+ *
823
+ * var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' );
824
+ * // returns <ndarray>
825
+ *
826
+ * var opts = {
827
+ * 'order': 'row-major'
828
+ * };
829
+ * var y = filter( x, opts, isEven );
830
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
831
+ */
832
+ declare function filter<V = unknown>( x: int16ndarray, options: OrderOptions, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): int16ndarray;
833
+
834
+ /**
835
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
836
+ *
837
+ * @param x - input ndarray
838
+ * @param options - function options
839
+ * @param options.order - iteration order
840
+ * @param predicate - predicate function
841
+ * @param thisArg - predicate function execution context
842
+ * @returns output ndarray
843
+ *
844
+ * @example
845
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
846
+ * var Int8Array = require( '@stdlib/array-int8' );
847
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
848
+ *
849
+ * var buffer = new Int8Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
850
+ * var shape = [ 2, 3 ];
851
+ * var strides = [ 6, 1 ];
852
+ * var offset = 1;
853
+ *
854
+ * var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' );
855
+ * // returns <ndarray>
856
+ *
857
+ * var opts = {
858
+ * 'order': 'row-major'
859
+ * };
860
+ * var y = filter( x, opts, isEven );
861
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
862
+ */
863
+ declare function filter<V = unknown>( x: int8ndarray, options: OrderOptions, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): int8ndarray;
864
+
865
+ /**
866
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
867
+ *
868
+ * @param x - input ndarray
869
+ * @param options - function options
870
+ * @param options.order - iteration order
871
+ * @param predicate - predicate function
872
+ * @param thisArg - predicate function execution context
873
+ * @returns output ndarray
874
+ *
875
+ * @example
876
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
877
+ * var Uint32Array = require( '@stdlib/array-uint32' );
878
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
879
+ *
880
+ * var buffer = new Uint32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
881
+ * var shape = [ 2, 3 ];
882
+ * var strides = [ 6, 1 ];
883
+ * var offset = 1;
884
+ *
885
+ * var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' );
886
+ * // returns <ndarray>
887
+ *
888
+ * var opts = {
889
+ * 'order': 'row-major'
890
+ * };
891
+ * var y = filter( x, opts, isEven );
892
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
893
+ */
894
+ declare function filter<V = unknown>( x: uint32ndarray, options: OrderOptions, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): uint32ndarray;
895
+
896
+ /**
897
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
898
+ *
899
+ * @param x - input ndarray
900
+ * @param options - function options
901
+ * @param options.order - iteration order
902
+ * @param predicate - predicate function
903
+ * @param thisArg - predicate function execution context
904
+ * @returns output ndarray
905
+ *
906
+ * @example
907
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
908
+ * var Uint16Array = require( '@stdlib/array-uint16' );
909
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
910
+ *
911
+ * var buffer = new Uint16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
912
+ * var shape = [ 2, 3 ];
913
+ * var strides = [ 6, 1 ];
914
+ * var offset = 1;
915
+ *
916
+ * var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' );
917
+ * // returns <ndarray>
918
+ *
919
+ * var opts = {
920
+ * 'order': 'row-major'
921
+ * };
922
+ * var y = filter( x, opts, isEven );
923
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
924
+ */
925
+ declare function filter<V = unknown>( x: uint16ndarray, options: OrderOptions, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): uint16ndarray;
926
+
927
+ /**
928
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
929
+ *
930
+ * @param x - input ndarray
931
+ * @param options - function options
932
+ * @param options.order - iteration order
933
+ * @param predicate - predicate function
934
+ * @param thisArg - predicate function execution context
935
+ * @returns output ndarray
936
+ *
937
+ * @example
938
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
939
+ * var Uint8Array = require( '@stdlib/array-uint8' );
940
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
941
+ *
942
+ * var buffer = new Uint8Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
943
+ * var shape = [ 2, 3 ];
944
+ * var strides = [ 6, 1 ];
945
+ * var offset = 1;
946
+ *
947
+ * var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' );
948
+ * // returns <ndarray>
949
+ *
950
+ * var opts = {
951
+ * 'order': 'row-major'
952
+ * };
953
+ * var y = filter( x, opts, isEven );
954
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
955
+ */
956
+ declare function filter<V = unknown>( x: uint8ndarray, options: OrderOptions, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): uint8ndarray;
957
+
958
+ /**
959
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
960
+ *
961
+ * @param x - input ndarray
962
+ * @param options - function options
963
+ * @param options.order - iteration order
964
+ * @param predicate - predicate function
965
+ * @param thisArg - predicate function execution context
966
+ * @returns output ndarray
967
+ *
968
+ * @example
969
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
970
+ * var Uint8ClampedArray = require( '@stdlib/array-uint8c' );
971
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
972
+ *
973
+ * var buffer = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
974
+ * var shape = [ 2, 3 ];
975
+ * var strides = [ 6, 1 ];
976
+ * var offset = 1;
977
+ *
978
+ * var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' );
979
+ * // returns <ndarray>
980
+ *
981
+ * var opts = {
982
+ * 'order': 'row-major'
983
+ * };
984
+ * var y = filter( x, opts, isEven );
985
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
986
+ */
987
+ declare function filter<V = unknown>( x: uint8cndarray, options: OrderOptions, predicate: Predicate<number, V>, thisArg?: ThisParameterType<Predicate<number, V>> ): uint8cndarray;
988
+
989
+ /**
990
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
991
+ *
992
+ * @param x - input ndarray
993
+ * @param options - function options
994
+ * @param options.order - iteration order
995
+ * @param predicate - predicate function
996
+ * @param thisArg - predicate function execution context
997
+ * @returns output ndarray
998
+ *
999
+ * @example
1000
+ * var BooleanArray = require( '@stdlib/array-bool' );
1001
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1002
+ *
1003
+ * function predicate( z ) {
1004
+ * return z;
1005
+ * }
1006
+ *
1007
+ * var buffer = new BooleanArray( [ false, true, false, true, false, true, false, true, false, true, false, true ] );
1008
+ * var shape = [ 2, 3 ];
1009
+ * var strides = [ 6, 1 ];
1010
+ * var offset = 1;
1011
+ *
1012
+ * var x = ndarray( 'bool', buffer, shape, strides, offset, 'row-major' );
1013
+ * // returns <ndarray>
1014
+ *
1015
+ * var opts = {
1016
+ * 'order': 'row-major'
1017
+ * };
1018
+ * var y = filter( x, opts, predicate );
1019
+ * // returns <ndarray>[ true, true, true, true ]
1020
+ */
1021
+ declare function filter<V = unknown>( x: boolndarray, options: OrderOptions, predicate: Predicate<boolean, V>, thisArg?: ThisParameterType<Predicate<boolean, V>> ): boolndarray;
1022
+
1023
+ /**
1024
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1025
+ *
1026
+ * @param x - input ndarray
1027
+ * @param options - function options
1028
+ * @param options.order - iteration order
1029
+ * @param predicate - predicate function
1030
+ * @param thisArg - predicate function execution context
1031
+ * @returns output ndarray
1032
+ *
1033
+ * @example
1034
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1035
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1036
+ *
1037
+ * var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ];
1038
+ * var shape = [ 2, 3 ];
1039
+ * var strides = [ 6, 1 ];
1040
+ * var offset = 1;
1041
+ *
1042
+ * var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
1043
+ * // returns <ndarray>
1044
+ *
1045
+ * var opts = {
1046
+ * 'order': 'row-major'
1047
+ * };
1048
+ * var y = filter( x, opts, isEven );
1049
+ * // returns <ndarray>[ 2.0, 4.0, 8.0, 10.0 ]
1050
+ */
1051
+ declare function filter<T = unknown, V = unknown>( x: genericndarray<T>, options: OrderOptions, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): genericndarray<T>;
1052
+
1053
+ /**
1054
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1055
+ *
1056
+ * @param x - input ndarray
1057
+ * @param options - options
1058
+ * @param options.dtype - output ndarray data type
1059
+ * @param options.order - iteration order
1060
+ * @param predicate - predicate function
1061
+ * @param thisArg - predicate function execution context
1062
+ * @returns output ndarray
1063
+ *
1064
+ * @example
1065
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1066
+ * var Float64Array = require( '@stdlib/array-float64' );
1067
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1068
+ *
1069
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1070
+ * var shape = [ 2, 3 ];
1071
+ * var strides = [ 6, 1 ];
1072
+ * var offset = 1;
1073
+ *
1074
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1075
+ * // returns <ndarray>
1076
+ *
1077
+ * var opts = {
1078
+ * 'dtype': 'float64'
1079
+ * };
1080
+ * var y = filter( x, opts, isEven );
1081
+ * // returns <ndarray>[ 2.0, 4.0, 8.0, 10.0 ]
1082
+ */
1083
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Float64Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): float64ndarray;
1084
+
1085
+ /**
1086
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1087
+ *
1088
+ * @param x - input ndarray
1089
+ * @param options - options
1090
+ * @param options.dtype - output ndarray data type
1091
+ * @param options.order - iteration order
1092
+ * @param predicate - predicate function
1093
+ * @param thisArg - predicate function execution context
1094
+ * @returns output ndarray
1095
+ *
1096
+ * @example
1097
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1098
+ * var Float64Array = require( '@stdlib/array-float64' );
1099
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1100
+ *
1101
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1102
+ * var shape = [ 2, 3 ];
1103
+ * var strides = [ 6, 1 ];
1104
+ * var offset = 1;
1105
+ *
1106
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1107
+ * // returns <ndarray>
1108
+ *
1109
+ * var opts = {
1110
+ * 'dtype': 'float32'
1111
+ * };
1112
+ * var y = filter( x, opts, isEven );
1113
+ * // returns <ndarray>[ 2.0, 4.0, 8.0, 10.0 ]
1114
+ */
1115
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Float32Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): float32ndarray;
1116
+
1117
+ /**
1118
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1119
+ *
1120
+ * @param x - input ndarray
1121
+ * @param options - options
1122
+ * @param options.dtype - output ndarray data type
1123
+ * @param options.order - iteration order
1124
+ * @param predicate - predicate function
1125
+ * @param thisArg - predicate function execution context
1126
+ * @returns output ndarray
1127
+ *
1128
+ * @example
1129
+ * var Complex128Array = require( '@stdlib/array-complex128' );
1130
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1131
+ *
1132
+ * function predicate( z, idx ) {
1133
+ * return idx[ 0 ] > 0;
1134
+ * }
1135
+ *
1136
+ * var buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1137
+ * var shape = [ 2, 3 ];
1138
+ * var strides = [ 3, 1 ];
1139
+ * var offset = 0;
1140
+ *
1141
+ * var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' );
1142
+ * // returns <ndarray>
1143
+ *
1144
+ * var opts = {
1145
+ * 'dtype': 'complex128'
1146
+ * };
1147
+ * var y = filter( x, opts, predicate );
1148
+ * // returns <ndarray>
1149
+ */
1150
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Complex128Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): complex128ndarray;
1151
+
1152
+ /**
1153
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1154
+ *
1155
+ * @param x - input ndarray
1156
+ * @param options - options
1157
+ * @param options.dtype - output ndarray data type
1158
+ * @param options.order - iteration order
1159
+ * @param predicate - predicate function
1160
+ * @param thisArg - predicate function execution context
1161
+ * @returns output ndarray
1162
+ *
1163
+ * @example
1164
+ * var Complex128Array = require( '@stdlib/array-complex128' );
1165
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1166
+ *
1167
+ * function predicate( z, idx ) {
1168
+ * return idx[ 0 ] > 0;
1169
+ * }
1170
+ *
1171
+ * var buffer = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1172
+ * var shape = [ 2, 3 ];
1173
+ * var strides = [ 3, 1 ];
1174
+ * var offset = 0;
1175
+ *
1176
+ * var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' );
1177
+ * // returns <ndarray>
1178
+ *
1179
+ * var opts = {
1180
+ * 'dtype': 'complex64'
1181
+ * };
1182
+ * var y = filter( x, opts, predicate );
1183
+ * // returns <ndarray>
1184
+ */
1185
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Complex64Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): complex64ndarray;
1186
+
1187
+ /**
1188
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1189
+ *
1190
+ * @param x - input ndarray
1191
+ * @param options - options
1192
+ * @param options.dtype - output ndarray data type
1193
+ * @param options.order - iteration order
1194
+ * @param predicate - predicate function
1195
+ * @param thisArg - predicate function execution context
1196
+ * @returns output ndarray
1197
+ *
1198
+ * @example
1199
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1200
+ * var Float64Array = require( '@stdlib/array-float64' );
1201
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1202
+ *
1203
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1204
+ * var shape = [ 2, 3 ];
1205
+ * var strides = [ 6, 1 ];
1206
+ * var offset = 1;
1207
+ *
1208
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1209
+ * // returns <ndarray>
1210
+ *
1211
+ * var opts = {
1212
+ * 'dtype': 'int32'
1213
+ * };
1214
+ * var y = filter( x, opts, isEven );
1215
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
1216
+ */
1217
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Int32Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): int32ndarray;
1218
+
1219
+ /**
1220
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1221
+ *
1222
+ * @param x - input ndarray
1223
+ * @param options - options
1224
+ * @param options.dtype - output ndarray data type
1225
+ * @param options.order - iteration order
1226
+ * @param predicate - predicate function
1227
+ * @param thisArg - predicate function execution context
1228
+ * @returns output ndarray
1229
+ *
1230
+ * @example
1231
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1232
+ * var Float64Array = require( '@stdlib/array-float64' );
1233
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1234
+ *
1235
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1236
+ * var shape = [ 2, 3 ];
1237
+ * var strides = [ 6, 1 ];
1238
+ * var offset = 1;
1239
+ *
1240
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1241
+ * // returns <ndarray>
1242
+ *
1243
+ * var opts = {
1244
+ * 'dtype': 'int16'
1245
+ * };
1246
+ * var y = filter( x, opts, isEven );
1247
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
1248
+ */
1249
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Int16Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): int16ndarray;
1250
+
1251
+ /**
1252
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1253
+ *
1254
+ * @param x - input ndarray
1255
+ * @param options - options
1256
+ * @param options.dtype - output ndarray data type
1257
+ * @param options.order - iteration order
1258
+ * @param predicate - predicate function
1259
+ * @param thisArg - predicate function execution context
1260
+ * @returns output ndarray
1261
+ *
1262
+ * @example
1263
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1264
+ * var Float64Array = require( '@stdlib/array-float64' );
1265
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1266
+ *
1267
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1268
+ * var shape = [ 2, 3 ];
1269
+ * var strides = [ 6, 1 ];
1270
+ * var offset = 1;
1271
+ *
1272
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1273
+ * // returns <ndarray>
1274
+ *
1275
+ * var opts = {
1276
+ * 'dtype': 'int8'
1277
+ * };
1278
+ * var y = filter( x, opts, isEven );
1279
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
1280
+ */
1281
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Int8Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): int8ndarray;
1282
+
1283
+ /**
1284
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1285
+ *
1286
+ * @param x - input ndarray
1287
+ * @param options - options
1288
+ * @param options.dtype - output ndarray data type
1289
+ * @param options.order - iteration order
1290
+ * @param predicate - predicate function
1291
+ * @param thisArg - predicate function execution context
1292
+ * @returns output ndarray
1293
+ *
1294
+ * @example
1295
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1296
+ * var Float64Array = require( '@stdlib/array-float64' );
1297
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1298
+ *
1299
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1300
+ * var shape = [ 2, 3 ];
1301
+ * var strides = [ 6, 1 ];
1302
+ * var offset = 1;
1303
+ *
1304
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1305
+ * // returns <ndarray>
1306
+ *
1307
+ * var opts = {
1308
+ * 'dtype': 'uint32'
1309
+ * };
1310
+ * var y = filter( x, opts, isEven );
1311
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
1312
+ */
1313
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Uint32Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): uint32ndarray;
1314
+
1315
+ /**
1316
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1317
+ *
1318
+ * @param x - input ndarray
1319
+ * @param options - options
1320
+ * @param options.dtype - output ndarray data type
1321
+ * @param options.order - iteration order
1322
+ * @param predicate - predicate function
1323
+ * @param thisArg - predicate function execution context
1324
+ * @returns output ndarray
1325
+ *
1326
+ * @example
1327
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1328
+ * var Float64Array = require( '@stdlib/array-float64' );
1329
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1330
+ *
1331
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1332
+ * var shape = [ 2, 3 ];
1333
+ * var strides = [ 6, 1 ];
1334
+ * var offset = 1;
1335
+ *
1336
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1337
+ * // returns <ndarray>
1338
+ *
1339
+ * var opts = {
1340
+ * 'dtype': 'uint16'
1341
+ * };
1342
+ * var y = filter( x, opts, isEven );
1343
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
1344
+ */
1345
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Uint16Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): uint16ndarray;
1346
+
1347
+ /**
1348
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1349
+ *
1350
+ * @param x - input ndarray
1351
+ * @param options - options
1352
+ * @param options.dtype - output ndarray data type
1353
+ * @param options.order - iteration order
1354
+ * @param predicate - predicate function
1355
+ * @param thisArg - predicate function execution context
1356
+ * @returns output ndarray
1357
+ *
1358
+ * @example
1359
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1360
+ * var Float64Array = require( '@stdlib/array-float64' );
1361
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1362
+ *
1363
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1364
+ * var shape = [ 2, 3 ];
1365
+ * var strides = [ 6, 1 ];
1366
+ * var offset = 1;
1367
+ *
1368
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1369
+ * // returns <ndarray>
1370
+ *
1371
+ * var opts = {
1372
+ * 'dtype': 'uint8'
1373
+ * };
1374
+ * var y = filter( x, opts, isEven );
1375
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
1376
+ */
1377
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Uint8Options, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): uint8ndarray;
1378
+
1379
+ /**
1380
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1381
+ *
1382
+ * @param x - input ndarray
1383
+ * @param options - options
1384
+ * @param options.dtype - output ndarray data type
1385
+ * @param options.order - iteration order
1386
+ * @param predicate - predicate function
1387
+ * @param thisArg - predicate function execution context
1388
+ * @returns output ndarray
1389
+ *
1390
+ * @example
1391
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1392
+ * var Float64Array = require( '@stdlib/array-float64' );
1393
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1394
+ *
1395
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1396
+ * var shape = [ 2, 3 ];
1397
+ * var strides = [ 6, 1 ];
1398
+ * var offset = 1;
1399
+ *
1400
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1401
+ * // returns <ndarray>
1402
+ *
1403
+ * var opts = {
1404
+ * 'dtype': 'uint8c'
1405
+ * };
1406
+ * var y = filter( x, opts, isEven );
1407
+ * // returns <ndarray>[ 2, 4, 8, 10 ]
1408
+ */
1409
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: Uint8COptions, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): uint8cndarray;
1410
+
1411
+ /**
1412
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1413
+ *
1414
+ * @param x - input ndarray
1415
+ * @param options - options
1416
+ * @param options.dtype - output ndarray data type
1417
+ * @param options.order - iteration order
1418
+ * @param predicate - predicate function
1419
+ * @param thisArg - predicate function execution context
1420
+ * @returns output ndarray
1421
+ *
1422
+ * @example
1423
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1424
+ * var Float64Array = require( '@stdlib/array-float64' );
1425
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1426
+ *
1427
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1428
+ * var shape = [ 2, 3 ];
1429
+ * var strides = [ 6, 1 ];
1430
+ * var offset = 1;
1431
+ *
1432
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1433
+ * // returns <ndarray>
1434
+ *
1435
+ * var opts = {
1436
+ * 'dtype': 'bool'
1437
+ * };
1438
+ * var y = filter( x, opts, isEven );
1439
+ * // returns <ndarray>[ true, true, true, true ]
1440
+ */
1441
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: BoolOptions, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): boolndarray;
1442
+
1443
+ /**
1444
+ * Returns a shallow copy of an ndarray containing only those elements which pass a test implemented by a predicate function.
1445
+ *
1446
+ * @param x - input ndarray
1447
+ * @param options - options
1448
+ * @param options.dtype - output ndarray data type
1449
+ * @param options.order - iteration order
1450
+ * @param predicate - predicate function
1451
+ * @param thisArg - predicate function execution context
1452
+ * @returns output ndarray
1453
+ *
1454
+ * @example
1455
+ * var isEven = require( '@stdlib/assert-is-even' ).isPrimitive;
1456
+ * var Float64Array = require( '@stdlib/array-float64' );
1457
+ * var ndarray = require( '@stdlib/ndarray-ctor' );
1458
+ *
1459
+ * var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1460
+ * var shape = [ 2, 3 ];
1461
+ * var strides = [ 6, 1 ];
1462
+ * var offset = 1;
1463
+ *
1464
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
1465
+ * // returns <ndarray>
1466
+ *
1467
+ * var opts = {
1468
+ * 'dtype': 'generic'
1469
+ * };
1470
+ * var y = filter( x, opts, isEven );
1471
+ * // returns <ndarray>[ 2.0, 4.0, 8.0, 10.0 ]
1472
+ */
1473
+ declare function filter<T = unknown, V = unknown>( x: typedndarray<T>, options: GenericOptions, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): genericndarray<T>;
1474
+
1475
+
1476
+ // EXPORTS //
1477
+
1478
+ export = filter;