@danielsimonjr/mathts-core 0.21.0 → 0.21.1
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/dist/factory.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/internal.js +1 -1
- package/dist/types/fraction.d.ts +16 -2
- package/dist/types/fraction.d.ts.map +1 -1
- package/dist/types/unit/Unit.d.ts.map +1 -1
- package/dist/types/unit/va-var.d.ts +15 -0
- package/dist/types/unit/va-var.d.ts.map +1 -0
- package/dist/{unit-D3yD3jbu.js → unit-DfRY7PU0.js} +63 -20
- package/package.json +1 -1
package/dist/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,OAAO,GAAG,OAAO;IAChD,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAC1C,SAAS,EAAE,IAAI,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH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AAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQzB;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,eAAe,CAG9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,cAAc,EAAE,EAC9B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,IAAI,CAeN;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,cAAc,GAAG,OAAO,CAIxE;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,cAAc,GAAG,MAAM,CAExE"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as BIGNUMBER_LN10, A as formatExactScale, B as abs, Bn as Complex, C as clearExactScaleNumberCache, D as exactScaleOf, E as exactScaleNumberCacheSize, F as powerExactScale, Fn as isUnit$1, G as isNumeric, H as divideScalar, Hn as isComplex, I as ratioExactScale, J as pow, K as multiplyScalar, L as readScaleExpression, Ln as COMPLEX_NEG_ONE, M as isRationalScale, N as multiplyExactScales, O as exactScaleToNumber, P as namedIrrationalScale, Q as BIGNUMBER_E, R as DimensionMismatchError, Rn as COMPLEX_ONE, S as binaryExactScale, T as divideExactScales, U as equal, V as addScalar, Vn as I, W as fix, X as subtractScalar, Xt as format, Y as round, _ as LN2_EXACT_SCALE, a as REFUSED_UNIT_SPELLINGS, at as BIGNUMBER_ZERO, b as UNIT_EXACT_SCALE, c as UNIT_ROW_ALIASES, ct as FRACTION_HALF, d as namedExactScale, dt as FRACTION_QUARTER, et as BIGNUMBER_LN2, f as readUnitScale, ft as FRACTION_THIRD, g as unitRowValue, gn as isBigNumber$2, h as unitRowExactScale, hn as isBigInt$1, ht as isFraction, i as NAMED_SCALES, it as BIGNUMBER_TEN, j as irrationalPower, k as exactScalesEqual, l as getUnitPrefix, lt as FRACTION_NEG_ONE, m as unitRowExactOffset, mt as Fraction, nn as nearlyEqual, nt as BIGNUMBER_ONE, o as UNIT_PREFIX_SETS, on as sign, ot as BigNumber, p as unitPrefixExactScale, pt as FRACTION_ZERO, q as number, rt as BIGNUMBER_PI, s as UNIT_ROWS, st as isBigNumber, t as Unit, tt as BIGNUMBER_NEG_ONE, u as getUnitRow, ut as FRACTION_ONE, v as NAMED_IRRATIONALS, vt as factory, w as decimalExactScale, x as addExactScales, y as PI_EXACT_SCALE, z as UnitParseError, zn as COMPLEX_ZERO } from "./unit-
|
|
1
|
+
import { $ as BIGNUMBER_LN10, A as formatExactScale, B as abs, Bn as Complex, C as clearExactScaleNumberCache, D as exactScaleOf, E as exactScaleNumberCacheSize, F as powerExactScale, Fn as isUnit$1, G as isNumeric, H as divideScalar, Hn as isComplex, I as ratioExactScale, J as pow, K as multiplyScalar, L as readScaleExpression, Ln as COMPLEX_NEG_ONE, M as isRationalScale, N as multiplyExactScales, O as exactScaleToNumber, P as namedIrrationalScale, Q as BIGNUMBER_E, R as DimensionMismatchError, Rn as COMPLEX_ONE, S as binaryExactScale, T as divideExactScales, U as equal, V as addScalar, Vn as I, W as fix, X as subtractScalar, Xt as format, Y as round, _ as LN2_EXACT_SCALE, a as REFUSED_UNIT_SPELLINGS, at as BIGNUMBER_ZERO, b as UNIT_EXACT_SCALE, c as UNIT_ROW_ALIASES, ct as FRACTION_HALF, d as namedExactScale, dt as FRACTION_QUARTER, et as BIGNUMBER_LN2, f as readUnitScale, ft as FRACTION_THIRD, g as unitRowValue, gn as isBigNumber$2, h as unitRowExactScale, hn as isBigInt$1, ht as isFraction, i as NAMED_SCALES, it as BIGNUMBER_TEN, j as irrationalPower, k as exactScalesEqual, l as getUnitPrefix, lt as FRACTION_NEG_ONE, m as unitRowExactOffset, mt as Fraction, nn as nearlyEqual, nt as BIGNUMBER_ONE, o as UNIT_PREFIX_SETS, on as sign, ot as BigNumber, p as unitPrefixExactScale, pt as FRACTION_ZERO, q as number, rt as BIGNUMBER_PI, s as UNIT_ROWS, st as isBigNumber, t as Unit, tt as BIGNUMBER_NEG_ONE, u as getUnitRow, ut as FRACTION_ONE, v as NAMED_IRRATIONALS, vt as factory, w as decimalExactScale, x as addExactScales, y as PI_EXACT_SCALE, z as UnitParseError, zn as COMPLEX_ZERO } from "./unit-DfRY7PU0.js";
|
|
2
2
|
import typed, { create } from "typed-function";
|
|
3
3
|
const createRangeClass = /* #__PURE__ */ factory("Range", [], () => {
|
|
4
4
|
class Range {
|
|
@@ -1407,6 +1407,6 @@ function rowMajorStrides(shape) {
|
|
|
1407
1407
|
}
|
|
1408
1408
|
//#endregion
|
|
1409
1409
|
//#region src/index.ts
|
|
1410
|
-
const VERSION = "0.21.
|
|
1410
|
+
const VERSION = "0.21.1";
|
|
1411
1411
|
//#endregion
|
|
1412
1412
|
export { ALL_UNITS, BASE_UNITS, BEST_PREFIXES, BIGNUMBER_E, BIGNUMBER_LN10, BIGNUMBER_LN2, BIGNUMBER_NEG_ONE, BIGNUMBER_ONE, BIGNUMBER_PI, BIGNUMBER_TEN, BIGNUMBER_ZERO, BigNumber, COMPLEX_NEG_ONE, COMPLEX_ONE, COMPLEX_ZERO, Complex, DEFAULT_CONFIG, DERIVED_UNITS, DIMENSIONLESS, DUAL_UNARY_RULES, DimensionMismatchError, Dual, E, FRACTION_HALF, FRACTION_NEG_ONE, FRACTION_ONE, FRACTION_QUARTER, FRACTION_THIRD, FRACTION_ZERO, Fraction, FunctionRegistry, I, LN10, LN2, LN2_EXACT_SCALE, LOG10E, LOG2E, MATHTS_CONVERSIONS, MATHTS_TYPES, NAMED_IRRATIONALS, NAMED_SCALES, PHI, PI, PI_EXACT_SCALE, REFUSED_UNIT_SPELLINGS, Range, SI_DIMENSION_LENGTH, SI_PREFIXES, SQRT1_2, SQRT2, TAU, TypeRegistry, UNIT_ALIASES, UNIT_DIMENSION_LENGTH, UNIT_EXACT_SCALE, UNIT_PREFIX_SETS, UNIT_ROWS, UNIT_ROW_ALIASES, Unit, UnitParseError, VERSION, abs, addExactScales, addScalar, binaryExactScale, boxMuller, clearExactScaleNumberCache, create, createFactory, createMathTSTyped, createRangeClass, createSeededRng, createTypedFunction, decimalExactScale, dim, divideExactScales, divideScalar, equal, exactScaleNumberCacheSize, exactScaleOf, exactScaleToNumber, exactScalesEqual, fix, formatExactScale, fromSiDimensionVector, fromSiDimensions, getPrefix, getUnitDef, getUnitPrefix, getUnitRow, initTypedWasm, irrationalPower, isArray, isBigInt, isBigNumber, isBoolean, isComplex, isDenseMatrix, isDual, isFraction, isFunction, isMatrix, isNull, isNumber, isNumeric, isObject, isRationalScale, isSparseMatrix, isString, isTypedWasmAvailable, isUndefined, isUnit, isUnit$1 as isUnitValue, math, mathTyped, mulberry32, multiplyExactScales, multiplyScalar, namedExactScale, namedIrrationalScale, neumaierCumsum, neumaierSum, norm2, number, pairwiseDot, pairwiseSum, pow, powerExactScale, ratioExactScale, readScaleExpression, readUnitScale, registerNativeTypes, registry, round, rowMajorStrides, scaledDistance, subtractScalar, sumSquaredDeviations, toSiDimensionVector, toSiDimensions, typed, unitPrefixExactScale, unitRowExactOffset, unitRowExactScale, unitRowValue };
|
package/dist/internal.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $t as log10, An as isRange, At as get, Bt as memoize, Cn as isFunction, Ct as MathjsError, Dn as isNull, Dt as deepFlatten, En as isMatrix, Et as deepExtend, Fn as isUnit, Ft as pickShallow, Gt as cbrt, Ht as acosh, In as typeOf, It as set, Jt as digits, Kt as copysign, Lt as traverse, Mn as isSparseMatrix, Mt as lazy, Nn as isString, Nt as mapObject, On as isNumber, Ot as deepStrictEqual, Pn as isUndefined, Pt as pick, Qt as isPowZeroAtInfinity, Rt as endsWith, Sn as isFraction, St as stripOptionalNotation, Tn as isMap, Tt as clone, Ut as asinh, Vt as warnOnce, Wt as atanh, Xt as format, Yt as expm1, Z as DEFAULT_CONFIG, Zt as isInteger, _n as isBoolean, _t as create, an as safeNumberType, bn as isDate, bt as isOptionalDependency, cn as splitNumber, dn as toExponential, en as log1p, fn as toFixed, gn as isBigNumber, gt as assertDependencies, hn as isBigInt, in as roundDigits, jn as isRegExp, jt as isLegacyFactory, kn as isObject, kt as extend, ln as tanh, mn as isArray, n as unitDependencies, nn as nearlyEqual, on as sign, pn as toPrecision, qt as cosh, r as createUnitClass, rn as normalizeFormatOptions, sn as sinh, t as Unit, tn as log2, un as toEngineering, vn as isCollection, vt as factory, wn as isIndex, wt as canDefineProperty, xn as isDenseMatrix, xt as sortFactories, yn as isComplex, yt as isFactory, zt as hasOwnProperty } from "./unit-
|
|
1
|
+
import { $t as log10, An as isRange, At as get, Bt as memoize, Cn as isFunction, Ct as MathjsError, Dn as isNull, Dt as deepFlatten, En as isMatrix, Et as deepExtend, Fn as isUnit, Ft as pickShallow, Gt as cbrt, Ht as acosh, In as typeOf, It as set, Jt as digits, Kt as copysign, Lt as traverse, Mn as isSparseMatrix, Mt as lazy, Nn as isString, Nt as mapObject, On as isNumber, Ot as deepStrictEqual, Pn as isUndefined, Pt as pick, Qt as isPowZeroAtInfinity, Rt as endsWith, Sn as isFraction, St as stripOptionalNotation, Tn as isMap, Tt as clone, Ut as asinh, Vt as warnOnce, Wt as atanh, Xt as format, Yt as expm1, Z as DEFAULT_CONFIG, Zt as isInteger, _n as isBoolean, _t as create, an as safeNumberType, bn as isDate, bt as isOptionalDependency, cn as splitNumber, dn as toExponential, en as log1p, fn as toFixed, gn as isBigNumber, gt as assertDependencies, hn as isBigInt, in as roundDigits, jn as isRegExp, jt as isLegacyFactory, kn as isObject, kt as extend, ln as tanh, mn as isArray, n as unitDependencies, nn as nearlyEqual, on as sign, pn as toPrecision, qt as cosh, r as createUnitClass, rn as normalizeFormatOptions, sn as sinh, t as Unit, tn as log2, un as toEngineering, vn as isCollection, vt as factory, wn as isIndex, wt as canDefineProperty, xn as isDenseMatrix, xt as sortFactories, yn as isComplex, yt as isFactory, zt as hasOwnProperty } from "./unit-DfRY7PU0.js";
|
|
2
2
|
//#region src/error/DimensionError.ts
|
|
3
3
|
var DimensionError = class DimensionError extends RangeError {
|
|
4
4
|
actual;
|
package/dist/types/fraction.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export declare class Fraction implements IFraction {
|
|
|
17
17
|
readonly numerator: bigint;
|
|
18
18
|
readonly denominator: bigint;
|
|
19
19
|
constructor(numerator: bigint | number | string | Fraction, denominator?: bigint | number | string | Fraction);
|
|
20
|
+
/**
|
|
21
|
+
* Build a Fraction from a pair the caller has already reduced (coprime, `den > 0`), skipping
|
|
22
|
+
* the gcd of the public constructor. For results of operations on reduced fractions only.
|
|
23
|
+
*/
|
|
24
|
+
private static fromReduced;
|
|
20
25
|
/**
|
|
21
26
|
* Create a Fraction from a number (with optional precision)
|
|
22
27
|
*/
|
|
@@ -85,7 +90,11 @@ export declare class Fraction implements IFraction {
|
|
|
85
90
|
*/
|
|
86
91
|
subtract(other: Scalar): Fraction;
|
|
87
92
|
/**
|
|
88
|
-
* Multiplication: a/b * c/d = ac / bd
|
|
93
|
+
* Multiplication: a/b * c/d = ac / bd.
|
|
94
|
+
*
|
|
95
|
+
* Cross-reduces first (Knuth, TAOCP 4.5.1): with both operands in lowest terms only `gcd(a, d)`
|
|
96
|
+
* and `gcd(c, b)` can be common factors, so the product is already reduced and the two gcds run
|
|
97
|
+
* on the small operands rather than on the full-size products.
|
|
89
98
|
*/
|
|
90
99
|
multiply(other: Scalar): Fraction;
|
|
91
100
|
/**
|
|
@@ -108,7 +117,12 @@ export declare class Fraction implements IFraction {
|
|
|
108
117
|
*/
|
|
109
118
|
inverse(): Fraction;
|
|
110
119
|
/**
|
|
111
|
-
* Power (integer exponent)
|
|
120
|
+
* Power (integer exponent).
|
|
121
|
+
*
|
|
122
|
+
* Raises numerator and denominator separately: powers of coprime integers stay coprime, so the
|
|
123
|
+
* result is already in lowest terms and no gcd or intermediate Fraction is needed.
|
|
124
|
+
*
|
|
125
|
+
* @throws TypeError if `n` is not an integer (a non-integer power is generally irrational)
|
|
112
126
|
*/
|
|
113
127
|
pow(n: number | bigint): Fraction;
|
|
114
128
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fraction.d.ts","sourceRoot":"","sources":["../../src/types/fraction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;
|
|
1
|
+
{"version":3,"file":"fraction.d.ts","sourceRoot":"","sources":["../../src/types/fraction.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAqCD;;;;GAIG;AACH,qBAAa,QAAS,YAAW,SAAS;IACxC,QAAQ,CAAC,IAAI,cAAc;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,YACE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,EAC9C,WAAW,GAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAa,EA4EtD;IAMD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAS1B;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,GAAE,MAAiB,GAAG,QAAQ,CAuCxE;IAED;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAoC9C;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,Q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IAAI,QAAQ,CAEhB;IAED;;OAEG;IACH,IAAI,IAAI,MAAM,CAIb;IAED;;OAEG;IACH,KAAK,IAAI,QAAQ,CAEhB;IAED;;OAEG;IACH,GAAG,IAAI,MAAM,CAEZ;IAED;;OAEG;IACH,mBAAmB,IAAI,MAAM,EAAE,CAiB9B;IAED;;OAEG;IACH,MAAM,CAAC,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,QAAQ,CAenD;IAED;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAEjC;CACF;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,UAAuB,CAAC;AAClD,eAAO,MAAM,YAAY,UAAuB,CAAC;AACjD,eAAO,MAAM,gBAAgB,UAAwB,CAAC;AACtD,eAAO,MAAM,aAAa,UAAuB,CAAC;AAClD,eAAO,MAAM,cAAc,UAAuB,CAAC;AACnD,eAAO,MAAM,gBAAgB,UAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Unit.d.ts","sourceRoot":"","sources":["../../../src/types/unit/Unit.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAcV,eAAe,EAQhB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"Unit.d.ts","sourceRoot":"","sources":["../../../src/types/unit/Unit.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAcV,eAAe,EAQhB,MAAM,iBAAiB,CAAC;AAkJzB,eAAO,MAAM,eAAe,6DAksF3B,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VA / VAR classification for complex-valued units.
|
|
3
|
+
* @module @danielsimonjr/mathts-core/types/unit/va-var
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Whether a complex value counts as purely imaginary, so that `VA` (volt-ampere) should read as
|
|
7
|
+
* `VAR` (reactive volt-ampere).
|
|
8
|
+
*
|
|
9
|
+
* The test is relative: the real part must be negligible next to the imaginary part (at most
|
|
10
|
+
* 1e-14 of it). An absolute cutoff called every value smaller than 1e-14 imaginary, including a
|
|
11
|
+
* purely real 1e-20 VA. `0 + 0i` still counts as imaginary, as it did under the absolute test;
|
|
12
|
+
* NaN in either part does not.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isEffectivelyImaginary(re: number, im: number): boolean;
|
|
15
|
+
//# sourceMappingURL=va-var.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"va-var.d.ts","sourceRoot":"","sources":["../../../src/types/unit/va-var.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAEtE"}
|
|
@@ -1081,11 +1081,18 @@ function reducePair(num, den) {
|
|
|
1081
1081
|
const g = gcd$1(num, den);
|
|
1082
1082
|
return [num / g, den / g];
|
|
1083
1083
|
}
|
|
1084
|
+
let reducedPending = false;
|
|
1084
1085
|
var Fraction = class Fraction {
|
|
1085
1086
|
type = "Fraction";
|
|
1086
1087
|
numerator;
|
|
1087
1088
|
denominator;
|
|
1088
1089
|
constructor(numerator, denominator = 1n) {
|
|
1090
|
+
if (reducedPending) {
|
|
1091
|
+
reducedPending = false;
|
|
1092
|
+
this.numerator = numerator;
|
|
1093
|
+
this.denominator = denominator;
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1089
1096
|
if (typeof numerator === "bigint" && typeof denominator === "bigint") {
|
|
1090
1097
|
const [num, den] = reducePair(numerator, denominator);
|
|
1091
1098
|
this.numerator = num;
|
|
@@ -1133,6 +1140,14 @@ var Fraction = class Fraction {
|
|
|
1133
1140
|
this.numerator = num / g;
|
|
1134
1141
|
this.denominator = den / g;
|
|
1135
1142
|
}
|
|
1143
|
+
static fromReduced(numerator, denominator) {
|
|
1144
|
+
reducedPending = true;
|
|
1145
|
+
try {
|
|
1146
|
+
return new Fraction(numerator, denominator);
|
|
1147
|
+
} finally {
|
|
1148
|
+
reducedPending = false;
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1136
1151
|
static fromNumber(n, maxDenominator = 1000000n) {
|
|
1137
1152
|
if (!Number.isFinite(n)) throw new Error("Cannot create fraction from non-finite number");
|
|
1138
1153
|
if (Number.isInteger(n)) return new Fraction(BigInt(n), 1n);
|
|
@@ -1263,13 +1278,22 @@ var Fraction = class Fraction {
|
|
|
1263
1278
|
return this.addSub(other, (a, b) => a - b);
|
|
1264
1279
|
}
|
|
1265
1280
|
multiply(other) {
|
|
1266
|
-
if (other instanceof Fraction)
|
|
1281
|
+
if (other instanceof Fraction) {
|
|
1282
|
+
const g1 = gcd$1(this.numerator, other.denominator);
|
|
1283
|
+
const g2 = gcd$1(other.numerator, this.denominator);
|
|
1284
|
+
return Fraction.fromReduced(this.numerator / g1 * (other.numerator / g2), this.denominator / g2 * (other.denominator / g1));
|
|
1285
|
+
}
|
|
1267
1286
|
return this.multiply(Fraction.fromNumber(Number(other.valueOf())));
|
|
1268
1287
|
}
|
|
1269
1288
|
divide(other) {
|
|
1270
1289
|
if (other instanceof Fraction) {
|
|
1271
1290
|
if (other.numerator === 0n) throw new Error("Division by zero");
|
|
1272
|
-
|
|
1291
|
+
const negative = other.numerator < 0n;
|
|
1292
|
+
const p = negative ? -other.denominator : other.denominator;
|
|
1293
|
+
const q = negative ? -other.numerator : other.numerator;
|
|
1294
|
+
const g1 = gcd$1(this.numerator, q);
|
|
1295
|
+
const g2 = gcd$1(p, this.denominator);
|
|
1296
|
+
return Fraction.fromReduced(this.numerator / g1 * (p / g2), this.denominator / g2 * (q / g1));
|
|
1273
1297
|
}
|
|
1274
1298
|
return this.divide(Fraction.fromNumber(Number(other.valueOf())));
|
|
1275
1299
|
}
|
|
@@ -1283,28 +1307,21 @@ var Fraction = class Fraction {
|
|
|
1283
1307
|
return this.divide(other);
|
|
1284
1308
|
}
|
|
1285
1309
|
negate() {
|
|
1286
|
-
return
|
|
1310
|
+
return Fraction.fromReduced(-this.numerator, this.denominator);
|
|
1287
1311
|
}
|
|
1288
1312
|
abs() {
|
|
1289
|
-
return
|
|
1313
|
+
return Fraction.fromReduced(this.numerator < 0n ? -this.numerator : this.numerator, this.denominator);
|
|
1290
1314
|
}
|
|
1291
1315
|
inverse() {
|
|
1292
1316
|
if (this.numerator === 0n) throw new Error("Cannot invert zero");
|
|
1293
|
-
return
|
|
1317
|
+
return this.numerator < 0n ? Fraction.fromReduced(-this.denominator, -this.numerator) : Fraction.fromReduced(this.denominator, this.numerator);
|
|
1294
1318
|
}
|
|
1295
1319
|
pow(n) {
|
|
1320
|
+
if (typeof n === "number" && !Number.isInteger(n)) throw new TypeError(`Fraction.pow: exponent must be an integer (got ${n})`);
|
|
1296
1321
|
const exp = typeof n === "bigint" ? n : BigInt(n);
|
|
1297
|
-
if (exp === 0n) return
|
|
1322
|
+
if (exp === 0n) return Fraction.fromReduced(1n, 1n);
|
|
1298
1323
|
if (exp < 0n) return this.inverse().pow(-exp);
|
|
1299
|
-
|
|
1300
|
-
let base = this.clone();
|
|
1301
|
-
let e = exp;
|
|
1302
|
-
while (e > 0n) {
|
|
1303
|
-
if (e % 2n === 1n) result = result.multiply(base);
|
|
1304
|
-
base = base.multiply(base);
|
|
1305
|
-
e = e / 2n;
|
|
1306
|
-
}
|
|
1307
|
-
return result;
|
|
1324
|
+
return Fraction.fromReduced(this.numerator ** exp, this.denominator ** exp);
|
|
1308
1325
|
}
|
|
1309
1326
|
mod(other) {
|
|
1310
1327
|
const floorQuot = this.divide(other).floor();
|
|
@@ -2329,6 +2346,11 @@ var DimensionMismatchError = class extends Error {
|
|
|
2329
2346
|
}
|
|
2330
2347
|
};
|
|
2331
2348
|
//#endregion
|
|
2349
|
+
//#region src/types/unit/va-var.ts
|
|
2350
|
+
function isEffectivelyImaginary(re, im) {
|
|
2351
|
+
return Math.abs(re) <= 1e-14 * Math.abs(im);
|
|
2352
|
+
}
|
|
2353
|
+
//#endregion
|
|
2332
2354
|
//#region src/types/unit/exact-scale.ts
|
|
2333
2355
|
const NAMED_IRRATIONALS = Object.freeze({
|
|
2334
2356
|
pi: "3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647",
|
|
@@ -4597,7 +4619,7 @@ const createUnitClass = /* #__PURE__ */ factory("Unit", [
|
|
|
4597
4619
|
return null;
|
|
4598
4620
|
}, {
|
|
4599
4621
|
hasher: (args) => args[0],
|
|
4600
|
-
limit:
|
|
4622
|
+
limit: 1e3
|
|
4601
4623
|
});
|
|
4602
4624
|
Unit.isValuelessUnit = function(name) {
|
|
4603
4625
|
return _findUnit(name) !== null;
|
|
@@ -5008,7 +5030,7 @@ const createUnitClass = /* #__PURE__ */ factory("Unit", [
|
|
|
5008
5030
|
}
|
|
5009
5031
|
function handleVAandVARUnits(simp) {
|
|
5010
5032
|
let isImaginary = false;
|
|
5011
|
-
if (typeof simp.value !== "undefined" && simp.value !== null && isComplex(simp.value)) isImaginary =
|
|
5033
|
+
if (typeof simp.value !== "undefined" && simp.value !== null && isComplex(simp.value)) isImaginary = isEffectivelyImaginary(simp.value.re, simp.value.im);
|
|
5012
5034
|
for (const i in simp.units) if (hasOwnProperty(simp.units, i)) {
|
|
5013
5035
|
const comp = simp.units[i];
|
|
5014
5036
|
if (comp.unit) {
|
|
@@ -5765,12 +5787,33 @@ const createUnitClass = /* #__PURE__ */ factory("Unit", [
|
|
|
5765
5787
|
const aliases = obj[key].aliases;
|
|
5766
5788
|
if (aliases) for (let i = 0; i < aliases.length; i++) Unit.deleteUnit(aliases[i]);
|
|
5767
5789
|
}
|
|
5768
|
-
|
|
5790
|
+
const keys = [];
|
|
5769
5791
|
for (const key in obj) if (hasOwnProperty(obj, key)) {
|
|
5770
5792
|
if (isPollutingKey(key)) throw new TypeError(`unsafe unit name '${key}'`);
|
|
5771
|
-
|
|
5793
|
+
keys.push(key);
|
|
5794
|
+
}
|
|
5795
|
+
const created = /* @__PURE__ */ new Map();
|
|
5796
|
+
let pending = keys;
|
|
5797
|
+
while (pending.length > 0) {
|
|
5798
|
+
const stillPending = [];
|
|
5799
|
+
let lastNotFound;
|
|
5800
|
+
for (const key of pending) try {
|
|
5801
|
+
created.set(key, Unit.createUnitSingle(key, obj[key]));
|
|
5802
|
+
} catch (ex) {
|
|
5803
|
+
if (ex instanceof UnitParseError && /not found\./.test(ex.message)) {
|
|
5804
|
+
stillPending.push(key);
|
|
5805
|
+
lastNotFound = ex;
|
|
5806
|
+
} else throw ex;
|
|
5807
|
+
}
|
|
5808
|
+
if (stillPending.length === pending.length) {
|
|
5809
|
+
if (stillPending.length === 1) throw lastNotFound;
|
|
5810
|
+
const err = /* @__PURE__ */ new Error(`Cannot create unit${stillPending.length > 1 ? "s" : ""} ` + stillPending.map((k) => `"${k}"`).join(", ") + ": " + lastNotFound.message);
|
|
5811
|
+
err.cause = lastNotFound;
|
|
5812
|
+
throw err;
|
|
5813
|
+
}
|
|
5814
|
+
pending = stillPending;
|
|
5772
5815
|
}
|
|
5773
|
-
return
|
|
5816
|
+
return keys.length > 0 ? created.get(keys[keys.length - 1]) : void 0;
|
|
5774
5817
|
};
|
|
5775
5818
|
Unit.createUnitSingle = function(name, obj) {
|
|
5776
5819
|
if (typeof obj === "undefined" || obj === null) obj = {};
|