conj.js 1.5 KB

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