time-to-botec

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

repl.txt (3408B)


      1 
      2 {{alias}}( N, x, stride, clbk[, thisArg] )
      3     Fills a strided array according to a provided callback function.
      4 
      5     The `N` and `stride` parameters determine which elements in `x` are accessed
      6     at runtime.
      7 
      8     Indexing is relative to the first index. To introduce an offset, use typed
      9     array views.
     10 
     11     If `N <= 0`, the function returns `x` unchanged.
     12 
     13     The callback function is provided four arguments:
     14 
     15     - value: array element
     16     - aidx: array index
     17     - sidx: strided index (offset + aidx*stride)
     18     - array: the input array
     19 
     20     The callback return value is used as the fill value for the current array
     21     index.
     22 
     23     Parameters
     24     ----------
     25     N: integer
     26         Number of indexed elements.
     27 
     28     x: Array|TypedArray|Object
     29         Input array/collection. If provided an object, the object must be array-
     30         like (excluding strings and functions).
     31 
     32     stride: integer
     33         Index increment for `x`.
     34 
     35     clbk: Function
     36         Callback function.
     37 
     38     thisArg: any (optional)
     39         Execution context.
     40 
     41     Returns
     42     -------
     43     x: Array|TypedArray|Object
     44         Input array/collection `x`.
     45 
     46     Examples
     47     --------
     48     // Standard Usage:
     49     > function fill() { return 5.0; };
     50     > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ];
     51     > {{alias}}( x.length, x, 1, fill )
     52     [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]
     53 
     54     // Using `N` and `stride` parameters:
     55     > x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ];
     56     > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
     57     > {{alias}}( N, x, 2, fill )
     58     [ 5.0, 1.0, 5.0, -5.0, 5.0, -1.0, -3.0 ]
     59 
     60     // Using view offsets:
     61     > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
     62     > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
     63     > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 );
     64     > {{alias}}( N, x1, 2, fill )
     65     <Float64Array>[ 5.0, 3.0, 5.0, 5.0, 5.0 ]
     66     > x0
     67     <Float64Array>[ 1.0, 5.0, 3.0, 5.0, 5.0, 5.0 ]
     68 
     69 {{alias}}.ndarray( N, x, stride, offset, clbk[, thisArg] )
     70     Fills a strided array according to a provided callback function and using
     71     alternative indexing semantics.
     72 
     73     While typed array views mandate a view offset based on the underlying
     74     buffer, the `offset` parameter supports indexing semantics based on a
     75     starting index.
     76 
     77     Parameters
     78     ----------
     79     N: integer
     80         Number of indexed elements.
     81 
     82     x: Array|TypedArray|Object
     83         Input array/collection. If provided an object, the object must be array-
     84         like (excluding strings and functions).
     85 
     86     stride: integer
     87         Index increment for `x`.
     88 
     89     offset: integer
     90         Starting index of `x`.
     91 
     92     clbk: Function
     93         Callback function.
     94 
     95     thisArg: any (optional)
     96         Execution context.
     97 
     98     Returns
     99     -------
    100     x: Array|TypedArray|Object
    101         Input array/collection `x`.
    102 
    103     Examples
    104     --------
    105     // Standard Usage:
    106     > function fill() { return 5.0; };
    107     > var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, -1.0, -3.0 ];
    108     > {{alias}}.ndarray( x.length, x, 1, 0, fill )
    109     [ 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0 ]
    110 
    111     // Using an index offset:
    112     > x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];
    113     > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
    114     > {{alias}}.ndarray( N, x, 2, 1, fill )
    115     [ 1.0, 5.0, 3.0, 5.0, 5.0, 5.0 ]
    116 
    117     See Also
    118     --------
    119