UNPKG

1.33 kBJavaScriptView Raw
1import { factory } from '../../utils/factory';
2import { deepMap } from '../../utils/collection';
3var name = 'conj';
4var dependencies = ['typed'];
5export var createConj =
6/* #__PURE__ */
7factory(name, dependencies, function (_ref) {
8 var typed = _ref.typed;
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 var conj = 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, conj);
47 }
48 });
49 return conj;
50});
\No newline at end of file