1 | import { createAlgorithm02 } from '../../type/matrix/utils/algorithm02';
|
2 | import { createAlgorithm11 } from '../../type/matrix/utils/algorithm11';
|
3 | import { createAlgorithm13 } from '../../type/matrix/utils/algorithm13';
|
4 | import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14';
|
5 | import { createAlgorithm06 } from '../../type/matrix/utils/algorithm06';
|
6 | import { factory } from '../../utils/factory';
|
7 | import { andNumber } from '../../plain/number';
|
8 | var name = 'and';
|
9 | var dependencies = ['typed', 'matrix', 'equalScalar', 'zeros', 'not'];
|
10 | export var createAnd =
|
11 |
|
12 | factory(name, dependencies, function (_ref) {
|
13 | var typed = _ref.typed,
|
14 | matrix = _ref.matrix,
|
15 | equalScalar = _ref.equalScalar,
|
16 | zeros = _ref.zeros,
|
17 | not = _ref.not;
|
18 | var algorithm02 = createAlgorithm02({
|
19 | typed: typed,
|
20 | equalScalar: equalScalar
|
21 | });
|
22 | var algorithm06 = createAlgorithm06({
|
23 | typed: typed,
|
24 | equalScalar: equalScalar
|
25 | });
|
26 | var algorithm11 = createAlgorithm11({
|
27 | typed: typed,
|
28 | equalScalar: equalScalar
|
29 | });
|
30 | var algorithm13 = createAlgorithm13({
|
31 | typed: typed
|
32 | });
|
33 | var algorithm14 = createAlgorithm14({
|
34 | typed: typed
|
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 |
|
63 |
|
64 |
|
65 | var and = typed(name, {
|
66 | 'number, number': andNumber,
|
67 | 'Complex, Complex': function ComplexComplex(x, y) {
|
68 | return (x.re !== 0 || x.im !== 0) && (y.re !== 0 || y.im !== 0);
|
69 | },
|
70 | 'BigNumber, BigNumber': function BigNumberBigNumber(x, y) {
|
71 | return !x.isZero() && !y.isZero() && !x.isNaN() && !y.isNaN();
|
72 | },
|
73 | 'Unit, Unit': function UnitUnit(x, y) {
|
74 | return and(x.value || 0, y.value || 0);
|
75 | },
|
76 | 'SparseMatrix, SparseMatrix': function SparseMatrixSparseMatrix(x, y) {
|
77 | return algorithm06(x, y, and, false);
|
78 | },
|
79 | 'SparseMatrix, DenseMatrix': function SparseMatrixDenseMatrix(x, y) {
|
80 | return algorithm02(y, x, and, true);
|
81 | },
|
82 | 'DenseMatrix, SparseMatrix': function DenseMatrixSparseMatrix(x, y) {
|
83 | return algorithm02(x, y, and, false);
|
84 | },
|
85 | 'DenseMatrix, DenseMatrix': function DenseMatrixDenseMatrix(x, y) {
|
86 | return algorithm13(x, y, and);
|
87 | },
|
88 | 'Array, Array': function ArrayArray(x, y) {
|
89 |
|
90 | return and(matrix(x), matrix(y)).valueOf();
|
91 | },
|
92 | 'Array, Matrix': function ArrayMatrix(x, y) {
|
93 |
|
94 | return and(matrix(x), y);
|
95 | },
|
96 | 'Matrix, Array': function MatrixArray(x, y) {
|
97 |
|
98 | return and(x, matrix(y));
|
99 | },
|
100 | 'SparseMatrix, any': function SparseMatrixAny(x, y) {
|
101 |
|
102 | if (not(y)) {
|
103 |
|
104 | return zeros(x.size(), x.storage());
|
105 | }
|
106 |
|
107 | return algorithm11(x, y, and, false);
|
108 | },
|
109 | 'DenseMatrix, any': function DenseMatrixAny(x, y) {
|
110 |
|
111 | if (not(y)) {
|
112 |
|
113 | return zeros(x.size(), x.storage());
|
114 | }
|
115 |
|
116 | return algorithm14(x, y, and, false);
|
117 | },
|
118 | 'any, SparseMatrix': function anySparseMatrix(x, y) {
|
119 |
|
120 | if (not(x)) {
|
121 |
|
122 | return zeros(x.size(), x.storage());
|
123 | }
|
124 |
|
125 | return algorithm11(y, x, and, true);
|
126 | },
|
127 | 'any, DenseMatrix': function anyDenseMatrix(x, y) {
|
128 |
|
129 | if (not(x)) {
|
130 |
|
131 | return zeros(x.size(), x.storage());
|
132 | }
|
133 |
|
134 | return algorithm14(y, x, and, true);
|
135 | },
|
136 | 'Array, any': function ArrayAny(x, y) {
|
137 |
|
138 | return and(matrix(x), y).valueOf();
|
139 | },
|
140 | 'any, Array': function anyArray(x, y) {
|
141 |
|
142 | return and(x, matrix(y)).valueOf();
|
143 | }
|
144 | });
|
145 | return and;
|
146 | }); |
\ | No newline at end of file |