time-to-botec

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

README.md (2193B)


      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 # phase
     22 
     23 > Compute the [argument][complex-number-argument] of a complex number in radians.
     24 
     25 <section class="intro">
     26 
     27 The [argument][complex-number-argument] of a complex number, also known as the **phase**, is the angle of the radius extending from the origin to the complex number plotted in the complex plane and the positive real axis.
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <section class="usage">
     34 
     35 ## Usage
     36 
     37 ```javascript
     38 var cphase = require( '@stdlib/math/base/special/cphase' );
     39 ```
     40 
     41 #### cphase( re, im )
     42 
     43 Computes the [argument][complex-number-argument] of a `complex` number comprised of a **real** component `re` and an **imaginary** component `im`.
     44 
     45 ```javascript
     46 var phi = cphase( 5.0, 3.0 );
     47 // returns ~0.5404
     48 ```
     49 
     50 </section>
     51 
     52 <!-- /.usage -->
     53 
     54 <section class="examples">
     55 
     56 ## Examples
     57 
     58 <!-- eslint no-undef: "error" -->
     59 
     60 ```javascript
     61 var Complex128 = require( '@stdlib/complex/float64' );
     62 var randu = require( '@stdlib/random/base/randu' );
     63 var round = require( '@stdlib/math/base/special/round' );
     64 var real = require( '@stdlib/complex/real' );
     65 var imag = require( '@stdlib/complex/imag' );
     66 var cphase = require( '@stdlib/math/base/special/cphase' );
     67 
     68 var re;
     69 var im;
     70 var z;
     71 var i;
     72 
     73 for ( i = 0; i < 100; i++ ) {
     74     re = round( randu()*100.0 ) - 50.0;
     75     im = round( randu()*100.0 ) - 50.0;
     76     z = new Complex128( re, im );
     77     console.log( 'arg(%s) = %d', z.toString(), cphase( real(z), imag(z) ) );
     78 }
     79 ```
     80 
     81 </section>
     82 
     83 <!-- /.examples -->
     84 
     85 <section class="links">
     86 
     87 [complex-number-argument]: https://en.wikipedia.org/wiki/Argument_%28complex_analysis%29
     88 
     89 </section>
     90 
     91 <!-- /.links -->