conj.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. * Compute the complex conjugate of a complex value.
  11. * If `x = a+bi`, the complex conjugate of `x` is `a - bi`.
  12. *
  13. * For matrices, the function is evaluated element wise.
  14. *
  15. * Syntax:
  16. *
  17. * math.conj(x)
  18. *
  19. * Examples:
  20. *
  21. * math.conj(math.complex('2 + 3i')) // returns Complex 2 - 3i
  22. * math.conj(math.complex('2 - 3i')) // returns Complex 2 + 3i
  23. * math.conj(math.complex('-5.2i')) // returns Complex 5.2i
  24. *
  25. * See also:
  26. *
  27. * re, im, arg, abs
  28. *
  29. * @param {number | BigNumber | Complex | Array | Matrix} x
  30. * A complex number or array with complex numbers
  31. * @return {number | BigNumber | Complex | Array | Matrix}
  32. * The complex conjugate of x
  33. */
  34. return typed(name, {
  35. 'number | BigNumber | Fraction': x => x,
  36. Complex: x => x.conjugate(),
  37. 'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))
  38. });
  39. });