README.md (6842B)
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 # Complex Numbers 22 23 [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] [![dependencies][dependencies-image]][dependencies-url] 24 25 > Complex number data types. 26 27 <section class="installation"> 28 29 ## Installation 30 31 ```bash 32 npm install @stdlib/complex 33 ``` 34 35 </section> 36 37 <section class="usage"> 38 39 ## Usage 40 41 ```javascript 42 var ns = require( '@stdlib/complex' ); 43 ``` 44 45 #### ns 46 47 Complex number data types. 48 49 ```javascript 50 var o = ns; 51 // returns {...} 52 ``` 53 54 The namespace constains complex number constructors. 55 56 <!-- <toc keywords="+data, +structure, +types"> --> 57 58 <div class="namespace-toc"> 59 60 - <span class="signature">[`complex( real, imag[, dtype] )`][@stdlib/complex/cmplx]</span><span class="delimiter">: </span><span class="description">create a complex number.</span> 61 - <span class="signature">[`Complex64( real, imag )`][@stdlib/complex/float32]</span><span class="delimiter">: </span><span class="description">64-bit complex number.</span> 62 - <span class="signature">[`Complex128( real, imag )`][@stdlib/complex/float64]</span><span class="delimiter">: </span><span class="description">128-bit complex number.</span> 63 64 </div> 65 66 <!-- </toc> --> 67 68 ```javascript 69 var z = ns.complex( 5.0, 3.0 ); 70 // returns <Complex128> 71 72 var str = z.toString(); 73 // returns '5 + 3i' 74 75 z = ns.complex( 5.0, 3.0, 'float32' ); 76 // returns <Complex64> 77 78 z = new ns.Complex64( 5.0, 3.0 ); 79 // returns <Complex64> 80 ``` 81 82 In addition, the namespace contains the following functions: 83 84 <!-- <toc keywords="-data, -structure, -types"> --> 85 86 <div class="namespace-toc"> 87 88 - <span class="signature">[`conj( z )`][@stdlib/complex/conj]</span><span class="delimiter">: </span><span class="description">return the complex conjugate of a complex number.</span> 89 - <span class="signature">[`imag( z )`][@stdlib/complex/imag]</span><span class="delimiter">: </span><span class="description">return the imaginary component of a complex number.</span> 90 - <span class="signature">[`real( z )`][@stdlib/complex/real]</span><span class="delimiter">: </span><span class="description">return the real component of a complex number.</span> 91 - <span class="signature">[`reim( z )`][@stdlib/complex/reim]</span><span class="delimiter">: </span><span class="description">return the real and imaginary components of a complex number.</span> 92 - <span class="signature">[`reviveComplex64( key, value )`][@stdlib/complex/reviver-float32]</span><span class="delimiter">: </span><span class="description">revive a JSON-serialized 64-bit complex number.</span> 93 - <span class="signature">[`reviveComplex128( key, value )`][@stdlib/complex/reviver-float64]</span><span class="delimiter">: </span><span class="description">revive a JSON-serialized 128-bit complex number.</span> 94 - <span class="signature">[`reviveComplex( key, value )`][@stdlib/complex/reviver]</span><span class="delimiter">: </span><span class="description">revive a JSON-serialized complex number.</span> 95 96 </div> 97 98 <!-- </toc> --> 99 100 ```javascript 101 var z = ns.complex( 5.0, 3.0 ); 102 var str = z.toString(); 103 // returns '5 + 3i' 104 105 var v = ns.conj( z ); 106 str = v.toString(); 107 // returns '5 - 3i' 108 ``` 109 110 </section> 111 112 <!-- /.usage --> 113 114 <section class="examples"> 115 116 ## Examples 117 118 <!-- TODO: better examples --> 119 120 <!-- eslint no-undef: "error" --> 121 122 ```javascript 123 var objectKeys = require( '@stdlib/utils/keys' ); 124 var ns = require( '@stdlib/complex' ); 125 126 console.log( objectKeys( ns ) ); 127 ``` 128 129 </section> 130 131 <!-- /.examples --> 132 133 134 <section class="main-repo" > 135 136 * * * 137 138 ## Notice 139 140 This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. 141 142 For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. 143 144 #### Community 145 146 [![Chat][chat-image]][chat-url] 147 148 --- 149 150 ## License 151 152 See [LICENSE][stdlib-license]. 153 154 155 ## Copyright 156 157 Copyright © 2016-2021. The Stdlib [Authors][stdlib-authors]. 158 159 </section> 160 161 <!-- /.stdlib --> 162 163 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 164 165 <section class="links"> 166 167 [npm-image]: http://img.shields.io/npm/v/@stdlib/complex.svg 168 [npm-url]: https://npmjs.org/package/@stdlib/complex 169 170 [test-image]: https://github.com/stdlib-js/complex/actions/workflows/test.yml/badge.svg 171 [test-url]: https://github.com/stdlib-js/complex/actions/workflows/test.yml 172 173 [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/complex/main.svg 174 [coverage-url]: https://codecov.io/github/stdlib-js/complex?branch=main 175 176 [dependencies-image]: https://img.shields.io/david/stdlib-js/complex.svg 177 [dependencies-url]: https://david-dm.org/stdlib-js/complex/main 178 179 [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg 180 [chat-url]: https://gitter.im/stdlib-js/stdlib/ 181 182 [stdlib]: https://github.com/stdlib-js/stdlib 183 184 [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors 185 186 [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/complex/main/LICENSE 187 188 <!-- <toc-links> --> 189 190 [@stdlib/complex/conj]: https://www.npmjs.com/package/@stdlib/complex/tree/main/conj 191 192 [@stdlib/complex/imag]: https://www.npmjs.com/package/@stdlib/complex/tree/main/imag 193 194 [@stdlib/complex/real]: https://www.npmjs.com/package/@stdlib/complex/tree/main/real 195 196 [@stdlib/complex/reim]: https://www.npmjs.com/package/@stdlib/complex/tree/main/reim 197 198 [@stdlib/complex/reviver-float32]: https://www.npmjs.com/package/@stdlib/complex/tree/main/reviver-float32 199 200 [@stdlib/complex/reviver-float64]: https://www.npmjs.com/package/@stdlib/complex/tree/main/reviver-float64 201 202 [@stdlib/complex/reviver]: https://www.npmjs.com/package/@stdlib/complex/tree/main/reviver 203 204 [@stdlib/complex/cmplx]: https://www.npmjs.com/package/@stdlib/complex/tree/main/cmplx 205 206 [@stdlib/complex/float32]: https://www.npmjs.com/package/@stdlib/complex/tree/main/float32 207 208 [@stdlib/complex/float64]: https://www.npmjs.com/package/@stdlib/complex/tree/main/float64 209 210 <!-- </toc-links> --> 211 212 </section> 213 214 <!-- /.links -->