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