1 | import { factory } from '../../utils/factory'
|
2 | import { createAlgorithm02 } from '../../type/matrix/utils/algorithm02'
|
3 | import { createAlgorithm09 } from '../../type/matrix/utils/algorithm09'
|
4 | import { createAlgorithm11 } from '../../type/matrix/utils/algorithm11'
|
5 | import { createAlgorithm13 } from '../../type/matrix/utils/algorithm13'
|
6 | import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14'
|
7 |
|
8 | const name = 'dotMultiply'
|
9 | const dependencies = [
|
10 | 'typed',
|
11 | 'matrix',
|
12 | 'equalScalar',
|
13 | 'multiplyScalar'
|
14 | ]
|
15 |
|
16 | export const createDotMultiply = factory(name, dependencies, ({ typed, matrix, equalScalar, multiplyScalar }) => {
|
17 | const algorithm02 = createAlgorithm02({ typed, equalScalar })
|
18 | const algorithm09 = createAlgorithm09({ typed, equalScalar })
|
19 | const algorithm11 = createAlgorithm11({ typed, equalScalar })
|
20 | const algorithm13 = createAlgorithm13({ typed })
|
21 | const algorithm14 = createAlgorithm14({ typed })
|
22 |
|
23 | |
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 |
|
49 | const dotMultiply = typed(name, {
|
50 |
|
51 | 'any, any': multiplyScalar,
|
52 |
|
53 | 'SparseMatrix, SparseMatrix': function (x, y) {
|
54 | return algorithm09(x, y, multiplyScalar, false)
|
55 | },
|
56 |
|
57 | 'SparseMatrix, DenseMatrix': function (x, y) {
|
58 | return algorithm02(y, x, multiplyScalar, true)
|
59 | },
|
60 |
|
61 | 'DenseMatrix, SparseMatrix': function (x, y) {
|
62 | return algorithm02(x, y, multiplyScalar, false)
|
63 | },
|
64 |
|
65 | 'DenseMatrix, DenseMatrix': function (x, y) {
|
66 | return algorithm13(x, y, multiplyScalar)
|
67 | },
|
68 |
|
69 | 'Array, Array': function (x, y) {
|
70 |
|
71 | return dotMultiply(matrix(x), matrix(y)).valueOf()
|
72 | },
|
73 |
|
74 | 'Array, Matrix': function (x, y) {
|
75 |
|
76 | return dotMultiply(matrix(x), y)
|
77 | },
|
78 |
|
79 | 'Matrix, Array': function (x, y) {
|
80 |
|
81 | return dotMultiply(x, matrix(y))
|
82 | },
|
83 |
|
84 | 'SparseMatrix, any': function (x, y) {
|
85 | return algorithm11(x, y, multiplyScalar, false)
|
86 | },
|
87 |
|
88 | 'DenseMatrix, any': function (x, y) {
|
89 | return algorithm14(x, y, multiplyScalar, false)
|
90 | },
|
91 |
|
92 | 'any, SparseMatrix': function (x, y) {
|
93 | return algorithm11(y, x, multiplyScalar, true)
|
94 | },
|
95 |
|
96 | 'any, DenseMatrix': function (x, y) {
|
97 | return algorithm14(y, x, multiplyScalar, true)
|
98 | },
|
99 |
|
100 | 'Array, any': function (x, y) {
|
101 |
|
102 | return algorithm14(matrix(x), y, multiplyScalar, false).valueOf()
|
103 | },
|
104 |
|
105 | 'any, Array': function (x, y) {
|
106 |
|
107 | return algorithm14(matrix(y), x, multiplyScalar, true).valueOf()
|
108 | }
|
109 | })
|
110 |
|
111 | return dotMultiply
|
112 | })
|