arg.js (1641B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.createArg = void 0; 7 8 var _factory = require("../../utils/factory.js"); 9 10 var _collection = require("../../utils/collection.js"); 11 12 var name = 'arg'; 13 var dependencies = ['typed']; 14 var createArg = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) { 15 var typed = _ref.typed; 16 17 /** 18 * Compute the argument of a complex value. 19 * For a complex number `a + bi`, the argument is computed as `atan2(b, a)`. 20 * 21 * For matrices, the function is evaluated element wise. 22 * 23 * Syntax: 24 * 25 * math.arg(x) 26 * 27 * Examples: 28 * 29 * const a = math.complex(2, 2) 30 * math.arg(a) / math.pi // returns number 0.25 31 * 32 * const b = math.complex('2 + 3i') 33 * math.arg(b) // returns number 0.982793723247329 34 * math.atan2(3, 2) // returns number 0.982793723247329 35 * 36 * See also: 37 * 38 * re, im, conj, abs 39 * 40 * @param {number | BigNumber | Complex | Array | Matrix} x 41 * A complex number or array with complex numbers 42 * @return {number | BigNumber | Array | Matrix} The argument of x 43 */ 44 return typed(name, { 45 number: function number(x) { 46 return Math.atan2(0, x); 47 }, 48 BigNumber: function BigNumber(x) { 49 return x.constructor.atan2(0, x); 50 }, 51 Complex: function Complex(x) { 52 return x.arg(); 53 }, 54 // TODO: implement BigNumber support for function arg 55 'Array | Matrix': function ArrayMatrix(x) { 56 return (0, _collection.deepMap)(x, this); 57 } 58 }); 59 }); 60 exports.createArg = createArg;