@stdlib/strided-base 0.0.7 → 0.2.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 +0 -304
- package/NOTICE +1 -1
- package/README.md +76 -10
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +668 -84
- package/lib/index.js +76 -0
- package/package.json +141 -113
- package/docs/types/test.ts +0 -29
package/docs/types/index.d.ts
CHANGED
|
@@ -16,27 +16,39 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
|
-
/*
|
|
22
|
-
/* tslint:disable:max-file-line-count */
|
|
21
|
+
/* eslint-disable max-lines */
|
|
23
22
|
|
|
24
23
|
import binary = require( '@stdlib/strided-base-binary' );
|
|
25
24
|
import binaryAddonDispatch = require( '@stdlib/strided-base-binary-addon-dispatch' );
|
|
25
|
+
import binaryDtypeSignatures = require( '@stdlib/strided-base-binary-dtype-signatures' );
|
|
26
|
+
import binarySignatureCallbacks = require( '@stdlib/strided-base-binary-signature-callbacks' );
|
|
27
|
+
import cmap = require( '@stdlib/strided-base-cmap' );
|
|
26
28
|
import dmap = require( '@stdlib/strided-base-dmap' );
|
|
27
29
|
import dmap2 = require( '@stdlib/strided-base-dmap2' );
|
|
28
30
|
import dmskmap = require( '@stdlib/strided-base-dmskmap' );
|
|
29
31
|
import dmskmap2 = require( '@stdlib/strided-base-dmskmap2' );
|
|
30
32
|
import dtypeEnum2Str = require( '@stdlib/strided-base-dtype-enum2str' );
|
|
31
33
|
import dtypeResolveEnum = require( '@stdlib/strided-base-dtype-resolve-enum' );
|
|
34
|
+
import dtypeResolveStr = require( '@stdlib/strided-base-dtype-resolve-str' );
|
|
32
35
|
import dtypeStr2Enum = require( '@stdlib/strided-base-dtype-str2enum' );
|
|
33
36
|
import mapBy = require( '@stdlib/strided-base-map-by' );
|
|
34
37
|
import mapBy2 = require( '@stdlib/strided-base-map-by2' );
|
|
38
|
+
import maxViewBufferIndex = require( '@stdlib/strided-base-max-view-buffer-index' );
|
|
35
39
|
import metaDataProps = require( '@stdlib/strided-base-meta-data-props' );
|
|
40
|
+
import minViewBufferIndex = require( '@stdlib/strided-base-min-view-buffer-index' );
|
|
36
41
|
import mskunary = require( '@stdlib/strided-base-mskunary' );
|
|
42
|
+
import mskunaryAddonDispatch = require( '@stdlib/strided-base-mskunary-addon-dispatch' );
|
|
43
|
+
import mskunaryDtypeSignatures = require( '@stdlib/strided-base-mskunary-dtype-signatures' );
|
|
44
|
+
import mskunarySignatureCallbacks = require( '@stdlib/strided-base-mskunary-signature-callbacks' );
|
|
37
45
|
import nullary = require( '@stdlib/strided-base-nullary' );
|
|
46
|
+
import nullaryAddonDispatch = require( '@stdlib/strided-base-nullary-addon-dispatch' );
|
|
47
|
+
import offsetView = require( '@stdlib/strided-base-offset-view' );
|
|
38
48
|
import quaternary = require( '@stdlib/strided-base-quaternary' );
|
|
39
49
|
import quinary = require( '@stdlib/strided-base-quinary' );
|
|
50
|
+
import reinterpretComplex64 = require( '@stdlib/strided-base-reinterpret-complex64' );
|
|
51
|
+
import reinterpretComplex128 = require( '@stdlib/strided-base-reinterpret-complex128' );
|
|
40
52
|
import smap = require( '@stdlib/strided-base-smap' );
|
|
41
53
|
import smap2 = require( '@stdlib/strided-base-smap2' );
|
|
42
54
|
import smskmap = require( '@stdlib/strided-base-smskmap' );
|
|
@@ -44,6 +56,10 @@ import smskmap2 = require( '@stdlib/strided-base-smskmap2' );
|
|
|
44
56
|
import ternary = require( '@stdlib/strided-base-ternary' );
|
|
45
57
|
import unary = require( '@stdlib/strided-base-unary' );
|
|
46
58
|
import unaryAddonDispatch = require( '@stdlib/strided-base-unary-addon-dispatch' );
|
|
59
|
+
import unaryBy = require( '@stdlib/strided-base-unary-by' );
|
|
60
|
+
import unaryDtypeSignatures = require( '@stdlib/strided-base-unary-dtype-signatures' );
|
|
61
|
+
import unarySignatureCallbacks = require( '@stdlib/strided-base-unary-signature-callbacks' );
|
|
62
|
+
import zmap = require( '@stdlib/strided-base-zmap' );
|
|
47
63
|
|
|
48
64
|
/**
|
|
49
65
|
* Interface describing the `base` namespace.
|
|
@@ -58,7 +74,7 @@ interface Namespace {
|
|
|
58
74
|
* @param fcn - binary callback
|
|
59
75
|
*
|
|
60
76
|
* @example
|
|
61
|
-
* var Float64Array = require(
|
|
77
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
62
78
|
*
|
|
63
79
|
* function add( x, y ) {
|
|
64
80
|
* return x + y;
|
|
@@ -77,7 +93,7 @@ interface Namespace {
|
|
|
77
93
|
* // => <Float64Array>[ 2.0, 4.0, 6.0, 8.0, 10.0 ]
|
|
78
94
|
*
|
|
79
95
|
* @example
|
|
80
|
-
* var Float64Array = require(
|
|
96
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
81
97
|
*
|
|
82
98
|
* function add( x, y ) {
|
|
83
99
|
* return x + y;
|
|
@@ -141,6 +157,146 @@ interface Namespace {
|
|
|
141
157
|
*/
|
|
142
158
|
binaryAddonDispatch: typeof binaryAddonDispatch;
|
|
143
159
|
|
|
160
|
+
/**
|
|
161
|
+
* Generates a list of binary interface signatures from strided array data types.
|
|
162
|
+
*
|
|
163
|
+
* ## Notes
|
|
164
|
+
*
|
|
165
|
+
* - The function returns a strided array having a stride length of `3` (i.e., every `3` elements define a binary interface signature).
|
|
166
|
+
* - For each signature (i.e., set of three consecutive non-overlapping strided array elements), the first two elements are the input data types and the third element is the return data type.
|
|
167
|
+
* - All signatures follow type promotion rules.
|
|
168
|
+
*
|
|
169
|
+
* @param dtypes1 - list of supported data types for the first argument
|
|
170
|
+
* @param dtypes2 - list of supported data types for the second argument
|
|
171
|
+
* @param dtypes3 - list of supported data types for the output
|
|
172
|
+
* @param options - options
|
|
173
|
+
* @param options.enums - boolean flag indicating whether to return signatures as a list of enumeration constants
|
|
174
|
+
* @throws must provide recognized data types
|
|
175
|
+
* @returns strided array containing binary interface signatures
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* var dtypes = [
|
|
179
|
+
* 'float64',
|
|
180
|
+
* 'float32',
|
|
181
|
+
* 'int32',
|
|
182
|
+
* 'uint8'
|
|
183
|
+
* ];
|
|
184
|
+
*
|
|
185
|
+
* var sigs = ns.binaryDtypeSignatures( dtypes, dtypes, dtypes );
|
|
186
|
+
* // returns [ 'float32', 'float32', 'float32', ... ]
|
|
187
|
+
*/
|
|
188
|
+
binaryDtypeSignatures: typeof binaryDtypeSignatures;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Assigns callbacks to binary interfaces according to type promotion rules.
|
|
192
|
+
*
|
|
193
|
+
* ## Notes
|
|
194
|
+
*
|
|
195
|
+
* - The function assumes that the provided signature array has the following properties:
|
|
196
|
+
*
|
|
197
|
+
* - a strided array having a stride length of `3` (i.e., every `3` elements define a binary interface signature).
|
|
198
|
+
* - for each signature (i.e., set of three consecutive non-overlapping strided array elements), the first two elements are the input data types and the third element is the return data type.
|
|
199
|
+
* - all signatures follow type promotion rules.
|
|
200
|
+
*
|
|
201
|
+
* @param table - callback table
|
|
202
|
+
* @param table.default - default callback
|
|
203
|
+
* @param table.complex64 - callback for single-precision complex floating-point numbers
|
|
204
|
+
* @param table.complex128 - callback for double-precision complex floating-point numbers
|
|
205
|
+
* @param signatures - strided array containing binary interface signatures
|
|
206
|
+
* @returns list of callbacks
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* var signatures = require( '@stdlib/strided-base-binary-dtype-signatures' );
|
|
210
|
+
* var add = require( '@stdlib/math-base-ops-add' );
|
|
211
|
+
* var cadd = require( '@stdlib/math-base-ops-cadd' );
|
|
212
|
+
* var caddf = require( '@stdlib/math-base-ops-caddf' );
|
|
213
|
+
*
|
|
214
|
+
* var dtypes = [
|
|
215
|
+
* 'float64',
|
|
216
|
+
* 'float32',
|
|
217
|
+
* 'int32',
|
|
218
|
+
* 'uint8'
|
|
219
|
+
* ];
|
|
220
|
+
*
|
|
221
|
+
* var sigs = signatures( dtypes, dtypes, dtypes );
|
|
222
|
+
* // returns [...]
|
|
223
|
+
*
|
|
224
|
+
* var table = {
|
|
225
|
+
* 'default': add,
|
|
226
|
+
* 'complex64': caddf,
|
|
227
|
+
* 'complex128': cadd
|
|
228
|
+
* };
|
|
229
|
+
*
|
|
230
|
+
* var list = ns.binarySignatureCallbacks( table, sigs );
|
|
231
|
+
* // returns [...]
|
|
232
|
+
*/
|
|
233
|
+
binarySignatureCallbacks: typeof binarySignatureCallbacks;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Applies a unary function to a single-precision complex floating-point strided input array and assigns results to a single-precision complex floating-point strided output array.
|
|
237
|
+
*
|
|
238
|
+
* @param N - number of indexed elements
|
|
239
|
+
* @param x - input array
|
|
240
|
+
* @param strideX - `x` stride length
|
|
241
|
+
* @param y - destination array
|
|
242
|
+
* @param strideY - `y` stride length
|
|
243
|
+
* @param fcn - unary function to apply
|
|
244
|
+
* @returns `y`
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
248
|
+
* var real = require( '@stdlib/complex-real' );
|
|
249
|
+
* var imag = require( '@stdlib/complex-imag' );
|
|
250
|
+
* var Complex64 = require( '@stdlib/complex-float32' );
|
|
251
|
+
*
|
|
252
|
+
* function scale( x ) {
|
|
253
|
+
* var re = real( x );
|
|
254
|
+
* var im = imag( x );
|
|
255
|
+
* return new Complex64( re*10.0, im*10.0 );
|
|
256
|
+
* }
|
|
257
|
+
*
|
|
258
|
+
* var x = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] );
|
|
259
|
+
* var y = new Complex64Array( x.length );
|
|
260
|
+
*
|
|
261
|
+
* ns.cmap( x.length, x, 1, y, 1, scale );
|
|
262
|
+
*
|
|
263
|
+
* var v = y.get( 0 );
|
|
264
|
+
* // returns <Complex64>
|
|
265
|
+
*
|
|
266
|
+
* var re = real( v );
|
|
267
|
+
* // returns 10.0
|
|
268
|
+
*
|
|
269
|
+
* var im = imag( v );
|
|
270
|
+
* // returns 10.0
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
274
|
+
* var real = require( '@stdlib/complex-real' );
|
|
275
|
+
* var imag = require( '@stdlib/complex-imag' );
|
|
276
|
+
* var Complex64 = require( '@stdlib/complex-float32' );
|
|
277
|
+
*
|
|
278
|
+
* function scale( x ) {
|
|
279
|
+
* var re = real( x );
|
|
280
|
+
* var im = imag( x );
|
|
281
|
+
* return new Complex64( re*10.0, im*10.0 );
|
|
282
|
+
* }
|
|
283
|
+
*
|
|
284
|
+
* var x = new Complex64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] );
|
|
285
|
+
* var y = new Complex64Array( x.length );
|
|
286
|
+
*
|
|
287
|
+
* ns.cmap.ndarray( x.length, x, 1, 0, y, 1, 0, scale );
|
|
288
|
+
*
|
|
289
|
+
* var v = y.get( 0 );
|
|
290
|
+
* // returns <Complex64>
|
|
291
|
+
*
|
|
292
|
+
* var re = real( v );
|
|
293
|
+
* // returns 10.0
|
|
294
|
+
*
|
|
295
|
+
* var im = imag( v );
|
|
296
|
+
* // returns 10.0
|
|
297
|
+
*/
|
|
298
|
+
cmap: typeof cmap;
|
|
299
|
+
|
|
144
300
|
/**
|
|
145
301
|
* Applies a unary function to a double-precision floating-point strided input array and assigns results to a double-precision floating-point strided output array.
|
|
146
302
|
*
|
|
@@ -153,7 +309,7 @@ interface Namespace {
|
|
|
153
309
|
* @returns `y`
|
|
154
310
|
*
|
|
155
311
|
* @example
|
|
156
|
-
* var Float64Array = require(
|
|
312
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
157
313
|
*
|
|
158
314
|
* function identity( x ) {
|
|
159
315
|
* return x;
|
|
@@ -166,7 +322,7 @@ interface Namespace {
|
|
|
166
322
|
* // y => <Float64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
|
|
167
323
|
*
|
|
168
324
|
* @example
|
|
169
|
-
* var Float64Array = require(
|
|
325
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
170
326
|
*
|
|
171
327
|
* function identity( x ) {
|
|
172
328
|
* return x;
|
|
@@ -194,8 +350,8 @@ interface Namespace {
|
|
|
194
350
|
* @returns `z`
|
|
195
351
|
*
|
|
196
352
|
* @example
|
|
197
|
-
* var Float64Array = require(
|
|
198
|
-
* var add = require(
|
|
353
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
354
|
+
* var add = require( '@stdlib/math-base-ops-add' );
|
|
199
355
|
*
|
|
200
356
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
201
357
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -205,8 +361,8 @@ interface Namespace {
|
|
|
205
361
|
* // z => <Float64Array>[ 2.0, 4.0, 6.0, 8.0, 10.0 ]
|
|
206
362
|
*
|
|
207
363
|
* @example
|
|
208
|
-
* var Float64Array = require(
|
|
209
|
-
* var add = require(
|
|
364
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
365
|
+
* var add = require( '@stdlib/math-base-ops-add' );
|
|
210
366
|
*
|
|
211
367
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
212
368
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -231,8 +387,8 @@ interface Namespace {
|
|
|
231
387
|
* @returns `y`
|
|
232
388
|
*
|
|
233
389
|
* @example
|
|
234
|
-
* var Float64Array = require(
|
|
235
|
-
* var Uint8Array = require(
|
|
390
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
391
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
236
392
|
*
|
|
237
393
|
* function identity( x ) {
|
|
238
394
|
* return x;
|
|
@@ -246,8 +402,8 @@ interface Namespace {
|
|
|
246
402
|
* // y => <Float64Array>[ 1.0, 2.0, 0.0, 4.0, 5.0 ]
|
|
247
403
|
*
|
|
248
404
|
* @example
|
|
249
|
-
* var Float64Array = require(
|
|
250
|
-
* var Uint8Array = require(
|
|
405
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
406
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
251
407
|
*
|
|
252
408
|
* function identity( x ) {
|
|
253
409
|
* return x;
|
|
@@ -278,9 +434,9 @@ interface Namespace {
|
|
|
278
434
|
* @returns `z`
|
|
279
435
|
*
|
|
280
436
|
* @example
|
|
281
|
-
* var Float64Array = require(
|
|
282
|
-
* var Uint8Array = require(
|
|
283
|
-
* var add = require(
|
|
437
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
438
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
439
|
+
* var add = require( '@stdlib/math-base-ops-add' );
|
|
284
440
|
*
|
|
285
441
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
286
442
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -291,9 +447,9 @@ interface Namespace {
|
|
|
291
447
|
* // z => <Float64Array>[ 2.0, 4.0, 0.0, 8.0, 10.0 ]
|
|
292
448
|
*
|
|
293
449
|
* @example
|
|
294
|
-
* var Float64Array = require(
|
|
295
|
-
* var Uint8Array = require(
|
|
296
|
-
* var add = require(
|
|
450
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
451
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
452
|
+
* var add = require( '@stdlib/math-base-ops-add' );
|
|
297
453
|
*
|
|
298
454
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
299
455
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -312,7 +468,7 @@ interface Namespace {
|
|
|
312
468
|
* @returns data type string
|
|
313
469
|
*
|
|
314
470
|
* @example
|
|
315
|
-
* var str2enum = require(
|
|
471
|
+
* var str2enum = require( '@stdlib/strided-base-dtype-str2enum' );
|
|
316
472
|
*
|
|
317
473
|
* var v = str2enum( 'float64' );
|
|
318
474
|
* // returns <number>
|
|
@@ -338,6 +494,20 @@ interface Namespace {
|
|
|
338
494
|
*/
|
|
339
495
|
dtypeResolveEnum: typeof dtypeResolveEnum;
|
|
340
496
|
|
|
497
|
+
/**
|
|
498
|
+
* Returns the data type string associated with a strided array data type value.
|
|
499
|
+
*
|
|
500
|
+
* @param dtype - data type value
|
|
501
|
+
* @returns data type string
|
|
502
|
+
*
|
|
503
|
+
* @example
|
|
504
|
+
* var str2enum = require( '@stdlib/strided-base-dtype-str2enum' );
|
|
505
|
+
*
|
|
506
|
+
* var v = ns.dtypeResolveStr( str2enum( 'float64' ) );
|
|
507
|
+
* // returns 'float64'
|
|
508
|
+
*/
|
|
509
|
+
dtypeResolveStr: typeof dtypeResolveStr;
|
|
510
|
+
|
|
341
511
|
/**
|
|
342
512
|
* Returns the enumeration constant associated with a strided array data type string.
|
|
343
513
|
*
|
|
@@ -368,7 +538,7 @@ interface Namespace {
|
|
|
368
538
|
* @returns `y`
|
|
369
539
|
*
|
|
370
540
|
* @example
|
|
371
|
-
* var abs = require(
|
|
541
|
+
* var abs = require( '@stdlib/math-base-special-abs' );
|
|
372
542
|
*
|
|
373
543
|
* function accessor( v ) {
|
|
374
544
|
* return v * 2.0;
|
|
@@ -381,7 +551,7 @@ interface Namespace {
|
|
|
381
551
|
* // y => [ 2.0, 4.0, 6.0, 8.0, 10.0 ]
|
|
382
552
|
*
|
|
383
553
|
* @example
|
|
384
|
-
* var abs = require(
|
|
554
|
+
* var abs = require( '@stdlib/math-base-special-abs' );
|
|
385
555
|
*
|
|
386
556
|
* function accessor( v ) {
|
|
387
557
|
* return v * 2.0;
|
|
@@ -411,10 +581,11 @@ interface Namespace {
|
|
|
411
581
|
* @returns `z`
|
|
412
582
|
*
|
|
413
583
|
* @example
|
|
414
|
-
* var add = require(
|
|
584
|
+
* var add = require( '@stdlib/math-base-ops-add' );
|
|
415
585
|
*
|
|
416
|
-
* function accessor(
|
|
417
|
-
*
|
|
586
|
+
* function accessor( values ) {
|
|
587
|
+
* values[ 0 ] *= 2.0;
|
|
588
|
+
* values[ 1 ] *= 2.0;
|
|
418
589
|
* }
|
|
419
590
|
*
|
|
420
591
|
* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ];
|
|
@@ -425,10 +596,11 @@ interface Namespace {
|
|
|
425
596
|
* // z => [ 4.0, 0.0, 12.0, 0.0, 20.0 ]
|
|
426
597
|
*
|
|
427
598
|
* @example
|
|
428
|
-
* var add = require(
|
|
599
|
+
* var add = require( '@stdlib/math-base-ops-add' );
|
|
429
600
|
*
|
|
430
|
-
* function accessor(
|
|
431
|
-
*
|
|
601
|
+
* function accessor( values ) {
|
|
602
|
+
* values[ 0 ] *= 2.0;
|
|
603
|
+
* values[ 1 ] *= 2.0;
|
|
432
604
|
* }
|
|
433
605
|
*
|
|
434
606
|
* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ];
|
|
@@ -440,6 +612,20 @@ interface Namespace {
|
|
|
440
612
|
*/
|
|
441
613
|
mapBy2: typeof mapBy2;
|
|
442
614
|
|
|
615
|
+
/**
|
|
616
|
+
* Returns the maximum accessible index based on a set of provided strided array parameters.
|
|
617
|
+
*
|
|
618
|
+
* @param N - number of indexed elements
|
|
619
|
+
* @param stride - stride length
|
|
620
|
+
* @param offset - starting index
|
|
621
|
+
* @returns maximum accessible index
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* var idx = ns.maxViewBufferIndex( 3, 2, 10 );
|
|
625
|
+
* // returns 14
|
|
626
|
+
*/
|
|
627
|
+
maxViewBufferIndex: typeof maxViewBufferIndex;
|
|
628
|
+
|
|
443
629
|
/**
|
|
444
630
|
* Defines non-enumerable read-only properties which expose strided array function meta data.
|
|
445
631
|
*
|
|
@@ -475,6 +661,20 @@ interface Namespace {
|
|
|
475
661
|
*/
|
|
476
662
|
metaDataProps: typeof metaDataProps;
|
|
477
663
|
|
|
664
|
+
/**
|
|
665
|
+
* Returns the minimum accessible index based on a set of provided strided array parameters.
|
|
666
|
+
*
|
|
667
|
+
* @param N - number of indexed elements
|
|
668
|
+
* @param stride - stride length
|
|
669
|
+
* @param offset - starting index
|
|
670
|
+
* @returns minimum accessible index
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* var idx = ns.minViewBufferIndex( 3, -2, 10 );
|
|
674
|
+
* // returns 6
|
|
675
|
+
*/
|
|
676
|
+
minViewBufferIndex: typeof minViewBufferIndex;
|
|
677
|
+
|
|
478
678
|
/**
|
|
479
679
|
* Applies a unary callback to elements in a strided input array according to elements in a strided mask array and assigns results to elements in a strided output array.
|
|
480
680
|
*
|
|
@@ -484,8 +684,8 @@ interface Namespace {
|
|
|
484
684
|
* @param fcn - unary callback
|
|
485
685
|
*
|
|
486
686
|
* @example
|
|
487
|
-
* var Float64Array = require(
|
|
488
|
-
* var Uint8Array = require(
|
|
687
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
688
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
489
689
|
*
|
|
490
690
|
* function scale( x ) {
|
|
491
691
|
* return x * 10.0;
|
|
@@ -504,8 +704,8 @@ interface Namespace {
|
|
|
504
704
|
* // => <Float64Array>[ 10.0, 20.0, 0.0, 40.0, 50.0 ]
|
|
505
705
|
*
|
|
506
706
|
* @example
|
|
507
|
-
* var Float64Array = require(
|
|
508
|
-
* var Uint8Array = require(
|
|
707
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
708
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
509
709
|
*
|
|
510
710
|
* function scale( x ) {
|
|
511
711
|
* return x * 10.0;
|
|
@@ -526,6 +726,124 @@ interface Namespace {
|
|
|
526
726
|
*/
|
|
527
727
|
mskunary: typeof mskunary;
|
|
528
728
|
|
|
729
|
+
/**
|
|
730
|
+
* Returns a function which dispatches to a native add-on applying a unary function to an input strided array according to a mask strided array.
|
|
731
|
+
*
|
|
732
|
+
* @param addon - add-on function
|
|
733
|
+
* @param fallback - fallback function
|
|
734
|
+
* @returns dispatch function
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
* function addon( N, dtypeX, x, strideX, dtypeMask, mask, strideMask, dtypeY, y, strideY ) {
|
|
738
|
+
* // Call into native add-on...
|
|
739
|
+
* }
|
|
740
|
+
*
|
|
741
|
+
* function fallback( N, dtypeX, x, strideX, dtypeMask, mask, strideMask, dtypeY, y, strideY ) {
|
|
742
|
+
* // Fallback JavaScript implementation...
|
|
743
|
+
* }
|
|
744
|
+
*
|
|
745
|
+
* // Create a ns.mskunaryAddonDispatch function:
|
|
746
|
+
* var f = ns.mskunaryAddonDispatch( addon, fallback );
|
|
747
|
+
*
|
|
748
|
+
* // ...
|
|
749
|
+
*
|
|
750
|
+
* // Invoke the ns.mskunaryAddonDispatch function with strided array arguments:
|
|
751
|
+
* f( 2, 'generic', [ 1, 2 ], 1, 'generic', [ 0, 0 ], 1, 'generic', [ 0, 0 ], 1 );
|
|
752
|
+
*
|
|
753
|
+
* @example
|
|
754
|
+
* function addon( N, dtypeX, x, strideX, dtypeMask, mask, strideMask, dtypeY, y, strideY ) {
|
|
755
|
+
* // Call into native add-on...
|
|
756
|
+
* }
|
|
757
|
+
*
|
|
758
|
+
* function fallback( N, dtypeX, x, strideX, offsetX, dtypeMask, mask, strideMask, offsetMask, dtypeY, y, strideY, offsetY ) {
|
|
759
|
+
* // Fallback JavaScript implementation...
|
|
760
|
+
* }
|
|
761
|
+
*
|
|
762
|
+
* // Create a ns.mskunaryAddonDispatch function:
|
|
763
|
+
* var f = ns.mskunaryAddonDispatch.ndarray( addon, fallback );
|
|
764
|
+
*
|
|
765
|
+
* // ...
|
|
766
|
+
*
|
|
767
|
+
* // Invoke the ns.mskunaryAddonDispatch function with strided array arguments:
|
|
768
|
+
* f( 2, 'generic', [ 1, 2 ], 1, 0, 'generic', [ 0, 0 ], 1, 0, 'generic', [ 0, 0 ], 1, 0 );
|
|
769
|
+
*/
|
|
770
|
+
mskunaryAddonDispatch: typeof mskunaryAddonDispatch;
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Generates a list of masked unary interface signatures from strided array data types.
|
|
774
|
+
*
|
|
775
|
+
* ## Notes
|
|
776
|
+
*
|
|
777
|
+
* - The function returns a strided array having a stride length of `3` (i.e., every `3` elements define a masked unary interface signature).
|
|
778
|
+
* - For each signature (i.e., set of three consecutive non-overlapping strided array elements), the first element is the input data type, the second element is the mask data type, and the last element is the return data type.
|
|
779
|
+
* - All signatures follow type promotion rules.
|
|
780
|
+
* - The mask array data type is always `uint8`.
|
|
781
|
+
*
|
|
782
|
+
* @param dtypes1 - list of supported data types for the first argument
|
|
783
|
+
* @param dtypes2 - list of supported data types for the output argument
|
|
784
|
+
* @param options - options
|
|
785
|
+
* @param options.enums - boolean flag indicating whether to return signatures as a list of enumeration constants
|
|
786
|
+
* @throws must provide recognized data types
|
|
787
|
+
* @returns strided array containing masked unary interface signatures
|
|
788
|
+
*
|
|
789
|
+
* @example
|
|
790
|
+
* var dtypes = [
|
|
791
|
+
* 'float64',
|
|
792
|
+
* 'float32',
|
|
793
|
+
* 'int32',
|
|
794
|
+
* 'uint8'
|
|
795
|
+
* ];
|
|
796
|
+
*
|
|
797
|
+
* var sigs = ns.mskunaryDtypeSignatures( dtypes, dtypes );
|
|
798
|
+
* // e.g., returns [ 'float32', 'uint8', 'float32', ... ]
|
|
799
|
+
*/
|
|
800
|
+
mskunaryDtypeSignatures: typeof mskunaryDtypeSignatures;
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Assigns callbacks to masked unary interfaces according to type promotion rules.
|
|
804
|
+
*
|
|
805
|
+
* ## Notes
|
|
806
|
+
*
|
|
807
|
+
* - The function assumes that the provided signature array has the following properties:
|
|
808
|
+
*
|
|
809
|
+
* - a strided array having a stride length of `3` (i.e., every `3` elements define a masked unary interface signature).
|
|
810
|
+
* - for each signature (i.e., set of three consecutive non-overlapping strided array elements), the first element is the input data type, the second element is the mask data type, and the last element is the return data type.
|
|
811
|
+
* - all signatures (excluding the mask data type) follow type promotion rules.
|
|
812
|
+
*
|
|
813
|
+
* @param table - callback table
|
|
814
|
+
* @param table.default - default callback
|
|
815
|
+
* @param table.complex64 - callback for single-precision complex floating-point numbers
|
|
816
|
+
* @param table.complex128 - callback for double-precision complex floating-point numbers
|
|
817
|
+
* @param signatures - strided array containing masked unary interface signatures
|
|
818
|
+
* @returns list of callbacks
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* var signatures = require( '@stdlib/strided-base-mskunary-dtype-signatures' );
|
|
822
|
+
* var identity = require( '@stdlib/math-base-special-identity' );
|
|
823
|
+
* var cidentity = require( '@stdlib/math-base-special-cidentity' );
|
|
824
|
+
* var cidentityf = require( '@stdlib/math-base-special-cidentityf' );
|
|
825
|
+
*
|
|
826
|
+
* var dtypes = [
|
|
827
|
+
* 'float64',
|
|
828
|
+
* 'float32',
|
|
829
|
+
* 'int32',
|
|
830
|
+
* 'uint8'
|
|
831
|
+
* ];
|
|
832
|
+
*
|
|
833
|
+
* var sigs = signatures( dtypes, dtypes );
|
|
834
|
+
* // returns [...]
|
|
835
|
+
*
|
|
836
|
+
* var table = {
|
|
837
|
+
* 'default': identity,
|
|
838
|
+
* 'complex64': cidentityf,
|
|
839
|
+
* 'complex128': cidentity
|
|
840
|
+
* };
|
|
841
|
+
*
|
|
842
|
+
* var list = ns.mskunarySignatureCallbacks( table, sigs );
|
|
843
|
+
* // returns [...]
|
|
844
|
+
*/
|
|
845
|
+
mskunarySignatureCallbacks: typeof mskunarySignatureCallbacks;
|
|
846
|
+
|
|
529
847
|
/**
|
|
530
848
|
* Applies a nullary callback and assigns results to elements in a strided output array.
|
|
531
849
|
*
|
|
@@ -535,7 +853,7 @@ interface Namespace {
|
|
|
535
853
|
* @param fcn - nullary callback
|
|
536
854
|
*
|
|
537
855
|
* @example
|
|
538
|
-
* var Float64Array = require(
|
|
856
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
539
857
|
*
|
|
540
858
|
* function fill() {
|
|
541
859
|
* return 3.0;
|
|
@@ -552,7 +870,7 @@ interface Namespace {
|
|
|
552
870
|
* // => <Float64Array>[ 3.0, 3.0, 3.0, 3.0, 3.0 ]
|
|
553
871
|
*
|
|
554
872
|
* @example
|
|
555
|
-
* var Float64Array = require(
|
|
873
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
556
874
|
*
|
|
557
875
|
* function fill() {
|
|
558
876
|
* return 3.0;
|
|
@@ -571,6 +889,68 @@ interface Namespace {
|
|
|
571
889
|
*/
|
|
572
890
|
nullary: typeof nullary;
|
|
573
891
|
|
|
892
|
+
/**
|
|
893
|
+
* Returns a function which dispatches to a native add-on applying a nullary function.
|
|
894
|
+
*
|
|
895
|
+
* @param addon - add-on function
|
|
896
|
+
* @param fallback - fallback function
|
|
897
|
+
* @returns dispatch function
|
|
898
|
+
*
|
|
899
|
+
* @example
|
|
900
|
+
* function addon( N, dtypeX, x, strideX ) {
|
|
901
|
+
* // Call into native add-on...
|
|
902
|
+
* }
|
|
903
|
+
*
|
|
904
|
+
* function fallback( N, dtypeX, x, strideX ) {
|
|
905
|
+
* // Fallback JavaScript implementation...
|
|
906
|
+
* }
|
|
907
|
+
*
|
|
908
|
+
* // Create a ns.nullaryAddonDispatch function:
|
|
909
|
+
* var f = ns.nullaryAddonDispatch( addon, fallback );
|
|
910
|
+
*
|
|
911
|
+
* // ...
|
|
912
|
+
*
|
|
913
|
+
* // Invoke the ns.nullaryAddonDispatch function with strided array arguments:
|
|
914
|
+
* f( 2, 'generic', [ 1, 2 ], 1 );
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* function addon( N, dtypeX, x, strideX ) {
|
|
918
|
+
* // Call into native add-on...
|
|
919
|
+
* }
|
|
920
|
+
*
|
|
921
|
+
* function fallback( N, dtypeX, x, strideX, offsetX ) {
|
|
922
|
+
* // Fallback JavaScript implementation...
|
|
923
|
+
* }
|
|
924
|
+
*
|
|
925
|
+
* // Create a ns.nullaryAddonDispatch function:
|
|
926
|
+
* var f = ns.nullaryAddonDispatch.ndarray( addon, fallback );
|
|
927
|
+
*
|
|
928
|
+
* // ...
|
|
929
|
+
*
|
|
930
|
+
* // Invoke the ns.nullaryAddonDispatch function with strided array arguments:
|
|
931
|
+
* f( 2, 'generic', [ 1, 2 ], 1, 0 );
|
|
932
|
+
*/
|
|
933
|
+
nullaryAddonDispatch: typeof nullaryAddonDispatch;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* Returns a typed array view having the same data type as a provided input typed array and starting at a specified index offset.
|
|
937
|
+
*
|
|
938
|
+
* @param x - input array
|
|
939
|
+
* @param offset - starting index
|
|
940
|
+
* @returns typed array view
|
|
941
|
+
*
|
|
942
|
+
* @example
|
|
943
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
944
|
+
*
|
|
945
|
+
* var x = new Float64Array( 10 );
|
|
946
|
+
*
|
|
947
|
+
* var out = ns.offsetView( x, 0 );
|
|
948
|
+
* // returns <Float64Array>
|
|
949
|
+
*
|
|
950
|
+
* var bool = ( out.buffer === x.buffer );
|
|
951
|
+
*/
|
|
952
|
+
offsetView: typeof offsetView;
|
|
953
|
+
|
|
574
954
|
/**
|
|
575
955
|
* Applies a quaternary callback to strided input array elements and assigns results to elements in a strided output array.
|
|
576
956
|
*
|
|
@@ -580,11 +960,8 @@ interface Namespace {
|
|
|
580
960
|
* @param fcn - quaternary callback
|
|
581
961
|
*
|
|
582
962
|
* @example
|
|
583
|
-
* var
|
|
584
|
-
*
|
|
585
|
-
* function add( x, y, z, w ) {
|
|
586
|
-
* return x + y + z + w;
|
|
587
|
-
* }
|
|
963
|
+
* var add = require( '@stdlib/math-base-ops-add4' );
|
|
964
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
588
965
|
*
|
|
589
966
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
590
967
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -601,11 +978,8 @@ interface Namespace {
|
|
|
601
978
|
* // => <Float64Array>[ 4.0, 8.0, 12.0, 16.0, 20.0 ]
|
|
602
979
|
*
|
|
603
980
|
* @example
|
|
604
|
-
* var
|
|
605
|
-
*
|
|
606
|
-
* function add( x, y, z, w ) {
|
|
607
|
-
* return x + y + z + w;
|
|
608
|
-
* }
|
|
981
|
+
* var add = require( '@stdlib/math-base-ops-add4' );
|
|
982
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
609
983
|
*
|
|
610
984
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
611
985
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -633,11 +1007,8 @@ interface Namespace {
|
|
|
633
1007
|
* @param fcn - quinary callback
|
|
634
1008
|
*
|
|
635
1009
|
* @example
|
|
636
|
-
* var
|
|
637
|
-
*
|
|
638
|
-
* function add( x, y, z, w, u ) {
|
|
639
|
-
* return x + y + z + w + u;
|
|
640
|
-
* }
|
|
1010
|
+
* var add = require( '@stdlib/math-base-ops-add5' );
|
|
1011
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
641
1012
|
*
|
|
642
1013
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
643
1014
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -655,11 +1026,8 @@ interface Namespace {
|
|
|
655
1026
|
* // => <Float64Array>[ 5.0, 10.0, 15.0, 20.0, 25.0 ]
|
|
656
1027
|
*
|
|
657
1028
|
* @example
|
|
658
|
-
* var
|
|
659
|
-
*
|
|
660
|
-
* function add( x, y, z, w, u ) {
|
|
661
|
-
* return x + y + z + w + u;
|
|
662
|
-
* }
|
|
1029
|
+
* var add = require( '@stdlib/math-base-ops-add5' );
|
|
1030
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
663
1031
|
*
|
|
664
1032
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
665
1033
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -679,6 +1047,44 @@ interface Namespace {
|
|
|
679
1047
|
*/
|
|
680
1048
|
quinary: typeof quinary;
|
|
681
1049
|
|
|
1050
|
+
/**
|
|
1051
|
+
* Reinterprets a `Complex64Array` as a `Float32Array`.
|
|
1052
|
+
*
|
|
1053
|
+
* @param x - input array
|
|
1054
|
+
* @param offset - starting index
|
|
1055
|
+
* @returns `Float32Array` view
|
|
1056
|
+
*
|
|
1057
|
+
* @example
|
|
1058
|
+
* var Complex64Array = require( '@stdlib/array-complex64' );
|
|
1059
|
+
*
|
|
1060
|
+
* var x = new Complex64Array( 10 );
|
|
1061
|
+
*
|
|
1062
|
+
* var out = ns.reinterpretComplex64( x, 0 );
|
|
1063
|
+
* // returns <Float32Array>
|
|
1064
|
+
*
|
|
1065
|
+
* var bool = ( out.buffer === x.buffer );
|
|
1066
|
+
*/
|
|
1067
|
+
reinterpretComplex64: typeof reinterpretComplex64;
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Reinterprets a `Complex128Array` as a `Float64Array`.
|
|
1071
|
+
*
|
|
1072
|
+
* @param x - input array
|
|
1073
|
+
* @param offset - starting index
|
|
1074
|
+
* @returns `Float64Array` view
|
|
1075
|
+
*
|
|
1076
|
+
* @example
|
|
1077
|
+
* var Complex128Array = require( '@stdlib/array-complex128' );
|
|
1078
|
+
*
|
|
1079
|
+
* var x = new Complex128Array( 10 );
|
|
1080
|
+
*
|
|
1081
|
+
* var out = ns.reinterpretComplex128( x, 0 );
|
|
1082
|
+
* // returns <Float64Array>
|
|
1083
|
+
*
|
|
1084
|
+
* var bool = ( out.buffer === x.buffer );
|
|
1085
|
+
*/
|
|
1086
|
+
reinterpretComplex128: typeof reinterpretComplex128;
|
|
1087
|
+
|
|
682
1088
|
/**
|
|
683
1089
|
* Applies a unary function to a single-precision floating-point strided input array and assigns results to a single-precision floating-point strided output array.
|
|
684
1090
|
*
|
|
@@ -691,7 +1097,7 @@ interface Namespace {
|
|
|
691
1097
|
* @returns `y`
|
|
692
1098
|
*
|
|
693
1099
|
* @example
|
|
694
|
-
* var Float32Array = require(
|
|
1100
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
695
1101
|
*
|
|
696
1102
|
* function identity( x ) {
|
|
697
1103
|
* return x;
|
|
@@ -704,7 +1110,7 @@ interface Namespace {
|
|
|
704
1110
|
* // y => <Float32Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
|
|
705
1111
|
*
|
|
706
1112
|
* @example
|
|
707
|
-
* var Float32Array = require(
|
|
1113
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
708
1114
|
*
|
|
709
1115
|
* function identity( x ) {
|
|
710
1116
|
* return x;
|
|
@@ -732,8 +1138,8 @@ interface Namespace {
|
|
|
732
1138
|
* @returns `z`
|
|
733
1139
|
*
|
|
734
1140
|
* @example
|
|
735
|
-
* var Float32Array = require(
|
|
736
|
-
* var addf = require(
|
|
1141
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
1142
|
+
* var addf = require( '@stdlib/math-base-ops-addf' );
|
|
737
1143
|
*
|
|
738
1144
|
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
739
1145
|
* var y = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -743,8 +1149,8 @@ interface Namespace {
|
|
|
743
1149
|
* // z => <Float32Array>[ 2.0, 4.0, 6.0, 8.0, 10.0 ]
|
|
744
1150
|
*
|
|
745
1151
|
* @example
|
|
746
|
-
* var Float32Array = require(
|
|
747
|
-
* var addf = require(
|
|
1152
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
1153
|
+
* var addf = require( '@stdlib/math-base-ops-addf' );
|
|
748
1154
|
*
|
|
749
1155
|
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
750
1156
|
* var y = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -769,8 +1175,8 @@ interface Namespace {
|
|
|
769
1175
|
* @returns `y`
|
|
770
1176
|
*
|
|
771
1177
|
* @example
|
|
772
|
-
* var Float32Array = require(
|
|
773
|
-
* var Uint8Array = require(
|
|
1178
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
1179
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
774
1180
|
*
|
|
775
1181
|
* function identity( x ) {
|
|
776
1182
|
* return x;
|
|
@@ -784,8 +1190,8 @@ interface Namespace {
|
|
|
784
1190
|
* // y => <Float32Array>[ 1.0, 2.0, 0.0, 4.0, 5.0 ]
|
|
785
1191
|
*
|
|
786
1192
|
* @example
|
|
787
|
-
* var Float32Array = require(
|
|
788
|
-
* var Uint8Array = require(
|
|
1193
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
1194
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
789
1195
|
*
|
|
790
1196
|
* function identity( x ) {
|
|
791
1197
|
* return x;
|
|
@@ -816,9 +1222,9 @@ interface Namespace {
|
|
|
816
1222
|
* @returns `z`
|
|
817
1223
|
*
|
|
818
1224
|
* @example
|
|
819
|
-
* var Float32Array = require(
|
|
820
|
-
* var Uint8Array = require(
|
|
821
|
-
* var addf = require(
|
|
1225
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
1226
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
1227
|
+
* var addf = require( '@stdlib/math-base-ops-addf' );
|
|
822
1228
|
*
|
|
823
1229
|
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
824
1230
|
* var y = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -829,9 +1235,9 @@ interface Namespace {
|
|
|
829
1235
|
* // z => <Float32Array>[ 2.0, 4.0, 0.0, 8.0, 10.0 ]
|
|
830
1236
|
*
|
|
831
1237
|
* @example
|
|
832
|
-
* var Float32Array = require(
|
|
833
|
-
* var Uint8Array = require(
|
|
834
|
-
* var addf = require(
|
|
1238
|
+
* var Float32Array = require( '@stdlib/array-float32' );
|
|
1239
|
+
* var Uint8Array = require( '@stdlib/array-uint8' );
|
|
1240
|
+
* var addf = require( '@stdlib/math-base-ops-addf' );
|
|
835
1241
|
*
|
|
836
1242
|
* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
837
1243
|
* var y = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -852,11 +1258,8 @@ interface Namespace {
|
|
|
852
1258
|
* @param fcn - ternary callback
|
|
853
1259
|
*
|
|
854
1260
|
* @example
|
|
855
|
-
* var
|
|
856
|
-
*
|
|
857
|
-
* function add( x, y, z ) {
|
|
858
|
-
* return x + y + z;
|
|
859
|
-
* }
|
|
1261
|
+
* var add = require( '@stdlib/math-base-ops-add3' );
|
|
1262
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
860
1263
|
*
|
|
861
1264
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
862
1265
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -872,11 +1275,8 @@ interface Namespace {
|
|
|
872
1275
|
* // => <Float64Array>[ 3.0, 6.0, 9.0, 12.0, 15.0 ]
|
|
873
1276
|
*
|
|
874
1277
|
* @example
|
|
875
|
-
* var
|
|
876
|
-
*
|
|
877
|
-
* function add( x, y, z ) {
|
|
878
|
-
* return x + y + z;
|
|
879
|
-
* }
|
|
1278
|
+
* var add = require( '@stdlib/math-base-ops-add3' );
|
|
1279
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
880
1280
|
*
|
|
881
1281
|
* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
882
1282
|
* var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
|
|
@@ -903,7 +1303,7 @@ interface Namespace {
|
|
|
903
1303
|
* @param fcn - unary callback
|
|
904
1304
|
*
|
|
905
1305
|
* @example
|
|
906
|
-
* var Float64Array = require(
|
|
1306
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
907
1307
|
*
|
|
908
1308
|
* function scale( x ) {
|
|
909
1309
|
* return x * 10.0;
|
|
@@ -921,7 +1321,7 @@ interface Namespace {
|
|
|
921
1321
|
* // => <Float64Array>[ 10.0, 20.0, 30.0, 40.0, 50.0 ]
|
|
922
1322
|
*
|
|
923
1323
|
* @example
|
|
924
|
-
* var Float64Array = require(
|
|
1324
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
925
1325
|
*
|
|
926
1326
|
* function scale( x ) {
|
|
927
1327
|
* return x * 10.0;
|
|
@@ -983,6 +1383,190 @@ interface Namespace {
|
|
|
983
1383
|
* f( 2, 'generic', [ 1, 2 ], 1, 0, 'generic', [ 0, 0 ], 1, 0 );
|
|
984
1384
|
*/
|
|
985
1385
|
unaryAddonDispatch: typeof unaryAddonDispatch;
|
|
1386
|
+
|
|
1387
|
+
/**
|
|
1388
|
+
* Applies a unary function to each element retrieved from a strided input array according to a callback function and assigns results to a strided output array.
|
|
1389
|
+
*
|
|
1390
|
+
* @param arrays - array-like object containing one input array and one output array
|
|
1391
|
+
* @param shape - array-like object containing a single element, the number of indexed elements
|
|
1392
|
+
* @param strides - array-like object containing the stride lengths for the input and output arrays
|
|
1393
|
+
* @param fcn - unary function to apply to callback return values
|
|
1394
|
+
* @param clbk - callback function
|
|
1395
|
+
* @param thisArg - callback execution context
|
|
1396
|
+
*
|
|
1397
|
+
* @example
|
|
1398
|
+
* var abs = require( '@stdlib/math-base-special-abs' );
|
|
1399
|
+
*
|
|
1400
|
+
* function accessor( v ) {
|
|
1401
|
+
* return v * 2.0;
|
|
1402
|
+
* }
|
|
1403
|
+
*
|
|
1404
|
+
* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ];
|
|
1405
|
+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
|
|
1406
|
+
*
|
|
1407
|
+
* var shape = [ x.length ];
|
|
1408
|
+
* var strides = [ 1, 1 ];
|
|
1409
|
+
*
|
|
1410
|
+
* ns.unaryBy( [ x, y ], shape, strides, abs, accessor );
|
|
1411
|
+
* // y => [ 2.0, 4.0, 6.0, 8.0, 10.0 ]
|
|
1412
|
+
*
|
|
1413
|
+
* @example
|
|
1414
|
+
* var abs = require( '@stdlib/math-base-special-abs' );
|
|
1415
|
+
*
|
|
1416
|
+
* function accessor( v ) {
|
|
1417
|
+
* return v * 2.0;
|
|
1418
|
+
* }
|
|
1419
|
+
*
|
|
1420
|
+
* var x = [ 1.0, -2.0, 3.0, -4.0, 5.0 ];
|
|
1421
|
+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
|
|
1422
|
+
*
|
|
1423
|
+
* var shape = [ x.length ];
|
|
1424
|
+
* var strides = [ 1, 1 ];
|
|
1425
|
+
* var offsets = [ 0, 0 ];
|
|
1426
|
+
*
|
|
1427
|
+
* ns.unaryBy.ndarray( [ x, y ], shape, strides, offsets, abs, accessor );
|
|
1428
|
+
* // y => [ 2.0, 4.0, 6.0, 8.0, 10.0 ]
|
|
1429
|
+
*/
|
|
1430
|
+
unaryBy: typeof unaryBy;
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Generates a list of unary interface signatures from strided array data types.
|
|
1434
|
+
*
|
|
1435
|
+
* ## Notes
|
|
1436
|
+
*
|
|
1437
|
+
* - The function returns a strided array having a stride length of `2` (i.e., every `2` elements define a unary interface signature).
|
|
1438
|
+
* - For each signature (i.e., set of two consecutive non-overlapping strided array elements), the first element is the input data type and the second element is the return data type.
|
|
1439
|
+
* - All signatures follow type promotion rules.
|
|
1440
|
+
*
|
|
1441
|
+
* @param dtypes1 - list of supported data types for the first argument
|
|
1442
|
+
* @param dtypes2 - list of supported data types for the output argument
|
|
1443
|
+
* @param options - options
|
|
1444
|
+
* @param options.enums - boolean flag indicating whether to return signatures as a list of enumeration constants
|
|
1445
|
+
* @throws must provide recognized data types
|
|
1446
|
+
* @returns strided array containing unary interface signatures
|
|
1447
|
+
*
|
|
1448
|
+
* @example
|
|
1449
|
+
* var dtypes = [
|
|
1450
|
+
* 'float64',
|
|
1451
|
+
* 'float32',
|
|
1452
|
+
* 'int32',
|
|
1453
|
+
* 'uint8'
|
|
1454
|
+
* ];
|
|
1455
|
+
*
|
|
1456
|
+
* var sigs = ns.unaryDtypeSignatures( dtypes, dtypes );
|
|
1457
|
+
* // e.g., returns [ 'float32', 'float32', ... ]
|
|
1458
|
+
*/
|
|
1459
|
+
unaryDtypeSignatures: typeof unaryDtypeSignatures;
|
|
1460
|
+
|
|
1461
|
+
/**
|
|
1462
|
+
* Assigns callbacks to unary interfaces according to type promotion rules.
|
|
1463
|
+
*
|
|
1464
|
+
* ## Notes
|
|
1465
|
+
*
|
|
1466
|
+
* - The function assumes that the provided signature array has the following properties:
|
|
1467
|
+
*
|
|
1468
|
+
* - a strided array having a stride length of `2` (i.e., every `2` elements define a unary interface signature).
|
|
1469
|
+
* - for each signature (i.e., set of two consecutive non-overlapping strided array elements), the first element is the input data type and the second element is the return data type.
|
|
1470
|
+
* - all signatures follow type promotion rules.
|
|
1471
|
+
*
|
|
1472
|
+
* @param table - callback table
|
|
1473
|
+
* @param table.default - default callback
|
|
1474
|
+
* @param table.complex64 - callback for single-precision complex floating-point numbers
|
|
1475
|
+
* @param table.complex128 - callback for double-precision complex floating-point numbers
|
|
1476
|
+
* @param signatures - strided array containing unary interface signatures
|
|
1477
|
+
* @returns list of callbacks
|
|
1478
|
+
*
|
|
1479
|
+
* @example
|
|
1480
|
+
* var signatures = require( '@stdlib/strided-base-unary-dtype-signatures' );
|
|
1481
|
+
* var identity = require( '@stdlib/math-base-special-identity' );
|
|
1482
|
+
* var cidentity = require( '@stdlib/math-base-special-cidentity' );
|
|
1483
|
+
* var cidentityf = require( '@stdlib/math-base-special-cidentityf' );
|
|
1484
|
+
*
|
|
1485
|
+
* var dtypes = [
|
|
1486
|
+
* 'float64',
|
|
1487
|
+
* 'float32',
|
|
1488
|
+
* 'int32',
|
|
1489
|
+
* 'uint8'
|
|
1490
|
+
* ];
|
|
1491
|
+
*
|
|
1492
|
+
* var sigs = signatures( dtypes, dtypes );
|
|
1493
|
+
* // returns [...]
|
|
1494
|
+
*
|
|
1495
|
+
* var table = {
|
|
1496
|
+
* 'default': identity,
|
|
1497
|
+
* 'complex64': cidentityf,
|
|
1498
|
+
* 'complex128': cidentity
|
|
1499
|
+
* };
|
|
1500
|
+
*
|
|
1501
|
+
* var list = ns.unarySignatureCallbacks( table, sigs );
|
|
1502
|
+
* // returns [...]
|
|
1503
|
+
*/
|
|
1504
|
+
unarySignatureCallbacks: typeof unarySignatureCallbacks;
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Applies a unary function to a double-precision complex floating-point strided input array and assigns results to a double-precision complex floating-point strided output array.
|
|
1508
|
+
*
|
|
1509
|
+
* @param N - number of indexed elements
|
|
1510
|
+
* @param x - input array
|
|
1511
|
+
* @param strideX - `x` stride length
|
|
1512
|
+
* @param y - destination array
|
|
1513
|
+
* @param strideY - `y` stride length
|
|
1514
|
+
* @param fcn - unary function to apply
|
|
1515
|
+
* @returns `y`
|
|
1516
|
+
*
|
|
1517
|
+
* @example
|
|
1518
|
+
* var Complex128Array = require( '@stdlib/array-complex128' );
|
|
1519
|
+
* var real = require( '@stdlib/complex-real' );
|
|
1520
|
+
* var imag = require( '@stdlib/complex-imag' );
|
|
1521
|
+
* var Complex128 = require( '@stdlib/complex-float64' );
|
|
1522
|
+
*
|
|
1523
|
+
* function scale( x ) {
|
|
1524
|
+
* var re = real( x );
|
|
1525
|
+
* var im = imag( x );
|
|
1526
|
+
* return new Complex128( re*10.0, im*10.0 );
|
|
1527
|
+
* }
|
|
1528
|
+
*
|
|
1529
|
+
* var x = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] );
|
|
1530
|
+
* var y = new Complex128Array( x.length );
|
|
1531
|
+
*
|
|
1532
|
+
* ns.zmap( x.length, x, 1, y, 1, scale );
|
|
1533
|
+
*
|
|
1534
|
+
* var v = y.get( 0 );
|
|
1535
|
+
* // returns <Complex128>
|
|
1536
|
+
*
|
|
1537
|
+
* var re = real( v );
|
|
1538
|
+
* // returns 10.0
|
|
1539
|
+
*
|
|
1540
|
+
* var im = imag( v );
|
|
1541
|
+
* // returns 10.0
|
|
1542
|
+
*
|
|
1543
|
+
* @example
|
|
1544
|
+
* var Complex128Array = require( '@stdlib/array-complex128' );
|
|
1545
|
+
* var real = require( '@stdlib/complex-real' );
|
|
1546
|
+
* var imag = require( '@stdlib/complex-imag' );
|
|
1547
|
+
* var Complex128 = require( '@stdlib/complex-float64' );
|
|
1548
|
+
*
|
|
1549
|
+
* function scale( x ) {
|
|
1550
|
+
* var re = real( x );
|
|
1551
|
+
* var im = imag( x );
|
|
1552
|
+
* return new Complex128( re*10.0, im*10.0 );
|
|
1553
|
+
* }
|
|
1554
|
+
*
|
|
1555
|
+
* var x = new Complex128Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, 4.0, 4.0, 5.0, 5.0 ] );
|
|
1556
|
+
* var y = new Complex128Array( x.length );
|
|
1557
|
+
*
|
|
1558
|
+
* ns.zmap.ndarray( x.length, x, 1, 0, y, 1, 0, scale );
|
|
1559
|
+
*
|
|
1560
|
+
* var v = y.get( 0 );
|
|
1561
|
+
* // returns <Complex128>
|
|
1562
|
+
*
|
|
1563
|
+
* var re = real( v );
|
|
1564
|
+
* // returns 10.0
|
|
1565
|
+
*
|
|
1566
|
+
* var im = imag( v );
|
|
1567
|
+
* // returns 10.0
|
|
1568
|
+
*/
|
|
1569
|
+
zmap: typeof zmap;
|
|
986
1570
|
}
|
|
987
1571
|
|
|
988
1572
|
/**
|