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