time-to-botec

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

repl.txt (2879B)


      1 
      2 {{alias}}( x[, options] )
      3     Computes the absolute value.
      4 
      5     If provided a number, the function returns a number.
      6 
      7     If provided an ndarray or array-like object, the function performs element-
      8     wise computation.
      9 
     10     If provided an array-like object, the function returns an array-like object
     11     having the same length and data type as `x`.
     12 
     13     If provided an ndarray, the function returns an ndarray having the same
     14     shape and data type as `x`.
     15 
     16     Parameters
     17     ----------
     18     x: ndarray|ArrayLikeObject|number
     19         Input value.
     20 
     21     options: Object (optional)
     22         Options.
     23 
     24     options.order: string (optional)
     25         Output array order (either row-major (C-style) or column-major (Fortran-
     26         style)). Only applicable when the input array is an ndarray. By default,
     27         the output array order is inferred from the input array.
     28 
     29     options.dtype: string (optional)
     30         Output array data type. Only applicable when the input array is either
     31         an ndarray or array-like object. By default, the output array data type
     32         is inferred from the input array.
     33 
     34     Returns
     35     -------
     36     y: ndarray|ArrayLikeObject|number
     37         Results.
     38 
     39     Examples
     40     --------
     41     // Provide a number:
     42     > var y = {{alias}}( -1.0 )
     43     1.0
     44 
     45     // Provide an array-like object:
     46     > var x = new {{alias:@stdlib/array/float64}}( [ -1.0, -2.0 ] );
     47     > y = {{alias}}( x )
     48     <Float64Array>[ 1.0, 2.0 ]
     49 
     50     > x = [ -1.0, -2.0 ];
     51     > y = {{alias}}( x )
     52     [ 1.0, 2.0 ]
     53 
     54     // Provide an ndarray:
     55     > x = {{alias:@stdlib/ndarray/array}}( [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] );
     56     > y = {{alias}}( x )
     57     <ndarray>
     58     > y.get( 0, 1 )
     59     2.0
     60 
     61 
     62 {{alias}}.assign( x, y )
     63     Computes the absolute value and assigns results to a provided output array.
     64 
     65     Parameters
     66     ----------
     67     x: ndarray|ArrayLikeObject
     68         Input array.
     69 
     70     y: ndarray|ArrayLikeObject
     71         Output array. Must be the same data "kind" (i.e., ndarray or array-like
     72         object) as the input array.
     73 
     74     Returns
     75     -------
     76     y: ndarray|ArrayLikeObject
     77         Output array.
     78 
     79     Examples
     80     --------
     81     // Provide an array-like object:
     82     > var x = new {{alias:@stdlib/array/float64}}( [ -1.0, -2.0 ] );
     83     > var y = new {{alias:@stdlib/array/float64}}( x.length );
     84     > var out = {{alias}}.assign( x, y )
     85     <Float64Array>[ 1.0, 2.0 ]
     86     > var bool = ( out === y )
     87     true
     88 
     89     > x = [ -1.0, -2.0 ];
     90     > y = [ 0.0, 0.0 ];
     91     > out = {{alias}}.assign( x, y )
     92     [ 1.0, 2.0 ]
     93     > bool = ( out === y )
     94     true
     95 
     96     // Provide an ndarray:
     97     > x = {{alias:@stdlib/ndarray/array}}( [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] );
     98     > y = {{alias:@stdlib/ndarray/array}}( [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] );
     99     > out = {{alias}}.assign( x, y )
    100     <ndarray>
    101     > out.get( 0, 1 )
    102     2.0
    103     > bool = ( out === y )
    104     true
    105 
    106     See Also
    107     --------
    108