time-to-botec

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

repl.txt (11191B)


      1 
      2 {{alias}}( dtype, buffer, shape, strides, offset, order[, options] )
      3     Returns an ndarray.
      4 
      5     Parameters
      6     ----------
      7     dtype: string
      8         Underlying data type.
      9 
     10     buffer: ArrayLikeObject|TypedArray|Buffer
     11         Data buffer. A data buffer must be an array-like object (i.e., have a
     12         `length` property). For data buffers which are not indexed collections
     13         (i.e., collections which cannot support direct index access, such as
     14         `buffer[ index ]`; e.g., Complex64Array, Complex128Array, etc), a data
     15         buffer should provide `#.get( idx )` and `#.set( v[, idx] )` methods.
     16         Note that, for `set` methods, the value to set should be the first
     17         argument, followed by the linear index, similar to the native typed
     18         array `set` method.
     19 
     20     shape: ArrayLikeObject<integer>
     21         Array shape.
     22 
     23     strides: ArrayLikeObject<integer>
     24         Array strides.
     25 
     26     offset: integer
     27         Index offset.
     28 
     29     order: string
     30         Specifies whether an array is row-major (C-style) or column-major
     31         (Fortran-style).
     32 
     33     options: Object (optional)
     34         Options.
     35 
     36     options.mode: string (optional)
     37         Specifies how to handle indices which exceed array dimensions. If equal
     38         to 'throw', an ndarray instance throws an error when an index exceeds
     39         array dimensions. If equal to 'wrap', an ndarray instance wraps around
     40         indices exceeding array dimensions using modulo arithmetic. If equal to
     41         'clamp', an ndarray instance sets an index exceeding array dimensions to
     42         either `0` (minimum index) or the maximum index. Default: 'throw'.
     43 
     44     options.submode: Array<string> (optional)
     45         Specifies how to handle subscripts which exceed array dimensions. If a
     46         mode for a corresponding dimension is equal to 'throw', an ndarray
     47         instance throws an error when a subscript exceeds array dimensions. If
     48         equal to 'wrap', an ndarray instance wraps around subscripts exceeding
     49         array dimensions using modulo arithmetic. If equal to 'clamp', an
     50         ndarray instance sets a subscript exceeding array dimensions to either
     51         `0` (minimum index) or the maximum index. If the number of modes is
     52         fewer than the number of dimensions, the function recycles modes using
     53         modulo arithmetic. Default: [ options.mode ].
     54 
     55     Returns
     56     -------
     57     ndarray: ndarray
     58         ndarray instance.
     59 
     60     Examples
     61     --------
     62     // Create a new instance...
     63     > var b = [ 1.0, 2.0, 3.0, 4.0 ]; // underlying data buffer
     64     > var d = [ 2, 2 ]; // shape
     65     > var s = [ 2, 1 ]; // strides
     66     > var o = 0; // index offset
     67     > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' )
     68     <ndarray>
     69 
     70     // Get an element using subscripts:
     71     > var v = arr.get( 1, 1 )
     72     4.0
     73 
     74     // Get an element using a linear index:
     75     > v = arr.iget( 3 )
     76     4.0
     77 
     78     // Set an element using subscripts:
     79     > arr.set( 1, 1, 40.0 );
     80     > arr.get( 1, 1 )
     81     40.0
     82 
     83     // Set an element using a linear index:
     84     > arr.iset( 3, 99.0 );
     85     > arr.get( 1, 1 )
     86     99.0
     87 
     88 
     89 {{alias}}.prototype.byteLength
     90     Size (in bytes) of the array (if known).
     91 
     92     Returns
     93     -------
     94     size: integer|null
     95         Size (in bytes) of the array.
     96 
     97     Examples
     98     --------
     99     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    100     > var d = [ 2, 2 ];
    101     > var s = [ 2, 1 ];
    102     > var o = 0;
    103     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    104     > var sz = arr.byteLength
    105     32
    106 
    107 
    108 {{alias}}.prototype.BYTES_PER_ELEMENT
    109     Size (in bytes) of each array element (if known).
    110 
    111     Returns
    112     -------
    113     size: integer|null
    114         Size (in bytes) of each array element.
    115 
    116     Examples
    117     --------
    118     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    119     > var d = [ 2, 2 ];
    120     > var s = [ 2, 1 ];
    121     > var o = 0;
    122     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    123     > var sz = arr.BYTES_PER_ELEMENT
    124     8
    125 
    126 
    127 {{alias}}.prototype.data
    128     Pointer to the underlying data buffer.
    129 
    130     Returns
    131     -------
    132     buf: ArrayLikeObject|TypedArray|Buffer
    133         Underlying data buffer.
    134 
    135     Examples
    136     --------
    137     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    138     > var d = [ 2, 2 ];
    139     > var s = [ 2, 1 ];
    140     > var o = 0;
    141     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    142     > var buf = arr.data
    143     <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
    144 
    145 
    146 {{alias}}.prototype.dtype
    147     Underlying data type.
    148 
    149     Returns
    150     -------
    151     dtype: string
    152         Underlying data type.
    153 
    154     Examples
    155     --------
    156     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    157     > var d = [ 2, 2 ];
    158     > var s = [ 2, 1 ];
    159     > var o = 0;
    160     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    161     > var dt = arr.dtype
    162     'float64'
    163 
    164 
    165 {{alias}}.prototype.flags
    166     Information about the memory layout of the array.
    167 
    168     Returns
    169     -------
    170     flags: Object
    171         Info object.
    172 
    173     Examples
    174     --------
    175     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    176     > var d = [ 2, 2 ];
    177     > var s = [ 2, 1 ];
    178     > var o = 0;
    179     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    180     > var fl = arr.flags
    181     {...}
    182 
    183 
    184 {{alias}}.prototype.length
    185     Length of the array (i.e., number of elements).
    186 
    187     Returns
    188     -------
    189     len: integer
    190         Array length.
    191 
    192     Examples
    193     --------
    194     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    195     > var d = [ 2, 2 ];
    196     > var s = [ 2, 1 ];
    197     > var o = 0;
    198     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    199     > var len = arr.length
    200     4
    201 
    202 
    203 {{alias}}.prototype.ndims
    204     Number of dimensions.
    205 
    206     Returns
    207     -------
    208     ndims: integer
    209         Number of dimensions.
    210 
    211     Examples
    212     --------
    213     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    214     > var d = [ 2, 2 ];
    215     > var s = [ 2, 1 ];
    216     > var o = 0;
    217     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    218     > var n = arr.ndims
    219     2
    220 
    221 
    222 {{alias}}.prototype.offset
    223     Index offset which specifies the buffer index at which to start iterating
    224     over array elements.
    225 
    226     Returns
    227     -------
    228     offset: integer
    229         Index offset.
    230 
    231     Examples
    232     --------
    233     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    234     > var d = [ 2, 2 ];
    235     > var s = [ 2, 1 ];
    236     > var o = 0;
    237     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    238     > var v = arr.offset
    239     0
    240 
    241 
    242 {{alias}}.prototype.order
    243     Array order.
    244 
    245     The array order is either row-major (C-style) or column-major (Fortran-
    246     style).
    247 
    248     Returns
    249     -------
    250     order: string
    251         Array order.
    252 
    253     Examples
    254     --------
    255     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    256     > var d = [ 2, 2 ];
    257     > var s = [ 2, 1 ];
    258     > var o = 0;
    259     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    260     > var ord = arr.order
    261     'row-major'
    262 
    263 
    264 {{alias}}.prototype.shape
    265     Array shape.
    266 
    267     Returns
    268     -------
    269     shape: Array
    270         Array shape.
    271 
    272     Examples
    273     --------
    274     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    275     > var d = [ 2, 2 ];
    276     > var s = [ 2, 1 ];
    277     > var o = 0;
    278     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    279     > var sh = arr.shape
    280     [ 2, 2 ]
    281 
    282 
    283 {{alias}}.prototype.strides
    284     Index strides which specify how to access data along corresponding array
    285     dimensions.
    286 
    287     Returns
    288     -------
    289     strides: Array
    290         Index strides.
    291 
    292     Examples
    293     --------
    294     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    295     > var d = [ 2, 2 ];
    296     > var s = [ 2, 1 ];
    297     > var o = 0;
    298     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    299     > var st = arr.strides
    300     [ 2, 1 ]
    301 
    302 
    303 {{alias}}.prototype.get( ...idx )
    304     Returns an array element specified according to provided subscripts.
    305 
    306     The number of provided subscripts should equal the number of dimensions.
    307 
    308     For zero-dimensional arrays, no indices should be provided.
    309 
    310     Parameters
    311     ----------
    312     idx: ...integer
    313         Subscripts.
    314 
    315     Returns
    316     -------
    317     out: any
    318         Array element.
    319 
    320     Examples
    321     --------
    322     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    323     > var d = [ 2, 2 ];
    324     > var s = [ 2, 1 ];
    325     > var o = 0;
    326     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    327     > var v = arr.get( 1, 1 )
    328     4.0
    329 
    330 
    331 {{alias}}.prototype.iget( idx )
    332     Returns an array element located at a specified linear index.
    333 
    334     For zero-dimensional arrays, the input argument is ignored and, for clarity,
    335     should not be provided.
    336 
    337     Parameters
    338     ----------
    339     idx: integer
    340         Linear index.
    341 
    342     Returns
    343     -------
    344     out: any
    345         Array element.
    346 
    347     Examples
    348     --------
    349     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    350     > var d = [ 2, 2 ];
    351     > var s = [ 2, 1 ];
    352     > var o = 0;
    353     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    354     > var v = arr.iget( 3 )
    355     4.0
    356 
    357 
    358 {{alias}}.prototype.set( ...idx, v )
    359     Sets an array element specified according to provided subscripts.
    360 
    361     The number of provided subscripts should equal the number of dimensions.
    362 
    363     For zero-dimensional arrays, no indices should be provided.
    364 
    365     Parameters
    366     ----------
    367     idx: ...integer
    368         Subscripts.
    369 
    370     v: any
    371         Value to set.
    372 
    373     Returns
    374     -------
    375     out: ndarray
    376         ndarray instance.
    377 
    378     Examples
    379     --------
    380     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    381     > var d = [ 2, 2 ];
    382     > var s = [ 2, 1 ];
    383     > var o = 0;
    384     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    385     > arr.set( 1, 1, -4.0 );
    386     > arr.get( 1, 1 )
    387     -4.0
    388 
    389 
    390 {{alias}}.prototype.iset( idx, v )
    391     Sets an array element located at a specified linear index.
    392 
    393     For zero-dimensional arrays, the first, and only, argument should be the
    394     value to set.
    395 
    396     Parameters
    397     ----------
    398     idx: integer
    399         Linear index.
    400 
    401     v: any
    402         Value to set.
    403 
    404     Returns
    405     -------
    406     out: ndarray
    407         ndarray instance.
    408 
    409     Examples
    410     --------
    411     > var b = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] );
    412     > var d = [ 2, 2 ];
    413     > var s = [ 2, 1 ];
    414     > var o = 0;
    415     > var arr = {{alias}}( 'float64', b, d, s, o, 'row-major' );
    416     > arr.iset( 3, -4.0 );
    417     > arr.iget( 3 )
    418     -4.0
    419 
    420 
    421 {{alias}}.prototype.toString()
    422     Serializes an ndarray as a string.
    423 
    424     This method does **not** serialize data outside of the buffer region defined
    425     by the array configuration.
    426 
    427     Returns
    428     -------
    429     str: string
    430         Serialized ndarray string.
    431 
    432     Examples
    433     --------
    434     > var b = [ 1, 2, 3, 4 ];
    435     > var d = [ 2, 2 ];
    436     > var s = [ 2, 1 ];
    437     > var o = 0;
    438     > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' );
    439     > arr.toString()
    440     '...'
    441 
    442 
    443 {{alias}}.prototype.toJSON()
    444     Serializes an ndarray as a JSON object.
    445 
    446     This method does **not** serialize data outside of the buffer region defined
    447     by the array configuration.
    448 
    449     Returns
    450     -------
    451     obj: Object
    452         JSON object.
    453 
    454     Examples
    455     --------
    456     > var b = [ 1, 2, 3, 4 ];
    457     > var d = [ 2, 2 ];
    458     > var s = [ 2, 1 ];
    459     > var o = 0;
    460     > var arr = {{alias}}( 'generic', b, d, s, o, 'row-major' );
    461     > arr.toJSON()
    462     {...}
    463 
    464     See Also
    465     --------
    466