File: repl.txt

package info (click to toggle)
node-stdlib 0.0.96%2Bds1%2B~cs0.0.429-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 421,476 kB
  • sloc: javascript: 1,562,831; ansic: 109,702; lisp: 49,823; cpp: 27,224; python: 7,871; sh: 6,807; makefile: 6,089; fortran: 3,102; awk: 387
file content (87 lines) | stat: -rw-r--r-- 2,864 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

{{alias}}( fcns, types, data, nargs, nin, nout )
    Returns an ndarray function interface which performs multiple dispatch.

    An ndarray function interface has the following signature:

      f( x, y, ... )

    where

    - x: ndarray.
    - y: ndarray.
    - ...: additional ndarrays.

    The number of parameters is derived from `nargs`, the number of input
    ndarrays is derived from `nin`, and the number of output ndarrays is derived
    from `nout`.

    Parameters
    ----------
    fcns: Function|ArrayLikeObject<Function>
        List of ndarray functions. An ndarray function should have the following
        signature:

          f( arrays, data )

        where

        - arrays: array containing input and output ndarrays.
        - data: ndarray function data (e.g., a callback).

        For convenience, a single ndarray function may be provided which will be
        invoked whenever the ndarray argument data types match a sequence of
        types in `types`. Providing a single ndarray function is particularly
        convenient for the case where, regardless of array data types,
        traversing arrays remains the same, but the ndarray function `data`
        differs (e.g., callbacks which differ based on the array data types).

    types: ArrayLikeObject<string>
        One-dimensional list of ndarray argument data types.

    data: ArrayLikeObject|null
        ndarray function data (e.g., callbacks). If `null`, a returned ndarray
        function interface does **not** provide a `data` argument to an invoked
        ndarray function.

    nargs: integer
        Total number of ndarray function interface arguments.

    nin: integer
        Number of input ndarrays.

    nout: integer
        Number of output ndarrays.

    Returns
    -------
    fcn: Function
        ndarray function interface.

    Examples
    --------
    // Define ndarray argument data types:
    > var t = [ 'float64', 'float64', 'float32', 'float32' ];

    // Define a list of ndarray function data (callbacks):
    > var d = [ {{alias:@stdlib/math/base/special/abs}}, {{alias:@stdlib/math/base/special/absf}} ];

    // Create an ndarray function interface for applying unary callbacks:
    > var f = {{alias}}( {{alias:@stdlib/ndarray/base/unary}}, t, d, 2, 1, 1 );

    // Create an input ndarray:
    > var xbuf = new {{alias:@stdlib/array/float64}}( [ -1.0, -2.0, -3.0, -4.0 ] );
    > var x = {{alias:@stdlib/ndarray/ctor}}( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );

    // Create an output ndarray:
    > var ybuf = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] );
    > var y = {{alias:@stdlib/ndarray/ctor}}( 'float64', ybuf, [ 4 ], [ 1 ], 0, 'row-major' );

    // Compute the element-wise absolute value:
    > f( x, y );
    > ybuf
    <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]

    See Also
    --------