1 | import { nearlyEqual as bigNearlyEqual } from '../../utils/bignumber/nearlyEqual.js';
|
2 | import { nearlyEqual } from '../../utils/number.js';
|
3 | import { factory } from '../../utils/factory.js';
|
4 | import { createAlgorithm03 } from '../../type/matrix/utils/algorithm03.js';
|
5 | import { createAlgorithm07 } from '../../type/matrix/utils/algorithm07.js';
|
6 | import { createAlgorithm12 } from '../../type/matrix/utils/algorithm12.js';
|
7 | import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14.js';
|
8 | import { createAlgorithm13 } from '../../type/matrix/utils/algorithm13.js';
|
9 | var name = 'largerEq';
|
10 | var dependencies = ['typed', 'config', 'matrix', 'DenseMatrix'];
|
11 | export var createLargerEq = factory(name, dependencies, _ref => {
|
12 | var {
|
13 | typed,
|
14 | config,
|
15 | matrix,
|
16 | DenseMatrix
|
17 | } = _ref;
|
18 | var algorithm03 = createAlgorithm03({
|
19 | typed
|
20 | });
|
21 | var algorithm07 = createAlgorithm07({
|
22 | typed,
|
23 | DenseMatrix
|
24 | });
|
25 | var algorithm12 = createAlgorithm12({
|
26 | typed,
|
27 | DenseMatrix
|
28 | });
|
29 | var algorithm13 = createAlgorithm13({
|
30 | typed
|
31 | });
|
32 | var algorithm14 = createAlgorithm14({
|
33 | typed
|
34 | });
|
35 | |
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | return typed(name, {
|
64 | 'boolean, boolean': function booleanBoolean(x, y) {
|
65 | return x >= y;
|
66 | },
|
67 | 'number, number': function numberNumber(x, y) {
|
68 | return x >= y || nearlyEqual(x, y, config.epsilon);
|
69 | },
|
70 | 'BigNumber, BigNumber': function BigNumberBigNumber(x, y) {
|
71 | return x.gte(y) || bigNearlyEqual(x, y, config.epsilon);
|
72 | },
|
73 | 'Fraction, Fraction': function FractionFraction(x, y) {
|
74 | return x.compare(y) !== -1;
|
75 | },
|
76 | 'Complex, Complex': function ComplexComplex() {
|
77 | throw new TypeError('No ordering relation is defined for complex numbers');
|
78 | },
|
79 | 'Unit, Unit': function UnitUnit(x, y) {
|
80 | if (!x.equalBase(y)) {
|
81 | throw new Error('Cannot compare units with different base');
|
82 | }
|
83 |
|
84 | return this(x.value, y.value);
|
85 | },
|
86 | 'SparseMatrix, SparseMatrix': function SparseMatrixSparseMatrix(x, y) {
|
87 | return algorithm07(x, y, this);
|
88 | },
|
89 | 'SparseMatrix, DenseMatrix': function SparseMatrixDenseMatrix(x, y) {
|
90 | return algorithm03(y, x, this, true);
|
91 | },
|
92 | 'DenseMatrix, SparseMatrix': function DenseMatrixSparseMatrix(x, y) {
|
93 | return algorithm03(x, y, this, false);
|
94 | },
|
95 | 'DenseMatrix, DenseMatrix': function DenseMatrixDenseMatrix(x, y) {
|
96 | return algorithm13(x, y, this);
|
97 | },
|
98 | 'Array, Array': function ArrayArray(x, y) {
|
99 |
|
100 | return this(matrix(x), matrix(y)).valueOf();
|
101 | },
|
102 | 'Array, Matrix': function ArrayMatrix(x, y) {
|
103 |
|
104 | return this(matrix(x), y);
|
105 | },
|
106 | 'Matrix, Array': function MatrixArray(x, y) {
|
107 |
|
108 | return this(x, matrix(y));
|
109 | },
|
110 | 'SparseMatrix, any': function SparseMatrixAny(x, y) {
|
111 | return algorithm12(x, y, this, false);
|
112 | },
|
113 | 'DenseMatrix, any': function DenseMatrixAny(x, y) {
|
114 | return algorithm14(x, y, this, false);
|
115 | },
|
116 | 'any, SparseMatrix': function anySparseMatrix(x, y) {
|
117 | return algorithm12(y, x, this, true);
|
118 | },
|
119 | 'any, DenseMatrix': function anyDenseMatrix(x, y) {
|
120 | return algorithm14(y, x, this, true);
|
121 | },
|
122 | 'Array, any': function ArrayAny(x, y) {
|
123 |
|
124 | return algorithm14(matrix(x), y, this, false).valueOf();
|
125 | },
|
126 | 'any, Array': function anyArray(x, y) {
|
127 |
|
128 | return algorithm14(matrix(y), x, this, true).valueOf();
|
129 | }
|
130 | });
|
131 | });
|
132 | export var createLargerEqNumber = factory(name, ['typed', 'config'], _ref2 => {
|
133 | var {
|
134 | typed,
|
135 | config
|
136 | } = _ref2;
|
137 | return typed(name, {
|
138 | 'number, number': function numberNumber(x, y) {
|
139 | return x >= y || nearlyEqual(x, y, config.epsilon);
|
140 | }
|
141 | });
|
142 | }); |
\ | No newline at end of file |