time-to-botec

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

README.md (5097B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2020 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # dcuminabs
     22 
     23 > Calculate the cumulative minimum absolute value of double-precision floating-point strided array elements.
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var dcuminabs = require( '@stdlib/stats/base/dcuminabs' );
     37 ```
     38 
     39 #### dcuminabs( N, x, strideX, y, strideY )
     40 
     41 Computes the cumulative minimum absolute value of double-precision floating-point strided array elements.
     42 
     43 ```javascript
     44 var Float64Array = require( '@stdlib/array/float64' );
     45 
     46 var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
     47 var y = new Float64Array( x.length );
     48 
     49 dcuminabs( x.length, x, 1, y, 1 );
     50 // y => <Float64Array>[ 1.0, 1.0, 1.0 ]
     51 ```
     52 
     53 The function has the following parameters:
     54 
     55 -   **N**: number of indexed elements.
     56 -   **x**: input [`Float64Array`][@stdlib/array/float64].
     57 -   **strideX**: index increment for `x`.
     58 -   **y**: output [`Float64Array`][@stdlib/array/float64].
     59 -   **strideY**: index increment for `y`.
     60 
     61 The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative minimum absolute value of every other element in `x`,
     62 
     63 ```javascript
     64 var Float64Array = require( '@stdlib/array/float64' );
     65 
     66 var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] );
     67 var y = new Float64Array( x.length );
     68 
     69 var v = dcuminabs( 4, x, 2, y, 1 );
     70 // y => <Float64Array>[ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0 ]
     71 ```
     72 
     73 Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
     74 
     75 <!-- eslint-disable stdlib/capitalized-comments -->
     76 
     77 ```javascript
     78 var Float64Array = require( '@stdlib/array/float64' );
     79 
     80 // Initial arrays...
     81 var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
     82 var y0 = new Float64Array( x0.length );
     83 
     84 // Create offset views...
     85 var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
     86 var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element
     87 
     88 dcuminabs( 4, x1, -2, y1, 1 );
     89 // y0 => <Float64Array>[ 0.0, 0.0, 0.0, 4.0, 2.0, 2.0, 1.0, 0.0 ]
     90 ```
     91 
     92 #### dcuminabs.ndarray( N, x, strideX, offsetX, y, strideY, offsetY )
     93 
     94 Computes the cumulative minimum absolute value of double-precision floating-point strided array elements using alternative indexing semantics.
     95 
     96 ```javascript
     97 var Float64Array = require( '@stdlib/array/float64' );
     98 
     99 var x = new Float64Array( [ 1.0, -2.0, 2.0 ] );
    100 var y = new Float64Array( x.length );
    101 
    102 dcuminabs.ndarray( x.length, x, 1, 0, y, 1, 0 );
    103 // y => <Float64Array>[ 1.0, 1.0, 1.0 ]
    104 ```
    105 
    106 The function has the following additional parameters:
    107 
    108 -   **offsetX**: starting index for `x`.
    109 -   **offsetY**: starting index for `y`.
    110 
    111 While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative minimum absolute value of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element
    112 
    113 ```javascript
    114 var Float64Array = require( '@stdlib/array/float64' );
    115 
    116 var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
    117 var y = new Float64Array( x.length );
    118 
    119 dcuminabs.ndarray( 4, x, 2, 1, y, -1, y.length-1 );
    120 // y => <Float64Array>[ 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0 ]
    121 ```
    122 
    123 </section>
    124 
    125 <!-- /.usage -->
    126 
    127 <section class="notes">
    128 
    129 ## Notes
    130 
    131 -   If `N <= 0`, both functions return `y` unchanged.
    132 
    133 </section>
    134 
    135 <!-- /.notes -->
    136 
    137 <section class="examples">
    138 
    139 ## Examples
    140 
    141 <!-- eslint no-undef: "error" -->
    142 
    143 ```javascript
    144 var randu = require( '@stdlib/random/base/randu' );
    145 var round = require( '@stdlib/math/base/special/round' );
    146 var Float64Array = require( '@stdlib/array/float64' );
    147 var dcuminabs = require( '@stdlib/stats/base/dcuminabs' );
    148 
    149 var y;
    150 var x;
    151 var i;
    152 
    153 x = new Float64Array( 10 );
    154 y = new Float64Array( x.length );
    155 for ( i = 0; i < x.length; i++ ) {
    156     x[ i ] = round( (randu()*100.0) - 50.0 );
    157 }
    158 console.log( x );
    159 console.log( y );
    160 
    161 dcuminabs( x.length, x, 1, y, -1 );
    162 console.log( y );
    163 ```
    164 
    165 </section>
    166 
    167 <!-- /.examples -->
    168 
    169 <section class="references">
    170 
    171 </section>
    172 
    173 <!-- /.references -->
    174 
    175 <section class="links">
    176 
    177 [@stdlib/array/float64]: https://www.npmjs.com/package/@stdlib/array-float64
    178 
    179 [mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray
    180 
    181 </section>
    182 
    183 <!-- /.links -->