time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

repl.txt (5112B)


      1 
      2 {{alias}}( fcns, types, data, nargs, nin, nout )
      3     Returns a strided array function interface which performs multiple dispatch.
      4 
      5     Without offsets, a strided array function interface has the following
      6     signature:
      7 
      8       f( N, x, strideX, y, strideY, ... )
      9 
     10     where
     11 
     12     - N: number of indexed elements.
     13     - x: strided array.
     14     - strideX: index increment for `x`.
     15     - y: strided array.
     16     - strideY: index increment for `y`.
     17     - ...: additional strided arrays and associated strides.
     18 
     19     The number of parameters is derived from `nargs`, the number of input
     20     strided arrays is derived from `nin`, and the number of output strided
     21     arrays is derived from `nout`.
     22 
     23     Without offsets, the number of parameters must obey the following relation:
     24 
     25       nargs = 2*(nout+nin) + 1
     26 
     27     With offsets, the number of parameters must obey the following relation:
     28 
     29       nargs = 3*(nout+nin) + 1
     30 
     31     With offsets, a strided array function interface has the following
     32     signature:
     33 
     34       f( N, x, strideX, offsetX, y, strideY, offsetY, ... )
     35 
     36     where
     37 
     38     - N: number of indexed elements.
     39     - x: strided array.
     40     - strideX: index increment for `x`.
     41     - offsetX: starting index for `x`.
     42     - y: strided array.
     43     - strideY: index increment for `y`.
     44     - offsetY: starting index for `y`.
     45     - ...: additional strided arrays and associated strides and offsets.
     46 
     47     The choice of which strided array function interface to return depends on
     48     the use case. The former is suitable for typed array views; while the latter
     49     affords alternative indexing semantics more suitable for n-dimensional
     50     arrays (ndarrays).
     51 
     52     Parameters
     53     ----------
     54     fcns: Function|ArrayLikeObject<Function>
     55         List of strided array functions. Without offsets, a strided array
     56         function should have the following signature:
     57 
     58           f( arrays, shape, strides, data )
     59 
     60         where
     61 
     62         - arrays: array containing strided input and output arrays.
     63         - shape: array containing a single element, the number of indexed
     64           elements.
     65         - strides: array containing the stride lengths for the strided input and
     66           output arrays.
     67         - data: strided array function data (e.g., a callback).
     68 
     69         With offsets, a strided array function should have the following
     70         signature:
     71 
     72           f( arrays, shape, strides, offsets, data )
     73 
     74         where
     75 
     76         - offsets: array containing the starting indices (i.e., index offsets)
     77           for the strided input and output arrays.
     78 
     79         For convenience, a single strided array function may be provided which
     80         will be invoked whenever the strided array argument data types match a
     81         sequence of types in `types`. Providing a single strided array function
     82         is particularly convenient for the case where, regardless of array data
     83         types, traversing arrays remains the same, but the strided array
     84         function `data` differs (e.g., callbacks which differ based on the array
     85         data types).
     86 
     87     types: ArrayLikeObject<string>
     88         One-dimensional list of strided array argument data types.
     89 
     90     data: ArrayLikeObject|null
     91         Strided array function data (e.g., callbacks). If `null`, a returned
     92         strided array function interface does **not** provide a `data` argument
     93         to an invoked strided array function.
     94 
     95     nargs: integer
     96         Total number of strided array function interface arguments (including
     97         strides and offsets).
     98 
     99     nin: integer
    100         Number of input strided arrays.
    101 
    102     nout: integer
    103         Number of output strided arrays.
    104 
    105     Returns
    106     -------
    107     fcn: Function
    108         Strided array function interface.
    109 
    110     Examples
    111     --------
    112     // Define strided array argument data types:
    113     > var t = [ 'float64', 'float64', 'float32', 'float32' ];
    114 
    115     // Define a list of strided array function data (callbacks):
    116     > var d = [ {{alias:@stdlib/math/base/special/abs}}, {{alias:@stdlib/math/base/special/absf}} ];
    117 
    118     // Create a strided array function interface for applying unary callbacks:
    119     > var f = {{alias}}( {{alias:@stdlib/strided/base/unary}}, t, d, 5, 1, 1 );
    120 
    121     // Create an input strided array:
    122     > var x = new {{alias:@stdlib/array/float64}}( [ -1.0, -2.0, -3.0, -4.0 ] );
    123 
    124     // Create an output strided array:
    125     > var y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] );
    126 
    127     // Compute the element-wise absolute value:
    128     > f( x.length, x, 1, y, 1 );
    129     > y
    130     <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
    131 
    132     // Create a strided array function interface supporting offsets:
    133     > f = {{alias}}( {{alias:@stdlib/strided/base/unary}}.ndarray, t, d, 7, 1, 1 );
    134 
    135     // Create an input strided array:
    136     > x = new {{alias:@stdlib/array/float64}}( [ -1.0, -2.0, -3.0, -4.0 ] );
    137 
    138     // Create an output strided array:
    139     > y = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] );
    140 
    141     // Compute the element-wise absolute value starting from the third element:
    142     > f( x.length/2, x, 1, 2, y, 1, 2 );
    143     > y
    144     <Float64Array>[ 0.0, 0.0, 3.0, 4.0 ]
    145 
    146     See Also
    147     --------
    148