@stdlib/ndarray-filter-map 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.
- package/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +362 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +1651 -0
- package/lib/index.js +56 -0
- package/lib/main.js +197 -0
- package/package.json +85 -0
|
@@ -0,0 +1,1651 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 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, ComplexLike } from '@stdlib/types/complex';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Callback invoked for each ndarray element.
|
|
30
|
+
*
|
|
31
|
+
* @returns output value
|
|
32
|
+
*/
|
|
33
|
+
type Nullary<U, V> = ( this: V ) => U | void;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Callback invoked for each ndarray element.
|
|
37
|
+
*
|
|
38
|
+
* @param value - current array element
|
|
39
|
+
* @returns output value
|
|
40
|
+
*/
|
|
41
|
+
type Unary<T, U, V> = ( this: V, value: T ) => U | void;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Callback invoked for each ndarray element.
|
|
45
|
+
*
|
|
46
|
+
* @param value - current array element
|
|
47
|
+
* @param indices - current array element indices
|
|
48
|
+
* @returns output value
|
|
49
|
+
*/
|
|
50
|
+
type Binary<T, U, V> = ( this: V, value: T, indices: Array<number> ) => U | void;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Callback invoked for each ndarray element.
|
|
54
|
+
*
|
|
55
|
+
* @param value - current array element
|
|
56
|
+
* @param indices - current array element indices
|
|
57
|
+
* @param arr - input array
|
|
58
|
+
* @returns output value
|
|
59
|
+
*/
|
|
60
|
+
type Ternary<T, U, V> = ( this: V, value: T, indices: Array<number>, arr: typedndarray<T> ) => U | void;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Callback invoked for each ndarray element.
|
|
64
|
+
*
|
|
65
|
+
* @param value - current array element
|
|
66
|
+
* @param indices - current array element indices
|
|
67
|
+
* @param arr - input array
|
|
68
|
+
* @returns output value
|
|
69
|
+
*/
|
|
70
|
+
type Callback<T, U, V> = Nullary<U, V> | Unary<T, U, V> | Binary<T, U, V> | Ternary<T, U, 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
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
298
|
+
*
|
|
299
|
+
* @param x - input ndarray
|
|
300
|
+
* @param fcn - callback function
|
|
301
|
+
* @param thisArg - callback function execution context
|
|
302
|
+
* @returns output ndarray
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
306
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
307
|
+
*
|
|
308
|
+
* function scale( z ) {
|
|
309
|
+
* if ( z > 5.0 ) {
|
|
310
|
+
* return z * 10.0;
|
|
311
|
+
* }
|
|
312
|
+
* }
|
|
313
|
+
*
|
|
314
|
+
* 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 ] );
|
|
315
|
+
* var shape = [ 2, 3 ];
|
|
316
|
+
* var strides = [ 6, 1 ];
|
|
317
|
+
* var offset = 1;
|
|
318
|
+
*
|
|
319
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
320
|
+
* // returns <ndarray>
|
|
321
|
+
*
|
|
322
|
+
* var y = filterMap( x, scale );
|
|
323
|
+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
|
|
324
|
+
*/
|
|
325
|
+
declare function filterMap<V = unknown>( x: float64ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float64ndarray;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
329
|
+
*
|
|
330
|
+
* @param x - input ndarray
|
|
331
|
+
* @param fcn - callback function
|
|
332
|
+
* @param thisArg - callback function execution context
|
|
333
|
+
* @returns output ndarray
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
337
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
338
|
+
*
|
|
339
|
+
* function scale( z ) {
|
|
340
|
+
* if ( z > 5.0 ) {
|
|
341
|
+
* return z * 10.0;
|
|
342
|
+
* }
|
|
343
|
+
* }
|
|
344
|
+
*
|
|
345
|
+
* 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 ] );
|
|
346
|
+
* var shape = [ 2, 3 ];
|
|
347
|
+
* var strides = [ 6, 1 ];
|
|
348
|
+
* var offset = 1;
|
|
349
|
+
*
|
|
350
|
+
* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' );
|
|
351
|
+
* // returns <ndarray>
|
|
352
|
+
*
|
|
353
|
+
* var y = filterMap( x, scale );
|
|
354
|
+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
|
|
355
|
+
*/
|
|
356
|
+
declare function filterMap<V = unknown>( x: float32ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float32ndarray;
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
360
|
+
*
|
|
361
|
+
* @param x - input ndarray
|
|
362
|
+
* @param fcn - callback function
|
|
363
|
+
* @param thisArg - callback function execution context
|
|
364
|
+
* @returns output ndarray
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
368
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
369
|
+
*
|
|
370
|
+
* function fcn( z, idx ) {
|
|
371
|
+
* if ( idx[ 0 ] > 0 ) {
|
|
372
|
+
* return z;
|
|
373
|
+
* }
|
|
374
|
+
* }
|
|
375
|
+
*
|
|
376
|
+
* 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 ] );
|
|
377
|
+
* var shape = [ 2, 3 ];
|
|
378
|
+
* var strides = [ 3, 1 ];
|
|
379
|
+
* var offset = 0;
|
|
380
|
+
*
|
|
381
|
+
* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' );
|
|
382
|
+
* // returns <ndarray>
|
|
383
|
+
*
|
|
384
|
+
* var y = filterMap( x, fcn );
|
|
385
|
+
* // returns <ndarray>
|
|
386
|
+
*/
|
|
387
|
+
declare function filterMap<V = unknown>( x: complex64ndarray, fcn: Callback<Complex64, ComplexLike, V>, thisArg?: ThisParameterType<Callback<Complex64, ComplexLike, V>> ): complex64ndarray;
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
391
|
+
*
|
|
392
|
+
* @param x - input ndarray
|
|
393
|
+
* @param fcn - callback function
|
|
394
|
+
* @param thisArg - callback function execution context
|
|
395
|
+
* @returns output ndarray
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* var Complex128Array = require( '@stdlib/array-complex128' );
|
|
399
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
400
|
+
*
|
|
401
|
+
* function fcn( z, idx ) {
|
|
402
|
+
* if ( idx[ 0 ] > 0 ) {
|
|
403
|
+
* return z;
|
|
404
|
+
* }
|
|
405
|
+
* }
|
|
406
|
+
*
|
|
407
|
+
* 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 ] );
|
|
408
|
+
* var shape = [ 2, 3 ];
|
|
409
|
+
* var strides = [ 3, 1 ];
|
|
410
|
+
* var offset = 0;
|
|
411
|
+
*
|
|
412
|
+
* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' );
|
|
413
|
+
* // returns <ndarray>
|
|
414
|
+
*
|
|
415
|
+
* var y = filterMap( x, fcn );
|
|
416
|
+
* // returns <ndarray>
|
|
417
|
+
*/
|
|
418
|
+
declare function filterMap<V = unknown>( x: complex128ndarray, fcn: Callback<Complex128, ComplexLike, V>, thisArg?: ThisParameterType<Callback<Complex128, ComplexLike, V>> ): complex128ndarray;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
422
|
+
*
|
|
423
|
+
* @param x - input ndarray
|
|
424
|
+
* @param fcn - callback function
|
|
425
|
+
* @param thisArg - callback function execution context
|
|
426
|
+
* @returns output ndarray
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* var Int32Array = require( '@stdlib/array-int32' );
|
|
430
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
431
|
+
*
|
|
432
|
+
* function scale( z ) {
|
|
433
|
+
* if ( z > 5 ) {
|
|
434
|
+
* return z * 10;
|
|
435
|
+
* }
|
|
436
|
+
* }
|
|
437
|
+
*
|
|
438
|
+
* var buffer = new Int32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
439
|
+
* var shape = [ 2, 3 ];
|
|
440
|
+
* var strides = [ 6, 1 ];
|
|
441
|
+
* var offset = 1;
|
|
442
|
+
*
|
|
443
|
+
* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' );
|
|
444
|
+
* // returns <ndarray>
|
|
445
|
+
*
|
|
446
|
+
* var y = filterMap( x, scale );
|
|
447
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
448
|
+
*/
|
|
449
|
+
declare function filterMap<V = unknown>( x: int32ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): int32ndarray;
|
|
450
|
+
|
|
451
|
+
/**
|
|
452
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
453
|
+
*
|
|
454
|
+
* @param x - input ndarray
|
|
455
|
+
* @param fcn - callback function
|
|
456
|
+
* @param thisArg - callback function execution context
|
|
457
|
+
* @returns output ndarray
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* var Int16Array = require( '@stdlib/array-int16' );
|
|
461
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
462
|
+
*
|
|
463
|
+
* function scale( z ) {
|
|
464
|
+
* if ( z > 5 ) {
|
|
465
|
+
* return z * 10;
|
|
466
|
+
* }
|
|
467
|
+
* }
|
|
468
|
+
*
|
|
469
|
+
* var buffer = new Int16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
470
|
+
* var shape = [ 2, 3 ];
|
|
471
|
+
* var strides = [ 6, 1 ];
|
|
472
|
+
* var offset = 1;
|
|
473
|
+
*
|
|
474
|
+
* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' );
|
|
475
|
+
* // returns <ndarray>
|
|
476
|
+
*
|
|
477
|
+
* var y = filterMap( x, scale );
|
|
478
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
479
|
+
*/
|
|
480
|
+
declare function filterMap<V = unknown>( x: int16ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): int16ndarray;
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
484
|
+
*
|
|
485
|
+
* @param x - input ndarray
|
|
486
|
+
* @param fcn - callback function
|
|
487
|
+
* @param thisArg - callback function execution context
|
|
488
|
+
* @returns output ndarray
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* var Int8Array = require( '@stdlib/array-int8' );
|
|
492
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
493
|
+
*
|
|
494
|
+
* function scale( z ) {
|
|
495
|
+
* if ( z > 5 ) {
|
|
496
|
+
* return z * 10;
|
|
497
|
+
* }
|
|
498
|
+
* }
|
|
499
|
+
*
|
|
500
|
+
* var buffer = new Int8Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
501
|
+
* var shape = [ 2, 3 ];
|
|
502
|
+
* var strides = [ 6, 1 ];
|
|
503
|
+
* var offset = 1;
|
|
504
|
+
*
|
|
505
|
+
* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' );
|
|
506
|
+
* // returns <ndarray>
|
|
507
|
+
*
|
|
508
|
+
* var y = filterMap( x, scale );
|
|
509
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
510
|
+
*/
|
|
511
|
+
declare function filterMap<V = unknown>( x: int8ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): int8ndarray;
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
515
|
+
*
|
|
516
|
+
* @param x - input ndarray
|
|
517
|
+
* @param fcn - callback function
|
|
518
|
+
* @param thisArg - callback function execution context
|
|
519
|
+
* @returns output ndarray
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* var Uint32Array = require( '@stdlib/array-uint32' );
|
|
523
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
524
|
+
*
|
|
525
|
+
* function scale( z ) {
|
|
526
|
+
* if ( z > 5 ) {
|
|
527
|
+
* return z * 10;
|
|
528
|
+
* }
|
|
529
|
+
* }
|
|
530
|
+
*
|
|
531
|
+
* var buffer = new Uint32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
532
|
+
* var shape = [ 2, 3 ];
|
|
533
|
+
* var strides = [ 6, 1 ];
|
|
534
|
+
* var offset = 1;
|
|
535
|
+
*
|
|
536
|
+
* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' );
|
|
537
|
+
* // returns <ndarray>
|
|
538
|
+
*
|
|
539
|
+
* var y = filterMap( x, scale );
|
|
540
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
541
|
+
*/
|
|
542
|
+
declare function filterMap<V = unknown>( x: uint32ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): uint32ndarray;
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
546
|
+
*
|
|
547
|
+
* @param x - input ndarray
|
|
548
|
+
* @param fcn - callback function
|
|
549
|
+
* @param thisArg - callback function execution context
|
|
550
|
+
* @returns output ndarray
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* var Uint16Array = require( '@stdlib/array-uint16' );
|
|
554
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
555
|
+
*
|
|
556
|
+
* function scale( z ) {
|
|
557
|
+
* if ( z > 5 ) {
|
|
558
|
+
* return z * 10;
|
|
559
|
+
* }
|
|
560
|
+
* }
|
|
561
|
+
*
|
|
562
|
+
* var buffer = new Uint16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
563
|
+
* var shape = [ 2, 3 ];
|
|
564
|
+
* var strides = [ 6, 1 ];
|
|
565
|
+
* var offset = 1;
|
|
566
|
+
*
|
|
567
|
+
* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' );
|
|
568
|
+
* // returns <ndarray>
|
|
569
|
+
*
|
|
570
|
+
* var y = filterMap( x, scale );
|
|
571
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
572
|
+
*/
|
|
573
|
+
declare function filterMap<V = unknown>( x: uint16ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): uint16ndarray;
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
577
|
+
*
|
|
578
|
+
* @param x - input ndarray
|
|
579
|
+
* @param fcn - callback function
|
|
580
|
+
* @param thisArg - callback function execution context
|
|
581
|
+
* @returns output ndarray
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
585
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
586
|
+
*
|
|
587
|
+
* function scale( z ) {
|
|
588
|
+
* if ( z > 5 ) {
|
|
589
|
+
* return z * 10;
|
|
590
|
+
* }
|
|
591
|
+
* }
|
|
592
|
+
*
|
|
593
|
+
* var buffer = new Uint8Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
594
|
+
* var shape = [ 2, 3 ];
|
|
595
|
+
* var strides = [ 6, 1 ];
|
|
596
|
+
* var offset = 1;
|
|
597
|
+
*
|
|
598
|
+
* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' );
|
|
599
|
+
* // returns <ndarray>
|
|
600
|
+
*
|
|
601
|
+
* var y = filterMap( x, scale );
|
|
602
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
603
|
+
*/
|
|
604
|
+
declare function filterMap<V = unknown>( x: uint8ndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): uint8ndarray;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
608
|
+
*
|
|
609
|
+
* @param x - input ndarray
|
|
610
|
+
* @param fcn - callback function
|
|
611
|
+
* @param thisArg - callback function execution context
|
|
612
|
+
* @returns output ndarray
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* var Uint8ClampedArray = require( '@stdlib/array-uint8c' );
|
|
616
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
617
|
+
*
|
|
618
|
+
* function scale( z ) {
|
|
619
|
+
* if ( z > 5 ) {
|
|
620
|
+
* return z * 10;
|
|
621
|
+
* }
|
|
622
|
+
* }
|
|
623
|
+
*
|
|
624
|
+
* var buffer = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
625
|
+
* var shape = [ 2, 3 ];
|
|
626
|
+
* var strides = [ 6, 1 ];
|
|
627
|
+
* var offset = 1;
|
|
628
|
+
*
|
|
629
|
+
* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' );
|
|
630
|
+
* // returns <ndarray>
|
|
631
|
+
*
|
|
632
|
+
* var y = filterMap( x, scale );
|
|
633
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
634
|
+
*/
|
|
635
|
+
declare function filterMap<V = unknown>( x: uint8cndarray, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): uint8cndarray;
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
639
|
+
*
|
|
640
|
+
* @param x - input ndarray
|
|
641
|
+
* @param fcn - callback function
|
|
642
|
+
* @param thisArg - callback function execution context
|
|
643
|
+
* @returns output ndarray
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* var BooleanArray = require( '@stdlib/array-bool' );
|
|
647
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
648
|
+
*
|
|
649
|
+
* function invert( v ) {
|
|
650
|
+
* if ( v ) {
|
|
651
|
+
* return !v;
|
|
652
|
+
* }
|
|
653
|
+
* }
|
|
654
|
+
*
|
|
655
|
+
* var buffer = new BooleanArray( [ true, true, true, true, true, true, true, true, true, true, true, true ] );
|
|
656
|
+
* var shape = [ 2, 3 ];
|
|
657
|
+
* var strides = [ 6, 1 ];
|
|
658
|
+
* var offset = 1;
|
|
659
|
+
*
|
|
660
|
+
* var x = ndarray( 'bool', buffer, shape, strides, offset, 'row-major' );
|
|
661
|
+
* // returns <ndarray>
|
|
662
|
+
*
|
|
663
|
+
* var y = filterMap( x, invert );
|
|
664
|
+
* // returns <ndarray>[ false, false, false ]
|
|
665
|
+
*/
|
|
666
|
+
declare function filterMap<V = unknown>( x: boolndarray, fcn: Callback<boolean, boolean, V>, thisArg?: ThisParameterType<Callback<boolean, boolean, V>> ): boolndarray;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
670
|
+
*
|
|
671
|
+
* @param x - input ndarray
|
|
672
|
+
* @param fcn - callback function
|
|
673
|
+
* @param thisArg - callback function execution context
|
|
674
|
+
* @returns output ndarray
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
678
|
+
*
|
|
679
|
+
* function scale( z ) {
|
|
680
|
+
* if ( z > 5 ) {
|
|
681
|
+
* return z * 10.0;
|
|
682
|
+
* }
|
|
683
|
+
* }
|
|
684
|
+
*
|
|
685
|
+
* 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 ];
|
|
686
|
+
* var shape = [ 2, 3 ];
|
|
687
|
+
* var strides = [ 6, 1 ];
|
|
688
|
+
* var offset = 1;
|
|
689
|
+
*
|
|
690
|
+
* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
|
|
691
|
+
* // returns <ndarray>
|
|
692
|
+
*
|
|
693
|
+
* var y = filterMap( x, scale );
|
|
694
|
+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
|
|
695
|
+
*/
|
|
696
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: genericndarray<T>, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): genericndarray<U>;
|
|
697
|
+
|
|
698
|
+
/**
|
|
699
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
700
|
+
*
|
|
701
|
+
* @param x - input ndarray
|
|
702
|
+
* @param options - function options
|
|
703
|
+
* @param options.order - iteration order
|
|
704
|
+
* @param fcn - callback function
|
|
705
|
+
* @param thisArg - callback function execution context
|
|
706
|
+
* @returns output ndarray
|
|
707
|
+
*
|
|
708
|
+
* @example
|
|
709
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
710
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
711
|
+
*
|
|
712
|
+
* function scale( z ) {
|
|
713
|
+
* if ( z > 5.0 ) {
|
|
714
|
+
* return z * 10.0;
|
|
715
|
+
* }
|
|
716
|
+
* }
|
|
717
|
+
*
|
|
718
|
+
* 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 ] );
|
|
719
|
+
* var shape = [ 2, 3 ];
|
|
720
|
+
* var strides = [ 6, 1 ];
|
|
721
|
+
* var offset = 1;
|
|
722
|
+
*
|
|
723
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
724
|
+
* // returns <ndarray>
|
|
725
|
+
*
|
|
726
|
+
* var opts = {
|
|
727
|
+
* 'order': 'row-major'
|
|
728
|
+
* };
|
|
729
|
+
* var y = filterMap( x, opts, scale );
|
|
730
|
+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
|
|
731
|
+
*/
|
|
732
|
+
declare function filterMap<V = unknown>( x: float64ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float64ndarray;
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
736
|
+
*
|
|
737
|
+
* @param x - input ndarray
|
|
738
|
+
* @param options - function options
|
|
739
|
+
* @param options.order - iteration order
|
|
740
|
+
* @param fcn - callback function
|
|
741
|
+
* @param thisArg - callback function execution context
|
|
742
|
+
* @returns output ndarray
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
746
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
747
|
+
*
|
|
748
|
+
* function scale( z ) {
|
|
749
|
+
* if ( z > 5.0 ) {
|
|
750
|
+
* return z * 10.0;
|
|
751
|
+
* }
|
|
752
|
+
* }
|
|
753
|
+
*
|
|
754
|
+
* 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 ] );
|
|
755
|
+
* var shape = [ 2, 3 ];
|
|
756
|
+
* var strides = [ 6, 1 ];
|
|
757
|
+
* var offset = 1;
|
|
758
|
+
*
|
|
759
|
+
* var x = ndarray( 'float32', buffer, shape, strides, offset, 'row-major' );
|
|
760
|
+
* // returns <ndarray>
|
|
761
|
+
*
|
|
762
|
+
* var opts = {
|
|
763
|
+
* 'order': 'row-major'
|
|
764
|
+
* };
|
|
765
|
+
* var y = filterMap( x, opts, scale );
|
|
766
|
+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
|
|
767
|
+
*/
|
|
768
|
+
declare function filterMap<V = unknown>( x: float32ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): float32ndarray;
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
772
|
+
*
|
|
773
|
+
* @param x - input ndarray
|
|
774
|
+
* @param options - function options
|
|
775
|
+
* @param options.order - iteration order
|
|
776
|
+
* @param fcn - callback function
|
|
777
|
+
* @param thisArg - callback function execution context
|
|
778
|
+
* @returns output ndarray
|
|
779
|
+
*
|
|
780
|
+
* @example
|
|
781
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
782
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
783
|
+
*
|
|
784
|
+
* function fcn( z, idx ) {
|
|
785
|
+
* if ( idx[ 0 ] > 0 ) {
|
|
786
|
+
* return z;
|
|
787
|
+
* }
|
|
788
|
+
* }
|
|
789
|
+
*
|
|
790
|
+
* 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 ] );
|
|
791
|
+
* var shape = [ 2, 3 ];
|
|
792
|
+
* var strides = [ 3, 1 ];
|
|
793
|
+
* var offset = 0;
|
|
794
|
+
*
|
|
795
|
+
* var x = ndarray( 'complex64', buffer, shape, strides, offset, 'row-major' );
|
|
796
|
+
* // returns <ndarray>
|
|
797
|
+
*
|
|
798
|
+
* var opts = {
|
|
799
|
+
* 'order': 'row-major'
|
|
800
|
+
* };
|
|
801
|
+
* var y = filterMap( x, opts, fcn );
|
|
802
|
+
* // returns <ndarray>
|
|
803
|
+
*/
|
|
804
|
+
declare function filterMap<V = unknown>( x: complex64ndarray, options: OrderOptions, fcn: Callback<Complex64, ComplexLike, V>, thisArg?: ThisParameterType<Callback<Complex64, ComplexLike, V>> ): complex64ndarray;
|
|
805
|
+
|
|
806
|
+
/**
|
|
807
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
808
|
+
*
|
|
809
|
+
* @param x - input ndarray
|
|
810
|
+
* @param options - function options
|
|
811
|
+
* @param options.order - iteration order
|
|
812
|
+
* @param fcn - callback function
|
|
813
|
+
* @param thisArg - callback function execution context
|
|
814
|
+
* @returns output ndarray
|
|
815
|
+
*
|
|
816
|
+
* @example
|
|
817
|
+
* var Complex128Array = require( '@stdlib/array-complex128' );
|
|
818
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
819
|
+
*
|
|
820
|
+
* function fcn( z, idx ) {
|
|
821
|
+
* if ( idx[ 0 ] > 0 ) {
|
|
822
|
+
* return z;
|
|
823
|
+
* }
|
|
824
|
+
* }
|
|
825
|
+
*
|
|
826
|
+
* 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 ] );
|
|
827
|
+
* var shape = [ 2, 3 ];
|
|
828
|
+
* var strides = [ 3, 1 ];
|
|
829
|
+
* var offset = 0;
|
|
830
|
+
*
|
|
831
|
+
* var x = ndarray( 'complex128', buffer, shape, strides, offset, 'row-major' );
|
|
832
|
+
* // returns <ndarray>
|
|
833
|
+
*
|
|
834
|
+
* var opts = {
|
|
835
|
+
* 'order': 'row-major'
|
|
836
|
+
* };
|
|
837
|
+
* var y = filterMap( x, opts, fcn );
|
|
838
|
+
* // returns <ndarray>
|
|
839
|
+
*/
|
|
840
|
+
declare function filterMap<V = unknown>( x: complex128ndarray, options: OrderOptions, fcn: Callback<Complex128, ComplexLike, V>, thisArg?: ThisParameterType<Callback<Complex128, ComplexLike, V>> ): complex128ndarray;
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
844
|
+
*
|
|
845
|
+
* @param x - input ndarray
|
|
846
|
+
* @param options - function options
|
|
847
|
+
* @param options.order - iteration order
|
|
848
|
+
* @param fcn - callback function
|
|
849
|
+
* @param thisArg - callback function execution context
|
|
850
|
+
* @returns output ndarray
|
|
851
|
+
*
|
|
852
|
+
* @example
|
|
853
|
+
* var Int32Array = require( '@stdlib/array-int32' );
|
|
854
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
855
|
+
*
|
|
856
|
+
* function scale( z ) {
|
|
857
|
+
* if ( z > 5 ) {
|
|
858
|
+
* return z * 10;
|
|
859
|
+
* }
|
|
860
|
+
* }
|
|
861
|
+
*
|
|
862
|
+
* var buffer = new Int32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
863
|
+
* var shape = [ 2, 3 ];
|
|
864
|
+
* var strides = [ 6, 1 ];
|
|
865
|
+
* var offset = 1;
|
|
866
|
+
*
|
|
867
|
+
* var x = ndarray( 'int32', buffer, shape, strides, offset, 'row-major' );
|
|
868
|
+
* // returns <ndarray>
|
|
869
|
+
*
|
|
870
|
+
* var opts = {
|
|
871
|
+
* 'order': 'row-major'
|
|
872
|
+
* };
|
|
873
|
+
* var y = filterMap( x, opts, scale );
|
|
874
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
875
|
+
*/
|
|
876
|
+
declare function filterMap<V = unknown>( x: int32ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): int32ndarray;
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
880
|
+
*
|
|
881
|
+
* @param x - input ndarray
|
|
882
|
+
* @param options - function options
|
|
883
|
+
* @param options.order - iteration order
|
|
884
|
+
* @param fcn - callback function
|
|
885
|
+
* @param thisArg - callback function execution context
|
|
886
|
+
* @returns output ndarray
|
|
887
|
+
*
|
|
888
|
+
* @example
|
|
889
|
+
* var Int16Array = require( '@stdlib/array-int16' );
|
|
890
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
891
|
+
*
|
|
892
|
+
* function scale( z ) {
|
|
893
|
+
* if ( z > 5 ) {
|
|
894
|
+
* return z * 10;
|
|
895
|
+
* }
|
|
896
|
+
* }
|
|
897
|
+
*
|
|
898
|
+
* var buffer = new Int16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
899
|
+
* var shape = [ 2, 3 ];
|
|
900
|
+
* var strides = [ 6, 1 ];
|
|
901
|
+
* var offset = 1;
|
|
902
|
+
*
|
|
903
|
+
* var x = ndarray( 'int16', buffer, shape, strides, offset, 'row-major' );
|
|
904
|
+
* // returns <ndarray>
|
|
905
|
+
*
|
|
906
|
+
* var opts = {
|
|
907
|
+
* 'order': 'row-major'
|
|
908
|
+
* };
|
|
909
|
+
* var y = filterMap( x, opts, scale );
|
|
910
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
911
|
+
*/
|
|
912
|
+
declare function filterMap<V = unknown>( x: int16ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): int16ndarray;
|
|
913
|
+
|
|
914
|
+
/**
|
|
915
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
916
|
+
*
|
|
917
|
+
* @param x - input ndarray
|
|
918
|
+
* @param options - function options
|
|
919
|
+
* @param options.order - iteration order
|
|
920
|
+
* @param fcn - callback function
|
|
921
|
+
* @param thisArg - callback function execution context
|
|
922
|
+
* @returns output ndarray
|
|
923
|
+
*
|
|
924
|
+
* @example
|
|
925
|
+
* var Int8Array = require( '@stdlib/array-int8' );
|
|
926
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
927
|
+
*
|
|
928
|
+
* function scale( z ) {
|
|
929
|
+
* if ( z > 5 ) {
|
|
930
|
+
* return z * 10;
|
|
931
|
+
* }
|
|
932
|
+
* }
|
|
933
|
+
*
|
|
934
|
+
* var buffer = new Int8Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
935
|
+
* var shape = [ 2, 3 ];
|
|
936
|
+
* var strides = [ 6, 1 ];
|
|
937
|
+
* var offset = 1;
|
|
938
|
+
*
|
|
939
|
+
* var x = ndarray( 'int8', buffer, shape, strides, offset, 'row-major' );
|
|
940
|
+
* // returns <ndarray>
|
|
941
|
+
*
|
|
942
|
+
* var opts = {
|
|
943
|
+
* 'order': 'row-major'
|
|
944
|
+
* };
|
|
945
|
+
* var y = filterMap( x, opts, scale );
|
|
946
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
947
|
+
*/
|
|
948
|
+
declare function filterMap<V = unknown>( x: int8ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): int8ndarray;
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
952
|
+
*
|
|
953
|
+
* @param x - input ndarray
|
|
954
|
+
* @param options - function options
|
|
955
|
+
* @param options.order - iteration order
|
|
956
|
+
* @param fcn - callback function
|
|
957
|
+
* @param thisArg - callback function execution context
|
|
958
|
+
* @returns output ndarray
|
|
959
|
+
*
|
|
960
|
+
* @example
|
|
961
|
+
* var Uint32Array = require( '@stdlib/array-uint32' );
|
|
962
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
963
|
+
*
|
|
964
|
+
* function scale( z ) {
|
|
965
|
+
* if ( z > 5 ) {
|
|
966
|
+
* return z * 10;
|
|
967
|
+
* }
|
|
968
|
+
* }
|
|
969
|
+
*
|
|
970
|
+
* var buffer = new Uint32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
971
|
+
* var shape = [ 2, 3 ];
|
|
972
|
+
* var strides = [ 6, 1 ];
|
|
973
|
+
* var offset = 1;
|
|
974
|
+
*
|
|
975
|
+
* var x = ndarray( 'uint32', buffer, shape, strides, offset, 'row-major' );
|
|
976
|
+
* // returns <ndarray>
|
|
977
|
+
*
|
|
978
|
+
* var opts = {
|
|
979
|
+
* 'order': 'row-major'
|
|
980
|
+
* };
|
|
981
|
+
* var y = filterMap( x, opts, scale );
|
|
982
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
983
|
+
*/
|
|
984
|
+
declare function filterMap<V = unknown>( x: uint32ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): uint32ndarray;
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
988
|
+
*
|
|
989
|
+
* @param x - input ndarray
|
|
990
|
+
* @param options - function options
|
|
991
|
+
* @param options.order - iteration order
|
|
992
|
+
* @param fcn - callback function
|
|
993
|
+
* @param thisArg - callback function execution context
|
|
994
|
+
* @returns output ndarray
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* var Uint16Array = require( '@stdlib/array-uint16' );
|
|
998
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
999
|
+
*
|
|
1000
|
+
* function scale( z ) {
|
|
1001
|
+
* if ( z > 5 ) {
|
|
1002
|
+
* return z * 10;
|
|
1003
|
+
* }
|
|
1004
|
+
* }
|
|
1005
|
+
*
|
|
1006
|
+
* var buffer = new Uint16Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
1007
|
+
* var shape = [ 2, 3 ];
|
|
1008
|
+
* var strides = [ 6, 1 ];
|
|
1009
|
+
* var offset = 1;
|
|
1010
|
+
*
|
|
1011
|
+
* var x = ndarray( 'uint16', buffer, shape, strides, offset, 'row-major' );
|
|
1012
|
+
* // returns <ndarray>
|
|
1013
|
+
*
|
|
1014
|
+
* var opts = {
|
|
1015
|
+
* 'order': 'row-major'
|
|
1016
|
+
* };
|
|
1017
|
+
* var y = filterMap( x, opts, scale );
|
|
1018
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1019
|
+
*/
|
|
1020
|
+
declare function filterMap<V = unknown>( x: uint16ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): uint16ndarray;
|
|
1021
|
+
|
|
1022
|
+
/**
|
|
1023
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1024
|
+
*
|
|
1025
|
+
* @param x - input ndarray
|
|
1026
|
+
* @param options - function options
|
|
1027
|
+
* @param options.order - iteration order
|
|
1028
|
+
* @param fcn - callback function
|
|
1029
|
+
* @param thisArg - callback function execution context
|
|
1030
|
+
* @returns output ndarray
|
|
1031
|
+
*
|
|
1032
|
+
* @example
|
|
1033
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
1034
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1035
|
+
*
|
|
1036
|
+
* function scale( z ) {
|
|
1037
|
+
* if ( z > 5 ) {
|
|
1038
|
+
* return z * 10;
|
|
1039
|
+
* }
|
|
1040
|
+
* }
|
|
1041
|
+
*
|
|
1042
|
+
* var buffer = new Uint8Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
1043
|
+
* var shape = [ 2, 3 ];
|
|
1044
|
+
* var strides = [ 6, 1 ];
|
|
1045
|
+
* var offset = 1;
|
|
1046
|
+
*
|
|
1047
|
+
* var x = ndarray( 'uint8', buffer, shape, strides, offset, 'row-major' );
|
|
1048
|
+
* // returns <ndarray>
|
|
1049
|
+
*
|
|
1050
|
+
* var opts = {
|
|
1051
|
+
* 'order': 'row-major'
|
|
1052
|
+
* };
|
|
1053
|
+
* var y = filterMap( x, opts, scale );
|
|
1054
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1055
|
+
*/
|
|
1056
|
+
declare function filterMap<V = unknown>( x: uint8ndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): uint8ndarray;
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1060
|
+
*
|
|
1061
|
+
* @param x - input ndarray
|
|
1062
|
+
* @param options - function options
|
|
1063
|
+
* @param options.order - iteration order
|
|
1064
|
+
* @param fcn - callback function
|
|
1065
|
+
* @param thisArg - callback function execution context
|
|
1066
|
+
* @returns output ndarray
|
|
1067
|
+
*
|
|
1068
|
+
* @example
|
|
1069
|
+
* var Uint8ClampedArray = require( '@stdlib/array-uint8c' );
|
|
1070
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1071
|
+
*
|
|
1072
|
+
* function scale( z ) {
|
|
1073
|
+
* if ( z > 5 ) {
|
|
1074
|
+
* return z * 10;
|
|
1075
|
+
* }
|
|
1076
|
+
* }
|
|
1077
|
+
*
|
|
1078
|
+
* var buffer = new Uint8ClampedArray( [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ] );
|
|
1079
|
+
* var shape = [ 2, 3 ];
|
|
1080
|
+
* var strides = [ 6, 1 ];
|
|
1081
|
+
* var offset = 1;
|
|
1082
|
+
*
|
|
1083
|
+
* var x = ndarray( 'uint8c', buffer, shape, strides, offset, 'row-major' );
|
|
1084
|
+
* // returns <ndarray>
|
|
1085
|
+
*
|
|
1086
|
+
* var opts = {
|
|
1087
|
+
* 'order': 'row-major'
|
|
1088
|
+
* };
|
|
1089
|
+
* var y = filterMap( x, opts, scale );
|
|
1090
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1091
|
+
*/
|
|
1092
|
+
declare function filterMap<V = unknown>( x: uint8cndarray, options: OrderOptions, fcn: Callback<number, number, V>, thisArg?: ThisParameterType<Callback<number, number, V>> ): uint8cndarray;
|
|
1093
|
+
|
|
1094
|
+
/**
|
|
1095
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1096
|
+
*
|
|
1097
|
+
* @param x - input ndarray
|
|
1098
|
+
* @param options - function options
|
|
1099
|
+
* @param options.order - iteration order
|
|
1100
|
+
* @param fcn - callback function
|
|
1101
|
+
* @param thisArg - callback function execution context
|
|
1102
|
+
* @returns output ndarray
|
|
1103
|
+
*
|
|
1104
|
+
* @example
|
|
1105
|
+
* var BooleanArray = require( '@stdlib/array-bool' );
|
|
1106
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1107
|
+
*
|
|
1108
|
+
* function invert( v ) {
|
|
1109
|
+
* if ( v ) {
|
|
1110
|
+
* return !v;
|
|
1111
|
+
* }
|
|
1112
|
+
* }
|
|
1113
|
+
*
|
|
1114
|
+
* var buffer = new BooleanArray( [ true, true, true, true, true, true, true, true, true, true, true, true ] );
|
|
1115
|
+
* var shape = [ 2, 3 ];
|
|
1116
|
+
* var strides = [ 6, 1 ];
|
|
1117
|
+
* var offset = 1;
|
|
1118
|
+
*
|
|
1119
|
+
* var x = ndarray( 'bool', buffer, shape, strides, offset, 'row-major' );
|
|
1120
|
+
* // returns <ndarray>
|
|
1121
|
+
*
|
|
1122
|
+
* var opts = {
|
|
1123
|
+
* 'order': 'row-major'
|
|
1124
|
+
* };
|
|
1125
|
+
* var y = filterMap( x, opts, invert );
|
|
1126
|
+
* // returns <ndarray>[ false, false, false ]
|
|
1127
|
+
*/
|
|
1128
|
+
declare function filterMap<V = unknown>( x: boolndarray, options: OrderOptions, fcn: Callback<boolean, boolean, V>, thisArg?: ThisParameterType<Callback<boolean, boolean, V>> ): boolndarray;
|
|
1129
|
+
|
|
1130
|
+
/**
|
|
1131
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1132
|
+
*
|
|
1133
|
+
* @param x - input ndarray
|
|
1134
|
+
* @param options - function options
|
|
1135
|
+
* @param options.order - iteration order
|
|
1136
|
+
* @param fcn - callback function
|
|
1137
|
+
* @param thisArg - callback function execution context
|
|
1138
|
+
* @returns output ndarray
|
|
1139
|
+
*
|
|
1140
|
+
* @example
|
|
1141
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1142
|
+
*
|
|
1143
|
+
* function scale( z ) {
|
|
1144
|
+
* if ( z > 5.0 ) {
|
|
1145
|
+
* return z * 10.0;
|
|
1146
|
+
* }
|
|
1147
|
+
* }
|
|
1148
|
+
*
|
|
1149
|
+
* 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 ];
|
|
1150
|
+
* var shape = [ 2, 3 ];
|
|
1151
|
+
* var strides = [ 6, 1 ];
|
|
1152
|
+
* var offset = 1;
|
|
1153
|
+
*
|
|
1154
|
+
* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );
|
|
1155
|
+
* // returns <ndarray>
|
|
1156
|
+
*
|
|
1157
|
+
* var opts = {
|
|
1158
|
+
* 'order': 'row-major'
|
|
1159
|
+
* };
|
|
1160
|
+
* var y = filterMap( x, opts, scale );
|
|
1161
|
+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
|
|
1162
|
+
*/
|
|
1163
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: genericndarray<T>, options: OrderOptions, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): genericndarray<U>;
|
|
1164
|
+
|
|
1165
|
+
/**
|
|
1166
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1167
|
+
*
|
|
1168
|
+
* @param x - input ndarray
|
|
1169
|
+
* @param options - options
|
|
1170
|
+
* @param options.dtype - output ndarray data type
|
|
1171
|
+
* @param options.order - iteration order
|
|
1172
|
+
* @param fcn - callback function
|
|
1173
|
+
* @param thisArg - callback function execution context
|
|
1174
|
+
* @returns output ndarray
|
|
1175
|
+
*
|
|
1176
|
+
* @example
|
|
1177
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1178
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1179
|
+
*
|
|
1180
|
+
* function scale( z ) {
|
|
1181
|
+
* if ( z > 5.0 ) {
|
|
1182
|
+
* return z * 10.0;
|
|
1183
|
+
* }
|
|
1184
|
+
* }
|
|
1185
|
+
*
|
|
1186
|
+
* 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 ] );
|
|
1187
|
+
* var shape = [ 2, 3 ];
|
|
1188
|
+
* var strides = [ 6, 1 ];
|
|
1189
|
+
* var offset = 1;
|
|
1190
|
+
*
|
|
1191
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1192
|
+
* // returns <ndarray>
|
|
1193
|
+
*
|
|
1194
|
+
* var opts = {
|
|
1195
|
+
* 'dtype': 'float64'
|
|
1196
|
+
* };
|
|
1197
|
+
* var y = filterMap( x, opts, scale );
|
|
1198
|
+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
|
|
1199
|
+
*/
|
|
1200
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Float64Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): float64ndarray;
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1204
|
+
*
|
|
1205
|
+
* @param x - input ndarray
|
|
1206
|
+
* @param options - options
|
|
1207
|
+
* @param options.dtype - output ndarray data type
|
|
1208
|
+
* @param options.order - iteration order
|
|
1209
|
+
* @param fcn - callback function
|
|
1210
|
+
* @param thisArg - callback function execution context
|
|
1211
|
+
* @returns output ndarray
|
|
1212
|
+
*
|
|
1213
|
+
* @example
|
|
1214
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1215
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1216
|
+
*
|
|
1217
|
+
* function scale( z ) {
|
|
1218
|
+
* if ( z > 5.0 ) {
|
|
1219
|
+
* return z * 10.0;
|
|
1220
|
+
* }
|
|
1221
|
+
* }
|
|
1222
|
+
*
|
|
1223
|
+
* 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 ] );
|
|
1224
|
+
* var shape = [ 2, 3 ];
|
|
1225
|
+
* var strides = [ 6, 1 ];
|
|
1226
|
+
* var offset = 1;
|
|
1227
|
+
*
|
|
1228
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1229
|
+
* // returns <ndarray>
|
|
1230
|
+
*
|
|
1231
|
+
* var opts = {
|
|
1232
|
+
* 'dtype': 'float32'
|
|
1233
|
+
* };
|
|
1234
|
+
* var y = filterMap( x, opts, scale );
|
|
1235
|
+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
|
|
1236
|
+
*/
|
|
1237
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Float32Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): float32ndarray;
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1241
|
+
*
|
|
1242
|
+
* @param x - input ndarray
|
|
1243
|
+
* @param options - options
|
|
1244
|
+
* @param options.dtype - output ndarray data type
|
|
1245
|
+
* @param options.order - iteration order
|
|
1246
|
+
* @param fcn - callback function
|
|
1247
|
+
* @param thisArg - callback function execution context
|
|
1248
|
+
* @returns output ndarray
|
|
1249
|
+
*
|
|
1250
|
+
* @example
|
|
1251
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1252
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1253
|
+
* var Complex128 = require( '@stdlib/complex-float64-ctor' );
|
|
1254
|
+
*
|
|
1255
|
+
* function fcn( z, idx ) {
|
|
1256
|
+
* if ( idx[ 0 ] > 0 ) {
|
|
1257
|
+
* return new Complex128( z, 0.0 );
|
|
1258
|
+
* }
|
|
1259
|
+
* }
|
|
1260
|
+
*
|
|
1261
|
+
* 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 ] );
|
|
1262
|
+
* var shape = [ 2, 3 ];
|
|
1263
|
+
* var strides = [ 6, 1 ];
|
|
1264
|
+
* var offset = 1;
|
|
1265
|
+
*
|
|
1266
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1267
|
+
* // returns <ndarray>
|
|
1268
|
+
*
|
|
1269
|
+
* var opts = {
|
|
1270
|
+
* 'dtype': 'complex128'
|
|
1271
|
+
* };
|
|
1272
|
+
* var y = filterMap( x, opts, fcn );
|
|
1273
|
+
* // returns <ndarray>
|
|
1274
|
+
*/
|
|
1275
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Complex128Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): complex128ndarray;
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1279
|
+
*
|
|
1280
|
+
* @param x - input ndarray
|
|
1281
|
+
* @param options - options
|
|
1282
|
+
* @param options.dtype - output ndarray data type
|
|
1283
|
+
* @param options.order - iteration order
|
|
1284
|
+
* @param fcn - callback function
|
|
1285
|
+
* @param thisArg - callback function execution context
|
|
1286
|
+
* @returns output ndarray
|
|
1287
|
+
*
|
|
1288
|
+
* @example
|
|
1289
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1290
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1291
|
+
* var Complex64 = require( '@stdlib/complex-float64-ctor' );
|
|
1292
|
+
*
|
|
1293
|
+
* function fcn( z, idx ) {
|
|
1294
|
+
* if ( idx[ 0 ] > 0 ) {
|
|
1295
|
+
* return new Complex64( z, 0.0 );
|
|
1296
|
+
* }
|
|
1297
|
+
* }
|
|
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': 'complex64'
|
|
1309
|
+
* };
|
|
1310
|
+
* var y = filterMap( x, opts, fcn );
|
|
1311
|
+
* // returns <ndarray>
|
|
1312
|
+
*/
|
|
1313
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Complex64Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): complex64ndarray;
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback 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 fcn - callback function
|
|
1323
|
+
* @param thisArg - callback function execution context
|
|
1324
|
+
* @returns output ndarray
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1328
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1329
|
+
*
|
|
1330
|
+
* function scale( z ) {
|
|
1331
|
+
* if ( z > 5.0 ) {
|
|
1332
|
+
* return z * 10.0;
|
|
1333
|
+
* }
|
|
1334
|
+
* }
|
|
1335
|
+
*
|
|
1336
|
+
* 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 ] );
|
|
1337
|
+
* var shape = [ 2, 3 ];
|
|
1338
|
+
* var strides = [ 6, 1 ];
|
|
1339
|
+
* var offset = 1;
|
|
1340
|
+
*
|
|
1341
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1342
|
+
* // returns <ndarray>
|
|
1343
|
+
*
|
|
1344
|
+
* var opts = {
|
|
1345
|
+
* 'dtype': 'int32'
|
|
1346
|
+
* };
|
|
1347
|
+
* var y = filterMap( x, opts, scale );
|
|
1348
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1349
|
+
*/
|
|
1350
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Int32Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): int32ndarray;
|
|
1351
|
+
|
|
1352
|
+
/**
|
|
1353
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1354
|
+
*
|
|
1355
|
+
* @param x - input ndarray
|
|
1356
|
+
* @param options - options
|
|
1357
|
+
* @param options.dtype - output ndarray data type
|
|
1358
|
+
* @param options.order - iteration order
|
|
1359
|
+
* @param fcn - callback function
|
|
1360
|
+
* @param thisArg - callback function execution context
|
|
1361
|
+
* @returns output ndarray
|
|
1362
|
+
*
|
|
1363
|
+
* @example
|
|
1364
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1365
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1366
|
+
*
|
|
1367
|
+
* function scale( z ) {
|
|
1368
|
+
* if ( z > 5.0 ) {
|
|
1369
|
+
* return z * 10.0;
|
|
1370
|
+
* }
|
|
1371
|
+
* }
|
|
1372
|
+
*
|
|
1373
|
+
* 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 ] );
|
|
1374
|
+
* var shape = [ 2, 3 ];
|
|
1375
|
+
* var strides = [ 6, 1 ];
|
|
1376
|
+
* var offset = 1;
|
|
1377
|
+
*
|
|
1378
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1379
|
+
* // returns <ndarray>
|
|
1380
|
+
*
|
|
1381
|
+
* var opts = {
|
|
1382
|
+
* 'dtype': 'int16'
|
|
1383
|
+
* };
|
|
1384
|
+
* var y = filterMap( x, opts, scale );
|
|
1385
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1386
|
+
*/
|
|
1387
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Int16Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): int16ndarray;
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1391
|
+
*
|
|
1392
|
+
* @param x - input ndarray
|
|
1393
|
+
* @param options - options
|
|
1394
|
+
* @param options.dtype - output ndarray data type
|
|
1395
|
+
* @param options.order - iteration order
|
|
1396
|
+
* @param fcn - callback function
|
|
1397
|
+
* @param thisArg - callback function execution context
|
|
1398
|
+
* @returns output ndarray
|
|
1399
|
+
*
|
|
1400
|
+
* @example
|
|
1401
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1402
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1403
|
+
*
|
|
1404
|
+
* function scale( z ) {
|
|
1405
|
+
* if ( z > 5.0 ) {
|
|
1406
|
+
* return z * 10.0;
|
|
1407
|
+
* }
|
|
1408
|
+
* }
|
|
1409
|
+
*
|
|
1410
|
+
* 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 ] );
|
|
1411
|
+
* var shape = [ 2, 3 ];
|
|
1412
|
+
* var strides = [ 6, 1 ];
|
|
1413
|
+
* var offset = 1;
|
|
1414
|
+
*
|
|
1415
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1416
|
+
* // returns <ndarray>
|
|
1417
|
+
*
|
|
1418
|
+
* var opts = {
|
|
1419
|
+
* 'dtype': 'int8'
|
|
1420
|
+
* };
|
|
1421
|
+
* var y = filterMap( x, opts, scale );
|
|
1422
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1423
|
+
*/
|
|
1424
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Int8Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): int8ndarray;
|
|
1425
|
+
|
|
1426
|
+
/**
|
|
1427
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1428
|
+
*
|
|
1429
|
+
* @param x - input ndarray
|
|
1430
|
+
* @param options - options
|
|
1431
|
+
* @param options.dtype - output ndarray data type
|
|
1432
|
+
* @param options.order - iteration order
|
|
1433
|
+
* @param fcn - callback function
|
|
1434
|
+
* @param thisArg - callback function execution context
|
|
1435
|
+
* @returns output ndarray
|
|
1436
|
+
*
|
|
1437
|
+
* @example
|
|
1438
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1439
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1440
|
+
*
|
|
1441
|
+
* function scale( z ) {
|
|
1442
|
+
* if ( z > 5.0 ) {
|
|
1443
|
+
* return z * 10.0;
|
|
1444
|
+
* }
|
|
1445
|
+
* }
|
|
1446
|
+
*
|
|
1447
|
+
* 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 ] );
|
|
1448
|
+
* var shape = [ 2, 3 ];
|
|
1449
|
+
* var strides = [ 6, 1 ];
|
|
1450
|
+
* var offset = 1;
|
|
1451
|
+
*
|
|
1452
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1453
|
+
* // returns <ndarray>
|
|
1454
|
+
*
|
|
1455
|
+
* var opts = {
|
|
1456
|
+
* 'dtype': 'uint32'
|
|
1457
|
+
* };
|
|
1458
|
+
* var y = filterMap( x, opts, scale );
|
|
1459
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1460
|
+
*/
|
|
1461
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Uint32Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): uint32ndarray;
|
|
1462
|
+
|
|
1463
|
+
/**
|
|
1464
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1465
|
+
*
|
|
1466
|
+
* @param x - input ndarray
|
|
1467
|
+
* @param options - options
|
|
1468
|
+
* @param options.dtype - output ndarray data type
|
|
1469
|
+
* @param options.order - iteration order
|
|
1470
|
+
* @param fcn - callback function
|
|
1471
|
+
* @param thisArg - callback function execution context
|
|
1472
|
+
* @returns output ndarray
|
|
1473
|
+
*
|
|
1474
|
+
* @example
|
|
1475
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1476
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1477
|
+
*
|
|
1478
|
+
* function scale( z ) {
|
|
1479
|
+
* if ( z > 5.0 ) {
|
|
1480
|
+
* return z * 10.0;
|
|
1481
|
+
* }
|
|
1482
|
+
* }
|
|
1483
|
+
*
|
|
1484
|
+
* 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 ] );
|
|
1485
|
+
* var shape = [ 2, 3 ];
|
|
1486
|
+
* var strides = [ 6, 1 ];
|
|
1487
|
+
* var offset = 1;
|
|
1488
|
+
*
|
|
1489
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1490
|
+
* // returns <ndarray>
|
|
1491
|
+
*
|
|
1492
|
+
* var opts = {
|
|
1493
|
+
* 'dtype': 'uint16'
|
|
1494
|
+
* };
|
|
1495
|
+
* var y = filterMap( x, opts, scale );
|
|
1496
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1497
|
+
*/
|
|
1498
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Uint16Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): uint16ndarray;
|
|
1499
|
+
|
|
1500
|
+
/**
|
|
1501
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1502
|
+
*
|
|
1503
|
+
* @param x - input ndarray
|
|
1504
|
+
* @param options - options
|
|
1505
|
+
* @param options.dtype - output ndarray data type
|
|
1506
|
+
* @param options.order - iteration order
|
|
1507
|
+
* @param fcn - callback function
|
|
1508
|
+
* @param thisArg - callback function execution context
|
|
1509
|
+
* @returns output ndarray
|
|
1510
|
+
*
|
|
1511
|
+
* @example
|
|
1512
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1513
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1514
|
+
*
|
|
1515
|
+
* function scale( z ) {
|
|
1516
|
+
* if ( z > 5.0 ) {
|
|
1517
|
+
* return z * 10.0;
|
|
1518
|
+
* }
|
|
1519
|
+
* }
|
|
1520
|
+
*
|
|
1521
|
+
* 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 ] );
|
|
1522
|
+
* var shape = [ 2, 3 ];
|
|
1523
|
+
* var strides = [ 6, 1 ];
|
|
1524
|
+
* var offset = 1;
|
|
1525
|
+
*
|
|
1526
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1527
|
+
* // returns <ndarray>
|
|
1528
|
+
*
|
|
1529
|
+
* var opts = {
|
|
1530
|
+
* 'dtype': 'uint8'
|
|
1531
|
+
* };
|
|
1532
|
+
* var y = filterMap( x, opts, scale );
|
|
1533
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1534
|
+
*/
|
|
1535
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Uint8Options, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): uint8ndarray;
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1539
|
+
*
|
|
1540
|
+
* @param x - input ndarray
|
|
1541
|
+
* @param options - options
|
|
1542
|
+
* @param options.dtype - output ndarray data type
|
|
1543
|
+
* @param options.order - iteration order
|
|
1544
|
+
* @param fcn - callback function
|
|
1545
|
+
* @param thisArg - callback function execution context
|
|
1546
|
+
* @returns output ndarray
|
|
1547
|
+
*
|
|
1548
|
+
* @example
|
|
1549
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1550
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1551
|
+
*
|
|
1552
|
+
* function scale( z ) {
|
|
1553
|
+
* if ( z > 5.0 ) {
|
|
1554
|
+
* return z * 10.0;
|
|
1555
|
+
* }
|
|
1556
|
+
* }
|
|
1557
|
+
*
|
|
1558
|
+
* 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 ] );
|
|
1559
|
+
* var shape = [ 2, 3 ];
|
|
1560
|
+
* var strides = [ 6, 1 ];
|
|
1561
|
+
* var offset = 1;
|
|
1562
|
+
*
|
|
1563
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1564
|
+
* // returns <ndarray>
|
|
1565
|
+
*
|
|
1566
|
+
* var opts = {
|
|
1567
|
+
* 'dtype': 'uint8c'
|
|
1568
|
+
* };
|
|
1569
|
+
* var y = filterMap( x, opts, scale );
|
|
1570
|
+
* // returns <ndarray>[ 80, 90, 100 ]
|
|
1571
|
+
*/
|
|
1572
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: Uint8COptions, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): uint8cndarray;
|
|
1573
|
+
|
|
1574
|
+
/**
|
|
1575
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1576
|
+
*
|
|
1577
|
+
* @param x - input ndarray
|
|
1578
|
+
* @param options - options
|
|
1579
|
+
* @param options.dtype - output ndarray data type
|
|
1580
|
+
* @param options.order - iteration order
|
|
1581
|
+
* @param fcn - callback function
|
|
1582
|
+
* @param thisArg - callback function execution context
|
|
1583
|
+
* @returns output ndarray
|
|
1584
|
+
*
|
|
1585
|
+
* @example
|
|
1586
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1587
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1588
|
+
*
|
|
1589
|
+
* function fcn( z ) {
|
|
1590
|
+
* if ( z > 5.0 ) {
|
|
1591
|
+
* return true;
|
|
1592
|
+
* }
|
|
1593
|
+
* }
|
|
1594
|
+
*
|
|
1595
|
+
* 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 ] );
|
|
1596
|
+
* var shape = [ 2, 3 ];
|
|
1597
|
+
* var strides = [ 6, 1 ];
|
|
1598
|
+
* var offset = 1;
|
|
1599
|
+
*
|
|
1600
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1601
|
+
* // returns <ndarray>
|
|
1602
|
+
*
|
|
1603
|
+
* var opts = {
|
|
1604
|
+
* 'dtype': 'bool'
|
|
1605
|
+
* };
|
|
1606
|
+
* var y = filterMap( x, opts, fcn );
|
|
1607
|
+
* // returns <ndarray>[ true, true, true ]
|
|
1608
|
+
*/
|
|
1609
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: BoolOptions, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): boolndarray;
|
|
1610
|
+
|
|
1611
|
+
/**
|
|
1612
|
+
* Filters and maps elements in an input ndarray to elements in a new output ndarray according to a callback function.
|
|
1613
|
+
*
|
|
1614
|
+
* @param x - input ndarray
|
|
1615
|
+
* @param options - options
|
|
1616
|
+
* @param options.dtype - output ndarray data type
|
|
1617
|
+
* @param options.order - iteration order
|
|
1618
|
+
* @param fcn - callback function
|
|
1619
|
+
* @param thisArg - callback function execution context
|
|
1620
|
+
* @returns output ndarray
|
|
1621
|
+
*
|
|
1622
|
+
* @example
|
|
1623
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
1624
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
1625
|
+
*
|
|
1626
|
+
* function scale( z ) {
|
|
1627
|
+
* if ( z > 5.0 ) {
|
|
1628
|
+
* return z * 10.0;
|
|
1629
|
+
* }
|
|
1630
|
+
* }
|
|
1631
|
+
*
|
|
1632
|
+
* 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 ] );
|
|
1633
|
+
* var shape = [ 2, 3 ];
|
|
1634
|
+
* var strides = [ 6, 1 ];
|
|
1635
|
+
* var offset = 1;
|
|
1636
|
+
*
|
|
1637
|
+
* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
|
|
1638
|
+
* // returns <ndarray>
|
|
1639
|
+
*
|
|
1640
|
+
* var opts = {
|
|
1641
|
+
* 'dtype': 'generic'
|
|
1642
|
+
* };
|
|
1643
|
+
* var y = filterMap( x, opts, scale );
|
|
1644
|
+
* // returns <ndarray>[ 80.0, 90.0, 100.0 ]
|
|
1645
|
+
*/
|
|
1646
|
+
declare function filterMap<T = unknown, U = unknown, V = unknown>( x: typedndarray<T>, options: GenericOptions, fcn: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): genericndarray<U>;
|
|
1647
|
+
|
|
1648
|
+
|
|
1649
|
+
// EXPORTS //
|
|
1650
|
+
|
|
1651
|
+
export = filterMap;
|