simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

conj.js (1491B)


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