simple-squiggle

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

conj.js (1315B)


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