simple-squiggle/node_modules/mathjs/lib/esm/function/complex/conj.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

import { factory } from '../../utils/factory.js';
import { deepMap } from '../../utils/collection.js';
var name = 'conj';
var dependencies = ['typed'];
export var createConj = /* #__PURE__ */factory(name, dependencies, _ref => {
var {
typed
} = _ref;
/**
* Compute the complex conjugate of a complex value.
* If `x = a+bi`, the complex conjugate of `x` is `a - bi`.
*
* For matrices, the function is evaluated element wise.
*
* Syntax:
*
* math.conj(x)
*
* Examples:
*
* math.conj(math.complex('2 + 3i')) // returns Complex 2 - 3i
* math.conj(math.complex('2 - 3i')) // returns Complex 2 + 3i
* math.conj(math.complex('-5.2i')) // returns Complex 5.2i
*
* See also:
*
* re, im, arg, abs
*
* @param {number | BigNumber | Complex | Array | Matrix} x
* A complex number or array with complex numbers
* @return {number | BigNumber | Complex | Array | Matrix}
* The complex conjugate of x
*/
return typed(name, {
number: function number(x) {
return x;
},
BigNumber: function BigNumber(x) {
return x;
},
Complex: function Complex(x) {
return x.conjugate();
},
'Array | Matrix': function ArrayMatrix(x) {
return deepMap(x, this);
}
});
});