Skip to content

Commit bf2d88b

Browse files
Update namespace TypeScript declarations (stdlib-js#625)
Co-authored-by: kgryte <kgryte@users.noreply.github.com>
1 parent 62f530f commit bf2d88b

File tree

4 files changed

+355
-0
lines changed

4 files changed

+355
-0
lines changed

lib/node_modules/@stdlib/complex/base/docs/types/index.d.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,51 @@
2121
/* tslint:disable:max-line-length */
2222
/* tslint:disable:max-file-line-count */
2323

24+
import cast = require( '@stdlib/complex/base/cast-return' );
2425
import wrap = require( '@stdlib/complex/base/wrap-function' );
2526

2627
/**
2728
* Interface describing the `base` namespace.
2829
*/
2930
interface Namespace {
31+
/**
32+
* 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: typeof cast;
68+
3069
/**
3170
* Wraps an n-ary function accepting complex number arguments to support providing both real and complex numbers.
3271
*

lib/node_modules/@stdlib/math/strided/special/docs/types/index.d.ts

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ import bessely0By = require( '@stdlib/math/strided/special/bessely0-by' );
4545
import bessely1By = require( '@stdlib/math/strided/special/bessely1-by' );
4646
import binetBy = require( '@stdlib/math/strided/special/binet-by' );
4747
import cbrt = require( '@stdlib/math/strided/special/cbrt' );
48+
import cbrtBy = require( '@stdlib/math/strided/special/cbrt-by' );
4849
import ceil = require( '@stdlib/math/strided/special/ceil' );
50+
import cosBy = require( '@stdlib/math/strided/special/cos-by' );
4951
import dabs = require( '@stdlib/math/strided/special/dabs' );
5052
import dabs2 = require( '@stdlib/math/strided/special/dabs2' );
5153
import dcbrt = require( '@stdlib/math/strided/special/dcbrt' );
@@ -79,6 +81,7 @@ import scbrt = require( '@stdlib/math/strided/special/scbrt' );
7981
import sceil = require( '@stdlib/math/strided/special/sceil' );
8082
import sdeg2rad = require( '@stdlib/math/strided/special/sdeg2rad' );
8183
import sfloor = require( '@stdlib/math/strided/special/sfloor' );
84+
import sinBy = require( '@stdlib/math/strided/special/sin-by' );
8285
import sinv = require( '@stdlib/math/strided/special/sinv' );
8386
import smskabs = require( '@stdlib/math/strided/special/smskabs' );
8487
import smskabs2 = require( '@stdlib/math/strided/special/smskabs2' );
@@ -92,6 +95,7 @@ import smskrsqrt = require( '@stdlib/math/strided/special/smskrsqrt' );
9295
import smsksqrt = require( '@stdlib/math/strided/special/smsksqrt' );
9396
import smsktrunc = require( '@stdlib/math/strided/special/smsktrunc' );
9497
import sqrt = require( '@stdlib/math/strided/special/sqrt' );
98+
import sqrtBy = require( '@stdlib/math/strided/special/sqrt-by' );
9599
import sramp = require( '@stdlib/math/strided/special/sramp' );
96100
import srsqrt = require( '@stdlib/math/strided/special/srsqrt' );
97101
import ssqrt = require( '@stdlib/math/strided/special/ssqrt' );
@@ -963,6 +967,42 @@ interface Namespace {
963967
*/
964968
cbrt: typeof cbrt;
965969

970+
/**
971+
* 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`.
972+
*
973+
* @param N - number of indexed elements
974+
* @param x - input array
975+
* @param strideX - `x` stride length
976+
* @param y - destination array
977+
* @param strideY - `y` stride length
978+
* @param clbk - callback function
979+
* @param thisArg - callback execution context
980+
* @returns `y`
981+
*
982+
* @example
983+
* function accessor( v ) {
984+
* return v;
985+
* }
986+
*
987+
* var x = [ 1.0, 9.0, -27.0, 81.0, -125.0 ];
988+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
989+
*
990+
* ns.cbrtBy( x.length, x, 1, y, 1, accessor );
991+
* // y => [ 1.0, ~2.08, -3.0, ~4.327, -5.0 ]
992+
*
993+
* @example
994+
* function accessor( v ) {
995+
* return v;
996+
* }
997+
*
998+
* var x = [ 1.0, 9.0, -27.0, 81.0, -125.0 ];
999+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
1000+
*
1001+
* ns.cbrtBy.ndarray( x.length, x, 1, 0, y, 1, 0, accessor );
1002+
* // y => [ 1.0, ~2.08, -3.0, ~4.327, -5.0 ]
1003+
*/
1004+
cbrtBy: typeof cbrtBy;
1005+
9661006
/**
9671007
* Rounds each element in a strided array `x` toward positive infinity and assigns the results to elements in a strided array `y`.
9681008
*
@@ -998,6 +1038,42 @@ interface Namespace {
9981038
*/
9991039
ceil: typeof ceil;
10001040

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`.
1043+
*
1044+
* @param N - number of indexed elements
1045+
* @param x - input array
1046+
* @param strideX - `x` stride length
1047+
* @param y - destination array
1048+
* @param strideY - `y` stride length
1049+
* @param clbk - callback function
1050+
* @param thisArg - callback execution context
1051+
* @returns `y`
1052+
*
1053+
* @example
1054+
* function accessor( v ) {
1055+
* return v;
1056+
* }
1057+
*
1058+
* var x = [ 0.0, 3.14, -3.14, 10.0, -15.0 ];
1059+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
1060+
*
1061+
* ns.cosBy( x.length, x, 1, y, 1, accessor );
1062+
* // y => [ 1.0, ~-1.0, ~-1.0, ~-0.839, ~-0.76 ]
1063+
*
1064+
* @example
1065+
* function accessor( v ) {
1066+
* return v;
1067+
* }
1068+
*
1069+
* var x = [ 0.0, 3.14, -3.14, 10.0, -15.0 ];
1070+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
1071+
*
1072+
* ns.cosBy.ndarray( x.length, x, 1, 0, y, 1, 0, accessor );
1073+
* // y => [ 1.0, ~-1.0, ~-1.0, ~-0.839, ~-0.76 ]
1074+
*/
1075+
cosBy: typeof cosBy;
1076+
10011077
/**
10021078
* 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`.
10031079
*
@@ -2079,6 +2155,42 @@ interface Namespace {
20792155
*/
20802156
sfloor: typeof sfloor;
20812157

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`.
2160+
*
2161+
* @param N - number of indexed elements
2162+
* @param x - input array
2163+
* @param strideX - `x` stride length
2164+
* @param y - destination array
2165+
* @param strideY - `y` stride length
2166+
* @param clbk - callback function
2167+
* @param thisArg - callback execution context
2168+
* @returns `y`
2169+
*
2170+
* @example
2171+
* function accessor( v ) {
2172+
* return v;
2173+
* }
2174+
*
2175+
* var x = [ 0.0, 3.14, -3.14, 10.0, -15.0 ];
2176+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
2177+
*
2178+
* ns.sinBy( x.length, x, 1, y, 1, accessor );
2179+
* // y => [ 0.0, ~0.002, ~-0.002, ~-0.544, ~-0.65 ]
2180+
*
2181+
* @example
2182+
* function accessor( v ) {
2183+
* return v;
2184+
* }
2185+
*
2186+
* var x = [ 0.0, 3.14, -3.14, 10.0, -15.0 ];
2187+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
2188+
*
2189+
* ns.sinBy.ndarray( x.length, x, 1, 0, y, 1, 0, accessor );
2190+
* // y => [ 0.0, ~0.002, ~-0.002, ~-0.544, ~-0.65 ]
2191+
*/
2192+
sinBy: typeof sinBy;
2193+
20822194
/**
20832195
* 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`.
20842196
*
@@ -2540,6 +2652,42 @@ interface Namespace {
25402652
*/
25412653
sqrt: typeof sqrt;
25422654

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`.
2657+
*
2658+
* @param N - number of indexed elements
2659+
* @param x - input array
2660+
* @param strideX - `x` stride length
2661+
* @param y - destination array
2662+
* @param strideY - `y` stride length
2663+
* @param clbk - callback function
2664+
* @param thisArg - callback execution context
2665+
* @returns `y`
2666+
*
2667+
* @example
2668+
* function accessor( v ) {
2669+
* return v;
2670+
* }
2671+
*
2672+
* var x = [ 0.0, 1.0, 122.0, 50.0, 80.7 ];
2673+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
2674+
*
2675+
* ns.sqrtBy( x.length, x, 1, y, 1, accessor );
2676+
* // y => [ 0.0, 1.0, ~11.045, ~7.071, ~8.983 ]
2677+
*
2678+
* @example
2679+
* function accessor( v ) {
2680+
* return v;
2681+
* }
2682+
*
2683+
* var x = [ 0.0, 1.0, 122.0, 50.0, 80.7 ];
2684+
* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];
2685+
*
2686+
* ns.sqrtBy.ndarray( x.length, x, 1, 0, y, 1, 0, accessor );
2687+
* // y => [ 0.0, 1.0, ~11.045, ~7.071, ~8.983 ]
2688+
*/
2689+
sqrtBy: typeof sqrtBy;
2690+
25432691
/**
25442692
* 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`.
25452693
*

lib/node_modules/@stdlib/strided/base/docs/types/index.d.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import metaDataProps = require( '@stdlib/strided/base/meta-data-props' );
4141
import minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' );
4242
import mskunary = require( '@stdlib/strided/base/mskunary' );
4343
import nullary = require( '@stdlib/strided/base/nullary' );
44+
import nullaryAddonDispatch = require( '@stdlib/strided/base/nullary-addon-dispatch' );
4445
import offsetView = require( '@stdlib/strided/base/offset-view' );
4546
import quaternary = require( '@stdlib/strided/base/quaternary' );
4647
import quinary = require( '@stdlib/strided/base/quinary' );
@@ -53,6 +54,8 @@ import smskmap2 = require( '@stdlib/strided/base/smskmap2' );
5354
import ternary = require( '@stdlib/strided/base/ternary' );
5455
import unary = require( '@stdlib/strided/base/unary' );
5556
import unaryAddonDispatch = require( '@stdlib/strided/base/unary-addon-dispatch' );
57+
import unaryDtypeSignatures = require( '@stdlib/strided/base/unary-dtype-signatures' );
58+
import unarySignatureCallbacks = require( '@stdlib/strided/base/unary-signature-callbacks' );
5659
import zmap = require( '@stdlib/strided/base/zmap' );
5760

5861
/**
@@ -763,6 +766,49 @@ interface Namespace {
763766
*/
764767
nullary: typeof nullary;
765768

769+
/**
770+
* 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: typeof nullaryAddonDispatch;
811+
766812
/**
767813
* Returns a typed array view having the same data type as a provided input typed array and starting at a specified index offset.
768814
*
@@ -1233,6 +1279,80 @@ interface Namespace {
12331279
*/
12341280
unaryAddonDispatch: typeof unaryAddonDispatch;
12351281

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
1295+
* @throws must provide recognized data types
1296+
* @returns strided array containing unary interface signatures
1297+
*
1298+
* @example
1299+
* var dtypes = [
1300+
* 'float64',
1301+
* 'float32',
1302+
* 'int32',
1303+
* 'uint8'
1304+
* ];
1305+
*
1306+
* var sigs = ns.unaryDtypeSignatures( dtypes, dtypes );
1307+
* // e.g., returns [ 'float32', 'float32', ... ]
1308+
*/
1309+
unaryDtypeSignatures: typeof unaryDtypeSignatures;
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
1326+
* @param signatures - strided array containing unary interface signatures
1327+
* @returns list of callbacks
1328+
*
1329+
* @example
1330+
* var signatures = require( `@stdlib/strided/base/unary-dtype-signatures` );
1331+
* var identity = require( `@stdlib/math/base/special/identity` );
1332+
* var cidentity = require( `@stdlib/math/base/special/cidentity` );
1333+
* var cidentityf = require( `@stdlib/math/base/special/cidentityf` );
1334+
*
1335+
* var dtypes = [
1336+
* 'float64',
1337+
* 'float32',
1338+
* 'int32',
1339+
* 'uint8'
1340+
* ];
1341+
*
1342+
* var sigs = signatures( dtypes, dtypes );
1343+
* // returns [...]
1344+
*
1345+
* var table = {
1346+
* 'default': identity,
1347+
* 'complex64': cidentityf,
1348+
* 'complex128': cidentity
1349+
* };
1350+
*
1351+
* var list = ns.unarySignatureCallbacks( table, sigs );
1352+
* // returns [...]
1353+
*/
1354+
unarySignatureCallbacks: typeof unarySignatureCallbacks;
1355+
12361356
/**
12371357
* 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.
12381358
*

0 commit comments

Comments
 (0)