im.js (1418B)
1 import { factory } from '../../utils/factory.js'; 2 import { deepMap } from '../../utils/collection.js'; 3 var name = 'im'; 4 var dependencies = ['typed']; 5 export var createIm = /* #__PURE__ */factory(name, dependencies, _ref => { 6 var { 7 typed 8 } = _ref; 9 10 /** 11 * Get the imaginary part of a complex number. 12 * For a complex number `a + bi`, the function returns `b`. 13 * 14 * For matrices, the function is evaluated element wise. 15 * 16 * Syntax: 17 * 18 * math.im(x) 19 * 20 * Examples: 21 * 22 * const a = math.complex(2, 3) 23 * math.re(a) // returns number 2 24 * math.im(a) // returns number 3 25 * 26 * math.re(math.complex('-5.2i')) // returns number -5.2 27 * math.re(math.complex(2.4)) // returns number 0 28 * 29 * See also: 30 * 31 * re, conj, abs, arg 32 * 33 * @param {number | BigNumber | Complex | Array | Matrix} x 34 * A complex number or array with complex numbers 35 * @return {number | BigNumber | Array | Matrix} The imaginary part of x 36 */ 37 return typed(name, { 38 number: function number(x) { 39 return 0; 40 }, 41 BigNumber: function BigNumber(x) { 42 return x.mul(0); 43 }, 44 Fraction: function Fraction(x) { 45 return x.mul(0); 46 }, 47 Complex: function Complex(x) { 48 return x.im; 49 }, 50 'Array | Matrix': function ArrayMatrix(x) { 51 return deepMap(x, this); 52 } 53 }); 54 });