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 = 'smaller';
|
10 | var dependencies = ['typed', 'config', 'matrix', 'DenseMatrix'];
|
11 | export var createSmaller = 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 |
|
64 |
|
65 |
|
66 |
|
67 | return typed(name, {
|
68 | 'boolean, boolean': function booleanBoolean(x, y) {
|
69 | return x < y;
|
70 | },
|
71 | 'number, number': function numberNumber(x, y) {
|
72 | return x < y && !nearlyEqual(x, y, config.epsilon);
|
73 | },
|
74 | 'BigNumber, BigNumber': function BigNumberBigNumber(x, y) {
|
75 | return x.lt(y) && !bigNearlyEqual(x, y, config.epsilon);
|
76 | },
|
77 | 'Fraction, Fraction': function FractionFraction(x, y) {
|
78 | return x.compare(y) === -1;
|
79 | },
|
80 | 'Complex, Complex': function ComplexComplex(x, y) {
|
81 | throw new TypeError('No ordering relation is defined for complex numbers');
|
82 | },
|
83 | 'Unit, Unit': function UnitUnit(x, y) {
|
84 | if (!x.equalBase(y)) {
|
85 | throw new Error('Cannot compare units with different base');
|
86 | }
|
87 |
|
88 | return this(x.value, y.value);
|
89 | },
|
90 | 'SparseMatrix, SparseMatrix': function SparseMatrixSparseMatrix(x, y) {
|
91 | return algorithm07(x, y, this);
|
92 | },
|
93 | 'SparseMatrix, DenseMatrix': function SparseMatrixDenseMatrix(x, y) {
|
94 | return algorithm03(y, x, this, true);
|
95 | },
|
96 | 'DenseMatrix, SparseMatrix': function DenseMatrixSparseMatrix(x, y) {
|
97 | return algorithm03(x, y, this, false);
|
98 | },
|
99 | 'DenseMatrix, DenseMatrix': function DenseMatrixDenseMatrix(x, y) {
|
100 | return algorithm13(x, y, this);
|
101 | },
|
102 | 'Array, Array': function ArrayArray(x, y) {
|
103 |
|
104 | return this(matrix(x), matrix(y)).valueOf();
|
105 | },
|
106 | 'Array, Matrix': function ArrayMatrix(x, y) {
|
107 |
|
108 | return this(matrix(x), y);
|
109 | },
|
110 | 'Matrix, Array': function MatrixArray(x, y) {
|
111 |
|
112 | return this(x, matrix(y));
|
113 | },
|
114 | 'SparseMatrix, any': function SparseMatrixAny(x, y) {
|
115 | return algorithm12(x, y, this, false);
|
116 | },
|
117 | 'DenseMatrix, any': function DenseMatrixAny(x, y) {
|
118 | return algorithm14(x, y, this, false);
|
119 | },
|
120 | 'any, SparseMatrix': function anySparseMatrix(x, y) {
|
121 | return algorithm12(y, x, this, true);
|
122 | },
|
123 | 'any, DenseMatrix': function anyDenseMatrix(x, y) {
|
124 | return algorithm14(y, x, this, true);
|
125 | },
|
126 | 'Array, any': function ArrayAny(x, y) {
|
127 |
|
128 | return algorithm14(matrix(x), y, this, false).valueOf();
|
129 | },
|
130 | 'any, Array': function anyArray(x, y) {
|
131 |
|
132 | return algorithm14(matrix(y), x, this, true).valueOf();
|
133 | }
|
134 | });
|
135 | });
|
136 | export var createSmallerNumber = factory(name, ['typed', 'config'], _ref2 => {
|
137 | var {
|
138 | typed,
|
139 | config
|
140 | } = _ref2;
|
141 | return typed(name, {
|
142 | 'number, number': function numberNumber(x, y) {
|
143 | return x < y && !nearlyEqual(x, y, config.epsilon);
|
144 | }
|
145 | });
|
146 | }); |
\ | No newline at end of file |