time-to-botec

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

README.md (3777B)


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