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