complex.d.ts (5569B)
1 type AValue = 2 | Complex 3 | { im: number; re: number } 4 | { abs: number; arg: number } 5 | { r: number; phi: number } 6 | [number, number] 7 | string 8 | number 9 | null 10 | undefined; 11 type BValue = number | undefined; 12 13 export function Complex(a: AValue, b?: BValue): Complex; 14 15 export default Complex; 16 17 /** 18 * 19 * This class allows the manipulation of complex numbers. 20 * You can pass a complex number in different formats. Either as object, double, string or two integer parameters. 21 * 22 * Object form 23 * { re: <real>, im: <imaginary> } 24 * { arg: <angle>, abs: <radius> } 25 * { phi: <angle>, r: <radius> } 26 * 27 * Array / Vector form 28 * [ real, imaginary ] 29 * 30 * Double form 31 * 99.3 - Single double value 32 * 33 * String form 34 * '23.1337' - Simple real number 35 * '15+3i' - a simple complex number 36 * '3-i' - a simple complex number 37 * 38 * Example: 39 * 40 * var c = new Complex('99.3+8i'); 41 * c.mul({r: 3, i: 9}).div(4.9).sub(3, 2); 42 * 43 */ 44 export class Complex { 45 re: number; 46 im: number; 47 48 constructor(a: AValue, b?: BValue); 49 50 /** 51 * Calculates the sign of a complex number, which is a normalized complex 52 * 53 */ 54 sign(): Complex; 55 /** 56 * Adds two complex numbers 57 * 58 */ 59 add(a: AValue, b?: BValue): Complex; 60 /** 61 * Subtracts two complex numbers 62 * 63 */ 64 sub(a: AValue, b?: BValue): Complex; 65 /** 66 * Multiplies two complex numbers 67 * 68 */ 69 mul(a: AValue, b?: BValue): Complex; 70 /** 71 * Divides two complex numbers 72 * 73 */ 74 div(a: AValue, b?: BValue): Complex; 75 /** 76 * Calculate the power of two complex numbers 77 * 78 */ 79 pow(a: AValue, b?: BValue): Complex; 80 /** 81 * Calculate the complex square root 82 * 83 */ 84 sqrt(): Complex; 85 /** 86 * Calculate the complex exponent 87 * 88 */ 89 exp(): Complex; 90 /** 91 * Calculate the complex exponent and subtracts one. 92 * 93 * This may be more accurate than `Complex(x).exp().sub(1)` if 94 * `x` is small. 95 * 96 */ 97 expm1(): Complex; 98 /** 99 * Calculate the natural log 100 * 101 */ 102 log(): Complex; 103 /** 104 * Calculate the magnitude of the complex number 105 * 106 */ 107 abs(): number; 108 /** 109 * Calculate the angle of the complex number 110 * 111 */ 112 arg(): number; 113 /** 114 * Calculate the sine of the complex number 115 * 116 */ 117 sin(): Complex; 118 /** 119 * Calculate the cosine 120 * 121 */ 122 cos(): Complex; 123 /** 124 * Calculate the tangent 125 * 126 */ 127 tan(): Complex; 128 /** 129 * Calculate the cotangent 130 * 131 */ 132 cot(): Complex; 133 /** 134 * Calculate the secant 135 * 136 */ 137 sec(): Complex; 138 /** 139 * Calculate the cosecans 140 * 141 */ 142 csc(): Complex; 143 /** 144 * Calculate the complex arcus sinus 145 * 146 */ 147 asin(): Complex; 148 /** 149 * Calculate the complex arcus cosinus 150 * 151 */ 152 acos(): Complex; 153 /** 154 * Calculate the complex arcus tangent 155 * 156 */ 157 atan(): Complex; 158 /** 159 * Calculate the complex arcus cotangent 160 * 161 */ 162 acot(): Complex; 163 /** 164 * Calculate the complex arcus secant 165 * 166 */ 167 asec(): Complex; 168 /** 169 * Calculate the complex arcus cosecans 170 * 171 */ 172 acsc(): Complex; 173 /** 174 * Calculate the complex sinh 175 * 176 */ 177 sinh(): Complex; 178 /** 179 * Calculate the complex cosh 180 * 181 */ 182 cosh(): Complex; 183 /** 184 * Calculate the complex tanh 185 * 186 */ 187 tanh(): Complex; 188 /** 189 * Calculate the complex coth 190 * 191 */ 192 coth(): Complex; 193 /** 194 * Calculate the complex coth 195 * 196 */ 197 csch(): Complex; 198 /** 199 * Calculate the complex sech 200 * 201 */ 202 sech(): Complex; 203 /** 204 * Calculate the complex asinh 205 * 206 */ 207 asinh(): Complex; 208 /** 209 * Calculate the complex acosh 210 * 211 */ 212 acosh(): Complex; 213 /** 214 * Calculate the complex atanh 215 * 216 */ 217 atanh(): Complex; 218 /** 219 * Calculate the complex acoth 220 * 221 */ 222 acoth(): Complex; 223 /** 224 * Calculate the complex acsch 225 * 226 */ 227 acsch(): Complex; 228 /** 229 * Calculate the complex asech 230 * 231 */ 232 asech(): Complex; 233 /** 234 * Calculate the complex inverse 1/z 235 * 236 */ 237 inverse(): Complex; 238 /** 239 * Returns the complex conjugate 240 * 241 */ 242 conjugate(): Complex; 243 /** 244 * Gets the negated complex number 245 * 246 */ 247 neg(): Complex; 248 /** 249 * Ceils the actual complex number 250 * 251 */ 252 ceil(places: number): Complex; 253 /** 254 * Floors the actual complex number 255 * 256 */ 257 floor(places: number): Complex; 258 /** 259 * Ceils the actual complex number 260 * 261 */ 262 round(places: number): Complex; 263 /** 264 * Compares two complex numbers 265 * 266 * **Note:** new Complex(Infinity).equals(Infinity) === false 267 * 268 */ 269 equals(a: AValue, b?: BValue): boolean; 270 /** 271 * Clones the actual object 272 * 273 */ 274 clone(): Complex; 275 /** 276 * Gets a string of the actual complex number 277 * 278 */ 279 toString(): string; 280 /** 281 * Returns the actual number as a vector 282 * 283 */ 284 toVector(): number[]; 285 /** 286 * Returns the actual real value of the current object 287 * 288 * @returns {number|null} 289 */ 290 valueOf(): number | null; 291 /** 292 * Determines whether a complex number is not on the Riemann sphere. 293 * 294 */ 295 isNaN(): boolean; 296 /** 297 * Determines whether or not a complex number is at the zero pole of the 298 * Riemann sphere. 299 * 300 */ 301 isZero(): boolean; 302 /** 303 * Determines whether a complex number is not at the infinity pole of the 304 * Riemann sphere. 305 * 306 */ 307 isFinite(): boolean; 308 /** 309 * Determines whether or not a complex number is at the infinity pole of the 310 * Riemann sphere. 311 * 312 */ 313 isInfinite(): boolean; 314 315 static ZERO: Complex; 316 static ONE: Complex; 317 static I: Complex; 318 static PI: Complex; 319 static E: Complex; 320 static INFINITY: Complex; 321 static NAN: Complex; 322 static EPSILON: number; 323 }