time-to-botec

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

README.md (2321B)


      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 # sincos
     22 
     23 > Simultaneously compute the [sine][@stdlib/math/base/special/sin] and [cosine][@stdlib/math/base/special/cos] of a number.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var sincos = require( '@stdlib/math/base/special/sincos' );
     31 ```
     32 
     33 #### sincos( \[out,] x )
     34 
     35 Simultaneously computes the [sine][@stdlib/math/base/special/sin] and [cosine][@stdlib/math/base/special/cos] of a `number` (in radians).
     36 
     37 ```javascript
     38 var v = sincos( 0.0 );
     39 // returns [ ~0.0, ~1.0 ]
     40 
     41 v = sincos( 3.141592653589793/2.0 );
     42 // returns [ ~1.0, ~0.0 ]
     43 
     44 v = sincos( -3.141592653589793/6.0 );
     45 // returns [ ~-0.5, ~0.866 ]
     46 ```
     47 
     48 By default, the function returns the sine and cosine as a two-element `array`. To avoid extra memory allocation, the function supports providing an output (destination) object.
     49 
     50 ```javascript
     51 var Float64Array = require( '@stdlib/array/float64' );
     52 
     53 var out = new Float64Array( 2 );
     54 
     55 var v = sincos( out, 0.0 );
     56 // returns <Float64Array>[ ~0.0, ~1.0 ]
     57 
     58 var bool = ( v === out );
     59 // returns true
     60 ```
     61 
     62 </section>
     63 
     64 <!-- /.usage -->
     65 
     66 <section class="examples">
     67 
     68 ## Examples
     69 
     70 <!-- eslint no-undef: "error" -->
     71 
     72 ```javascript
     73 var linspace = require( '@stdlib/array/linspace' );
     74 var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
     75 var sincos = require( '@stdlib/math/base/special/sincos' );
     76 
     77 var x = linspace( 0.0, TWO_PI, 100 );
     78 var i;
     79 
     80 for ( i = 0; i < x.length; i++ ) {
     81     console.log( sincos( x[ i ] ) );
     82 }
     83 ```
     84 
     85 </section>
     86 
     87 <!-- /.examples -->
     88 
     89 <section class="links">
     90 
     91 [@stdlib/math/base/special/sin]: https://www.npmjs.com/package/@stdlib/math/tree/main/base/special/sin
     92 
     93 [@stdlib/math/base/special/cos]: https://www.npmjs.com/package/@stdlib/math/tree/main/base/special/cos
     94 
     95 </section>
     96 
     97 <!-- /.links -->