UNPKG

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