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