forked from josdejong/mathjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultiplyScalar.js
More file actions
44 lines (35 loc) · 1.32 KB
/
multiplyScalar.js
File metadata and controls
44 lines (35 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
43
44
import { factory } from '../../utils/factory.js'
import { multiplyNumber } from '../../plain/number/index.js'
const name = 'multiplyScalar'
const dependencies = ['typed']
export const createMultiplyScalar = /* #__PURE__ */ factory(name, dependencies, ({ typed }) => {
/**
* Multiply two scalar values, `x * y`.
* This function is meant for internal use: it is used by the public function
* `multiply`
*
* This function does not support collections (Array or Matrix).
*
* @param {number | BigNumber | bigint | Fraction | Complex | Unit} x First value to multiply
* @param {number | BigNumber | bigint | Fraction | Complex} y Second value to multiply
* @return {number | BigNumber | bigint | Fraction | Complex | Unit} Multiplication of `x` and `y`
* @private
*/
return typed('multiplyScalar', {
'number, number': multiplyNumber,
'Complex, Complex': function (x, y) {
return x.mul(y)
},
'BigNumber, BigNumber': function (x, y) {
return x.times(y)
},
'bigint, bigint': function (x, y) {
return x * y
},
'Fraction, Fraction': function (x, y) {
return x.mul(y)
},
'number | Fraction | BigNumber | Complex, Unit': (x, y) => y.multiply(x),
'Unit, number | Fraction | BigNumber | Complex | Unit': (x, y) => x.multiply(y)
})
})