UNPKG

3.87 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.createBitOr = void 0;
7
8var _bitwise = require("../../utils/bignumber/bitwise");
9
10var _factory = require("../../utils/factory");
11
12var _algorithm = require("../../type/matrix/utils/algorithm14");
13
14var _algorithm2 = require("../../type/matrix/utils/algorithm13");
15
16var _algorithm3 = require("../../type/matrix/utils/algorithm10");
17
18var _algorithm4 = require("../../type/matrix/utils/algorithm04");
19
20var _algorithm5 = require("../../type/matrix/utils/algorithm01");
21
22var _number = require("../../plain/number");
23
24var name = 'bitOr';
25var dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix'];
26var createBitOr = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
27 var typed = _ref.typed,
28 matrix = _ref.matrix,
29 equalScalar = _ref.equalScalar,
30 DenseMatrix = _ref.DenseMatrix;
31 var algorithm01 = (0, _algorithm5.createAlgorithm01)({
32 typed: typed
33 });
34 var algorithm04 = (0, _algorithm4.createAlgorithm04)({
35 typed: typed,
36 equalScalar: equalScalar
37 });
38 var algorithm10 = (0, _algorithm3.createAlgorithm10)({
39 typed: typed,
40 DenseMatrix: DenseMatrix
41 });
42 var algorithm13 = (0, _algorithm2.createAlgorithm13)({
43 typed: typed
44 });
45 var algorithm14 = (0, _algorithm.createAlgorithm14)({
46 typed: typed
47 });
48 /**
49 * Bitwise OR two values, `x | y`.
50 * For matrices, the function is evaluated element wise.
51 * For units, the function is evaluated on the lowest print base.
52 *
53 * Syntax:
54 *
55 * math.bitOr(x, y)
56 *
57 * Examples:
58 *
59 * math.bitOr(1, 2) // returns number 3
60 *
61 * math.bitOr([1, 2, 3], 4) // returns Array [5, 6, 7]
62 *
63 * See also:
64 *
65 * bitAnd, bitNot, bitXor, leftShift, rightArithShift, rightLogShift
66 *
67 * @param {number | BigNumber | Array | Matrix} x First value to or
68 * @param {number | BigNumber | Array | Matrix} y Second value to or
69 * @return {number | BigNumber | Array | Matrix} OR of `x` and `y`
70 */
71
72 var bitOr = typed(name, {
73 'number, number': _number.bitOrNumber,
74 'BigNumber, BigNumber': _bitwise.bitOrBigNumber,
75 'SparseMatrix, SparseMatrix': function SparseMatrixSparseMatrix(x, y) {
76 return algorithm04(x, y, bitOr);
77 },
78 'SparseMatrix, DenseMatrix': function SparseMatrixDenseMatrix(x, y) {
79 return algorithm01(y, x, bitOr, true);
80 },
81 'DenseMatrix, SparseMatrix': function DenseMatrixSparseMatrix(x, y) {
82 return algorithm01(x, y, bitOr, false);
83 },
84 'DenseMatrix, DenseMatrix': function DenseMatrixDenseMatrix(x, y) {
85 return algorithm13(x, y, bitOr);
86 },
87 'Array, Array': function ArrayArray(x, y) {
88 // use matrix implementation
89 return bitOr(matrix(x), matrix(y)).valueOf();
90 },
91 'Array, Matrix': function ArrayMatrix(x, y) {
92 // use matrix implementation
93 return bitOr(matrix(x), y);
94 },
95 'Matrix, Array': function MatrixArray(x, y) {
96 // use matrix implementation
97 return bitOr(x, matrix(y));
98 },
99 'SparseMatrix, any': function SparseMatrixAny(x, y) {
100 return algorithm10(x, y, bitOr, false);
101 },
102 'DenseMatrix, any': function DenseMatrixAny(x, y) {
103 return algorithm14(x, y, bitOr, false);
104 },
105 'any, SparseMatrix': function anySparseMatrix(x, y) {
106 return algorithm10(y, x, bitOr, true);
107 },
108 'any, DenseMatrix': function anyDenseMatrix(x, y) {
109 return algorithm14(y, x, bitOr, true);
110 },
111 'Array, any': function ArrayAny(x, y) {
112 // use matrix implementation
113 return algorithm14(matrix(x), y, bitOr, false).valueOf();
114 },
115 'any, Array': function anyArray(x, y) {
116 // use matrix implementation
117 return algorithm14(matrix(y), x, bitOr, true).valueOf();
118 }
119 });
120 return bitOr;
121});
122exports.createBitOr = createBitOr;
\No newline at end of file