1 | 'use strict'
|
2 |
|
3 | function factory (type, config, load, typed) {
|
4 | const matrix = load(require('../../type/matrix/function/matrix'))
|
5 | const divideScalar = load(require('./divideScalar'))
|
6 | const latex = require('../../utils/latex')
|
7 |
|
8 | const algorithm02 = load(require('../../type/matrix/utils/algorithm02'))
|
9 | const algorithm03 = load(require('../../type/matrix/utils/algorithm03'))
|
10 | const algorithm07 = load(require('../../type/matrix/utils/algorithm07'))
|
11 | const algorithm11 = load(require('../../type/matrix/utils/algorithm11'))
|
12 | const algorithm12 = load(require('../../type/matrix/utils/algorithm12'))
|
13 | const algorithm13 = load(require('../../type/matrix/utils/algorithm13'))
|
14 | const algorithm14 = load(require('../../type/matrix/utils/algorithm14'))
|
15 |
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | const dotDivide = typed('dotDivide', {
|
43 |
|
44 | 'any, any': divideScalar,
|
45 |
|
46 | 'SparseMatrix, SparseMatrix': function (x, y) {
|
47 | return algorithm07(x, y, divideScalar, false)
|
48 | },
|
49 |
|
50 | 'SparseMatrix, DenseMatrix': function (x, y) {
|
51 | return algorithm02(y, x, divideScalar, true)
|
52 | },
|
53 |
|
54 | 'DenseMatrix, SparseMatrix': function (x, y) {
|
55 | return algorithm03(x, y, divideScalar, false)
|
56 | },
|
57 |
|
58 | 'DenseMatrix, DenseMatrix': function (x, y) {
|
59 | return algorithm13(x, y, divideScalar)
|
60 | },
|
61 |
|
62 | 'Array, Array': function (x, y) {
|
63 |
|
64 | return dotDivide(matrix(x), matrix(y)).valueOf()
|
65 | },
|
66 |
|
67 | 'Array, Matrix': function (x, y) {
|
68 |
|
69 | return dotDivide(matrix(x), y)
|
70 | },
|
71 |
|
72 | 'Matrix, Array': function (x, y) {
|
73 |
|
74 | return dotDivide(x, matrix(y))
|
75 | },
|
76 |
|
77 | 'SparseMatrix, any': function (x, y) {
|
78 | return algorithm11(x, y, divideScalar, false)
|
79 | },
|
80 |
|
81 | 'DenseMatrix, any': function (x, y) {
|
82 | return algorithm14(x, y, divideScalar, false)
|
83 | },
|
84 |
|
85 | 'any, SparseMatrix': function (x, y) {
|
86 | return algorithm12(y, x, divideScalar, true)
|
87 | },
|
88 |
|
89 | 'any, DenseMatrix': function (x, y) {
|
90 | return algorithm14(y, x, divideScalar, true)
|
91 | },
|
92 |
|
93 | 'Array, any': function (x, y) {
|
94 |
|
95 | return algorithm14(matrix(x), y, divideScalar, false).valueOf()
|
96 | },
|
97 |
|
98 | 'any, Array': function (x, y) {
|
99 |
|
100 | return algorithm14(matrix(y), x, divideScalar, true).valueOf()
|
101 | }
|
102 | })
|
103 |
|
104 | dotDivide.toTex = {
|
105 | 2: `\\left(\${args[0]}${latex.operators['dotDivide']}\${args[1]}\\right)`
|
106 | }
|
107 |
|
108 | return dotDivide
|
109 | }
|
110 |
|
111 | exports.name = 'dotDivide'
|
112 | exports.factory = factory
|