bitOr.js (3866B)
1 "use strict"; 2 3 Object.defineProperty(exports, "__esModule", { 4 value: true 5 }); 6 exports.createBitOr = void 0; 7 8 var _bitwise = require("../../utils/bignumber/bitwise.js"); 9 10 var _factory = require("../../utils/factory.js"); 11 12 var _algorithm = require("../../type/matrix/utils/algorithm14.js"); 13 14 var _algorithm2 = require("../../type/matrix/utils/algorithm13.js"); 15 16 var _algorithm3 = require("../../type/matrix/utils/algorithm10.js"); 17 18 var _algorithm4 = require("../../type/matrix/utils/algorithm04.js"); 19 20 var _algorithm5 = require("../../type/matrix/utils/algorithm01.js"); 21 22 var _index = require("../../plain/number/index.js"); 23 24 var name = 'bitOr'; 25 var dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix']; 26 var 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 return typed(name, { 73 'number, number': _index.bitOrNumber, 74 'BigNumber, BigNumber': _bitwise.bitOrBigNumber, 75 'SparseMatrix, SparseMatrix': function SparseMatrixSparseMatrix(x, y) { 76 return algorithm04(x, y, this); 77 }, 78 'SparseMatrix, DenseMatrix': function SparseMatrixDenseMatrix(x, y) { 79 return algorithm01(y, x, this, true); 80 }, 81 'DenseMatrix, SparseMatrix': function DenseMatrixSparseMatrix(x, y) { 82 return algorithm01(x, y, this, false); 83 }, 84 'DenseMatrix, DenseMatrix': function DenseMatrixDenseMatrix(x, y) { 85 return algorithm13(x, y, this); 86 }, 87 'Array, Array': function ArrayArray(x, y) { 88 // use matrix implementation 89 return this(matrix(x), matrix(y)).valueOf(); 90 }, 91 'Array, Matrix': function ArrayMatrix(x, y) { 92 // use matrix implementation 93 return this(matrix(x), y); 94 }, 95 'Matrix, Array': function MatrixArray(x, y) { 96 // use matrix implementation 97 return this(x, matrix(y)); 98 }, 99 'SparseMatrix, any': function SparseMatrixAny(x, y) { 100 return algorithm10(x, y, this, false); 101 }, 102 'DenseMatrix, any': function DenseMatrixAny(x, y) { 103 return algorithm14(x, y, this, false); 104 }, 105 'any, SparseMatrix': function anySparseMatrix(x, y) { 106 return algorithm10(y, x, this, true); 107 }, 108 'any, DenseMatrix': function anyDenseMatrix(x, y) { 109 return algorithm14(y, x, this, true); 110 }, 111 'Array, any': function ArrayAny(x, y) { 112 // use matrix implementation 113 return algorithm14(matrix(x), y, this, false).valueOf(); 114 }, 115 'any, Array': function anyArray(x, y) { 116 // use matrix implementation 117 return algorithm14(matrix(y), x, this, true).valueOf(); 118 } 119 }); 120 }); 121 exports.createBitOr = createBitOr;