time-to-botec

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

README.md (4186B)


      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 # pdiff
     22 
     23 > Return the positive difference between `x` and `y`.
     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 pdiff = require( '@stdlib/math/base/special/pdiff' );
     41 ```
     42 
     43 #### pdiff( x, y )
     44 
     45 Returns the positive difference between `x` and `y` if `x < y`; otherwise, returns `0`.
     46 
     47 ```javascript
     48 var v = pdiff( 4.2, 3.14 );
     49 // returns 1.06
     50 
     51 v = pdiff( 3.14, 4.2 );
     52 // returns +0.0
     53 
     54 v = pdiff( -0.0, +0.0 );
     55 // returns +0.0
     56 ```
     57 
     58 If any argument is `NaN`, the function returns `NaN`.
     59 
     60 ```javascript
     61 var v = pdiff( 4.2, NaN );
     62 // returns NaN
     63 
     64 v = pdiff( NaN, 3.14 );
     65 // returns NaN
     66 
     67 v = pdiff( NaN, NaN );
     68 // returns NaN
     69 ```
     70 
     71 </section>
     72 
     73 <!-- /.usage -->
     74 
     75 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     76 
     77 <section class="notes">
     78 
     79 ## Notes
     80 
     81 -   This function is the equivalent of [`fdim`][fdim] in the C/C++ standard library.
     82 
     83 </section>
     84 
     85 <!-- /.notes -->
     86 
     87 <!-- Package usage examples. -->
     88 
     89 <section class="examples">
     90 
     91 ## Examples
     92 
     93 <!-- eslint no-undef: "error" -->
     94 
     95 ```javascript
     96 var minstd = require( '@stdlib/random/base/minstd-shuffle' );
     97 var pdiff = require( '@stdlib/math/base/special/pdiff' );
     98 
     99 var x;
    100 var y;
    101 var v;
    102 var i;
    103 
    104 for ( i = 0; i < 100; i++ ) {
    105     x = minstd();
    106     y = minstd();
    107     v = pdiff( x, y );
    108     console.log( 'pdiff(%d,%d) = %d', x, y, v );
    109 }
    110 ```
    111 
    112 </section>
    113 
    114 <!-- /.examples -->
    115 
    116 <!-- C interface documentation. -->
    117 
    118 * * *
    119 
    120 <section class="c">
    121 
    122 ## C APIs
    123 
    124 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
    125 
    126 <section class="intro">
    127 
    128 </section>
    129 
    130 <!-- /.intro -->
    131 
    132 <!-- C usage documentation. -->
    133 
    134 <section class="usage">
    135 
    136 ### Usage
    137 
    138 ```c
    139 #include "stdlib/math/base/special/pdiff.h
    140 ```
    141 
    142 #### stdlib_base_pdiff( x, y )
    143 
    144 Returns the positive difference between `x` and `y`.
    145 
    146 ```c
    147 double v = stdlib_base_pdiff( 4.0, 3.0 );
    148 // returns 1.0
    149 ```
    150 
    151 The function accepts the following arguments:
    152 
    153 -   **x**: `[in] double` input value.
    154 -   **y**: `[in] double` input value.
    155 
    156 ```c
    157 double stdlib_base_pdiff( const double x, const double y );
    158 ```
    159 
    160 </section>
    161 
    162 <!-- /.usage -->
    163 
    164 <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    165 
    166 <section class="notes">
    167 
    168 </section>
    169 
    170 <!-- /.notes -->
    171 
    172 <!-- C API usage examples. -->
    173 
    174 <section class="examples">
    175 
    176 ### Examples
    177 
    178 ```c
    179 #include "stdlib/math/base/special/pdiff.h"
    180 #include <stdio.h>
    181 
    182 int main() {
    183     double x[] = { 3.0, 4.0, 6.0, 5.0 };
    184 
    185     double y;
    186     int i;
    187     for ( i = 0; i < 4; i += 2 ) {
    188         y = stdlib_base_pdiff( x[ i ], x[ i+1 ] );
    189         printf( "pdiff(%lf, %lf) = %lf\n", x[ i ], x[ i+1 ], y );
    190     }
    191 }
    192 ```
    193 
    194 </section>
    195 
    196 <!-- /.examples -->
    197 
    198 </section>
    199 
    200 <!-- /.c -->
    201 
    202 <!-- 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. -->
    203 
    204 <section class="references">
    205 
    206 </section>
    207 
    208 <!-- /.references -->
    209 
    210 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    211 
    212 <section class="links">
    213 
    214 [fdim]: http://en.cppreference.com/w/cpp/numeric/math/fdim
    215 
    216 </section>
    217 
    218 <!-- /.links -->