You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Wraps an n-ary function and casts a function's return value to a complex number.
33
+
*
34
+
* ## Notes
35
+
*
36
+
* - The returned function **assumes** that the wrapped function returns either a real or complex number.
37
+
* - The returned function **assumes** that, if a return value is non-numeric (i.e., not of type `number`), then the return value is a complex number. The returned function does **not** verify that non-numeric return values are, in fact, complex number objects. The returned function returns non-numeric return values from the wrapped function without modification.
38
+
*
39
+
* @param fcn - function to wrap
40
+
* @param nargs - number of arguments
41
+
* @param ctor - complex number constructor
42
+
* @throws second argument must be a nonnegative integer
43
+
* @returns wrapped function
44
+
*
45
+
* @example
46
+
* var Complex64 = require( `@stdlib/complex/float32` );
47
+
* var realf = require( `@stdlib/complex/realf` );
48
+
* var imagf = require( `@stdlib/complex/imagf` );
49
+
*
50
+
* function add( x, y, z, w, v, t ) {
51
+
* return x + y + z + w + v + t;
52
+
* }
53
+
*
54
+
* var f = ns.cast( add, 6, Complex64 );
55
+
*
56
+
* // ...
57
+
*
58
+
* var z = f( 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 );
59
+
* // returns <Complex64>
60
+
*
61
+
* var re = realf( z );
62
+
* // returns 33.0
63
+
*
64
+
* var im = imagf( z );
65
+
* // returns 0.0
66
+
*/
67
+
cast: typeofcast;
68
+
30
69
/**
31
70
* Wraps an n-ary function accepting complex number arguments to support providing both real and complex numbers.
* Computes the cube root of each element retrieved from an input strided array `x` via a callback function and assigns each result to an element in an output strided array `y`.
* Rounds each element in a strided array `x` toward positive infinity and assigns the results to elements in a strided array `y`.
968
1008
*
@@ -998,6 +1038,42 @@ interface Namespace {
998
1038
*/
999
1039
ceil: typeofceil;
1000
1040
1041
+
/**
1042
+
* Computes the cosine for each element retrieved from an input strided array `x` via a callback function and assigns each result to an element in an output strided array `y`.
* Computes the absolute value for each element in a double-precision floating-point strided array `x` and assigns the results to elements in a double-precision floating-point strided array `y`.
1003
1079
*
@@ -2079,6 +2155,42 @@ interface Namespace {
2079
2155
*/
2080
2156
sfloor: typeofsfloor;
2081
2157
2158
+
/**
2159
+
* Computes the sine of each element retrieved from an input strided array `x` via a callback function and assigns each result to an element in an output strided array `y`.
* Computes the multiplicative inverse for each element in a single-precision floating-point strided array `x` and assigns the results to elements in a single-precision floating-point strided array `y`.
2084
2196
*
@@ -2540,6 +2652,42 @@ interface Namespace {
2540
2652
*/
2541
2653
sqrt: typeofsqrt;
2542
2654
2655
+
/**
2656
+
* Computes the principal square root for each element retrieved from an input strided array `x` via a callback function and assigns each result to an element in an output strided array `y`.
* Evaluates the ramp function for each element in a single-precision floating-point strided array `x` and assigns the results to elements in a single-precision floating-point strided array `y`.
* Returns a function which dispatches to a native add-on applying a nullary function.
771
+
*
772
+
* @param addon - add-on function
773
+
* @param fallback - fallback function
774
+
* @returns dispatch function
775
+
*
776
+
* @example
777
+
* function addon( N, dtypeX, x, strideX ) {
778
+
* // Call into native add-on...
779
+
* }
780
+
*
781
+
* function fallback( N, dtypeX, x, strideX ) {
782
+
* // Fallback JavaScript implementation...
783
+
* }
784
+
*
785
+
* // Create a ns.nullaryAddonDispatch function:
786
+
* var f = ns.nullaryAddonDispatch( addon, fallback );
787
+
*
788
+
* // ...
789
+
*
790
+
* // Invoke the ns.nullaryAddonDispatch function with strided array arguments:
791
+
* f( 2, 'generic', [ 1, 2 ], 1 );
792
+
*
793
+
* @example
794
+
* function addon( N, dtypeX, x, strideX ) {
795
+
* // Call into native add-on...
796
+
* }
797
+
*
798
+
* function fallback( N, dtypeX, x, strideX, offsetX ) {
799
+
* // Fallback JavaScript implementation...
800
+
* }
801
+
*
802
+
* // Create a ns.nullaryAddonDispatch function:
803
+
* var f = ns.nullaryAddonDispatch.ndarray( addon, fallback );
804
+
*
805
+
* // ...
806
+
*
807
+
* // Invoke the ns.nullaryAddonDispatch function with strided array arguments:
808
+
* f( 2, 'generic', [ 1, 2 ], 1, 0 );
809
+
*/
810
+
nullaryAddonDispatch: typeofnullaryAddonDispatch;
811
+
766
812
/**
767
813
* Returns a typed array view having the same data type as a provided input typed array and starting at a specified index offset.
768
814
*
@@ -1233,6 +1279,80 @@ interface Namespace {
1233
1279
*/
1234
1280
unaryAddonDispatch: typeofunaryAddonDispatch;
1235
1281
1282
+
/**
1283
+
* Generates a list of unary interface signatures from strided array data types.
1284
+
*
1285
+
* ## Notes
1286
+
*
1287
+
* - The function returns a strided array having a stride length of `2` (i.e., every `2` elements define a unary interface signature).
1288
+
* - 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.
1289
+
* - All signatures follow type promotion rules.
1290
+
*
1291
+
* @param dtypes1 - list of supported data types for the first argument
1292
+
* @param dtypes2 - list of supported data types for the output argument
1293
+
* @param options - options
1294
+
* @param options.enums - boolean flag indicating whether to return signatures as a list of enumeration constants
* var sigs = ns.unaryDtypeSignatures( dtypes, dtypes );
1307
+
* // e.g., returns [ 'float32', 'float32', ... ]
1308
+
*/
1309
+
unaryDtypeSignatures: typeofunaryDtypeSignatures;
1310
+
1311
+
/**
1312
+
* Assigns callbacks to unary interfaces according to type promotion rules.
1313
+
*
1314
+
* ## Notes
1315
+
*
1316
+
* - The function assumes that the provided signature array has the following properties:
1317
+
*
1318
+
* - a strided array having a stride length of `2` (i.e., every `2` elements define a unary interface signature).
1319
+
* - 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.
1320
+
* - all signatures follow type promotion rules.
1321
+
*
1322
+
* @param table - callback table
1323
+
* @param table.default - default callback
1324
+
* @param table.complex64 - callback for single-precision complex floating-point numbers
1325
+
* @param table.complex128 - callback for double-precision complex floating-point numbers
* 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.
0 commit comments