1 | import { factory } from '../../utils/factory'
|
2 | import { deepMap } from '../../utils/collection'
|
3 | import { cothNumber } from '../../plain/number'
|
4 |
|
5 | const name = 'coth'
|
6 | const dependencies = ['typed', 'BigNumber']
|
7 |
|
8 | export const createCoth = factory(name, dependencies, ({ typed, BigNumber }) => {
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | return typed(name, {
|
33 | number: cothNumber,
|
34 |
|
35 | Complex: function (x) {
|
36 | return x.coth()
|
37 | },
|
38 |
|
39 | BigNumber: function (x) {
|
40 | return new BigNumber(1).div(x.tanh())
|
41 | },
|
42 |
|
43 | Unit: function (x) {
|
44 | if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) {
|
45 | throw new TypeError('Unit in function coth is no angle')
|
46 | }
|
47 | return this(x.value)
|
48 | },
|
49 |
|
50 | 'Array | Matrix': function (x) {
|
51 | return deepMap(x, this)
|
52 | }
|
53 | })
|
54 | })
|