time-to-botec

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

repl.txt (3634B)


      1 
      2 {{alias}}( N, x, strideX, y, strideY )
      3     Computes the dot product of two single-precision floating-point vectors.
      4 
      5     The `N`, `strideX`, and `strideY` parameters determine which elements in `x`
      6     and `y` are accessed at runtime.
      7 
      8     Indexing is relative to the first index. To introduce an offset, use a typed
      9     array view.
     10 
     11     If `N <= 0`, the function returns `0.0`.
     12 
     13     Parameters
     14     ----------
     15     N: integer
     16         Number of indexed elements.
     17 
     18     x: Float32Array
     19         First input array.
     20 
     21     strideX: integer
     22         Index increment for `x`.
     23 
     24     y: Float32Array
     25         Second input array.
     26 
     27     strideY: integer
     28         Index increment for `y`.
     29 
     30     Returns
     31     -------
     32     dot: float
     33         The dot product of `x` and `y`.
     34 
     35     Examples
     36     --------
     37     // Standard usage:
     38     > var x = new {{alias:@stdlib/array/float32}}( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] );
     39     > var y = new {{alias:@stdlib/array/float32}}( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] );
     40     > var dot = {{alias}}( x.length, x, 1, y, 1 )
     41     -5.0
     42 
     43     // Strides:
     44     > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
     45     > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] );
     46     > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
     47     > dot = {{alias}}( N, x, 2, y, -1 )
     48     9.0
     49 
     50     // Using view offsets:
     51     > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
     52     > y = new {{alias:@stdlib/array/float32}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
     53     > var x1 = new {{alias:@stdlib/array/float32}}( x.buffer, x.BYTES_PER_ELEMENT*1 );
     54     > var y1 = new {{alias:@stdlib/array/float32}}( y.buffer, y.BYTES_PER_ELEMENT*3 );
     55     > N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
     56     > dot = {{alias}}( N, x1, -2, y1, 1 )
     57     128.0
     58 
     59 {{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY )
     60     Computes the dot product of two single-precision floating-point vectors
     61     using alternative indexing semantics.
     62 
     63     While typed array views mandate a view offset based on the underlying
     64     buffer, the `offsetX` and `offsetY` parameters support indexing based on a
     65     starting index.
     66 
     67     Parameters
     68     ----------
     69     N: integer
     70         Number of indexed elements.
     71 
     72     x: Float32Array
     73         First input array.
     74 
     75     strideX: integer
     76         Index increment for `x`.
     77 
     78     offsetX: integer
     79         Starting index for `x`.
     80 
     81     y: Float32Array
     82         Second input array.
     83 
     84     strideY: integer
     85         Index increment for `y`.
     86 
     87     offsetY: integer
     88         Starting index for `y`.
     89 
     90     Returns
     91     -------
     92     dot: float
     93         The dot product of `x` and `y`.
     94 
     95     Examples
     96     --------
     97     // Standard usage:
     98     > var x = new {{alias:@stdlib/array/float32}}( [ 4.0, 2.0, -3.0, 5.0, -1.0 ] );
     99     > var y = new {{alias:@stdlib/array/float32}}( [ 2.0, 6.0, -1.0, -4.0, 8.0 ] );
    100     > var dot = {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0 )
    101     -5.0
    102 
    103     // Strides:
    104     > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
    105     > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ] );
    106     > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
    107     > dot = {{alias}}.ndarray( N, x, 2, 0, y, 2, 0 )
    108     9.0
    109 
    110     // Using offset indices:
    111     > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
    112     > y = new {{alias:@stdlib/array/float32}}( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
    113     > N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 );
    114     > dot = {{alias}}.ndarray( N, x, -2, x.length-1, y, 1, 3 )
    115     128.0
    116 
    117     See Also
    118     --------
    119