1 | import { factory } from '../../utils/factory.js';
|
2 | import { deepMap } from '../../utils/collection.js';
|
3 | import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14.js';
|
4 | var name = 'fix';
|
5 | var dependencies = ['typed', 'Complex', 'matrix', 'ceil', 'floor'];
|
6 | export var createFix = factory(name, dependencies, (_ref) => {
|
7 | var {
|
8 | typed,
|
9 | Complex: _Complex,
|
10 | matrix,
|
11 | ceil,
|
12 | floor
|
13 | } = _ref;
|
14 | var algorithm14 = createAlgorithm14({
|
15 | typed
|
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 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 | return typed('fix', {
|
54 | number: function number(x) {
|
55 | return x > 0 ? floor(x) : ceil(x);
|
56 | },
|
57 | 'number, number | BigNumber': function numberNumberBigNumber(x, n) {
|
58 | return x > 0 ? floor(x, n) : ceil(x, n);
|
59 | },
|
60 | Complex: function Complex(x) {
|
61 | return new _Complex(x.re > 0 ? Math.floor(x.re) : Math.ceil(x.re), x.im > 0 ? Math.floor(x.im) : Math.ceil(x.im));
|
62 | },
|
63 | 'Complex, number | BigNumber': function ComplexNumberBigNumber(x, n) {
|
64 | return new _Complex(x.re > 0 ? floor(x.re, n) : ceil(x.re, n), x.im > 0 ? floor(x.im, n) : ceil(x.im, n));
|
65 | },
|
66 | BigNumber: function BigNumber(x) {
|
67 | return x.isNegative() ? ceil(x) : floor(x);
|
68 | },
|
69 | 'BigNumber, number | BigNumber': function BigNumberNumberBigNumber(x, n) {
|
70 | return x.isNegative() ? ceil(x, n) : floor(x, n);
|
71 | },
|
72 | Fraction: function Fraction(x) {
|
73 | return x.s < 0 ? x.ceil() : x.floor();
|
74 | },
|
75 | 'Fraction, number | BigNumber': function FractionNumberBigNumber(x, n) {
|
76 | return x.s < 0 ? x.ceil(n) : x.floor(n);
|
77 | },
|
78 | 'Array | Matrix': function ArrayMatrix(x) {
|
79 |
|
80 | return deepMap(x, this, true);
|
81 | },
|
82 | 'Array | Matrix, number | BigNumber': function ArrayMatrixNumberBigNumber(x, n) {
|
83 |
|
84 | return deepMap(x, i => this(i, n), true);
|
85 | },
|
86 | 'number | Complex | BigNumber, Array': function numberComplexBigNumberArray(x, y) {
|
87 |
|
88 | return algorithm14(matrix(y), x, this, true).valueOf();
|
89 | }
|
90 | });
|
91 | }); |
\ | No newline at end of file |