1 | import { createAlgorithm03 } from '../../type/matrix/utils/algorithm03';
|
2 | import { createAlgorithm07 } from '../../type/matrix/utils/algorithm07';
|
3 | import { createAlgorithm12 } from '../../type/matrix/utils/algorithm12';
|
4 | import { createAlgorithm13 } from '../../type/matrix/utils/algorithm13';
|
5 | import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14';
|
6 | import { factory } from '../../utils/factory';
|
7 | import { xorNumber } from '../../plain/number';
|
8 | var name = 'xor';
|
9 | var dependencies = ['typed', 'matrix', 'DenseMatrix'];
|
10 | export var createXor =
|
11 |
|
12 | factory(name, dependencies, function (_ref) {
|
13 | var typed = _ref.typed,
|
14 | matrix = _ref.matrix,
|
15 | DenseMatrix = _ref.DenseMatrix;
|
16 | var algorithm03 = createAlgorithm03({
|
17 | typed: typed
|
18 | });
|
19 | var algorithm07 = createAlgorithm07({
|
20 | typed: typed,
|
21 | DenseMatrix: DenseMatrix
|
22 | });
|
23 | var algorithm12 = createAlgorithm12({
|
24 | typed: typed,
|
25 | DenseMatrix: DenseMatrix
|
26 | });
|
27 | var algorithm13 = createAlgorithm13({
|
28 | typed: typed
|
29 | });
|
30 | var algorithm14 = createAlgorithm14({
|
31 | typed: typed
|
32 | });
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 | var xor = typed(name, {
|
63 | 'number, number': xorNumber,
|
64 | 'Complex, Complex': function ComplexComplex(x, y) {
|
65 | return (x.re !== 0 || x.im !== 0) !== (y.re !== 0 || y.im !== 0);
|
66 | },
|
67 | 'BigNumber, BigNumber': function BigNumberBigNumber(x, y) {
|
68 | return (!x.isZero() && !x.isNaN()) !== (!y.isZero() && !y.isNaN());
|
69 | },
|
70 | 'Unit, Unit': function UnitUnit(x, y) {
|
71 | return xor(x.value || 0, y.value || 0);
|
72 | },
|
73 | 'SparseMatrix, SparseMatrix': function SparseMatrixSparseMatrix(x, y) {
|
74 | return algorithm07(x, y, xor);
|
75 | },
|
76 | 'SparseMatrix, DenseMatrix': function SparseMatrixDenseMatrix(x, y) {
|
77 | return algorithm03(y, x, xor, true);
|
78 | },
|
79 | 'DenseMatrix, SparseMatrix': function DenseMatrixSparseMatrix(x, y) {
|
80 | return algorithm03(x, y, xor, false);
|
81 | },
|
82 | 'DenseMatrix, DenseMatrix': function DenseMatrixDenseMatrix(x, y) {
|
83 | return algorithm13(x, y, xor);
|
84 | },
|
85 | 'Array, Array': function ArrayArray(x, y) {
|
86 |
|
87 | return xor(matrix(x), matrix(y)).valueOf();
|
88 | },
|
89 | 'Array, Matrix': function ArrayMatrix(x, y) {
|
90 |
|
91 | return xor(matrix(x), y);
|
92 | },
|
93 | 'Matrix, Array': function MatrixArray(x, y) {
|
94 |
|
95 | return xor(x, matrix(y));
|
96 | },
|
97 | 'SparseMatrix, any': function SparseMatrixAny(x, y) {
|
98 | return algorithm12(x, y, xor, false);
|
99 | },
|
100 | 'DenseMatrix, any': function DenseMatrixAny(x, y) {
|
101 | return algorithm14(x, y, xor, false);
|
102 | },
|
103 | 'any, SparseMatrix': function anySparseMatrix(x, y) {
|
104 | return algorithm12(y, x, xor, true);
|
105 | },
|
106 | 'any, DenseMatrix': function anyDenseMatrix(x, y) {
|
107 | return algorithm14(y, x, xor, true);
|
108 | },
|
109 | 'Array, any': function ArrayAny(x, y) {
|
110 |
|
111 | return algorithm14(matrix(x), y, xor, false).valueOf();
|
112 | },
|
113 | 'any, Array': function anyArray(x, y) {
|
114 |
|
115 | return algorithm14(matrix(y), x, xor, true).valueOf();
|
116 | }
|
117 | });
|
118 | return xor;
|
119 | }); |
\ | No newline at end of file |