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