powiaina_num.js 0.2.0-alpha.2.8 → 0.2.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -72
- package/dist/PowiainaNum.cjs.js +233 -24
- package/dist/PowiainaNum.esm.js +233 -24
- package/dist/PowiainaNum.js +233 -24
- package/dist/PowiainaNum.min.js +1 -1
- package/dist/index.d.ts +21 -3
- package/dist/index.js +1762 -0
- package/dist/types/index.d.ts +184 -0
- package/package.json +47 -47
package/dist/PowiainaNum.js
CHANGED
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
var MSI_REC = 1.1102230246251568e-16;
|
|
49
49
|
var LONG_STRING_MIN_LENGTH = 17;
|
|
50
50
|
var EXP_E_REC = 1.444667861009766;
|
|
51
|
-
var isPowiainaNum = /^[-\+]*(Infinity|NaN|(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d*
|
|
51
|
+
var isPowiainaNum = /^(PN)?\/*[-\+]*(Infinity|NaN|(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d*\x20*)*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/;
|
|
52
52
|
function newOperator(r) {
|
|
53
53
|
var a = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
54
54
|
var e = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
@@ -73,6 +73,16 @@
|
|
|
73
73
|
}
|
|
74
74
|
return 0;
|
|
75
75
|
}
|
|
76
|
+
function replaceETo10(str) {
|
|
77
|
+
// 使用正则表达式匹配 (e^数字) 的模式
|
|
78
|
+
// 正则解释:\(e\^(\d+)\) 匹配 (e^数字),其中 \d+ 匹配一个或多个数字
|
|
79
|
+
return str.replace(/\(e\^(\d+)\)/g, '(10^)^$1 ').replace(/(\d+)\x20*PT/g, '(10^)^$1 ');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* 把一个字符串很长的数进行以10为底的对数
|
|
83
|
+
* @param str 被进行的字符串
|
|
84
|
+
* @returns 字符串以10为底的对数;
|
|
85
|
+
*/
|
|
76
86
|
function log10LongString(str) {
|
|
77
87
|
return Math.log10(Number(str.substring(0, LONG_STRING_MIN_LENGTH))) + (str.length - LONG_STRING_MIN_LENGTH);
|
|
78
88
|
}
|
|
@@ -157,6 +167,32 @@
|
|
|
157
167
|
}
|
|
158
168
|
throw Error("Iteration failed to converge: ".concat(z.toString())); //return Number.NaN;
|
|
159
169
|
}
|
|
170
|
+
function isTwoLengthArray(x) {
|
|
171
|
+
return x.length == 2;
|
|
172
|
+
}
|
|
173
|
+
function isTwoNumberArray(x) {
|
|
174
|
+
return typeof x[0] === "number" && typeof x[1] === "number";
|
|
175
|
+
}
|
|
176
|
+
function isExpantaNumArray(x) {
|
|
177
|
+
if (!Array.isArray(x)) return false;
|
|
178
|
+
for (var i = 0; i < x.length; i++) {
|
|
179
|
+
var arr = x[i];
|
|
180
|
+
if (!Array.isArray(arr)) return false;
|
|
181
|
+
if (!isTwoLengthArray(arr)) return false;
|
|
182
|
+
if (!isTwoNumberArray(arr)) return false;
|
|
183
|
+
}
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
function countLeadingZerosAfterDecimal(numStr) {
|
|
187
|
+
var match = numStr.match(/^0\.(0*)[1-9]/);
|
|
188
|
+
return match ? match[1].length : 0;
|
|
189
|
+
}
|
|
190
|
+
/*
|
|
191
|
+
function countLeadingZerosAfterDecimal(numStr) {
|
|
192
|
+
const match = numStr.match(/^0\.(0*)[1-9]/);
|
|
193
|
+
return match ? match[1].length : 0;
|
|
194
|
+
}
|
|
195
|
+
*/
|
|
160
196
|
//from https://github.com/scipy/scipy/blob/8dba340293fe20e62e173bdf2c10ae208286692f/scipy/special/lambertw.pxd
|
|
161
197
|
// The evaluation can become inaccurate very close to the branch point
|
|
162
198
|
// at ``-1/e``. In some corner cases, `lambertw` might currently
|
|
@@ -242,6 +278,10 @@
|
|
|
242
278
|
var b = y.abs();
|
|
243
279
|
return a.eq(b);
|
|
244
280
|
}()) return PowiainaNum.ZERO.clone();
|
|
281
|
+
// Run pure number calculates in there
|
|
282
|
+
if (x.abs().lt(MSI) && y.abs().lt(MSI)) {
|
|
283
|
+
return PowiainaNum.fromNumber(x.toNumber() + y.toNumber());
|
|
284
|
+
}
|
|
245
285
|
// calculate anything > e9e15 or <e-9e15, take absval bigger.
|
|
246
286
|
if (x.abs().lt(PowiainaNum.E_MSI_REC) || x.abs().gt(PowiainaNum.E_MSI) || y.abs().lt(PowiainaNum.E_MSI_REC) || y.abs().gt(PowiainaNum.E_MSI)) {
|
|
247
287
|
return x.maxabs(y);
|
|
@@ -345,6 +385,7 @@
|
|
|
345
385
|
if (r.lt(PowiainaNum.MSI_REC)) return PowiainaNum.ONE;
|
|
346
386
|
return new PowiainaNum(Math.pow(10, Math.pow(r.array[0].repeat, -1)));
|
|
347
387
|
}
|
|
388
|
+
if (r.gt(PowiainaNum.TETRATED_MSI)) return r;
|
|
348
389
|
r.setOperator(((_b = (_a = r.array[1]) === null || _a === void 0 ? void 0 : _a.repeat) !== null && _b !== void 0 ? _b : 0) + 1, 1);
|
|
349
390
|
r.normalize();
|
|
350
391
|
return r;
|
|
@@ -537,6 +578,7 @@
|
|
|
537
578
|
return _x.log10().neg();
|
|
538
579
|
}
|
|
539
580
|
if (this.array.length == 1) return new PowiainaNum(Math.log10(this.array[0].repeat));
|
|
581
|
+
if (this.gte(PowiainaNum.TETRATED_MSI)) return this.clone();
|
|
540
582
|
var x = this.clone();
|
|
541
583
|
x.array[1].repeat = x.array[1].repeat - 1;
|
|
542
584
|
x.normalize();
|
|
@@ -677,6 +719,93 @@
|
|
|
677
719
|
}
|
|
678
720
|
}
|
|
679
721
|
}
|
|
722
|
+
}, {
|
|
723
|
+
key: "arrow",
|
|
724
|
+
value: function arrow(arrows2) {
|
|
725
|
+
var t = this.clone();
|
|
726
|
+
var arrows = new PowiainaNum(arrows2);
|
|
727
|
+
if (!arrows.isInt() || arrows.lt(PowiainaNum.ZERO)) {
|
|
728
|
+
console.warn("The arrow is <0 or not a integer, the returned function will return NaN.");
|
|
729
|
+
return function () {
|
|
730
|
+
return PowiainaNum.NaN.clone();
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
if (arrows.eq(0)) return function (other) {
|
|
734
|
+
return t.mul(other);
|
|
735
|
+
};
|
|
736
|
+
if (arrows.eq(1)) return function (other) {
|
|
737
|
+
return t.pow(other);
|
|
738
|
+
};
|
|
739
|
+
if (arrows.eq(2)) return function (other) {
|
|
740
|
+
return t.tetrate(other);
|
|
741
|
+
};
|
|
742
|
+
return function (other2) {
|
|
743
|
+
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
744
|
+
var other = new PowiainaNum(other2);
|
|
745
|
+
var ctt = PowiainaNum.arrowFuncMap.get("".concat(t.toString(), " ").concat(arrows.toString(), " ").concat(other.toString()));
|
|
746
|
+
if (ctt) return ctt.clone();
|
|
747
|
+
var res = function () {
|
|
748
|
+
var r;
|
|
749
|
+
if (t.isNaN() || other.isNaN()) return PowiainaNum.NaN.clone();
|
|
750
|
+
if (other.lt(PowiainaNum.ZERO)) return PowiainaNum.NaN.clone();
|
|
751
|
+
if (t.eq(PowiainaNum.ZERO)) {
|
|
752
|
+
if (other.eq(PowiainaNum.ONE)) return PowiainaNum.ZERO.clone();
|
|
753
|
+
return PowiainaNum.NaN.clone();
|
|
754
|
+
}
|
|
755
|
+
if (t.eq(PowiainaNum.ONE)) return PowiainaNum.ONE.clone();
|
|
756
|
+
if (other.eq(PowiainaNum.ZERO)) return PowiainaNum.ONE.clone();
|
|
757
|
+
if (other.eq(PowiainaNum.ONE)) return t.clone();
|
|
758
|
+
if (arrows.gt(PowiainaNum.MSI)) {
|
|
759
|
+
r = arrows.clone();
|
|
760
|
+
r.setOperator(r.getOperator(Infinity) + 1, Infinity);
|
|
761
|
+
return r;
|
|
762
|
+
}
|
|
763
|
+
var arrowsNum = arrows.toNumber();
|
|
764
|
+
if (other.eq(2)) return t.arrow(arrowsNum - 1)(t, depth + 1);
|
|
765
|
+
if (t.max(other).gt(PowiainaNum.arrowMSI(arrowsNum + 1))) return t.max(other);
|
|
766
|
+
if (t.gt(PowiainaNum.arrowMSI(arrowsNum)) || other.gt(MSI)) {
|
|
767
|
+
if (t.gt(PowiainaNum.arrowMSI(arrowsNum))) {
|
|
768
|
+
r = t.clone();
|
|
769
|
+
r.setOperator(r.getOperator(arrowsNum) - 1, arrowsNum);
|
|
770
|
+
r.normalize();
|
|
771
|
+
} else if (t.gt(PowiainaNum.arrowMSI(arrowsNum - 1))) {
|
|
772
|
+
r = new PowiainaNum(t.getOperator(arrowsNum - 1));
|
|
773
|
+
} else {
|
|
774
|
+
r = PowiainaNum.ZERO;
|
|
775
|
+
}
|
|
776
|
+
var j = r.add(other);
|
|
777
|
+
j.setOperator(j.getOperator(arrowsNum) + 1, arrowsNum);
|
|
778
|
+
j.normalize();
|
|
779
|
+
return j;
|
|
780
|
+
}
|
|
781
|
+
if (depth >= PowiainaNum.maxOps + 10) {
|
|
782
|
+
return new PowiainaNum([[0, 10], [arrowsNum, 1]]);
|
|
783
|
+
}
|
|
784
|
+
var y = other.toNumber();
|
|
785
|
+
var f = Math.floor(y);
|
|
786
|
+
var arrows_m1 = arrows.sub(PowiainaNum.ONE);
|
|
787
|
+
r = t.arrow(arrows_m1)(y - f, depth + 1);
|
|
788
|
+
var i = 0;
|
|
789
|
+
for (var m = PowiainaNum.arrowMSI(arrowsNum - 1); f !== 0 && r.lt(m) && i < 100; i++) {
|
|
790
|
+
if (f > 0) {
|
|
791
|
+
r = t.arrow(arrows_m1)(r, depth + 1);
|
|
792
|
+
--f;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
if (i == 100) f = 0;
|
|
796
|
+
r.setOperator(r.getOperator(arrowsNum - 1) + f, arrowsNum - 1);
|
|
797
|
+
r.normalize();
|
|
798
|
+
return r;
|
|
799
|
+
}();
|
|
800
|
+
PowiainaNum.arrowFuncMap.set("".concat(t.toString(), " ").concat(arrows.toString(), " ").concat(other.toString()), res.clone());
|
|
801
|
+
return res;
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
}, {
|
|
805
|
+
key: "chain",
|
|
806
|
+
value: function chain(other, arrows) {
|
|
807
|
+
return this.arrow(arrows)(other);
|
|
808
|
+
}
|
|
680
809
|
}, {
|
|
681
810
|
key: "max",
|
|
682
811
|
value: function max(x) {
|
|
@@ -1007,7 +1136,7 @@
|
|
|
1007
1136
|
renormalize = true;
|
|
1008
1137
|
}
|
|
1009
1138
|
while (x.array.length >= 2 && x.array[0].repeat == 1 && x.array[1].repeat) {
|
|
1010
|
-
// for any 10{X}10{X} 1, turn into 10{
|
|
1139
|
+
// for any 10{X}10{X} 1, turn into 10{X}10
|
|
1011
1140
|
// [1, [R=sth, A=sth, E=sth, M=sth]]
|
|
1012
1141
|
if (x.array[1].repeat > 1) {
|
|
1013
1142
|
x.array[1].repeat--;
|
|
@@ -1017,8 +1146,9 @@
|
|
|
1017
1146
|
x.array[0].repeat = 10;
|
|
1018
1147
|
renormalize = true;
|
|
1019
1148
|
}
|
|
1020
|
-
if (x.array.length >= 2 && x.array[0].repeat < MSI && x.array[1].arrow >= 2 && x.array[1].repeat == 1) {
|
|
1149
|
+
if (x.array.length >= 2 && x.array[0].repeat < MSI && x.array[1].arrow >= 2 && x.array[1].repeat == 1 && isFinite(x.array[1].arrow)) {
|
|
1021
1150
|
// for any 10{A sample=2}1e9, turn into (10{A-1})^1e9-1 10
|
|
1151
|
+
// But dont convert when a is infinite
|
|
1022
1152
|
// [1e9, [R=1, A=2, sth, sth]]
|
|
1023
1153
|
x.array.splice(1, 1, newOperator(x.array[0].repeat, x.array[1].arrow - 1, x.array[1].expans, x.array[1].megota));
|
|
1024
1154
|
x.array[0].repeat = 10;
|
|
@@ -1034,12 +1164,13 @@
|
|
|
1034
1164
|
} while (renormalize);
|
|
1035
1165
|
return this;
|
|
1036
1166
|
}
|
|
1167
|
+
}, {
|
|
1168
|
+
key: "getOperatorIndex",
|
|
1169
|
+
value:
|
|
1037
1170
|
/**
|
|
1038
1171
|
* @returns number will return the index of the operator in array. return as x.5 if it's between the xth and x+1th operators.
|
|
1039
1172
|
*/
|
|
1040
|
-
|
|
1041
|
-
key: "getOperatorIndex",
|
|
1042
|
-
value: function getOperatorIndex(arrow) {
|
|
1173
|
+
function getOperatorIndex(arrow) {
|
|
1043
1174
|
var expans = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
1044
1175
|
var megota = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1045
1176
|
if (this.array.length == 1 && arrow == 0) return 0;
|
|
@@ -1092,7 +1223,7 @@
|
|
|
1092
1223
|
return false;
|
|
1093
1224
|
}
|
|
1094
1225
|
/**
|
|
1095
|
-
* @returns
|
|
1226
|
+
* @returns a PowiainaNum object which deep copied from `this` object.
|
|
1096
1227
|
*/
|
|
1097
1228
|
}, {
|
|
1098
1229
|
key: "clone",
|
|
@@ -1119,6 +1250,11 @@
|
|
|
1119
1250
|
this.layer = powlikeObject.layer;
|
|
1120
1251
|
return this;
|
|
1121
1252
|
}
|
|
1253
|
+
/**
|
|
1254
|
+
* Convert `this` to Javascript `number`
|
|
1255
|
+
*
|
|
1256
|
+
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
1257
|
+
*/
|
|
1122
1258
|
}, {
|
|
1123
1259
|
key: "toNumber",
|
|
1124
1260
|
value: function toNumber() {
|
|
@@ -1128,13 +1264,16 @@
|
|
|
1128
1264
|
if (this.array.length == 1) return this.array[0].repeat;else if (this.array.length == 2 && this.array[1].arrow == 1 && this.array[1].expans == 1 && this.array[1].megota == 1 && this.array[1].repeat == 1) return Math.pow(10, this.getOperator(0));
|
|
1129
1265
|
return NaN;
|
|
1130
1266
|
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Convert `this` to a string
|
|
1269
|
+
*/
|
|
1131
1270
|
}, {
|
|
1132
1271
|
key: "toString",
|
|
1133
1272
|
value: function toString() {
|
|
1134
1273
|
if (this.isNaN()) return "NaN";
|
|
1135
1274
|
if (this.sign == -1) return "-".concat(this.neg().toString());
|
|
1136
1275
|
if (this.small) {
|
|
1137
|
-
if (this.
|
|
1276
|
+
if (this.isZero()) return "0";
|
|
1138
1277
|
return "/".concat(this.rec().toString());
|
|
1139
1278
|
}
|
|
1140
1279
|
if (this.isInfi()) return "Infinity";
|
|
@@ -1150,12 +1289,22 @@
|
|
|
1150
1289
|
} else if (oper.repeat > 1) {
|
|
1151
1290
|
calc = "(".concat(calc, ")^").concat(oper.repeat, " ");
|
|
1152
1291
|
} else {
|
|
1153
|
-
calc = "".concat(calc
|
|
1292
|
+
calc = "".concat(calc);
|
|
1154
1293
|
}
|
|
1155
1294
|
res += "".concat(calc);
|
|
1156
1295
|
}
|
|
1157
1296
|
return res;
|
|
1158
1297
|
}
|
|
1298
|
+
}, {
|
|
1299
|
+
key: "toJSON",
|
|
1300
|
+
value:
|
|
1301
|
+
/**
|
|
1302
|
+
* Convert `this` to a JSON object
|
|
1303
|
+
* @returns a JSON object
|
|
1304
|
+
*/
|
|
1305
|
+
function toJSON() {
|
|
1306
|
+
return "PN" + this.toString();
|
|
1307
|
+
}
|
|
1159
1308
|
}, {
|
|
1160
1309
|
key: "arr01",
|
|
1161
1310
|
get:
|
|
@@ -1299,6 +1448,11 @@
|
|
|
1299
1448
|
value: function isNaN(x) {
|
|
1300
1449
|
return new PowiainaNum(x).isNaN();
|
|
1301
1450
|
}
|
|
1451
|
+
}, {
|
|
1452
|
+
key: "arrowMSI",
|
|
1453
|
+
value: function arrowMSI(arrowsNum) {
|
|
1454
|
+
return new PowiainaNum("10".concat(arrowsNum).concat(MSI));
|
|
1455
|
+
}
|
|
1302
1456
|
}, {
|
|
1303
1457
|
key: "fromNumber",
|
|
1304
1458
|
value: function fromNumber(x) {
|
|
@@ -1331,14 +1485,52 @@
|
|
|
1331
1485
|
var _a, _b, _c, _d, _e, _f;
|
|
1332
1486
|
var x = new PowiainaNum();
|
|
1333
1487
|
// Judge the string was a number
|
|
1334
|
-
|
|
1488
|
+
if (input.startsWith("PN")) input = input.substring(2);
|
|
1335
1489
|
if (!isNaN(Number(input))) {
|
|
1336
|
-
|
|
1337
|
-
|
|
1490
|
+
var res = Number(input);
|
|
1491
|
+
var _a2 = false;
|
|
1492
|
+
if (res == 0) {
|
|
1493
|
+
if (/^(0*\.0*e)|(0*\.0*)$/.test(input)) {
|
|
1494
|
+
_a2 = true;
|
|
1495
|
+
}
|
|
1496
|
+
} else {
|
|
1497
|
+
_a2 = true;
|
|
1498
|
+
}
|
|
1499
|
+
if (!_a2) {
|
|
1500
|
+
var m = input.search(/e/);
|
|
1501
|
+
var exponent = input.substring((m == -1 ? input.length : m) + 1);
|
|
1502
|
+
var mantissa = input.substring(0, m == -1 ? undefined : m);
|
|
1503
|
+
var mantissaME = [0, 0];
|
|
1504
|
+
// Handle mantissa to ME
|
|
1505
|
+
mantissaME[1] = Number(exponent ? exponent : "0");
|
|
1506
|
+
// Is regular number gte 1:
|
|
1507
|
+
if (Number(mantissa) >= 1) {
|
|
1508
|
+
// check The mantissa is very long?
|
|
1509
|
+
var log10mant = mantissa.length >= LONG_STRING_MIN_LENGTH ? log10LongString(mantissa) : Math.log10(Number(mantissa));
|
|
1510
|
+
var log10int = Math.floor(log10mant) - 1;
|
|
1511
|
+
var log10float = log10mant - log10int;
|
|
1512
|
+
mantissaME[0] = Math.pow(10, log10float);
|
|
1513
|
+
mantissaME[1] += log10float;
|
|
1514
|
+
} else {
|
|
1515
|
+
// If not , count how many zeros until reached non-zero numbers
|
|
1516
|
+
var zeros = countLeadingZerosAfterDecimal(mantissa);
|
|
1517
|
+
mantissa = mantissa.substring(mantissa.search(/[1-9]/));
|
|
1518
|
+
mantissa = mantissa.charAt(0) + "." + mantissa.substring(1);
|
|
1519
|
+
zeros += 1;
|
|
1520
|
+
mantissaME[0] = Number(mantissa);
|
|
1521
|
+
mantissaME[1] += -zeros;
|
|
1522
|
+
}
|
|
1523
|
+
// We'll get [a, b] which respents a*10^b;
|
|
1524
|
+
// actually b < 0; So we can ^-1
|
|
1525
|
+
// /((a*10^b)^-1) = /(a^-1*10^-b) = /(a^-1 * 10 * 10^(-b-1))
|
|
1526
|
+
return PowiainaNum.pow(10, -mantissaME[1] - 1).mul(Math.pow(mantissaME[0], -1) * 10).rec();
|
|
1527
|
+
}
|
|
1528
|
+
if (isFinite(res) && _a2) {
|
|
1338
1529
|
x.resetFromObject(PowiainaNum.fromNumber(Number(input)));
|
|
1339
1530
|
return x;
|
|
1340
1531
|
}
|
|
1341
1532
|
}
|
|
1533
|
+
input = replaceETo10(input);
|
|
1342
1534
|
if (!isPowiainaNum.test(input)) {
|
|
1343
1535
|
throw powiainaNumError + "malformed input: " + input;
|
|
1344
1536
|
}
|
|
@@ -1486,19 +1678,35 @@
|
|
|
1486
1678
|
value: function fromObject(powlikeObject) {
|
|
1487
1679
|
var obj = new PowiainaNum();
|
|
1488
1680
|
obj.array = [];
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1681
|
+
if (isExpantaNumArray(powlikeObject)) {
|
|
1682
|
+
for (var i = 0; i < powlikeObject.length; i++) {
|
|
1683
|
+
obj.array[i] = {
|
|
1684
|
+
arrow: powlikeObject[i][0],
|
|
1685
|
+
expans: 1,
|
|
1686
|
+
megota: 1,
|
|
1687
|
+
repeat: powlikeObject[i][1]
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
obj.small = false;
|
|
1691
|
+
obj.sign = 1;
|
|
1692
|
+
obj.layer = 0;
|
|
1693
|
+
obj.normalize();
|
|
1694
|
+
return obj;
|
|
1695
|
+
} else {
|
|
1696
|
+
for (var _i3 = 0; _i3 < powlikeObject.array.length; _i3++) {
|
|
1697
|
+
obj.array[_i3] = {
|
|
1698
|
+
arrow: powlikeObject.array[_i3].arrow,
|
|
1699
|
+
expans: powlikeObject.array[_i3].expans,
|
|
1700
|
+
megota: powlikeObject.array[_i3].megota,
|
|
1701
|
+
repeat: powlikeObject.array[_i3].repeat,
|
|
1702
|
+
valuereplaced: powlikeObject.array[_i3].valuereplaced
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
obj.small = powlikeObject.small;
|
|
1706
|
+
obj.sign = powlikeObject.sign;
|
|
1707
|
+
obj.layer = powlikeObject.layer;
|
|
1708
|
+
return obj;
|
|
1497
1709
|
}
|
|
1498
|
-
obj.small = powlikeObject.small;
|
|
1499
|
-
obj.sign = powlikeObject.sign;
|
|
1500
|
-
obj.layer = powlikeObject.layer;
|
|
1501
|
-
return obj;
|
|
1502
1710
|
}
|
|
1503
1711
|
}]);
|
|
1504
1712
|
}();
|
|
@@ -1620,6 +1828,7 @@
|
|
|
1620
1828
|
sign: 0
|
|
1621
1829
|
});
|
|
1622
1830
|
PowiainaNum.maxOps = 100;
|
|
1831
|
+
PowiainaNum.arrowFuncMap = new Map();
|
|
1623
1832
|
|
|
1624
1833
|
return PowiainaNum;
|
|
1625
1834
|
|
package/dist/PowiainaNum.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).PowiainaNum=e()}(this,(function(){"use strict";function r(r,a){for(var t=0;t<a.length;t++){var n=a[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,e(n.key),n)}}function e(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var a=r[Symbol.toPrimitive];if(void 0!==a){var t=a.call(r,e||"default");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}function a(r){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var t=9007199254740991,n=15.954589770191003,i=1.444667861009766,o=/^[-\+]*(Infinity|NaN|(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d* )*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/;function s(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{repeat:r,arrow:e,expans:a,megota:t,valuereplaced:e==1/0?0:a==1/0?1:-1}}function l(){for(var r=arguments.length,e=new Array(r),a=0;a<r;a++)e[a]=arguments[a];for(var t=0;t<Math.min(e[0].length,e[1].length);t++){var n=e[0][t],i=e[1][t];if(n<i)return-1;if(n>i)return 1}return 0}function u(r){return Math.log10(Number(r.substring(0,17)))+(r.length-17)}var h=.5671432904097838;function g(r){var e,a,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!Number.isFinite(r))return r;if(n){if(0===r)return r;if(1===r)return h;e=r<10?0:Math.log(r)-Math.log(Math.log(r))}else{if(0===r)return-1/0;e=r<=-.1?-2:Math.log(-r)-Math.log(-Math.log(-r))}for(var i=0;i<100;++i){if(a=(r*Math.exp(-e)+e*e)/(e+1),Math.abs(a-e)<t*Math.abs(a))return a;e=a}throw Error("Iteration failed to converge: ".concat(r.toString()))}function f(r){var e,a,t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(r.isInfiNaN())return r;if(o){if(r.eq(c.ZERO))return c.ZERO.clone();if(r.eq(c.ONE))return c.fromNumber(h);e=r.log()}else{if(r.eq(c.ZERO))return c.NEGATIVE_INFINITY.clone();e=r.neg().log()}for(var s=0;s<100;++s){if(a=e.neg().exp(),t=e.sub(r.mul(a)),(n=e.sub(t.div(e.add(1).sub(e.add(2).mul(t).div(e.mul(2).add(2)))))).sub(e).abs().lt(n.abs().mul(i)))return n;e=n}throw Error("Iteration failed to converge: ".concat(r.toString()))}var y,c=function(){function e(r){if(function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.array=[{arrow:0,expans:1,megota:1,repeat:NaN}],this.small=!1,this.sign=0,this.layer=0,void 0===r);else if("number"==typeof r){var t=e.fromNumber(r);this.resetFromObject(t)}else if("object"==a(r)){var n=e.fromObject(r);this.resetFromObject(n)}else if("string"==typeof r){var i=e.fromString(r);this.resetFromObject(i)}}return function(e,a,t){return a&&r(e.prototype,a),t&&r(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}(e,[{key:"add",value:function(r){var a,t,i,o,l,u,h=this.clone(),g=new e(r);if(h.eq(e.POSITIVE_INFINITY)&&g.eq(e.NEGATIVE_INFINITY)||h.eq(e.NEGATIVE_INFINITY)&&g.eq(e.POSITIVE_INFINITY))return e.NaN.clone();if(!h.isFinite())return h.clone();if(!g.isFinite())return g.clone();if(h.isZero())return g.clone();if(g.isZero())return h.clone();if(h.sign==-g.sign&&function(){var r=h.abs(),e=g.abs();return r.eq(e)}())return e.ZERO.clone();if(h.abs().lt(e.E_MSI_REC)||h.abs().gt(e.E_MSI)||g.abs().lt(e.E_MSI_REC)||g.abs().gt(e.E_MSI))return h.maxabs(g);if(-1==h.sign)return h.neg().add(g.neg()).neg();h.cmpabs(g)>0?(l=h,u=g):(u=h,l=g);var f=1;if(!(l.small||u.small||(null===(a=l.array[1])||void 0===a?void 0:a.repeat)||(null===(t=u.array[1])||void 0===t?void 0:t.repeat)||l.sign!=u.sign))return new e((l.array[0].repeat+u.array[0].repeat)*l.sign);var y=(l.small?-1:1)*((null===(i=l.array[1])||void 0===i?void 0:i.repeat)?l.array[0].repeat:Math.log10(l.array[0].repeat)),c=(u.small?-1:1)*((null===(o=u.array[1])||void 0===o?void 0:o.repeat)?u.array[0].repeat:Math.log10(u.array[0].repeat));if(y-c>n)return l;var p,m,v=-Math.floor(y),N=0;if((m=l.sign*Math.pow(10,y+v)+u.sign*Math.pow(10,c+v))>0&&(N=Math.log10(m)-v),m<0&&(N=Math.log10(-m)-v,f*=-1),0==m)throw Error("Encounter a calculate error");return(p=new e).sign=1,p.array=N>n||N<-n?[s(N,0),s(1,1)]:[s(Math.pow(10,Math.abs(N)),0)],p.small=N<0,p.sign*=f,p}},{key:"sub",value:function(r){return this.add(new e(r).neg())}},{key:"mul",value:function(r){var a,t=this.clone(),n=new e(r);return t.eq(e.POSITIVE_INFINITY)&&n.eq(e.NEGATIVE_INFINITY)||n.eq(e.POSITIVE_INFINITY)&&t.eq(e.NEGATIVE_INFINITY)?e.NEGATIVE_INFINITY.clone():t.isInfiNaN()&&n.eq(e.ZERO)&&n.isInfiNaN()&&t.eq(e.ZERO)?e.NaN.clone():t.eq(e.NEGATIVE_INFINITY)&&n.eq(e.NEGATIVE_INFINITY)?e.POSITIVE_INFINITY.clone():t.isFinite()?n.isFinite()?t.isZero()||n.isZero()?e.ZERO.clone():((a=t.abs().log10().add(n.abs().log10()).pow10()).sign=t.sign*n.sign,a):n.clone():t.clone()}},{key:"div",value:function(r){var a=new e(r).rec();return this.mul(a)}},{key:"pow10",value:function(){var r,a,t=this.clone();return this.isFinite()?t.isneg()?(t.sign*=-1,t.pow10().rec()):t.lte(308.25471555991675)?e.fromNumber(Math.pow(10,t.toNumber())):t.small?t.lt(e.MSI_REC)?e.ONE:new e(Math.pow(10,Math.pow(t.array[0].repeat,-1))):(t.setOperator((null!==(a=null===(r=t.array[1])||void 0===r?void 0:r.repeat)&&void 0!==a?a:0)+1,1),t.normalize(),t):this.clone()}},{key:"pow",value:function(r){var a=new e(r);if(!a.isFinite())return a.clone();if(!this.isFinite())return this.clone();if(this.eq(10))return a.pow10();if(this.isneg()){if(!a.isInt())return e.NaN.clone();var t=this.abs().pow(a);return t.sign=function(){var r=a.mod(2).round();return r.eq(0)||r.eq(2)?1:-1}(),t}var n=this.toNumber(),i=a.toNumber(),o=Math.pow(n,i);return isFinite(o)?e.fromNumber(o):this.log10().mul(a).pow10()}},{key:"pow_base",value:function(r){return new e(r).pow(this)}},{key:"root",value:function(r){var a=new e(r);return this.pow(a.rec())}},{key:"sqrt",value:function(){return this.pow(.5)}},{key:"cbrt",value:function(){return this.root(3)}},{key:"tetrate",value:function(r){var a,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=this.clone(),s=new e(r),l=new e(n);if(o.isNaN()||s.isNaN()||l.isNaN())return e.NaN.clone();if(l.neq(e.ONE)&&(s=s.add(l.slog(o))),s.isInfi()&&s.sign>0)return o.gte(i)?e.POSITIVE_INFINITY.clone():(a=this.log().neg()).lambertw().div(a);if(s.lte(-2))return e.NaN.clone();if(o.isZero())return s.isZero()?e.NaN.clone():s.gte(t/2)||s.toNumber()%2==0?e.ZERO.clone():e.ONE.clone();if(o.eq(e.ONE))return s.eq(e.ONE.neg())?e.NaN.clone():e.ONE.clone();if(s.eq(e.ONE.neg()))return e.ZERO.clone();if(s.eq(e.ZERO))return e.ONE.clone();if(s.eq(e.ONE))return o;if(s.eq(2))return o.pow(o);if(o.eq(2)){if(s.eq(3))return e.fromNumber(16);if(s.eq(4))return e.fromNumber(65536)}var u=o.max(s);if(u.gt(e.PENTATED_MSI))return u;if(u.gt(e.TETRATED_MSI)||s.gt(t)){if(this.lt(i))return(a=o.ln().neg()).lambertw().div(a);var h=o.slog(10).add(s);return h.setOperator(h.getOperator(2)+1,2),h.normalize(),h}for(var g=s.toNumber(),f=Math.floor(g),y=o.pow(g-f),c=e.NaN,p=0,m=e.E_MSI.clone();0!==f&&y.lt(m)&&p<100;++p)if(f>0){if(y=o.pow(y),c.eq(y)){f=0;break}c=y,--f}else{if(y=y.log(o),c.eq(y)){f=0;break}c=y,++f}return(100==p||this.lt(i))&&(f=0),y.setOperator(y.getOperator(1)+f,1),y.normalize(),y}},{key:"slog",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,a=this.clone(),t=new e(r);if(a.isInfiNaN())return a;if(t.isNaN())return t;if(t.isInfi())return e.ZERO.clone();if(a.isZero())return e.ONE.clone();if(a.eq(e.ONE))return e.ZERO.clone();if(a.eq(t))return e.ONE.clone();if(t.lt(i)){var n=t.tetrate(1/0);if(a.eq(n))return e.POSITIVE_INFINITY.clone();if(a.gt(n))return e.NaN.clone()}if(a.max(t).gt(e.PENTATED_MSI))return a.gt(t)?a:e.ZERO.clone();if(a.max(t).gt(e.TETRATED_MSI)&&a.gt(t))return a.setOperator(a.getOperator(2)-1,2),a.normalize(),a.sub(a.getOperator(1));if(a.lt(e.ZERO.clone()))return t.pow(a).sub(2);var o=0,s=a.getOperator(1)-t.getOperator(1);if(s>3){var l=s-3;o+=l,a.setOperator(a.getOperator(1)-l,1)}for(var u=0;u<100;++u){if(a.lte(e.ONE))return new e(o+a.toNumber());++o,a=e.log(a,r)}return console.warn("Failed to converage"),e.NaN.clone()}},{key:"abs",value:function(){var r=this.clone();return r.sign<0&&(r.sign*=-1),r}},{key:"log10",value:function(){if(this.isneg())return e.NaN.clone();if(this.isZero())return e.NEGATIVE_INFINITY.clone();if(this.small){var r=this.clone();return r.small=!r.small,r.log10().neg()}if(1==this.array.length)return new e(Math.log10(this.array[0].repeat));var a=this.clone();return a.array[1].repeat=a.array[1].repeat-1,a.normalize(),a}},{key:"log",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,a=new e(r);return this.log10().div(a.log10())}},{key:"ln",value:function(){return this.log()}},{key:"exp",value:function(){return this.pow_base(Math.E)}},{key:"mod",value:function(r){var a=new e(r),t=this.div(a);return t.sub(t.floor()).mul(a)}},{key:"factorial",value:function(){return this.abs().lt(t)?this.add(1).gamma():this.abs().lt(e.E_MSI)?e.exp(this.mul(this.log10().sub(1))):e.exp(this)}},{key:"gamma",value:function(){if(this.small)return this.rec();if(this.lte(t)){if(this.lt(24))return e.fromNumber(function(r){if(!isFinite(r))return r;if(r<-50)return r===Math.trunc(r)?Number.NEGATIVE_INFINITY:0;for(var e=1;r<10;)e*=r,++r;var a=.9189385332046727;a+=((r-=1)+.5)*Math.log(r),a-=r;var t=r*r,n=r;return a+=1/(12*n),a-=1/(360*(n*=t)),a+=1/(1260*(n*=t)),a-=1/(1680*(n*=t)),a+=1/(1188*(n*=t)),a-=691/(360360*(n*=t)),a+=7/(1092*(n*=t)),a-=3617/(122400*(n*=t)),Math.exp(a)/e}(this.sign*this.getOperator(0)));var r=this.getOperator(0)-1,a=.9189385332046727;a+=(r+.5)*Math.log(r);var n=r*r,i=r,o=12*i,s=1/o,l=(a-=r)+s;if(l===a)return e.exp(a);if((l=(a=l)-(s=1/(o=360*(i*=n))))===a)return e.exp(a);a=l;var u=1/(o=1260*(i*=n));return a+=u,a-=u=1/(o=1680*(i*=n)),e.exp(a)}return this.gt(t)?e.exp(this.mul(this.log().sub(1))):e.exp(this)}},{key:"lambertw",value:function(){var r=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.lt(-.3678794411710499)?e.NaN.clone():r?this.abs().lt("1e-300")?new e(this):this.small?e.fromNumber(g(this.toNumber())):0===this.layer?e.fromNumber(g(this.sign*this.getOperator(0))):this.lt("eee15")?f(this):this.log():1===this.sign?e.NaN.clone():0===this.layer?e.fromNumber(g(this.sign*this.array[0].repeat,1e-10,!1)):1==this.layer?f(this,1e-10,!1):this.neg().rec().lambertw().neg()}},{key:"max",value:function(r){var a=new e(r);return this.lt(a)?a.clone():this.clone()}},{key:"min",value:function(r){var a=new e(r);return this.gte(a)?a.clone():this.clone()}},{key:"maxabs",value:function(r){var a=new e(r).abs();return this.abs().lt(a)?a.clone():this.clone()}},{key:"minabs",value:function(r){var a=new e(r).abs();return this.abs().gt(a)?a.clone():this.clone()}},{key:"cmpabs",value:function(r){var a=new e(r).abs();return this.abs().cmp(a)}},{key:"neg",value:function(){var r=this.clone();return r.sign*=-1,r.normalize(),r}},{key:"rec",value:function(){var r=this.clone();return r.small=!r.small,r}},{key:"floor",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?e.ZERO.clone():e.ONE.neg().clone();var r=this.abs();return r.array[0].repeat=Math[1==this.sign?"floor":"ceil"](r.getOperator(0)),r}},{key:"ceil",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?e.ONE.clone():e.ZERO.clone();var r=this.abs();return r.array[0].repeat=Math[1==this.sign?"ceil":"floor"](r.getOperator(0)),r.sign=this.sign,r}},{key:"round",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?this.rec().lte(2)?e.ONE.clone():e.ZERO.clone():this.abs().rec().lte(2)?e.ZERO.clone():e.ONE.neg().clone();var r=this.abs();return r.array[0].repeat=Math.round(r.array[0].repeat),r.sign=this.sign,r}},{key:"trunc",value:function(){var r=this.clone();return r.gte(0)?r.floor():r.ceil()}},{key:"compare",value:function(r){var a=new e(r);if(this.isNaN()||a.isNaN())return 2;if(this.sign<a.sign)return-1;if(this.sign>a.sign)return 1;var t=-1==this.sign&&-1==a.sign;if(this.small&&!a.small)return-1*(t?-1:1);if(a.small&&!this.small)return 1*(t?-1:1);var n=1;this.small&&a.small&&(n*=-1),t&&(n*=-1);for(var i=0,o=0;this.array.length-1-o>=0&&a.array.length-1-o>=0;o++){var s=this.array[this.array.length-1-o],u=a.array[a.array.length-1-o],h=l([s.megota,s.expans,s.arrow,s.repeat],[u.megota,u.expans,u.arrow,u.repeat]);if(1==h){i=1;break}if(-1==h){i=-1;break}}return i*n+1-1}},{key:"cmp",value:function(r){return this.compare(r)}},{key:"eq",value:function(r){return 0===this.cmp(r)}},{key:"neq",value:function(r){return 0!==this.cmp(r)}},{key:"lt",value:function(r){return-1===this.cmp(r)}},{key:"lte",value:function(r){return this.cmp(r)<=0}},{key:"gt",value:function(r){return 1==this.cmp(r)}},{key:"gte",value:function(r){var e=this.cmp(r);return 0==e||1==e}},{key:"isNaN",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return isNaN(this.getOperator(0))}))},{key:"isZero",value:function(){return Boolean(this.small&&!isFinite(this.getOperator(0)))}},{key:"isFinite",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return Boolean(this.small||isFinite(this.getOperator(0)))&&!this.isNaN()}))},{key:"isInfi",value:function(){return this.rec().isZero()}},{key:"isInfiNaN",value:function(){return this.isInfi()||this.isNaN()}},{key:"isInt",value:function(){return!!this.isZero()||(!(this.small||!Number.isInteger(this.getOperator(0)))||!!this.abs().gte(t/2))}},{key:"ispos",value:function(){return this.sign>0}},{key:"isneg",value:function(){return this.sign<0}},{key:"normalize",value:function(){for(var r=!0,a=this,i=0;i<this.array.length;i++)if(this.array[i].repeat==1/0)return this.array=[{arrow:0,expans:1,megota:1,repeat:1/0}],this.layer=0,this;for(var o=1;o<a.array.length;++o){var u=a.array[o];if(null!==u.arrow&&void 0!==u.arrow||(u.arrow=0),null!==u.expans&&void 0!==u.expans||(u.expans=1),null!==u.megota&&void 0!==u.megota||(u.megota=1),isNaN(u.arrow)||isNaN(u.repeat)||isNaN(u.expans)||isNaN(u.megota))return a.array=[s(NaN,0,1,1)],a;if(!isFinite(u.repeat)||!isFinite(u.megota))return a.array=[s(1/0,0,1,1)],a;Number.isInteger(u.arrow)||(u.arrow=Math.floor(u.arrow)),Number.isInteger(u.repeat)||(u.repeat=Math.floor(u.repeat)),Number.isInteger(u.expans)||(u.expans=Math.floor(u.expans)),Number.isInteger(u.megota)||(u.megota=Math.floor(u.megota))}a.array.length||(a.small=!a.small,a.array=[s(1/0)]);do{for(r=!1,this.array.sort((function(r,e){return l([r.megota,r.expans,r.arrow],[e.megota,e.expans,e.arrow])})),o=1;o<a.array.length-1;++o)a.array[o].arrow==a.array[o+1].arrow&&a.array[o].expans==a.array[o+1].expans&&a.array[o].megota==a.array[o+1].megota&&(a.array[o].repeat+=a.array[o+1].repeat,a.array.splice(o+1,1),--o,r=!0);for(o=1;o<a.array.length;++o)0===a.array[o].arrow||0!==a.array[o].repeat&&null!==a.array[o].repeat&&void 0!==a.array[o].repeat?0==a.array[o].arrow&&a.array[o].expans>=2&&(a.array[o].arrow=1/0,a.array[o].valuereplaced=0,a.array[o].expans=a.array[o].expans-1):(a.array.splice(o,1),--o);for(a.array.length>e.maxOps&&a.array.splice(1,a.array.length-e.maxOps),this.getOperator(1)>=1&&this.getOperator(0)<n&&(this.setOperator(this.getOperator(1)-1,1),this.setOperator(Math.pow(10,this.getOperator(0)),0),r=!0),this.getOperator(0)>t&&(this.setOperator(this.getOperator(1)+1,1),this.setOperator(Math.log10(this.getOperator(0)),0),r=!0),1==this.array.length&&this.array[0].repeat<1&&(this.array[0].repeat=1/this.array[0].repeat,this.small=!this.small,r=!0);a.array.length>=2&&1==a.array[0].repeat&&a.array[1].repeat;)a.array[1].repeat>1?a.array[1].repeat--:a.array.splice(1,1),a.array[0].repeat=10,r=!0;a.array.length>=2&&a.array[0].repeat<t&&a.array[1].arrow>=2&&1==a.array[1].repeat&&(a.array.splice(1,1,s(a.array[0].repeat,a.array[1].arrow-1,a.array[1].expans,a.array[1].megota)),a.array[0].repeat=10,r=!0),a.array.length>=2&&a.array[1].repeat>t&&(a.array[1].arrow++,a.array[0].repeat=a.array[1].repeat,a.array[1].repeat=1,r=!0)}while(r);return this}},{key:"getOperatorIndex",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(1==this.array.length&&0==r)return 0;if(1==this.array.length&&1==r)return.5;if(2==this.array.length&&1==r)return 1;if(2==this.array.length&&0==r)return 0;for(var t=0;t<this.array.length;t++){var n=l([this.array[t].megota,this.array[t].expans,this.array[t].arrow],[a,e,r]);if(0==n)return t;if(1==n)return t-.5}return this.array.length-.5}},{key:"getOperator",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,t=this.getOperatorIndex(r,e,a);return this.array[t]?this.array[t].repeat:0}},{key:"setOperator",value:function(r,e){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=this.getOperatorIndex(e,a,t);return this.array[n]?(this.array[n].repeat=r,!1):(this.array.splice(Math.ceil(n),0,{arrow:e,expans:a,megota:t,valuereplaced:a===1/0?1:e==1/0?0:-1,repeat:r}),!0)}},{key:"clone",value:function(){var r=new e;return r.resetFromObject(this),r}},{key:"resetFromObject",value:function(r){this.array=[];for(var e=0;e<r.array.length;e++)this.array[e]={arrow:r.array[e].arrow,expans:r.array[e].expans,megota:r.array[e].megota,repeat:r.array[e].repeat,valuereplaced:r.array[e].valuereplaced};return this.small=r.small,this.sign=r.sign,this.layer=r.layer,this}},{key:"toNumber",value:function(){return-1==this.sign?-this.neg().toNumber():this.small?1/this.rec().toNumber():this.array.length>2?1/0:1==this.array.length?this.array[0].repeat:2==this.array.length&&1==this.array[1].arrow&&1==this.array[1].expans&&1==this.array[1].megota&&1==this.array[1].repeat?Math.pow(10,this.getOperator(0)):NaN}},{key:"toString",value:function(){if(this.isNaN())return"NaN";if(-1==this.sign)return"-".concat(this.neg().toString());if(this.small)return this.eq(e.ZERO)?"0":"/".concat(this.rec().toString());if(this.isInfi())return"Infinity";for(var r="",a=this.array.length-1;a>=0;a--){var t=this.array[a],n="10{".concat(t.arrow===1/0?"!":t.arrow).concat(t.expans>1||t.megota>1?",".concat(t.expans===1/0?"!":t.expans):"").concat(t.megota>1?",".concat(t.megota):"","}");n=1==t.arrow&&1==t.expans&&1==t.megota&&t.repeat<5?"e".repeat(t.repeat):0==t.arrow&&1==t.expans&&1==t.megota?t.repeat.toString():t.repeat>1?"(".concat(n,")^").concat(t.repeat," "):"".concat(n," "),r+="".concat(n)}return r}},{key:"arr01",get:function(){for(var r=[0],e=0;e<this.array.length;e++)0==e?r[0]=this.array[e].repeat:(r[e]=[0,0,0,0],r[e][0]=this.array[e].arrow==1/0?"x":this.array[e].arrow,r[e][1]=this.array[e].repeat,r[e][2]=this.array[e].expans==1/0?"x":this.array[e].expans,r[e][3]=this.array[e].megota);return r}}],[{key:"add",value:function(r,a){return new e(r).add(a)}},{key:"sub",value:function(r,a){return new e(r).sub(a)}},{key:"mul",value:function(r,a){return new e(r).mul(a)}},{key:"div",value:function(r,a){return new e(r).div(a)}},{key:"pow",value:function(r,a){return new e(r).pow(a)}},{key:"root",value:function(r,a){return new e(r).root(a)}},{key:"sqrt",value:function(r){return new e(r).sqrt()}},{key:"cbrt",value:function(r){return new e(r).cbrt()}},{key:"tetrate",value:function(r,a){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new e(r).tetrate(a,t)}},{key:"log10",value:function(r){return new e(r).log10()}},{key:"log",value:function(r){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new e(r).log(a)}},{key:"exp",value:function(r){return new e(r).pow_base(Math.E)}},{key:"factorial",value:function(r){return new e(r).factorial()}},{key:"gamma",value:function(r){return new e(r).gamma()}},{key:"lambertw",value:function(r){var a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new e(r).lambertw(a)}},{key:"tetrate_10",value:function(r){return e.fromNumber(10).tetrate(r)}},{key:"isNaN",value:function(r){return new e(r).isNaN()}},{key:"fromNumber",value:function(r){var a=new e;if(r<0)a.sign=-1;else{if(0==r)return a.sign=0,a.small=!0,a.array=[s(1/0,0)],a;r>0&&(a.sign=1)}var n=Math.abs(r);return n>=11102230246251568e-32&&n<1?(a.small=!0,a.array=[s(1/n,0)]):n<11102230246251568e-32?(a.small=!0,a.array=[s(-Math.log10(n),0),s(1,1)]):n<=t?a.array=[s(n,0)]:(a.setOperator(Math.log10(n),0),a.array=[s(Math.log10(n),0),s(1,1)]),a}},{key:"fromString",value:function(r){var a,i,l,h,g,f,y=new e;if(!isNaN(Number(r))&&isFinite(Number(r)))return y.resetFromObject(e.fromNumber(Number(r))),y;if(!o.test(r))throw"[PowiainaNum 0.2 error]malformed input: "+r;var c=!1,p=!1;if("-"==r[0]||"+"==r[0]){var m=r.search(/[^-\+]/);c=(null!==(i=null===(a=r.substring(0,m).match(/-/g))||void 0===a?void 0:a.length)&&void 0!==i?i:0)%2==1,r=r.substring(m)}if("/"==r[0]){m=r.search(/[^\/]/);p=(null!==(h=null===(l=r.substring(0,m).match(/\//g))||void 0===l?void 0:l.length)&&void 0!==h?h:0)%2==1,r=r.substring(m)}if("NaN"==r)y.array=[s(NaN)];else if("Infinity"==r)y.array=[s(1/0)];else{var v,N,w,b;for(y.sign=1,y.array=[s(0)];r&&/^(\(?10[\^\{])/.test(r);){var I,d,E;if("("==r[0]&&(r=r.substring(1)),"^"==r[2])I=v=r.substring(2).search(/[^\^]/),N=v+2;else{v=r.indexOf("}");var O=r.substring(3,v).split(",");I=Number("!"==O[0]?1/0:O[0]),d=Number(null!==(g="!"==O[1]?1/0:O[1])&&void 0!==g?g:1),E=Number(null!==(f=O[2])&&void 0!==f?f:1),N=v+1}")"==(r=r.substring(N))[0]?(v=r.indexOf(" "),w=Number(r.substring(2,v)),r=r.substring(v+1)):w=1,1==I&&1==d&&1==E?y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat+=w:y.array.splice(1,0,s(w,1,d,E)):2==I&&1==d&&1==E?(v=y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat:0,(N=y.array[0].repeat)>=1e10&&++v,N>=10&&++v,y.array[0].repeat=v,y.array.length>=2&&1==y.array[1].arrow&&y.array.splice(1,1),b=y.getOperatorIndex(2),Number.isInteger(b)?y.array[b].repeat+=w:y.array.splice(Math.ceil(b),0,s(w,2,d,E))):isFinite(I)?(v=y.getOperator(I-1),(N=y.getOperator(I-2))>=10&&++v,b=y.getOperatorIndex(I),y.array.splice(1,Math.ceil(b)-1),y.array[0].repeat=v,Number.isInteger(b)?y.array[1].repeat+=w:y.array.splice(1,0,s(w,I,d,E))):y.array.splice(1,0,s(w,I,d,E))}v=r.split(/[Ee]/),N=[y.array[0].repeat,0],w=1;for(var M=v.length-1;M>=0;--M){N[0]<n&&0===N[1]?N[0]=Math.pow(10,w*N[0]):-1==w?(0===N[1]?N[0]=Math.pow(10,w*N[0]):1==N[1]&&N[0]<=Math.log10(Number.MAX_VALUE)?N[0]=Math.pow(10,w*Math.pow(10,N[0])):N[0]=0,N[1]=0):N[1]++;var k=v[M].indexOf("."),x=-1==k?v[M].length:k;0===N[1]?x>=17?(N[0]=Math.log10(N[0])+u(v[M].substring(0,x)),N[1]=1):v[M]&&(N[0]*=Number(v[M])):(b=x>=17?u(v[M].substring(0,x)):v[M]?Math.log10(Number(v[M])):0,1==N[1]?N[0]+=b:2==N[1]&&N[0]<n+Math.log10(b)&&(N[0]+=Math.log10(1+Math.pow(10,Math.log10(b)-N[0])))),N[0]<n&&N[1]?(N[0]=Math.pow(10,N[0]),N[1]--):N[0]>t&&(N[0]=Math.log10(N[0]),N[1]++)}y.array[0].repeat=N[0],N[1]&&(y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat+=N[1]:y.array.splice(1,0,s(N[1],1,1,1)))}return c&&(y.sign*=-1),p&&(y.small=!y.small),y.normalize(),y.normalize(),y}},{key:"fromObject",value:function(r){var a=new e;a.array=[];for(var t=0;t<r.array.length;t++)a.array[t]={arrow:r.array[t].arrow,expans:r.array[t].expans,megota:r.array[t].megota,repeat:r.array[t].repeat,valuereplaced:r.array[t].valuereplaced};return a.small=r.small,a.sign=r.sign,a.layer=r.layer,a}}])}();return c.ZERO=new c({array:[{arrow:0,expans:1,megota:1,repeat:1/0}],small:!0,layer:0,sign:0}),c.ONE=new c({array:[{arrow:0,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),c.MSI=new c(t),c.MSI_REC=((y=new c(t)).small=!0,y),c.E_MSI=new c({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),c.E_MSI_REC=new c({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:1}],small:!0,layer:0,sign:1}),c.TETRATED_MSI=new c({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:t}],small:!1,layer:0,sign:1}),c.PENTATED_MSI=new c({array:[{arrow:0,expans:1,megota:1,repeat:t},{arrow:1,expans:1,megota:1,repeat:t},{arrow:2,expans:1,megota:1,repeat:t}],small:!1,layer:0,sign:1}),c.TRITRI=new c({small:!1,layer:0,sign:1,array:[s(3638334640023.7783,0,1,1),s(7625587484984,1,1,1)]}),c.GRAHAMS_NUMBER=new c("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783"),c.POSITIVE_INFINITY=new c(1/0),c.NEGATIVE_INFINITY=new c(-1/0),c.NaN=new c({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),c.maxOps=100,c}));
|
|
1
|
+
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).PowiainaNum=e()}(this,(function(){"use strict";function r(r,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,e(n.key),n)}}function e(r){var e=function(r,e){if("object"!=typeof r||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var a=t.call(r,e||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==typeof e?e:e+""}function t(r){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r})(r)}var a=9007199254740991,n=15.954589770191003,i=1.444667861009766,o=/^(PN)?\/*[-\+]*(Infinity|NaN|(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})|\(10(\^+|\{([1-9]\d*|!)(,([1-9]\d*|!))?(,[1-9]\d*)?\})\)\^[1-9]\d*\x20*)*((\d+(\.\d*)?|\d*\.\d+)?([Ee][-\+]*))*(0|\d+(\.\d*)?|\d*\.\d+))$/;function s(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return{repeat:r,arrow:e,expans:t,megota:a,valuereplaced:e==1/0?0:t==1/0?1:-1}}function l(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];for(var a=0;a<Math.min(e[0].length,e[1].length);a++){var n=e[0][a],i=e[1][a];if(n<i)return-1;if(n>i)return 1}return 0}function u(r){return Math.log10(Number(r.substring(0,17)))+(r.length-17)}var h=.5671432904097838;function g(r){var e,t,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!Number.isFinite(r))return r;if(n){if(0===r)return r;if(1===r)return h;e=r<10?0:Math.log(r)-Math.log(Math.log(r))}else{if(0===r)return-1/0;e=r<=-.1?-2:Math.log(-r)-Math.log(-Math.log(-r))}for(var i=0;i<100;++i){if(t=(r*Math.exp(-e)+e*e)/(e+1),Math.abs(t-e)<a*Math.abs(t))return t;e=t}throw Error("Iteration failed to converge: ".concat(r.toString()))}function f(r){return 2==r.length}function c(r){return"number"==typeof r[0]&&"number"==typeof r[1]}function y(r){var e,t,a,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e-10,o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(r.isInfiNaN())return r;if(o){if(r.eq(m.ZERO))return m.ZERO.clone();if(r.eq(m.ONE))return m.fromNumber(h);e=r.log()}else{if(r.eq(m.ZERO))return m.NEGATIVE_INFINITY.clone();e=r.neg().log()}for(var s=0;s<100;++s){if(t=e.neg().exp(),a=e.sub(r.mul(t)),(n=e.sub(a.div(e.add(1).sub(e.add(2).mul(a).div(e.mul(2).add(2)))))).sub(e).abs().lt(n.abs().mul(i)))return n;e=n}throw Error("Iteration failed to converge: ".concat(r.toString()))}var p,m=function(){function e(r){if(function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),this.array=[{arrow:0,expans:1,megota:1,repeat:NaN}],this.small=!1,this.sign=0,this.layer=0,void 0===r);else if("number"==typeof r){var a=e.fromNumber(r);this.resetFromObject(a)}else if("object"==t(r)){var n=e.fromObject(r);this.resetFromObject(n)}else if("string"==typeof r){var i=e.fromString(r);this.resetFromObject(i)}}return function(e,t,a){return t&&r(e.prototype,t),a&&r(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}(e,[{key:"add",value:function(r){var t,i,o,l,u,h,g=this.clone(),f=new e(r);if(g.eq(e.POSITIVE_INFINITY)&&f.eq(e.NEGATIVE_INFINITY)||g.eq(e.NEGATIVE_INFINITY)&&f.eq(e.POSITIVE_INFINITY))return e.NaN.clone();if(!g.isFinite())return g.clone();if(!f.isFinite())return f.clone();if(g.isZero())return f.clone();if(f.isZero())return g.clone();if(g.sign==-f.sign&&function(){var r=g.abs(),e=f.abs();return r.eq(e)}())return e.ZERO.clone();if(g.abs().lt(a)&&f.abs().lt(a))return e.fromNumber(g.toNumber()+f.toNumber());if(g.abs().lt(e.E_MSI_REC)||g.abs().gt(e.E_MSI)||f.abs().lt(e.E_MSI_REC)||f.abs().gt(e.E_MSI))return g.maxabs(f);if(-1==g.sign)return g.neg().add(f.neg()).neg();g.cmpabs(f)>0?(u=g,h=f):(h=g,u=f);var c=1;if(!(u.small||h.small||(null===(t=u.array[1])||void 0===t?void 0:t.repeat)||(null===(i=h.array[1])||void 0===i?void 0:i.repeat)||u.sign!=h.sign))return new e((u.array[0].repeat+h.array[0].repeat)*u.sign);var y=(u.small?-1:1)*((null===(o=u.array[1])||void 0===o?void 0:o.repeat)?u.array[0].repeat:Math.log10(u.array[0].repeat)),p=(h.small?-1:1)*((null===(l=h.array[1])||void 0===l?void 0:l.repeat)?h.array[0].repeat:Math.log10(h.array[0].repeat));if(y-p>n)return u;var m,v,N=-Math.floor(y),w=0;if((v=u.sign*Math.pow(10,y+N)+h.sign*Math.pow(10,p+N))>0&&(w=Math.log10(v)-N),v<0&&(w=Math.log10(-v)-N,c*=-1),0==v)throw Error("Encounter a calculate error");return(m=new e).sign=1,m.array=w>n||w<-n?[s(w,0),s(1,1)]:[s(Math.pow(10,Math.abs(w)),0)],m.small=w<0,m.sign*=c,m}},{key:"sub",value:function(r){return this.add(new e(r).neg())}},{key:"mul",value:function(r){var t,a=this.clone(),n=new e(r);return a.eq(e.POSITIVE_INFINITY)&&n.eq(e.NEGATIVE_INFINITY)||n.eq(e.POSITIVE_INFINITY)&&a.eq(e.NEGATIVE_INFINITY)?e.NEGATIVE_INFINITY.clone():a.isInfiNaN()&&n.eq(e.ZERO)&&n.isInfiNaN()&&a.eq(e.ZERO)?e.NaN.clone():a.eq(e.NEGATIVE_INFINITY)&&n.eq(e.NEGATIVE_INFINITY)?e.POSITIVE_INFINITY.clone():a.isFinite()?n.isFinite()?a.isZero()||n.isZero()?e.ZERO.clone():((t=a.abs().log10().add(n.abs().log10()).pow10()).sign=a.sign*n.sign,t):n.clone():a.clone()}},{key:"div",value:function(r){var t=new e(r).rec();return this.mul(t)}},{key:"pow10",value:function(){var r,t,a=this.clone();return this.isFinite()?a.isneg()?(a.sign*=-1,a.pow10().rec()):a.lte(308.25471555991675)?e.fromNumber(Math.pow(10,a.toNumber())):a.small?a.lt(e.MSI_REC)?e.ONE:new e(Math.pow(10,Math.pow(a.array[0].repeat,-1))):(a.gt(e.TETRATED_MSI)||(a.setOperator((null!==(t=null===(r=a.array[1])||void 0===r?void 0:r.repeat)&&void 0!==t?t:0)+1,1),a.normalize()),a):this.clone()}},{key:"pow",value:function(r){var t=new e(r);if(!t.isFinite())return t.clone();if(!this.isFinite())return this.clone();if(this.eq(10))return t.pow10();if(this.isneg()){if(!t.isInt())return e.NaN.clone();var a=this.abs().pow(t);return a.sign=function(){var r=t.mod(2).round();return r.eq(0)||r.eq(2)?1:-1}(),a}var n=this.toNumber(),i=t.toNumber(),o=Math.pow(n,i);return isFinite(o)?e.fromNumber(o):this.log10().mul(t).pow10()}},{key:"pow_base",value:function(r){return new e(r).pow(this)}},{key:"root",value:function(r){var t=new e(r);return this.pow(t.rec())}},{key:"sqrt",value:function(){return this.pow(.5)}},{key:"cbrt",value:function(){return this.root(3)}},{key:"tetrate",value:function(r){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=this.clone(),s=new e(r),l=new e(n);if(o.isNaN()||s.isNaN()||l.isNaN())return e.NaN.clone();if(l.neq(e.ONE)&&(s=s.add(l.slog(o))),s.isInfi()&&s.sign>0)return o.gte(i)?e.POSITIVE_INFINITY.clone():(t=this.log().neg()).lambertw().div(t);if(s.lte(-2))return e.NaN.clone();if(o.isZero())return s.isZero()?e.NaN.clone():s.gte(a/2)||s.toNumber()%2==0?e.ZERO.clone():e.ONE.clone();if(o.eq(e.ONE))return s.eq(e.ONE.neg())?e.NaN.clone():e.ONE.clone();if(s.eq(e.ONE.neg()))return e.ZERO.clone();if(s.eq(e.ZERO))return e.ONE.clone();if(s.eq(e.ONE))return o;if(s.eq(2))return o.pow(o);if(o.eq(2)){if(s.eq(3))return e.fromNumber(16);if(s.eq(4))return e.fromNumber(65536)}var u=o.max(s);if(u.gt(e.PENTATED_MSI))return u;if(u.gt(e.TETRATED_MSI)||s.gt(a)){if(this.lt(i))return(t=o.ln().neg()).lambertw().div(t);var h=o.slog(10).add(s);return h.setOperator(h.getOperator(2)+1,2),h.normalize(),h}for(var g=s.toNumber(),f=Math.floor(g),c=o.pow(g-f),y=e.NaN,p=0,m=e.E_MSI.clone();0!==f&&c.lt(m)&&p<100;++p)if(f>0){if(c=o.pow(c),y.eq(c)){f=0;break}y=c,--f}else{if(c=c.log(o),y.eq(c)){f=0;break}y=c,++f}return(100==p||this.lt(i))&&(f=0),c.setOperator(c.getOperator(1)+f,1),c.normalize(),c}},{key:"slog",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:10,t=this.clone(),a=new e(r);if(t.isInfiNaN())return t;if(a.isNaN())return a;if(a.isInfi())return e.ZERO.clone();if(t.isZero())return e.ONE.clone();if(t.eq(e.ONE))return e.ZERO.clone();if(t.eq(a))return e.ONE.clone();if(a.lt(i)){var n=a.tetrate(1/0);if(t.eq(n))return e.POSITIVE_INFINITY.clone();if(t.gt(n))return e.NaN.clone()}if(t.max(a).gt(e.PENTATED_MSI))return t.gt(a)?t:e.ZERO.clone();if(t.max(a).gt(e.TETRATED_MSI)&&t.gt(a))return t.setOperator(t.getOperator(2)-1,2),t.normalize(),t.sub(t.getOperator(1));if(t.lt(e.ZERO.clone()))return a.pow(t).sub(2);var o=0,s=t.getOperator(1)-a.getOperator(1);if(s>3){var l=s-3;o+=l,t.setOperator(t.getOperator(1)-l,1)}for(var u=0;u<100;++u){if(t.lte(e.ONE))return new e(o+t.toNumber());++o,t=e.log(t,r)}return console.warn("Failed to converage"),e.NaN.clone()}},{key:"abs",value:function(){var r=this.clone();return r.sign<0&&(r.sign*=-1),r}},{key:"log10",value:function(){if(this.isneg())return e.NaN.clone();if(this.isZero())return e.NEGATIVE_INFINITY.clone();if(this.small){var r=this.clone();return r.small=!r.small,r.log10().neg()}if(1==this.array.length)return new e(Math.log10(this.array[0].repeat));if(this.gte(e.TETRATED_MSI))return this.clone();var t=this.clone();return t.array[1].repeat=t.array[1].repeat-1,t.normalize(),t}},{key:"log",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Math.E,t=new e(r);return this.log10().div(t.log10())}},{key:"ln",value:function(){return this.log()}},{key:"exp",value:function(){return this.pow_base(Math.E)}},{key:"mod",value:function(r){var t=new e(r),a=this.div(t);return a.sub(a.floor()).mul(t)}},{key:"factorial",value:function(){return this.abs().lt(a)?this.add(1).gamma():this.abs().lt(e.E_MSI)?e.exp(this.mul(this.log10().sub(1))):e.exp(this)}},{key:"gamma",value:function(){if(this.small)return this.rec();if(this.lte(a)){if(this.lt(24))return e.fromNumber(function(r){if(!isFinite(r))return r;if(r<-50)return r===Math.trunc(r)?Number.NEGATIVE_INFINITY:0;for(var e=1;r<10;)e*=r,++r;var t=.9189385332046727;t+=((r-=1)+.5)*Math.log(r),t-=r;var a=r*r,n=r;return t+=1/(12*n),t-=1/(360*(n*=a)),t+=1/(1260*(n*=a)),t-=1/(1680*(n*=a)),t+=1/(1188*(n*=a)),t-=691/(360360*(n*=a)),t+=7/(1092*(n*=a)),t-=3617/(122400*(n*=a)),Math.exp(t)/e}(this.sign*this.getOperator(0)));var r=this.getOperator(0)-1,t=.9189385332046727;t+=(r+.5)*Math.log(r);var n=r*r,i=r,o=12*i,s=1/o,l=(t-=r)+s;if(l===t)return e.exp(t);if((l=(t=l)-(s=1/(o=360*(i*=n))))===t)return e.exp(t);t=l;var u=1/(o=1260*(i*=n));return t+=u,t-=u=1/(o=1680*(i*=n)),e.exp(t)}return this.gt(a)?e.exp(this.mul(this.log().sub(1))):e.exp(this)}},{key:"lambertw",value:function(){var r=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.lt(-.3678794411710499)?e.NaN.clone():r?this.abs().lt("1e-300")?new e(this):this.small?e.fromNumber(g(this.toNumber())):0===this.layer?e.fromNumber(g(this.sign*this.getOperator(0))):this.lt("eee15")?y(this):this.log():1===this.sign?e.NaN.clone():0===this.layer?e.fromNumber(g(this.sign*this.array[0].repeat,1e-10,!1)):1==this.layer?y(this,1e-10,!1):this.neg().rec().lambertw().neg()}},{key:"arrow",value:function(r){var t=this.clone(),n=new e(r);return!n.isInt()||n.lt(e.ZERO)?(console.warn("The arrow is <0 or not a integer, the returned function will return NaN."),function(){return e.NaN.clone()}):n.eq(0)?function(r){return t.mul(r)}:n.eq(1)?function(r){return t.pow(r)}:n.eq(2)?function(r){return t.tetrate(r)}:function(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=new e(r),s=e.arrowFuncMap.get("".concat(t.toString()," ").concat(n.toString()," ").concat(o.toString()));if(s)return s.clone();var l=function(){var r;if(t.isNaN()||o.isNaN())return e.NaN.clone();if(o.lt(e.ZERO))return e.NaN.clone();if(t.eq(e.ZERO))return o.eq(e.ONE)?e.ZERO.clone():e.NaN.clone();if(t.eq(e.ONE))return e.ONE.clone();if(o.eq(e.ZERO))return e.ONE.clone();if(o.eq(e.ONE))return t.clone();if(n.gt(e.MSI))return(r=n.clone()).setOperator(r.getOperator(1/0)+1,1/0),r;var s=n.toNumber();if(o.eq(2))return t.arrow(s-1)(t,i+1);if(t.max(o).gt(e.arrowMSI(s+1)))return t.max(o);if(t.gt(e.arrowMSI(s))||o.gt(a)){t.gt(e.arrowMSI(s))?((r=t.clone()).setOperator(r.getOperator(s)-1,s),r.normalize()):r=t.gt(e.arrowMSI(s-1))?new e(t.getOperator(s-1)):e.ZERO;var l=r.add(o);return l.setOperator(l.getOperator(s)+1,s),l.normalize(),l}if(i>=e.maxOps+10)return new e([[0,10],[s,1]]);var u=o.toNumber(),h=Math.floor(u),g=n.sub(e.ONE);r=t.arrow(g)(u-h,i+1);for(var f=0,c=e.arrowMSI(s-1);0!==h&&r.lt(c)&&f<100;f++)h>0&&(r=t.arrow(g)(r,i+1),--h);return 100==f&&(h=0),r.setOperator(r.getOperator(s-1)+h,s-1),r.normalize(),r}();return e.arrowFuncMap.set("".concat(t.toString()," ").concat(n.toString()," ").concat(o.toString()),l.clone()),l}}},{key:"chain",value:function(r,e){return this.arrow(e)(r)}},{key:"max",value:function(r){var t=new e(r);return this.lt(t)?t.clone():this.clone()}},{key:"min",value:function(r){var t=new e(r);return this.gte(t)?t.clone():this.clone()}},{key:"maxabs",value:function(r){var t=new e(r).abs();return this.abs().lt(t)?t.clone():this.clone()}},{key:"minabs",value:function(r){var t=new e(r).abs();return this.abs().gt(t)?t.clone():this.clone()}},{key:"cmpabs",value:function(r){var t=new e(r).abs();return this.abs().cmp(t)}},{key:"neg",value:function(){var r=this.clone();return r.sign*=-1,r.normalize(),r}},{key:"rec",value:function(){var r=this.clone();return r.small=!r.small,r}},{key:"floor",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?e.ZERO.clone():e.ONE.neg().clone();var r=this.abs();return r.array[0].repeat=Math[1==this.sign?"floor":"ceil"](r.getOperator(0)),r}},{key:"ceil",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?e.ONE.clone():e.ZERO.clone();var r=this.abs();return r.array[0].repeat=Math[1==this.sign?"ceil":"floor"](r.getOperator(0)),r.sign=this.sign,r}},{key:"round",value:function(){if(this.isInt())return this.clone();if(this.small)return 1==this.sign?this.rec().lte(2)?e.ONE.clone():e.ZERO.clone():this.abs().rec().lte(2)?e.ZERO.clone():e.ONE.neg().clone();var r=this.abs();return r.array[0].repeat=Math.round(r.array[0].repeat),r.sign=this.sign,r}},{key:"trunc",value:function(){var r=this.clone();return r.gte(0)?r.floor():r.ceil()}},{key:"compare",value:function(r){var t=new e(r);if(this.isNaN()||t.isNaN())return 2;if(this.sign<t.sign)return-1;if(this.sign>t.sign)return 1;var a=-1==this.sign&&-1==t.sign;if(this.small&&!t.small)return-1*(a?-1:1);if(t.small&&!this.small)return 1*(a?-1:1);var n=1;this.small&&t.small&&(n*=-1),a&&(n*=-1);for(var i=0,o=0;this.array.length-1-o>=0&&t.array.length-1-o>=0;o++){var s=this.array[this.array.length-1-o],u=t.array[t.array.length-1-o],h=l([s.megota,s.expans,s.arrow,s.repeat],[u.megota,u.expans,u.arrow,u.repeat]);if(1==h){i=1;break}if(-1==h){i=-1;break}}return i*n+1-1}},{key:"cmp",value:function(r){return this.compare(r)}},{key:"eq",value:function(r){return 0===this.cmp(r)}},{key:"neq",value:function(r){return 0!==this.cmp(r)}},{key:"lt",value:function(r){return-1===this.cmp(r)}},{key:"lte",value:function(r){return this.cmp(r)<=0}},{key:"gt",value:function(r){return 1==this.cmp(r)}},{key:"gte",value:function(r){var e=this.cmp(r);return 0==e||1==e}},{key:"isNaN",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return isNaN(this.getOperator(0))}))},{key:"isZero",value:function(){return Boolean(this.small&&!isFinite(this.getOperator(0)))}},{key:"isFinite",value:function(r){function e(){return r.apply(this,arguments)}return e.toString=function(){return r.toString()},e}((function(){return Boolean(this.small||isFinite(this.getOperator(0)))&&!this.isNaN()}))},{key:"isInfi",value:function(){return this.rec().isZero()}},{key:"isInfiNaN",value:function(){return this.isInfi()||this.isNaN()}},{key:"isInt",value:function(){return!!this.isZero()||(!(this.small||!Number.isInteger(this.getOperator(0)))||!!this.abs().gte(a/2))}},{key:"ispos",value:function(){return this.sign>0}},{key:"isneg",value:function(){return this.sign<0}},{key:"normalize",value:function(){for(var r=!0,t=this,i=0;i<this.array.length;i++)if(this.array[i].repeat==1/0)return this.array=[{arrow:0,expans:1,megota:1,repeat:1/0}],this.layer=0,this;for(var o=1;o<t.array.length;++o){var u=t.array[o];if(null!==u.arrow&&void 0!==u.arrow||(u.arrow=0),null!==u.expans&&void 0!==u.expans||(u.expans=1),null!==u.megota&&void 0!==u.megota||(u.megota=1),isNaN(u.arrow)||isNaN(u.repeat)||isNaN(u.expans)||isNaN(u.megota))return t.array=[s(NaN,0,1,1)],t;if(!isFinite(u.repeat)||!isFinite(u.megota))return t.array=[s(1/0,0,1,1)],t;Number.isInteger(u.arrow)||(u.arrow=Math.floor(u.arrow)),Number.isInteger(u.repeat)||(u.repeat=Math.floor(u.repeat)),Number.isInteger(u.expans)||(u.expans=Math.floor(u.expans)),Number.isInteger(u.megota)||(u.megota=Math.floor(u.megota))}t.array.length||(t.small=!t.small,t.array=[s(1/0)]);do{for(r=!1,this.array.sort((function(r,e){return l([r.megota,r.expans,r.arrow],[e.megota,e.expans,e.arrow])})),o=1;o<t.array.length-1;++o)t.array[o].arrow==t.array[o+1].arrow&&t.array[o].expans==t.array[o+1].expans&&t.array[o].megota==t.array[o+1].megota&&(t.array[o].repeat+=t.array[o+1].repeat,t.array.splice(o+1,1),--o,r=!0);for(o=1;o<t.array.length;++o)0===t.array[o].arrow||0!==t.array[o].repeat&&null!==t.array[o].repeat&&void 0!==t.array[o].repeat?0==t.array[o].arrow&&t.array[o].expans>=2&&(t.array[o].arrow=1/0,t.array[o].valuereplaced=0,t.array[o].expans=t.array[o].expans-1):(t.array.splice(o,1),--o);for(t.array.length>e.maxOps&&t.array.splice(1,t.array.length-e.maxOps),this.getOperator(1)>=1&&this.getOperator(0)<n&&(this.setOperator(this.getOperator(1)-1,1),this.setOperator(Math.pow(10,this.getOperator(0)),0),r=!0),this.getOperator(0)>a&&(this.setOperator(this.getOperator(1)+1,1),this.setOperator(Math.log10(this.getOperator(0)),0),r=!0),1==this.array.length&&this.array[0].repeat<1&&(this.array[0].repeat=1/this.array[0].repeat,this.small=!this.small,r=!0);t.array.length>=2&&1==t.array[0].repeat&&t.array[1].repeat;)t.array[1].repeat>1?t.array[1].repeat--:t.array.splice(1,1),t.array[0].repeat=10,r=!0;t.array.length>=2&&t.array[0].repeat<a&&t.array[1].arrow>=2&&1==t.array[1].repeat&&isFinite(t.array[1].arrow)&&(t.array.splice(1,1,s(t.array[0].repeat,t.array[1].arrow-1,t.array[1].expans,t.array[1].megota)),t.array[0].repeat=10,r=!0),t.array.length>=2&&t.array[1].repeat>a&&(t.array[1].arrow++,t.array[0].repeat=t.array[1].repeat,t.array[1].repeat=1,r=!0)}while(r);return this}},{key:"getOperatorIndex",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(1==this.array.length&&0==r)return 0;if(1==this.array.length&&1==r)return.5;if(2==this.array.length&&1==r)return 1;if(2==this.array.length&&0==r)return 0;for(var a=0;a<this.array.length;a++){var n=l([this.array[a].megota,this.array[a].expans,this.array[a].arrow],[t,e,r]);if(0==n)return a;if(1==n)return a-.5}return this.array.length-.5}},{key:"getOperator",value:function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=this.getOperatorIndex(r,e,t);return this.array[a]?this.array[a].repeat:0}},{key:"setOperator",value:function(r,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,n=this.getOperatorIndex(e,t,a);return this.array[n]?(this.array[n].repeat=r,!1):(this.array.splice(Math.ceil(n),0,{arrow:e,expans:t,megota:a,valuereplaced:t===1/0?1:e==1/0?0:-1,repeat:r}),!0)}},{key:"clone",value:function(){var r=new e;return r.resetFromObject(this),r}},{key:"resetFromObject",value:function(r){this.array=[];for(var e=0;e<r.array.length;e++)this.array[e]={arrow:r.array[e].arrow,expans:r.array[e].expans,megota:r.array[e].megota,repeat:r.array[e].repeat,valuereplaced:r.array[e].valuereplaced};return this.small=r.small,this.sign=r.sign,this.layer=r.layer,this}},{key:"toNumber",value:function(){return-1==this.sign?-this.neg().toNumber():this.small?1/this.rec().toNumber():this.array.length>2?1/0:1==this.array.length?this.array[0].repeat:2==this.array.length&&1==this.array[1].arrow&&1==this.array[1].expans&&1==this.array[1].megota&&1==this.array[1].repeat?Math.pow(10,this.getOperator(0)):NaN}},{key:"toString",value:function(){if(this.isNaN())return"NaN";if(-1==this.sign)return"-".concat(this.neg().toString());if(this.small)return this.isZero()?"0":"/".concat(this.rec().toString());if(this.isInfi())return"Infinity";for(var r="",e=this.array.length-1;e>=0;e--){var t=this.array[e],a="10{".concat(t.arrow===1/0?"!":t.arrow).concat(t.expans>1||t.megota>1?",".concat(t.expans===1/0?"!":t.expans):"").concat(t.megota>1?",".concat(t.megota):"","}");a=1==t.arrow&&1==t.expans&&1==t.megota&&t.repeat<5?"e".repeat(t.repeat):0==t.arrow&&1==t.expans&&1==t.megota?t.repeat.toString():t.repeat>1?"(".concat(a,")^").concat(t.repeat," "):"".concat(a),r+="".concat(a)}return r}},{key:"toJSON",value:function(){return"PN"+this.toString()}},{key:"arr01",get:function(){for(var r=[0],e=0;e<this.array.length;e++)0==e?r[0]=this.array[e].repeat:(r[e]=[0,0,0,0],r[e][0]=this.array[e].arrow==1/0?"x":this.array[e].arrow,r[e][1]=this.array[e].repeat,r[e][2]=this.array[e].expans==1/0?"x":this.array[e].expans,r[e][3]=this.array[e].megota);return r}}],[{key:"add",value:function(r,t){return new e(r).add(t)}},{key:"sub",value:function(r,t){return new e(r).sub(t)}},{key:"mul",value:function(r,t){return new e(r).mul(t)}},{key:"div",value:function(r,t){return new e(r).div(t)}},{key:"pow",value:function(r,t){return new e(r).pow(t)}},{key:"root",value:function(r,t){return new e(r).root(t)}},{key:"sqrt",value:function(r){return new e(r).sqrt()}},{key:"cbrt",value:function(r){return new e(r).cbrt()}},{key:"tetrate",value:function(r,t){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;return new e(r).tetrate(t,a)}},{key:"log10",value:function(r){return new e(r).log10()}},{key:"log",value:function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Math.E;return new e(r).log(t)}},{key:"exp",value:function(r){return new e(r).pow_base(Math.E)}},{key:"factorial",value:function(r){return new e(r).factorial()}},{key:"gamma",value:function(r){return new e(r).gamma()}},{key:"lambertw",value:function(r){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return new e(r).lambertw(t)}},{key:"tetrate_10",value:function(r){return e.fromNumber(10).tetrate(r)}},{key:"isNaN",value:function(r){return new e(r).isNaN()}},{key:"arrowMSI",value:function(r){return new e("10".concat(r).concat(a))}},{key:"fromNumber",value:function(r){var t=new e;if(r<0)t.sign=-1;else{if(0==r)return t.sign=0,t.small=!0,t.array=[s(1/0,0)],t;r>0&&(t.sign=1)}var n=Math.abs(r);return n>=11102230246251568e-32&&n<1?(t.small=!0,t.array=[s(1/n,0)]):n<11102230246251568e-32?(t.small=!0,t.array=[s(-Math.log10(n),0),s(1,1)]):n<=a?t.array=[s(n,0)]:(t.setOperator(Math.log10(n),0),t.array=[s(Math.log10(n),0),s(1,1)]),t}},{key:"fromString",value:function(r){var t,i,l,h,g,f,c,y=new e;if(r.startsWith("PN")&&(r=r.substring(2)),!isNaN(Number(r))){var p=Number(r),m=!1;if(0==p?/^(0*\.0*e)|(0*\.0*)$/.test(r)&&(m=!0):m=!0,!m){var v=r.search(/e/),N=r.substring((-1==v?r.length:v)+1),w=r.substring(0,-1==v?void 0:v),b=[0,0];if(b[1]=Number(N||"0"),Number(w)>=1){var I=w.length>=17?u(w):Math.log10(Number(w)),d=I-(Math.floor(I)-1);b[0]=Math.pow(10,d),b[1]+=d}else{var O=(c=w.match(/^0\.(0*)[1-9]/))?c[1].length:0;w=(w=w.substring(w.search(/[1-9]/))).charAt(0)+"."+w.substring(1),O+=1,b[0]=Number(w),b[1]+=-O}return e.pow(10,-b[1]-1).mul(10*Math.pow(b[0],-1)).rec()}if(isFinite(p)&&m)return y.resetFromObject(e.fromNumber(Number(r))),y}if(r=r.replace(/\(e\^(\d+)\)/g,"(10^)^$1 ").replace(/(\d+)\x20*PT/g,"(10^)^$1 "),!o.test(r))throw"[PowiainaNum 0.2 error]malformed input: "+r;var E=!1,M=!1;if("-"==r[0]||"+"==r[0]){var k=r.search(/[^-\+]/);E=(null!==(i=null===(t=r.substring(0,k).match(/-/g))||void 0===t?void 0:t.length)&&void 0!==i?i:0)%2==1,r=r.substring(k)}if("/"==r[0]){k=r.search(/[^\/]/);M=(null!==(h=null===(l=r.substring(0,k).match(/\//g))||void 0===l?void 0:l.length)&&void 0!==h?h:0)%2==1,r=r.substring(k)}if("NaN"==r)y.array=[s(NaN)];else if("Infinity"==r)y.array=[s(1/0)];else{var x,T,S,q;for(y.sign=1,y.array=[s(0)];r&&/^(\(?10[\^\{])/.test(r);){var F,_,R;if("("==r[0]&&(r=r.substring(1)),"^"==r[2])F=x=r.substring(2).search(/[^\^]/),T=x+2;else{x=r.indexOf("}");var Z=r.substring(3,x).split(",");F=Number("!"==Z[0]?1/0:Z[0]),_=Number(null!==(g="!"==Z[1]?1/0:Z[1])&&void 0!==g?g:1),R=Number(null!==(f=Z[2])&&void 0!==f?f:1),T=x+1}")"==(r=r.substring(T))[0]?(x=r.indexOf(" "),S=Number(r.substring(2,x)),r=r.substring(x+1)):S=1,1==F&&1==_&&1==R?y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat+=S:y.array.splice(1,0,s(S,1,_,R)):2==F&&1==_&&1==R?(x=y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat:0,(T=y.array[0].repeat)>=1e10&&++x,T>=10&&++x,y.array[0].repeat=x,y.array.length>=2&&1==y.array[1].arrow&&y.array.splice(1,1),q=y.getOperatorIndex(2),Number.isInteger(q)?y.array[q].repeat+=S:y.array.splice(Math.ceil(q),0,s(S,2,_,R))):isFinite(F)?(x=y.getOperator(F-1),(T=y.getOperator(F-2))>=10&&++x,q=y.getOperatorIndex(F),y.array.splice(1,Math.ceil(q)-1),y.array[0].repeat=x,Number.isInteger(q)?y.array[1].repeat+=S:y.array.splice(1,0,s(S,F,_,R))):y.array.splice(1,0,s(S,F,_,R))}x=r.split(/[Ee]/),T=[y.array[0].repeat,0],S=1;for(var A=x.length-1;A>=0;--A){T[0]<n&&0===T[1]?T[0]=Math.pow(10,S*T[0]):-1==S?(0===T[1]?T[0]=Math.pow(10,S*T[0]):1==T[1]&&T[0]<=Math.log10(Number.MAX_VALUE)?T[0]=Math.pow(10,S*Math.pow(10,T[0])):T[0]=0,T[1]=0):T[1]++;var P=x[A].indexOf("."),V=-1==P?x[A].length:P;0===T[1]?V>=17?(T[0]=Math.log10(T[0])+u(x[A].substring(0,V)),T[1]=1):x[A]&&(T[0]*=Number(x[A])):(q=V>=17?u(x[A].substring(0,V)):x[A]?Math.log10(Number(x[A])):0,1==T[1]?T[0]+=q:2==T[1]&&T[0]<n+Math.log10(q)&&(T[0]+=Math.log10(1+Math.pow(10,Math.log10(q)-T[0])))),T[0]<n&&T[1]?(T[0]=Math.pow(10,T[0]),T[1]--):T[0]>a&&(T[0]=Math.log10(T[0]),T[1]++)}y.array[0].repeat=T[0],T[1]&&(y.array.length>=2&&1==y.array[1].arrow?y.array[1].repeat+=T[1]:y.array.splice(1,0,s(T[1],1,1,1)))}return E&&(y.sign*=-1),M&&(y.small=!y.small),y.normalize(),y.normalize(),y}},{key:"fromObject",value:function(r){var t=new e;if(t.array=[],function(r){if(!Array.isArray(r))return!1;for(var e=0;e<r.length;e++){var t=r[e];if(!Array.isArray(t))return!1;if(!f(t))return!1;if(!c(t))return!1}return!0}(r)){for(var a=0;a<r.length;a++)t.array[a]={arrow:r[a][0],expans:1,megota:1,repeat:r[a][1]};return t.small=!1,t.sign=1,t.layer=0,t.normalize(),t}for(var n=0;n<r.array.length;n++)t.array[n]={arrow:r.array[n].arrow,expans:r.array[n].expans,megota:r.array[n].megota,repeat:r.array[n].repeat,valuereplaced:r.array[n].valuereplaced};return t.small=r.small,t.sign=r.sign,t.layer=r.layer,t}}])}();return m.ZERO=new m({array:[{arrow:0,expans:1,megota:1,repeat:1/0}],small:!0,layer:0,sign:0}),m.ONE=new m({array:[{arrow:0,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),m.MSI=new m(a),m.MSI_REC=((p=new m(a)).small=!0,p),m.E_MSI=new m({array:[{arrow:0,expans:1,megota:1,repeat:a},{arrow:1,expans:1,megota:1,repeat:1}],small:!1,layer:0,sign:1}),m.E_MSI_REC=new m({array:[{arrow:0,expans:1,megota:1,repeat:a},{arrow:1,expans:1,megota:1,repeat:1}],small:!0,layer:0,sign:1}),m.TETRATED_MSI=new m({array:[{arrow:0,expans:1,megota:1,repeat:a},{arrow:1,expans:1,megota:1,repeat:a}],small:!1,layer:0,sign:1}),m.PENTATED_MSI=new m({array:[{arrow:0,expans:1,megota:1,repeat:a},{arrow:1,expans:1,megota:1,repeat:a},{arrow:2,expans:1,megota:1,repeat:a}],small:!1,layer:0,sign:1}),m.TRITRI=new m({small:!1,layer:0,sign:1,array:[s(3638334640023.7783,0,1,1),s(7625587484984,1,1,1)]}),m.GRAHAMS_NUMBER=new m("(10{!})^63 10^^^(10^)^7625597484984 3638334640023.7783"),m.POSITIVE_INFINITY=new m(1/0),m.NEGATIVE_INFINITY=new m(-1/0),m.NaN=new m({array:[{arrow:0,expans:1,megota:1,repeat:NaN}],small:!1,layer:0,sign:0}),m.maxOps=100,m.arrowFuncMap=new Map,m}));
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ interface IPowiainaNum {
|
|
|
11
11
|
sign: -1 | 0 | 1;
|
|
12
12
|
layer: number;
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
type ExpantaNumArray = [number, number][];
|
|
15
|
+
export type PowiainaNumSource = number | string | IPowiainaNum | PowiainaNum | ExpantaNumArray;
|
|
15
16
|
export default class PowiainaNum implements IPowiainaNum {
|
|
16
17
|
array: Operator[];
|
|
17
18
|
small: boolean;
|
|
@@ -76,6 +77,8 @@ export default class PowiainaNum implements IPowiainaNum {
|
|
|
76
77
|
lambertw(princ?: boolean): PowiainaNum;
|
|
77
78
|
static lambertw(x: PowiainaNumSource, principal?: boolean): PowiainaNum;
|
|
78
79
|
static tetrate_10(other2: PowiainaNumSource): PowiainaNum;
|
|
80
|
+
arrow(arrows2: PowiainaNumSource): (other: PowiainaNumSource, depth?: number) => PowiainaNum;
|
|
81
|
+
chain(other: PowiainaNumSource, arrows: PowiainaNumSource): PowiainaNum;
|
|
79
82
|
max(x: PowiainaNumSource): PowiainaNum;
|
|
80
83
|
min(x: PowiainaNumSource): PowiainaNum;
|
|
81
84
|
maxabs(x: PowiainaNumSource): PowiainaNum;
|
|
@@ -124,6 +127,7 @@ export default class PowiainaNum implements IPowiainaNum {
|
|
|
124
127
|
* @returns normalized number
|
|
125
128
|
*/
|
|
126
129
|
normalize(): PowiainaNum;
|
|
130
|
+
private static arrowMSI;
|
|
127
131
|
/**
|
|
128
132
|
* @returns number will return the index of the operator in array. return as x.5 if it's between the xth and x+1th operators.
|
|
129
133
|
*/
|
|
@@ -139,15 +143,28 @@ export default class PowiainaNum implements IPowiainaNum {
|
|
|
139
143
|
*/
|
|
140
144
|
setOperator(val: number, arrow: number, expans?: number, megota?: number): boolean;
|
|
141
145
|
/**
|
|
142
|
-
* @returns
|
|
146
|
+
* @returns a PowiainaNum object which deep copied from `this` object.
|
|
143
147
|
*/
|
|
144
148
|
clone(): PowiainaNum;
|
|
145
149
|
resetFromObject(powlikeObject: IPowiainaNum): this;
|
|
150
|
+
/**
|
|
151
|
+
* Convert `this` to Javascript `number`
|
|
152
|
+
*
|
|
153
|
+
* returns `Infinity` when the number is greater than `Number.MAX_VALUE`
|
|
154
|
+
*/
|
|
146
155
|
toNumber(): number;
|
|
156
|
+
/**
|
|
157
|
+
* Convert `this` to a string
|
|
158
|
+
*/
|
|
147
159
|
toString(): string;
|
|
148
160
|
static fromNumber(x: number): PowiainaNum;
|
|
161
|
+
/**
|
|
162
|
+
* Convert `this` to a JSON object
|
|
163
|
+
* @returns a JSON object
|
|
164
|
+
*/
|
|
165
|
+
toJSON(): string;
|
|
149
166
|
static fromString(input: string): PowiainaNum;
|
|
150
|
-
static fromObject(powlikeObject: IPowiainaNum): PowiainaNum;
|
|
167
|
+
static fromObject(powlikeObject: IPowiainaNum | ExpantaNumArray): PowiainaNum;
|
|
151
168
|
/**
|
|
152
169
|
* A property arary value for version 0.1.x PowiainaNum.
|
|
153
170
|
*/
|
|
@@ -166,5 +183,6 @@ export default class PowiainaNum implements IPowiainaNum {
|
|
|
166
183
|
static readonly NEGATIVE_INFINITY: PowiainaNum;
|
|
167
184
|
static readonly NaN: PowiainaNum;
|
|
168
185
|
static readonly maxOps = 100;
|
|
186
|
+
static arrowFuncMap: Map<string, PowiainaNum>;
|
|
169
187
|
}
|
|
170
188
|
export {};
|