1 | 'use strict'
|
2 |
|
3 | function factory (type, config, load, typed) {
|
4 | |
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | const multiplyScalar = typed('multiplyScalar', {
|
18 |
|
19 | 'number, number': function (x, y) {
|
20 | return x * y
|
21 | },
|
22 |
|
23 | 'Complex, Complex': function (x, y) {
|
24 | return x.mul(y)
|
25 | },
|
26 |
|
27 | 'BigNumber, BigNumber': function (x, y) {
|
28 | return x.times(y)
|
29 | },
|
30 |
|
31 | 'Fraction, Fraction': function (x, y) {
|
32 | return x.mul(y)
|
33 | },
|
34 |
|
35 | 'number | Fraction | BigNumber | Complex, Unit': function (x, y) {
|
36 | const res = y.clone()
|
37 | res.value = (res.value === null) ? res._normalize(x) : multiplyScalar(res.value, x)
|
38 | return res
|
39 | },
|
40 |
|
41 | 'Unit, number | Fraction | BigNumber | Complex': function (x, y) {
|
42 | const res = x.clone()
|
43 | res.value = (res.value === null) ? res._normalize(y) : multiplyScalar(res.value, y)
|
44 | return res
|
45 | },
|
46 |
|
47 | 'Unit, Unit': function (x, y) {
|
48 | return x.multiply(y)
|
49 | }
|
50 |
|
51 | })
|
52 |
|
53 | return multiplyScalar
|
54 | }
|
55 |
|
56 | exports.factory = factory
|