or.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.createOr = void 0;
  6. var _matAlgo03xDSf = require("../../type/matrix/utils/matAlgo03xDSf.js");
  7. var _matAlgo12xSfs = require("../../type/matrix/utils/matAlgo12xSfs.js");
  8. var _matAlgo05xSfSf = require("../../type/matrix/utils/matAlgo05xSfSf.js");
  9. var _factory = require("../../utils/factory.js");
  10. var _matrixAlgorithmSuite = require("../../type/matrix/utils/matrixAlgorithmSuite.js");
  11. var _index = require("../../plain/number/index.js");
  12. var name = 'or';
  13. var dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'concat'];
  14. var createOr = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
  15. var typed = _ref.typed,
  16. matrix = _ref.matrix,
  17. equalScalar = _ref.equalScalar,
  18. DenseMatrix = _ref.DenseMatrix,
  19. concat = _ref.concat;
  20. var matAlgo03xDSf = (0, _matAlgo03xDSf.createMatAlgo03xDSf)({
  21. typed: typed
  22. });
  23. var matAlgo05xSfSf = (0, _matAlgo05xSfSf.createMatAlgo05xSfSf)({
  24. typed: typed,
  25. equalScalar: equalScalar
  26. });
  27. var matAlgo12xSfs = (0, _matAlgo12xSfs.createMatAlgo12xSfs)({
  28. typed: typed,
  29. DenseMatrix: DenseMatrix
  30. });
  31. var matrixAlgorithmSuite = (0, _matrixAlgorithmSuite.createMatrixAlgorithmSuite)({
  32. typed: typed,
  33. matrix: matrix,
  34. concat: concat
  35. });
  36. /**
  37. * Logical `or`. Test if at least one value is defined with a nonzero/nonempty value.
  38. * For matrices, the function is evaluated element wise.
  39. *
  40. * Syntax:
  41. *
  42. * math.or(x, y)
  43. *
  44. * Examples:
  45. *
  46. * math.or(2, 4) // returns true
  47. *
  48. * a = [2, 5, 0]
  49. * b = [0, 22, 0]
  50. * c = 0
  51. *
  52. * math.or(a, b) // returns [true, true, false]
  53. * math.or(b, c) // returns [false, true, false]
  54. *
  55. * See also:
  56. *
  57. * and, not, xor
  58. *
  59. * @param {number | BigNumber | Complex | Unit | Array | Matrix} x First value to check
  60. * @param {number | BigNumber | Complex | Unit | Array | Matrix} y Second value to check
  61. * @return {boolean | Array | Matrix}
  62. * Returns true when one of the inputs is defined with a nonzero/nonempty value.
  63. */
  64. return typed(name, {
  65. 'number, number': _index.orNumber,
  66. 'Complex, Complex': function ComplexComplex(x, y) {
  67. return x.re !== 0 || x.im !== 0 || y.re !== 0 || y.im !== 0;
  68. },
  69. 'BigNumber, BigNumber': function BigNumberBigNumber(x, y) {
  70. return !x.isZero() && !x.isNaN() || !y.isZero() && !y.isNaN();
  71. },
  72. 'Unit, Unit': typed.referToSelf(function (self) {
  73. return function (x, y) {
  74. return self(x.value || 0, y.value || 0);
  75. };
  76. })
  77. }, matrixAlgorithmSuite({
  78. SS: matAlgo05xSfSf,
  79. DS: matAlgo03xDSf,
  80. Ss: matAlgo12xSfs
  81. }));
  82. });
  83. exports.createOr = createOr;