1 | import { rightArithShiftBigNumber } from '../../utils/bignumber/bitwise'
|
2 | import { createAlgorithm02 } from '../../type/matrix/utils/algorithm02'
|
3 | import { createAlgorithm11 } from '../../type/matrix/utils/algorithm11'
|
4 | import { createAlgorithm13 } from '../../type/matrix/utils/algorithm13'
|
5 | import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14'
|
6 | import { createAlgorithm01 } from '../../type/matrix/utils/algorithm01'
|
7 | import { createAlgorithm10 } from '../../type/matrix/utils/algorithm10'
|
8 | import { createAlgorithm08 } from '../../type/matrix/utils/algorithm08'
|
9 | import { factory } from '../../utils/factory'
|
10 | import { rightArithShiftNumber } from '../../plain/number'
|
11 |
|
12 | const name = 'rightArithShift'
|
13 | const dependencies = [
|
14 | 'typed',
|
15 | 'matrix',
|
16 | 'equalScalar',
|
17 | 'zeros',
|
18 | 'DenseMatrix'
|
19 | ]
|
20 |
|
21 | export const createRightArithShift = factory(name, dependencies, ({ typed, matrix, equalScalar, zeros, DenseMatrix }) => {
|
22 | const algorithm01 = createAlgorithm01({ typed })
|
23 | const algorithm02 = createAlgorithm02({ typed, equalScalar })
|
24 | const algorithm08 = createAlgorithm08({ typed, equalScalar })
|
25 | const algorithm10 = createAlgorithm10({ typed, DenseMatrix })
|
26 | const algorithm11 = createAlgorithm11({ typed, equalScalar })
|
27 | const algorithm13 = createAlgorithm13({ typed })
|
28 | const algorithm14 = createAlgorithm14({ typed })
|
29 |
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | const rightArithShift = typed(name, {
|
54 |
|
55 | 'number, number': rightArithShiftNumber,
|
56 |
|
57 | 'BigNumber, BigNumber': rightArithShiftBigNumber,
|
58 |
|
59 | 'SparseMatrix, SparseMatrix': function (x, y) {
|
60 | return algorithm08(x, y, rightArithShift, false)
|
61 | },
|
62 |
|
63 | 'SparseMatrix, DenseMatrix': function (x, y) {
|
64 | return algorithm02(y, x, rightArithShift, true)
|
65 | },
|
66 |
|
67 | 'DenseMatrix, SparseMatrix': function (x, y) {
|
68 | return algorithm01(x, y, rightArithShift, false)
|
69 | },
|
70 |
|
71 | 'DenseMatrix, DenseMatrix': function (x, y) {
|
72 | return algorithm13(x, y, rightArithShift)
|
73 | },
|
74 |
|
75 | 'Array, Array': function (x, y) {
|
76 |
|
77 | return rightArithShift(matrix(x), matrix(y)).valueOf()
|
78 | },
|
79 |
|
80 | 'Array, Matrix': function (x, y) {
|
81 |
|
82 | return rightArithShift(matrix(x), y)
|
83 | },
|
84 |
|
85 | 'Matrix, Array': function (x, y) {
|
86 |
|
87 | return rightArithShift(x, matrix(y))
|
88 | },
|
89 |
|
90 | 'SparseMatrix, number | BigNumber': function (x, y) {
|
91 |
|
92 | if (equalScalar(y, 0)) {
|
93 | return x.clone()
|
94 | }
|
95 | return algorithm11(x, y, rightArithShift, false)
|
96 | },
|
97 |
|
98 | 'DenseMatrix, number | BigNumber': function (x, y) {
|
99 |
|
100 | if (equalScalar(y, 0)) {
|
101 | return x.clone()
|
102 | }
|
103 | return algorithm14(x, y, rightArithShift, false)
|
104 | },
|
105 |
|
106 | 'number | BigNumber, SparseMatrix': function (x, y) {
|
107 |
|
108 | if (equalScalar(x, 0)) {
|
109 | return zeros(y.size(), y.storage())
|
110 | }
|
111 | return algorithm10(y, x, rightArithShift, true)
|
112 | },
|
113 |
|
114 | 'number | BigNumber, DenseMatrix': function (x, y) {
|
115 |
|
116 | if (equalScalar(x, 0)) {
|
117 | return zeros(y.size(), y.storage())
|
118 | }
|
119 | return algorithm14(y, x, rightArithShift, true)
|
120 | },
|
121 |
|
122 | 'Array, number | BigNumber': function (x, y) {
|
123 |
|
124 | return rightArithShift(matrix(x), y).valueOf()
|
125 | },
|
126 |
|
127 | 'number | BigNumber, Array': function (x, y) {
|
128 |
|
129 | return rightArithShift(x, matrix(y)).valueOf()
|
130 | }
|
131 | })
|
132 |
|
133 | return rightArithShift
|
134 | })
|