time-to-botec

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

README.md (4466B)


      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 # iterAhavercos
     22 
     23 > Create an [iterator][mdn-iterator-protocol] which iteratively computes the [inverse half-value versed cosine][@stdlib/math/base/special/ahavercos].
     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 iterAhavercos = require( '@stdlib/math/iter/special/ahavercos' );
     41 ```
     42 
     43 #### iterAhavercos( iterator )
     44 
     45 Returns an [iterator][mdn-iterator-protocol] which iteratively computes the [inverse half-value versed cosine][@stdlib/math/base/special/ahavercos].
     46 
     47 ```javascript
     48 var array2iterator = require( '@stdlib/array/to-iterator' );
     49 
     50 var x = [ 0.0, 0.5, 1.0 ];
     51 var it = iterAhavercos( array2iterator( x ) );
     52 // returns <Object>
     53 
     54 var r = it.next().value;
     55 // returns ~3.1416
     56 
     57 r = it.next().value;
     58 // returns ~1.5708
     59 
     60 r = it.next().value;
     61 // returns 0.0
     62 
     63 // ...
     64 ```
     65 
     66 The returned [iterator][mdn-iterator-protocol] protocol-compliant object has the following properties:
     67 
     68 -   **next**: function which returns an [iterator][mdn-iterator-protocol] protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished.
     69 -   **return**: function which closes an [iterator][mdn-iterator-protocol] and returns a single (optional) argument in an [iterator][mdn-iterator-protocol] protocol-compliant object.
     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 -   The domain of inverse half-value versed cosine is restricted to `[0,1]`. If an iterated value is outside of the domain, the returned [iterator][mdn-iterator-protocol] returns `NaN`.
     82 -   If an iterated value is non-numeric (including `NaN`), the returned [iterator][mdn-iterator-protocol] returns `NaN`. If non-numeric iterated values are possible, you are advised to provide an [`iterator`][mdn-iterator-protocol] which type checks and handles non-numeric values accordingly.
     83 -   If an environment supports `Symbol.iterator` **and** a provided [iterator][mdn-iterator-protocol] is iterable, the returned [iterator][mdn-iterator-protocol] is iterable.
     84 
     85 </section>
     86 
     87 <!-- /.notes -->
     88 
     89 <!-- Package usage examples. -->
     90 
     91 <section class="examples">
     92 
     93 ## Examples
     94 
     95 <!-- eslint no-undef: "error" -->
     96 
     97 ```javascript
     98 var uniform = require( '@stdlib/random/iter/uniform' );
     99 var iterAhavercos = require( '@stdlib/math/iter/special/ahavercos' );
    100 
    101 // Create a seeded iterator for generating pseudorandom numbers:
    102 var rand = uniform( 0.0, 1.0, {
    103     'seed': 1234,
    104     'iter': 10
    105 });
    106 
    107 // Create an iterator which consumes the pseudorandom number iterator:
    108 var it = iterAhavercos( rand );
    109 
    110 // Perform manual iteration...
    111 var r;
    112 while ( true ) {
    113     r = it.next();
    114     if ( r.done ) {
    115         break;
    116     }
    117     console.log( r.value );
    118 }
    119 ```
    120 
    121 </section>
    122 
    123 <!-- /.examples -->
    124 
    125 <!-- 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. -->
    126 
    127 <section class="references">
    128 
    129 </section>
    130 
    131 <!-- /.references -->
    132 
    133 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    134 
    135 <section class="links">
    136 
    137 [mdn-iterator-protocol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterator_protocol
    138 
    139 [@stdlib/math/base/special/ahavercos]: https://www.npmjs.com/package/@stdlib/math/tree/main/base/special/ahavercos
    140 
    141 </section>
    142 
    143 <!-- /.links -->