acos.js (1563B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.createAcos = void 0; 7 8 var _factory = require("../../utils/factory.js"); 9 10 var _collection = require("../../utils/collection.js"); 11 12 var name = 'acos'; 13 var dependencies = ['typed', 'config', 'Complex']; 14 var createAcos = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) { 15 var typed = _ref.typed, 16 config = _ref.config, 17 Complex = _ref.Complex; 18 19 /** 20 * Calculate the inverse cosine of a value. 21 * 22 * For matrices, the function is evaluated element wise. 23 * 24 * Syntax: 25 * 26 * math.acos(x) 27 * 28 * Examples: 29 * 30 * math.acos(0.5) // returns number 1.0471975511965979 31 * math.acos(math.cos(1.5)) // returns number 1.5 32 * 33 * math.acos(2) // returns Complex 0 + 1.3169578969248166 i 34 * 35 * See also: 36 * 37 * cos, atan, asin 38 * 39 * @param {number | BigNumber | Complex | Array | Matrix} x Function input 40 * @return {number | BigNumber | Complex | Array | Matrix} The arc cosine of x 41 */ 42 return typed(name, { 43 number: function number(x) { 44 if (x >= -1 && x <= 1 || config.predictable) { 45 return Math.acos(x); 46 } else { 47 return new Complex(x, 0).acos(); 48 } 49 }, 50 Complex: function Complex(x) { 51 return x.acos(); 52 }, 53 BigNumber: function BigNumber(x) { 54 return x.acos(); 55 }, 56 'Array | Matrix': function ArrayMatrix(x) { 57 return (0, _collection.deepMap)(x, this); 58 } 59 }); 60 }); 61 exports.createAcos = createAcos;