1 | import { bitOrBigNumber } from '../../utils/bignumber/bitwise'
|
2 | import { factory } from '../../utils/factory'
|
3 | import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14'
|
4 | import { createAlgorithm13 } from '../../type/matrix/utils/algorithm13'
|
5 | import { createAlgorithm10 } from '../../type/matrix/utils/algorithm10'
|
6 | import { createAlgorithm04 } from '../../type/matrix/utils/algorithm04'
|
7 | import { createAlgorithm01 } from '../../type/matrix/utils/algorithm01'
|
8 | import { bitOrNumber } from '../../plain/number'
|
9 |
|
10 | const name = 'bitOr'
|
11 | const dependencies = [
|
12 | 'typed',
|
13 | 'matrix',
|
14 | 'equalScalar',
|
15 | 'DenseMatrix'
|
16 | ]
|
17 |
|
18 | export const createBitOr = factory(name, dependencies, ({ typed, matrix, equalScalar, DenseMatrix }) => {
|
19 | const algorithm01 = createAlgorithm01({ typed })
|
20 | const algorithm04 = createAlgorithm04({ typed, equalScalar })
|
21 | const algorithm10 = createAlgorithm10({ typed, DenseMatrix })
|
22 | const algorithm13 = createAlgorithm13({ typed })
|
23 | const algorithm14 = createAlgorithm14({ typed })
|
24 |
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 | const bitOr = typed(name, {
|
49 |
|
50 | 'number, number': bitOrNumber,
|
51 |
|
52 | 'BigNumber, BigNumber': bitOrBigNumber,
|
53 |
|
54 | 'SparseMatrix, SparseMatrix': function (x, y) {
|
55 | return algorithm04(x, y, bitOr)
|
56 | },
|
57 |
|
58 | 'SparseMatrix, DenseMatrix': function (x, y) {
|
59 | return algorithm01(y, x, bitOr, true)
|
60 | },
|
61 |
|
62 | 'DenseMatrix, SparseMatrix': function (x, y) {
|
63 | return algorithm01(x, y, bitOr, false)
|
64 | },
|
65 |
|
66 | 'DenseMatrix, DenseMatrix': function (x, y) {
|
67 | return algorithm13(x, y, bitOr)
|
68 | },
|
69 |
|
70 | 'Array, Array': function (x, y) {
|
71 |
|
72 | return bitOr(matrix(x), matrix(y)).valueOf()
|
73 | },
|
74 |
|
75 | 'Array, Matrix': function (x, y) {
|
76 |
|
77 | return bitOr(matrix(x), y)
|
78 | },
|
79 |
|
80 | 'Matrix, Array': function (x, y) {
|
81 |
|
82 | return bitOr(x, matrix(y))
|
83 | },
|
84 |
|
85 | 'SparseMatrix, any': function (x, y) {
|
86 | return algorithm10(x, y, bitOr, false)
|
87 | },
|
88 |
|
89 | 'DenseMatrix, any': function (x, y) {
|
90 | return algorithm14(x, y, bitOr, false)
|
91 | },
|
92 |
|
93 | 'any, SparseMatrix': function (x, y) {
|
94 | return algorithm10(y, x, bitOr, true)
|
95 | },
|
96 |
|
97 | 'any, DenseMatrix': function (x, y) {
|
98 | return algorithm14(y, x, bitOr, true)
|
99 | },
|
100 |
|
101 | 'Array, any': function (x, y) {
|
102 |
|
103 | return algorithm14(matrix(x), y, bitOr, false).valueOf()
|
104 | },
|
105 |
|
106 | 'any, Array': function (x, y) {
|
107 |
|
108 | return algorithm14(matrix(y), x, bitOr, true).valueOf()
|
109 | }
|
110 | })
|
111 |
|
112 | return bitOr
|
113 | })
|