time-to-botec

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

README.md (2993B)


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