time-to-botec

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

README.md (3113B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 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 # minmax
     22 
     23 > Return the minimum and maximum values.
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <!-- Package usage documentation. -->
     34 
     35 <section class="usage">
     36 
     37 ## Usage
     38 
     39 ```javascript
     40 var minmax = require( '@stdlib/math/base/special/minmax' );
     41 ```
     42 
     43 #### minmax( \[out,] x\[, y\[, ...args]] )
     44 
     45 Returns the minimum and maximum values in a single pass.
     46 
     47 ```javascript
     48 var v = minmax( 4.2, 3.14 );
     49 // returns [ 3.14, 4.2 ]
     50 
     51 v = minmax( +0.0, -0.0 );
     52 // returns [ -0.0, +0.0 ]
     53 
     54 v = minmax( 4.2, 3.14, -1.0, 6.8 );
     55 // returns [ -1.0, 6.8 ]
     56 ```
     57 
     58 If any argument is `NaN`, the function returns `NaN` for both the minimum value and the maximum value.
     59 
     60 ```javascript
     61 var v = minmax( 4.2, NaN );
     62 // returns [ NaN, NaN ]
     63 
     64 v = minmax( NaN, 3.14 );
     65 // returns [ NaN, NaN ]
     66 ```
     67 
     68 By default, the function returns minimum and maximum values as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object.
     69 
     70 ```javascript
     71 var Float64Array = require( '@stdlib/array/float64' );
     72 
     73 var out = new Float64Array( 2 );
     74 
     75 var v = minmax( out, 5.0, 3.0, -2.0, 1.0 );
     76 // returns <Float64Array>[ -2.0, 5.0 ]
     77 
     78 var bool = ( v === out );
     79 // returns true
     80 ```
     81 
     82 </section>
     83 
     84 <!-- /.usage -->
     85 
     86 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     87 
     88 <section class="notes">
     89 
     90 </section>
     91 
     92 <!-- /.notes -->
     93 
     94 <!-- Package usage examples. -->
     95 
     96 <section class="examples">
     97 
     98 ## Examples
     99 
    100 <!-- eslint no-undef: "error" -->
    101 
    102 ```javascript
    103 var minstd = require( '@stdlib/random/base/minstd-shuffle' );
    104 var minmax = require( '@stdlib/math/base/special/minmax' );
    105 
    106 var x;
    107 var y;
    108 var v;
    109 var i;
    110 
    111 for ( i = 0; i < 100; i++ ) {
    112     x = minstd();
    113     y = minstd();
    114     v = minmax( x, y );
    115     console.log( 'minmax(%d,%d) = [%d, %d]', x, y, v[0], v[1] );
    116 }
    117 ```
    118 
    119 </section>
    120 
    121 <!-- /.examples -->
    122 
    123 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    124 
    125 <section class="references">
    126 
    127 </section>
    128 
    129 <!-- /.references -->
    130 
    131 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    132 
    133 <section class="links">
    134 
    135 </section>
    136 
    137 <!-- /.links -->