README.md (2762B)
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 # reim 22 23 > Return the real and imaginary components of a complex number. 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 reim = require( '@stdlib/complex/reim' ); 41 ``` 42 43 #### reim( z ) 44 45 Returns the **real** and **imaginary** components of a `complex` number. 46 47 ```javascript 48 var Complex128 = require( '@stdlib/complex/float64' ); 49 var Complex64 = require( '@stdlib/complex/float32' ); 50 51 var z = new Complex128( 5.0, 3.0 ); 52 var out = reim( z ); 53 // returns <Float64Array>[ 5.0, 3.0 ] 54 55 z = new Complex64( 5.0, 3.0 ); 56 out = reim( z ); 57 // returns <Float32Array>[ 5.0, 3.0 ] 58 ``` 59 60 </section> 61 62 <!-- /.usage --> 63 64 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 65 66 <section class="notes"> 67 68 </section> 69 70 <!-- /.notes --> 71 72 <!-- Package usage examples. --> 73 74 <section class="examples"> 75 76 ## Examples 77 78 <!-- eslint no-undef: "error" --> 79 80 ```javascript 81 var Complex128 = require( '@stdlib/complex/float64' ); 82 var randu = require( '@stdlib/random/base/randu' ); 83 var round = require( '@stdlib/math/base/special/round' ); 84 var reim = require( '@stdlib/complex/reim' ); 85 86 var out; 87 var re; 88 var im; 89 var z; 90 var i; 91 92 for ( i = 0; i < 100; i++ ) { 93 re = round( (randu()*100.0) - 50.0 ); 94 im = round( (randu()*50.0) - 25.0 ); 95 z = new Complex128( re, im ); 96 out = reim( z ); 97 console.log( '%s => %d, %d', z.toString(), out[ 0 ], out[ 1 ] ); 98 } 99 ``` 100 101 </section> 102 103 <!-- /.examples --> 104 105 <!-- 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. --> 106 107 <section class="references"> 108 109 </section> 110 111 <!-- /.references --> 112 113 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 114 115 <section class="links"> 116 117 </section> 118 119 <!-- /.links -->