time-to-botec

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

README.md (3114B)


      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 # abs2
     22 
     23 > Compute the squared [absolute value][absolute-value] of a double-precision floating-point number.
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var abs2 = require( '@stdlib/math/base/special/abs2' );
     37 ```
     38 
     39 #### abs2( x )
     40 
     41 Computes the squared [absolute value][absolute-value] of a double-precision floating-point number.
     42 
     43 ```javascript
     44 var v = abs2( -1.0 );
     45 // returns 1.0
     46 
     47 v = abs2( 2.0 );
     48 // returns 4.0
     49 
     50 v = abs2( 0.0 );
     51 // returns 0.0
     52 
     53 v = abs2( -0.0 );
     54 // returns 0.0
     55 
     56 v = abs2( NaN );
     57 // returns NaN
     58 ```
     59 
     60 </section>
     61 
     62 <!-- /.usage -->
     63 
     64 <section class="examples">
     65 
     66 ## Examples
     67 
     68 <!-- eslint no-undef: "error" -->
     69 
     70 ```javascript
     71 var randu = require( '@stdlib/random/base/randu' );
     72 var round = require( '@stdlib/math/base/special/round' );
     73 var abs2 = require( '@stdlib/math/base/special/abs2' );
     74 
     75 var x;
     76 var i;
     77 
     78 for ( i = 0; i < 100; i++ ) {
     79     x = round( randu() * 100.0 ) - 50.0;
     80     console.log( 'abs2(%d) = %d', x, abs2( x ) );
     81 }
     82 ```
     83 
     84 </section>
     85 
     86 <!-- /.examples -->
     87 
     88 <!-- C interface documentation. -->
     89 
     90 * * *
     91 
     92 <section class="c">
     93 
     94 ## C APIs
     95 
     96 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     97 
     98 <section class="intro">
     99 
    100 </section>
    101 
    102 <!-- /.intro -->
    103 
    104 <!-- C usage documentation. -->
    105 
    106 <section class="usage">
    107 
    108 ### Usage
    109 
    110 ```c
    111 #include "stdlib/math/base/special/abs2.h"
    112 ```
    113 
    114 #### stdlib_base_abs2( x )
    115 
    116 Computes the squared absolute value of a double-precision floating-point number.
    117 
    118 ```c
    119 double y = stdlib_base_abs2( -5.0 );
    120 // returns 25.0
    121 ```
    122 
    123 The function accepts the following arguments:
    124 
    125 -   **x**: `[in] double` input value.
    126 
    127 ```c
    128 double stdlib_base_abs2( const double x );
    129 ```
    130 
    131 </section>
    132 
    133 <!-- /.usage -->
    134 
    135 <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    136 
    137 <section class="notes">
    138 
    139 </section>
    140 
    141 <!-- /.notes -->
    142 
    143 <!-- C API usage examples. -->
    144 
    145 <section class="examples">
    146 
    147 ### Examples
    148 
    149 ```c
    150 #include "stdlib/math/base/special/abs2.h"
    151 #include <stdio.h>
    152 
    153 int main() {
    154     double x[] = { 3.14, -3.14, 0.0, 0.0/0.0 };
    155 
    156     double y;
    157     int i;
    158     for ( i = 0; i < 4; i++ ) {
    159         y = stdlib_base_abs2( x[ i ] );
    160         printf( "abs2(%lf) = %lf\n", x[ i ], y );
    161     }
    162 }
    163 ```
    164 
    165 </section>
    166 
    167 <!-- /.examples -->
    168 
    169 </section>
    170 
    171 <!-- /.c -->
    172 
    173 <section class="links">
    174 
    175 [absolute-value]: https://en.wikipedia.org/wiki/Absolute_value
    176 
    177 </section>
    178 
    179 <!-- /.links -->