@danielsimonjr/mathts-functions 0.42.0 → 0.43.0
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/error/DimensionError.d.ts +11 -12
- package/dist/error/DimensionError.d.ts.map +1 -1
- package/dist/error/IndexError.d.ts +13 -19
- package/dist/error/IndexError.d.ts.map +1 -1
- package/dist/factories/index.d.ts.map +1 -1
- package/dist/factories/matrix-bridge.d.ts +1 -1
- package/dist/factories/scope.d.ts +1 -1
- package/dist/index.js +400 -1341
- package/dist/typed/arithmetic.d.ts.map +1 -1
- package/dist/typed/bitwise.d.ts +1 -1
- package/dist/typed/probability.d.ts +2 -2
- package/dist/typed/relational.d.ts +3 -3
- package/dist/typed/string.d.ts +3 -3
- package/dist/typed/typed-bridge.d.ts +1 -1
- package/dist/utils/array.d.ts +20 -237
- package/dist/utils/array.d.ts.map +1 -1
- package/dist/utils/collection.d.ts +12 -64
- package/dist/utils/collection.d.ts.map +1 -1
- package/dist/utils/factory.d.ts +42 -53
- package/dist/utils/factory.d.ts.map +1 -1
- package/dist/utils/map.d.ts +30 -103
- package/dist/utils/map.d.ts.map +1 -1
- package/dist/utils/string.d.ts +15 -59
- package/dist/utils/string.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/error/MathjsError.d.ts +0 -13
- package/dist/error/MathjsError.d.ts.map +0 -1
- package/dist/utils/bignumber/formatter.d.ts +0 -136
- package/dist/utils/bignumber/formatter.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -189,7 +189,7 @@ __export(typed_exports, {
|
|
|
189
189
|
findRoot: () => findRoot,
|
|
190
190
|
fix: () => fix,
|
|
191
191
|
floor: () => floor,
|
|
192
|
-
format: () =>
|
|
192
|
+
format: () => format2,
|
|
193
193
|
fourier: () => fourier,
|
|
194
194
|
fresnelC: () => fresnelC,
|
|
195
195
|
fresnelS: () => fresnelS,
|
|
@@ -517,6 +517,12 @@ import {
|
|
|
517
517
|
pairwiseDot,
|
|
518
518
|
sumSquaredDeviations
|
|
519
519
|
} from "@danielsimonjr/mathts-core";
|
|
520
|
+
import {
|
|
521
|
+
pow as corePow,
|
|
522
|
+
round as coreRound,
|
|
523
|
+
fix as coreFix,
|
|
524
|
+
equal as coreEqual
|
|
525
|
+
} from "@danielsimonjr/mathts-core";
|
|
520
526
|
import { DenseMatrix as DenseMatrix2, backendManager as backendManager2, singularValues } from "@danielsimonjr/mathts-matrix";
|
|
521
527
|
|
|
522
528
|
// src/factories/matrix-bridge.ts
|
|
@@ -837,7 +843,7 @@ var MathJSDenseMatrix = class _MathJSDenseMatrix {
|
|
|
837
843
|
}
|
|
838
844
|
// ---------------------------------------------------------------------------
|
|
839
845
|
// Accelerated operations — routed through the native matrix BackendManager
|
|
840
|
-
// (JS / WASM / GPU selected by size). Additive: the
|
|
846
|
+
// (JS / WASM / GPU selected by size). Additive: the activated factory
|
|
841
847
|
// `multiply`/`transpose` functions are unaffected.
|
|
842
848
|
// ---------------------------------------------------------------------------
|
|
843
849
|
/**
|
|
@@ -1655,13 +1661,19 @@ var sign = mathTyped2("sign", {
|
|
|
1655
1661
|
}
|
|
1656
1662
|
});
|
|
1657
1663
|
var pow = mathTyped2("pow", {
|
|
1664
|
+
// Hot cases stay inline.
|
|
1658
1665
|
"number, number": (a, b) => Math.pow(a, b),
|
|
1659
1666
|
"bigint, bigint": (a, b) => a ** b,
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1667
|
+
// Rich-type policy cases DELEGATE to core's scalar `pow`, which correctly guards
|
|
1668
|
+
// non-integer exponents of exact types (falling back to double-precision Math.pow,
|
|
1669
|
+
// returning a plain number). The old inline copies were buggy:
|
|
1670
|
+
// pow(BigNumber(2), 0.5) -> 1 (unguarded a.pow(0.5); core -> 1.4142…)
|
|
1671
|
+
// pow(Fraction(3), 2.9) -> 27 (silently floored via a.pow(Math.floor(b)); core -> 24.19…)
|
|
1672
|
+
"Complex, number": (a, b) => corePow(a, b),
|
|
1673
|
+
"Complex, Complex": (a, b) => corePow(a, b),
|
|
1674
|
+
"Fraction, number": (a, b) => corePow(a, b),
|
|
1675
|
+
"BigNumber, number": (a, b) => corePow(a, b),
|
|
1676
|
+
"BigNumber, BigNumber": (a, b) => corePow(a, b),
|
|
1665
1677
|
// Dual numbers (forward-mode AD): constant or variable exponent.
|
|
1666
1678
|
"Dual, number": (a, b) => a.powConst(b),
|
|
1667
1679
|
"Dual, Dual": (a, b) => a.pow(b),
|
|
@@ -1874,9 +1886,12 @@ var expm1 = mathTyped2("expm1", {
|
|
|
1874
1886
|
});
|
|
1875
1887
|
var round = mathTyped2("round", {
|
|
1876
1888
|
number: (a) => Math.round(a),
|
|
1877
|
-
|
|
1878
|
-
BigNumber
|
|
1879
|
-
|
|
1889
|
+
// Rich-type policy cases DELEGATE to core's scalar `round`, which uses `halfCeil`
|
|
1890
|
+
// for BigNumber so round(bignumber(-2.5)) = -2 (type-consistent with number/Fraction),
|
|
1891
|
+
// not the -3 the old inline `a.round()` (half-away-from-zero) produced.
|
|
1892
|
+
Fraction: (a) => coreRound(a),
|
|
1893
|
+
BigNumber: (a) => coreRound(a),
|
|
1894
|
+
Complex: (a) => coreRound(a),
|
|
1880
1895
|
"number, number": (a, decimals) => {
|
|
1881
1896
|
const factor2 = Math.pow(10, decimals);
|
|
1882
1897
|
return Math.round(a * factor2) / factor2;
|
|
@@ -1926,9 +1941,11 @@ var ceil = mathTyped2("ceil", {
|
|
|
1926
1941
|
});
|
|
1927
1942
|
var fix = mathTyped2("fix", {
|
|
1928
1943
|
number: (a) => Math.trunc(a),
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1944
|
+
// Rich-type policy cases DELEGATE to core's scalar `fix` (truncate toward zero:
|
|
1945
|
+
// floor for non-negative, ceil for negative). Removes the duplicated policy.
|
|
1946
|
+
Fraction: (a) => coreFix(a),
|
|
1947
|
+
BigNumber: (a) => coreFix(a),
|
|
1948
|
+
Complex: (a) => coreFix(a),
|
|
1932
1949
|
// Parallel array fix (truncate toward zero, matching the 'number' overload)
|
|
1933
1950
|
Float64Array: async (a) => {
|
|
1934
1951
|
if (computePool.shouldParallelize(a.length)) {
|
|
@@ -2141,11 +2158,17 @@ var tanh = mathTyped2("tanh", {
|
|
|
2141
2158
|
}
|
|
2142
2159
|
});
|
|
2143
2160
|
var equal = mathTyped2("equal", {
|
|
2144
|
-
|
|
2161
|
+
// number,number DELEGATES to core's TOLERANCE-based equality (relTol/absTol via
|
|
2162
|
+
// nearlyEqual) — mathjs parity. The old strict `a === b` made equal(0.1+0.2, 0.3)
|
|
2163
|
+
// return false; core (and mathjs) return true. Floats are almost never bit-equal
|
|
2164
|
+
// after arithmetic, so strict === is the wrong policy for a public math `equal`.
|
|
2165
|
+
"number, number": (a, b) => coreEqual(a, b),
|
|
2166
|
+
// bigint stays inline (core also compares bigints with ===; tolerance is meaningless).
|
|
2145
2167
|
"bigint, bigint": (a, b) => a === b,
|
|
2146
|
-
|
|
2147
|
-
"
|
|
2148
|
-
"
|
|
2168
|
+
// Rich-type cases delegate to core (exact equality for Fraction/BigNumber; Complex.equals).
|
|
2169
|
+
"Complex, Complex": (a, b) => coreEqual(a, b),
|
|
2170
|
+
"Fraction, Fraction": (a, b) => coreEqual(a, b),
|
|
2171
|
+
"BigNumber, BigNumber": (a, b) => coreEqual(a, b),
|
|
2149
2172
|
"Unit, Unit": (a, b) => unitSameDimension(a, b) && asUnit(a).value === asUnit(b).value
|
|
2150
2173
|
});
|
|
2151
2174
|
var smaller = mathTyped2("smaller", {
|
|
@@ -11604,19 +11627,6 @@ function isIndex(x) {
|
|
|
11604
11627
|
const obj = x;
|
|
11605
11628
|
return obj.constructor?.prototype?.isIndex === true;
|
|
11606
11629
|
}
|
|
11607
|
-
function isObject(x) {
|
|
11608
|
-
return !!(x && typeof x === "object" && x.constructor === Object && !isComplex(x) && !isFraction(x));
|
|
11609
|
-
}
|
|
11610
|
-
function isMap(object) {
|
|
11611
|
-
if (!object) {
|
|
11612
|
-
return false;
|
|
11613
|
-
}
|
|
11614
|
-
if (object instanceof Map) {
|
|
11615
|
-
return true;
|
|
11616
|
-
}
|
|
11617
|
-
const mapLike = object;
|
|
11618
|
-
return typeof mapLike.set === "function" && typeof mapLike.get === "function" && typeof mapLike.keys === "function" && typeof mapLike.has === "function";
|
|
11619
|
-
}
|
|
11620
11630
|
function isAccessorNode(x) {
|
|
11621
11631
|
if (!x || typeof x !== "object") return false;
|
|
11622
11632
|
const obj = x;
|
|
@@ -11703,24 +11713,15 @@ import {
|
|
|
11703
11713
|
traverse
|
|
11704
11714
|
} from "@danielsimonjr/mathts-core/internal";
|
|
11705
11715
|
|
|
11706
|
-
// src/error/MathjsError.ts
|
|
11707
|
-
var MathjsError = class _MathjsError extends Error {
|
|
11708
|
-
isMathjsError = true;
|
|
11709
|
-
/**
|
|
11710
|
-
* Create a MathjsError
|
|
11711
|
-
* @param message Error message
|
|
11712
|
-
*/
|
|
11713
|
-
constructor(message) {
|
|
11714
|
-
super(message);
|
|
11715
|
-
this.name = "MathjsError";
|
|
11716
|
-
const ErrorWithCapture = Error;
|
|
11717
|
-
if (ErrorWithCapture.captureStackTrace) {
|
|
11718
|
-
ErrorWithCapture.captureStackTrace(this, _MathjsError);
|
|
11719
|
-
}
|
|
11720
|
-
}
|
|
11721
|
-
};
|
|
11722
|
-
|
|
11723
11716
|
// src/utils/factory.ts
|
|
11717
|
+
import {
|
|
11718
|
+
isFactory,
|
|
11719
|
+
assertDependencies,
|
|
11720
|
+
isOptionalDependency,
|
|
11721
|
+
stripOptionalNotation,
|
|
11722
|
+
sortFactories as coreSortFactories,
|
|
11723
|
+
create as coreCreate
|
|
11724
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
11724
11725
|
function factory(name254, dependencies254, create, meta) {
|
|
11725
11726
|
function assertAndCreate(scope) {
|
|
11726
11727
|
const deps = pickShallow(scope, dependencies254.map(stripOptionalNotation));
|
|
@@ -11735,23 +11736,6 @@ function factory(name254, dependencies254, create, meta) {
|
|
|
11735
11736
|
}
|
|
11736
11737
|
return assertAndCreate;
|
|
11737
11738
|
}
|
|
11738
|
-
function assertDependencies(name254, dependencies254, scope) {
|
|
11739
|
-
const allDefined = dependencies254.filter((dependency) => !isOptionalDependency(dependency)).every((dependency) => scope[dependency] !== void 0);
|
|
11740
|
-
if (!allDefined) {
|
|
11741
|
-
const missingDependencies = dependencies254.filter(
|
|
11742
|
-
(dependency) => scope[dependency] === void 0
|
|
11743
|
-
);
|
|
11744
|
-
throw new MathjsError(
|
|
11745
|
-
`Cannot create function "${name254}", some dependencies are missing: ${missingDependencies.map((d) => `"${d}"`).join(", ")}.`
|
|
11746
|
-
);
|
|
11747
|
-
}
|
|
11748
|
-
}
|
|
11749
|
-
function isOptionalDependency(dependency) {
|
|
11750
|
-
return Boolean(dependency && dependency[0] === "?");
|
|
11751
|
-
}
|
|
11752
|
-
function stripOptionalNotation(dependency) {
|
|
11753
|
-
return dependency && dependency[0] === "?" ? dependency.slice(1) : dependency;
|
|
11754
|
-
}
|
|
11755
11739
|
|
|
11756
11740
|
// src/numeric/solveODE.ts
|
|
11757
11741
|
var WASM_ODE_THRESHOLD = 10;
|
|
@@ -12062,7 +12046,7 @@ var createSolveODE = /* @__PURE__ */ factory(
|
|
|
12062
12046
|
multiply: multiply2,
|
|
12063
12047
|
divide: divide2,
|
|
12064
12048
|
max: max2,
|
|
12065
|
-
map:
|
|
12049
|
+
map: map3,
|
|
12066
12050
|
abs: abs2,
|
|
12067
12051
|
isPositive: isPositive2,
|
|
12068
12052
|
isNegative: isNegative2,
|
|
@@ -12293,7 +12277,7 @@ var createSolveODE = /* @__PURE__ */ factory(
|
|
|
12293
12277
|
}
|
|
12294
12278
|
const errComb = stageCombo(deltaB, k);
|
|
12295
12279
|
const errArr = Array.isArray(errComb) ? errComb : [errComb];
|
|
12296
|
-
const TE = max2(abs2(
|
|
12280
|
+
const TE = max2(abs2(map3(errArr, (X) => isUnit(X) ? X.value : X)));
|
|
12297
12281
|
if (TE < tol && tol / TE > 1 / 4) {
|
|
12298
12282
|
t.push(add4(t[n], h));
|
|
12299
12283
|
y.push(add4(y[n], multiply2(h, stageCombo(b, k))));
|
|
@@ -18280,225 +18264,12 @@ var typedRelational = {
|
|
|
18280
18264
|
// src/typed/string.ts
|
|
18281
18265
|
import { mathTyped as mathTyped15, BigNumber as BigNumber7 } from "@danielsimonjr/mathts-core";
|
|
18282
18266
|
|
|
18283
|
-
// src/utils/bignumber/formatter.ts
|
|
18284
|
-
function formatBigNumberToBase(n, base, size2) {
|
|
18285
|
-
const BigNumberCtor = n.constructor;
|
|
18286
|
-
const big2 = new BigNumberCtor(2);
|
|
18287
|
-
let suffix = "";
|
|
18288
|
-
if (size2) {
|
|
18289
|
-
if (size2 < 1) {
|
|
18290
|
-
throw new Error("size must be in greater than 0");
|
|
18291
|
-
}
|
|
18292
|
-
if (!isInteger(size2)) {
|
|
18293
|
-
throw new Error("size must be an integer");
|
|
18294
|
-
}
|
|
18295
|
-
if (n.greaterThan(big2.pow(size2 - 1).sub(1)) || n.lessThan(big2.pow(size2 - 1).mul(-1))) {
|
|
18296
|
-
throw new Error(`Value must be in range [-2^${size2 - 1}, 2^${size2 - 1}-1]`);
|
|
18297
|
-
}
|
|
18298
|
-
if (!n.isInteger()) {
|
|
18299
|
-
throw new Error("Value must be an integer");
|
|
18300
|
-
}
|
|
18301
|
-
if (n.lessThan(0)) {
|
|
18302
|
-
n = n.add(big2.pow(size2));
|
|
18303
|
-
}
|
|
18304
|
-
suffix = `i${size2}`;
|
|
18305
|
-
}
|
|
18306
|
-
switch (base) {
|
|
18307
|
-
case 2:
|
|
18308
|
-
return `${n.toBinary()}${suffix}`;
|
|
18309
|
-
case 8:
|
|
18310
|
-
return `${n.toOctal()}${suffix}`;
|
|
18311
|
-
case 16:
|
|
18312
|
-
return `${n.toHexadecimal()}${suffix}`;
|
|
18313
|
-
default:
|
|
18314
|
-
throw new Error(`Base ${base} not supported `);
|
|
18315
|
-
}
|
|
18316
|
-
}
|
|
18317
|
-
function format2(value, options) {
|
|
18318
|
-
const v = value;
|
|
18319
|
-
if (typeof options === "function") {
|
|
18320
|
-
return options(value);
|
|
18321
|
-
}
|
|
18322
|
-
if (!v.isFinite()) {
|
|
18323
|
-
return v.isNaN() ? "NaN" : v.gt(0) ? "Infinity" : "-Infinity";
|
|
18324
|
-
}
|
|
18325
|
-
const { notation, precision, wordSize } = normalizeFormatOptions(
|
|
18326
|
-
options
|
|
18327
|
-
);
|
|
18328
|
-
switch (notation) {
|
|
18329
|
-
case "fixed":
|
|
18330
|
-
return toFixed2(v, precision);
|
|
18331
|
-
case "exponential":
|
|
18332
|
-
return toExponential2(v, precision);
|
|
18333
|
-
case "engineering":
|
|
18334
|
-
return toEngineering2(v, precision);
|
|
18335
|
-
case "bin":
|
|
18336
|
-
return formatBigNumberToBase(v, 2, wordSize);
|
|
18337
|
-
case "oct":
|
|
18338
|
-
return formatBigNumberToBase(v, 8, wordSize);
|
|
18339
|
-
case "hex":
|
|
18340
|
-
return formatBigNumberToBase(v, 16, wordSize);
|
|
18341
|
-
case "auto": {
|
|
18342
|
-
const optionsObj = options;
|
|
18343
|
-
const lowerExp = _toNumberOrDefault(optionsObj?.lowerExp, -3);
|
|
18344
|
-
const upperExp = _toNumberOrDefault(optionsObj?.upperExp, 5);
|
|
18345
|
-
if (v.isZero()) return "0";
|
|
18346
|
-
let str;
|
|
18347
|
-
const rounded = v.toSignificantDigits(precision);
|
|
18348
|
-
const exp2 = rounded.e;
|
|
18349
|
-
if (exp2 >= lowerExp && exp2 < upperExp) {
|
|
18350
|
-
str = rounded.toFixed();
|
|
18351
|
-
} else {
|
|
18352
|
-
str = toExponential2(v, precision);
|
|
18353
|
-
}
|
|
18354
|
-
return str.replace(
|
|
18355
|
-
/((\.\d*?)(0+))($|e)/,
|
|
18356
|
-
function(_match, _g1, digits2, _g3, e) {
|
|
18357
|
-
return digits2 !== "." ? digits2 + e : e;
|
|
18358
|
-
}
|
|
18359
|
-
);
|
|
18360
|
-
}
|
|
18361
|
-
default:
|
|
18362
|
-
throw new Error(
|
|
18363
|
-
'Unknown notation "' + notation + '". Choose "auto", "exponential", "fixed", "bin", "oct", or "hex.'
|
|
18364
|
-
);
|
|
18365
|
-
}
|
|
18366
|
-
}
|
|
18367
|
-
function toEngineering2(value, precision) {
|
|
18368
|
-
const e = value.e;
|
|
18369
|
-
const newExp = e % 3 === 0 ? e : e < 0 ? e - 3 - e % 3 : e - e % 3;
|
|
18370
|
-
const valueWithoutExp = value.mul(Math.pow(10, -newExp));
|
|
18371
|
-
let valueStr = valueWithoutExp.toPrecision(precision);
|
|
18372
|
-
if (valueStr.includes("e")) {
|
|
18373
|
-
const BigNumberCtor = value.constructor;
|
|
18374
|
-
valueStr = new BigNumberCtor(valueStr).toFixed();
|
|
18375
|
-
}
|
|
18376
|
-
return valueStr + "e" + (e >= 0 ? "+" : "") + newExp.toString();
|
|
18377
|
-
}
|
|
18378
|
-
function toExponential2(value, precision) {
|
|
18379
|
-
if (precision !== void 0) {
|
|
18380
|
-
return value.toExponential(precision - 1);
|
|
18381
|
-
} else {
|
|
18382
|
-
return value.toExponential();
|
|
18383
|
-
}
|
|
18384
|
-
}
|
|
18385
|
-
function toFixed2(value, precision) {
|
|
18386
|
-
return value.toFixed(precision);
|
|
18387
|
-
}
|
|
18388
|
-
function _toNumberOrDefault(value, defaultValue) {
|
|
18389
|
-
if (isNumber(value)) {
|
|
18390
|
-
return value;
|
|
18391
|
-
} else if (isBigNumber(value)) {
|
|
18392
|
-
return value.toNumber();
|
|
18393
|
-
} else {
|
|
18394
|
-
return defaultValue;
|
|
18395
|
-
}
|
|
18396
|
-
}
|
|
18397
|
-
|
|
18398
18267
|
// src/utils/string.ts
|
|
18399
|
-
|
|
18400
|
-
|
|
18401
|
-
|
|
18402
|
-
|
|
18403
|
-
|
|
18404
|
-
return result.substring(0, truncate - 3) + "...";
|
|
18405
|
-
}
|
|
18406
|
-
}
|
|
18407
|
-
return result;
|
|
18408
|
-
}
|
|
18409
|
-
function _format(value, options) {
|
|
18410
|
-
if (typeof value === "number") {
|
|
18411
|
-
return format(value, options);
|
|
18412
|
-
}
|
|
18413
|
-
if (isBigNumber(value)) {
|
|
18414
|
-
return format2(value, options);
|
|
18415
|
-
}
|
|
18416
|
-
if (looksLikeFraction(value)) {
|
|
18417
|
-
if (!options || options.fraction !== "decimal") {
|
|
18418
|
-
const signedNumerator = typeof value.n === "bigint" ? BigInt(value.s) * value.n : value.s * value.n;
|
|
18419
|
-
return `${signedNumerator}/${value.d}`;
|
|
18420
|
-
} else {
|
|
18421
|
-
return value.toString();
|
|
18422
|
-
}
|
|
18423
|
-
}
|
|
18424
|
-
if (Array.isArray(value)) {
|
|
18425
|
-
return formatArray(value, options);
|
|
18426
|
-
}
|
|
18427
|
-
if (isString(value)) {
|
|
18428
|
-
return stringify(value);
|
|
18429
|
-
}
|
|
18430
|
-
if (typeof value === "function") {
|
|
18431
|
-
const syntax = value.syntax;
|
|
18432
|
-
return syntax ? String(syntax) : "function";
|
|
18433
|
-
}
|
|
18434
|
-
if (value && typeof value === "object") {
|
|
18435
|
-
const obj = value;
|
|
18436
|
-
if (typeof obj.format === "function") {
|
|
18437
|
-
return obj.format(options);
|
|
18438
|
-
} else if (obj.toString(options) !== {}.toString()) {
|
|
18439
|
-
return obj.toString(options);
|
|
18440
|
-
} else {
|
|
18441
|
-
const entries = Object.keys(obj).map((key) => {
|
|
18442
|
-
return stringify(key) + ": " + format3(obj[key], options);
|
|
18443
|
-
});
|
|
18444
|
-
return "{" + entries.join(", ") + "}";
|
|
18445
|
-
}
|
|
18446
|
-
}
|
|
18447
|
-
return String(value);
|
|
18448
|
-
}
|
|
18449
|
-
function stringify(value) {
|
|
18450
|
-
const text = String(value);
|
|
18451
|
-
let escaped = "";
|
|
18452
|
-
let i = 0;
|
|
18453
|
-
while (i < text.length) {
|
|
18454
|
-
const c = text.charAt(i);
|
|
18455
|
-
escaped += c in controlCharacters ? controlCharacters[c] : c;
|
|
18456
|
-
i++;
|
|
18457
|
-
}
|
|
18458
|
-
return '"' + escaped + '"';
|
|
18459
|
-
}
|
|
18460
|
-
var controlCharacters = {
|
|
18461
|
-
'"': '\\"',
|
|
18462
|
-
"\\": "\\\\",
|
|
18463
|
-
"\b": "\\b",
|
|
18464
|
-
"\f": "\\f",
|
|
18465
|
-
"\n": "\\n",
|
|
18466
|
-
"\r": "\\r",
|
|
18467
|
-
" ": "\\t"
|
|
18468
|
-
};
|
|
18469
|
-
function formatArray(array, options) {
|
|
18470
|
-
if (Array.isArray(array)) {
|
|
18471
|
-
let str = "[";
|
|
18472
|
-
const len = array.length;
|
|
18473
|
-
for (let i = 0; i < len; i++) {
|
|
18474
|
-
if (i !== 0) {
|
|
18475
|
-
str += ", ";
|
|
18476
|
-
}
|
|
18477
|
-
str += formatArray(array[i], options);
|
|
18478
|
-
}
|
|
18479
|
-
str += "]";
|
|
18480
|
-
return str;
|
|
18481
|
-
} else {
|
|
18482
|
-
return format3(array, options);
|
|
18483
|
-
}
|
|
18484
|
-
}
|
|
18485
|
-
function looksLikeFraction(value) {
|
|
18486
|
-
const frac = value;
|
|
18487
|
-
return !!frac && typeof frac === "object" && typeof frac.s === "bigint" && typeof frac.n === "bigint" && typeof frac.d === "bigint" || false;
|
|
18488
|
-
}
|
|
18489
|
-
function compareText2(x, y) {
|
|
18490
|
-
if (!isString(x)) {
|
|
18491
|
-
throw new TypeError(
|
|
18492
|
-
"Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: " + typeOf(x) + ", index: 0)"
|
|
18493
|
-
);
|
|
18494
|
-
}
|
|
18495
|
-
if (!isString(y)) {
|
|
18496
|
-
throw new TypeError(
|
|
18497
|
-
"Unexpected type of argument in function compareText (expected: string or Array or Matrix, actual: " + typeOf(y) + ", index: 1)"
|
|
18498
|
-
);
|
|
18499
|
-
}
|
|
18500
|
-
return x === y ? 0 : x > y ? 1 : -1;
|
|
18501
|
-
}
|
|
18268
|
+
import {
|
|
18269
|
+
formatGeneric,
|
|
18270
|
+
stringify,
|
|
18271
|
+
compareText as compareText2
|
|
18272
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
18502
18273
|
|
|
18503
18274
|
// src/utils/print.ts
|
|
18504
18275
|
var printTemplate = /\$([\w.]+)/g;
|
|
@@ -18546,7 +18317,7 @@ function interpolate2(template, values, options) {
|
|
|
18546
18317
|
}
|
|
18547
18318
|
if (value !== void 0) {
|
|
18548
18319
|
if (!isString(value)) {
|
|
18549
|
-
return
|
|
18320
|
+
return formatGeneric(value, options);
|
|
18550
18321
|
} else {
|
|
18551
18322
|
return value;
|
|
18552
18323
|
}
|
|
@@ -18572,7 +18343,7 @@ var oct = mathTyped15("oct", {
|
|
|
18572
18343
|
BigNumber: (x) => bigNumberToBase(x, 8),
|
|
18573
18344
|
"BigNumber, number": (x, wordSize) => bigNumberToBase(x, 8, wordSize)
|
|
18574
18345
|
});
|
|
18575
|
-
var
|
|
18346
|
+
var format2 = mathTyped15("format", {
|
|
18576
18347
|
// Single-arg: format with defaults. For BigNumber, utils/string isBigNumber check
|
|
18577
18348
|
// may fail (core BigNumber uses .isBigNumber property but not on prototype), so
|
|
18578
18349
|
// we intercept BigNumber explicitly before delegating to formatValue.
|
|
@@ -18583,7 +18354,7 @@ var format4 = mathTyped15("format", {
|
|
|
18583
18354
|
if (!bn.isFinite()) return bn.isNegative() ? "-Infinity" : "Infinity";
|
|
18584
18355
|
return bn.toString();
|
|
18585
18356
|
}
|
|
18586
|
-
return
|
|
18357
|
+
return formatGeneric(x, void 0);
|
|
18587
18358
|
},
|
|
18588
18359
|
// Two-arg: format with options/precision. For BigNumber+number we use toPrecision
|
|
18589
18360
|
// directly; for everything else we delegate to formatValue.
|
|
@@ -18595,9 +18366,9 @@ var format4 = mathTyped15("format", {
|
|
|
18595
18366
|
if (typeof options === "number") {
|
|
18596
18367
|
return bn.toPrecision(options);
|
|
18597
18368
|
}
|
|
18598
|
-
return
|
|
18369
|
+
return formatGeneric(x, options);
|
|
18599
18370
|
}
|
|
18600
|
-
return
|
|
18371
|
+
return formatGeneric(x, options);
|
|
18601
18372
|
}
|
|
18602
18373
|
});
|
|
18603
18374
|
var print = mathTyped15("print", {
|
|
@@ -18608,7 +18379,7 @@ var typedString = {
|
|
|
18608
18379
|
bin,
|
|
18609
18380
|
hex,
|
|
18610
18381
|
oct,
|
|
18611
|
-
format:
|
|
18382
|
+
format: format2,
|
|
18612
18383
|
print
|
|
18613
18384
|
};
|
|
18614
18385
|
|
|
@@ -19072,7 +18843,7 @@ __export(factories_exports, {
|
|
|
19072
18843
|
catalan: () => catalan,
|
|
19073
18844
|
chain: () => chain,
|
|
19074
18845
|
classicalElectronRadius: () => classicalElectronRadius,
|
|
19075
|
-
clone: () =>
|
|
18846
|
+
clone: () => clone2,
|
|
19076
18847
|
column: () => column,
|
|
19077
18848
|
complex: () => complex,
|
|
19078
18849
|
composition: () => composition,
|
|
@@ -19184,7 +18955,7 @@ __export(factories_exports, {
|
|
|
19184
18955
|
fineStructure: () => fineStructure,
|
|
19185
18956
|
firstRadiation: () => firstRadiation,
|
|
19186
18957
|
flatten: () => flatten3,
|
|
19187
|
-
forEach: () =>
|
|
18958
|
+
forEach: () => forEach2,
|
|
19188
18959
|
fraction: () => fraction,
|
|
19189
18960
|
freqz: () => freqz,
|
|
19190
18961
|
gamma: () => gamma,
|
|
@@ -19225,7 +18996,7 @@ __export(factories_exports, {
|
|
|
19225
18996
|
mad: () => mad,
|
|
19226
18997
|
magneticConstant: () => magneticConstant,
|
|
19227
18998
|
magneticFluxQuantum: () => magneticFluxQuantum,
|
|
19228
|
-
map: () =>
|
|
18999
|
+
map: () => map2,
|
|
19229
19000
|
mapSlices: () => mapSlices,
|
|
19230
19001
|
matrix: () => matrix,
|
|
19231
19002
|
matrixFromColumns: () => matrixFromColumns,
|
|
@@ -19309,706 +19080,14 @@ __export(factories_exports, {
|
|
|
19309
19080
|
zpk2tf: () => zpk2tf
|
|
19310
19081
|
});
|
|
19311
19082
|
|
|
19312
|
-
// src/error/IndexError.ts
|
|
19313
|
-
var IndexError = class _IndexError extends RangeError {
|
|
19314
|
-
index;
|
|
19315
|
-
min;
|
|
19316
|
-
max;
|
|
19317
|
-
isIndexError = true;
|
|
19318
|
-
/**
|
|
19319
|
-
* Create an IndexError
|
|
19320
|
-
*
|
|
19321
|
-
* Can be called in two ways:
|
|
19322
|
-
* - IndexError(index, max) - assumes min=0
|
|
19323
|
-
* - IndexError(index, min, max)
|
|
19324
|
-
*
|
|
19325
|
-
* @param index The actual index
|
|
19326
|
-
* @param min Minimum index (included), or max if only 2 args provided
|
|
19327
|
-
* @param max Maximum index (excluded)
|
|
19328
|
-
*/
|
|
19329
|
-
constructor(index, min2, max2) {
|
|
19330
|
-
let actualMin;
|
|
19331
|
-
let actualMax;
|
|
19332
|
-
if (max2 === void 0) {
|
|
19333
|
-
actualMin = 0;
|
|
19334
|
-
actualMax = min2;
|
|
19335
|
-
} else {
|
|
19336
|
-
actualMin = min2;
|
|
19337
|
-
actualMax = max2;
|
|
19338
|
-
}
|
|
19339
|
-
let message;
|
|
19340
|
-
if (actualMin !== void 0 && index < actualMin) {
|
|
19341
|
-
message = "Index out of range (" + index + " < " + actualMin + ")";
|
|
19342
|
-
} else if (actualMax !== void 0 && index >= actualMax) {
|
|
19343
|
-
message = "Index out of range (" + index + " > " + (actualMax - 1) + ")";
|
|
19344
|
-
} else {
|
|
19345
|
-
message = "Index out of range (" + index + ")";
|
|
19346
|
-
}
|
|
19347
|
-
super(message);
|
|
19348
|
-
this.index = index;
|
|
19349
|
-
this.min = actualMin;
|
|
19350
|
-
this.max = actualMax;
|
|
19351
|
-
this.name = "IndexError";
|
|
19352
|
-
const ErrorWithCapture = Error;
|
|
19353
|
-
if (ErrorWithCapture.captureStackTrace) {
|
|
19354
|
-
ErrorWithCapture.captureStackTrace(this, _IndexError);
|
|
19355
|
-
}
|
|
19356
|
-
}
|
|
19357
|
-
};
|
|
19358
|
-
|
|
19359
|
-
// src/error/DimensionError.ts
|
|
19360
|
-
var DimensionError = class _DimensionError extends RangeError {
|
|
19361
|
-
actual;
|
|
19362
|
-
expected;
|
|
19363
|
-
relation;
|
|
19364
|
-
isDimensionError = true;
|
|
19365
|
-
/**
|
|
19366
|
-
* @param actual - The actual size or custom error message
|
|
19367
|
-
* @param expected - The expected size (optional if actual is a custom message)
|
|
19368
|
-
* @param relation - Optional relation between actual and expected size: '!=', '<', etc.
|
|
19369
|
-
*/
|
|
19370
|
-
constructor(actual, expected, relation) {
|
|
19371
|
-
let message;
|
|
19372
|
-
if (typeof actual === "string" && expected === void 0) {
|
|
19373
|
-
message = actual;
|
|
19374
|
-
} else {
|
|
19375
|
-
message = "Dimension mismatch (" + (Array.isArray(actual) ? "[" + actual.join(", ") + "]" : actual) + " " + (relation || "!=") + " " + (Array.isArray(expected) ? "[" + expected.join(", ") + "]" : expected) + ")";
|
|
19376
|
-
}
|
|
19377
|
-
super(message);
|
|
19378
|
-
this.name = "DimensionError";
|
|
19379
|
-
if (typeof actual === "string" && expected === void 0) {
|
|
19380
|
-
this.actual = void 0;
|
|
19381
|
-
this.expected = void 0;
|
|
19382
|
-
this.relation = void 0;
|
|
19383
|
-
} else {
|
|
19384
|
-
this.actual = actual;
|
|
19385
|
-
this.expected = expected;
|
|
19386
|
-
this.relation = relation;
|
|
19387
|
-
}
|
|
19388
|
-
const ErrorWithCapture = Error;
|
|
19389
|
-
if (ErrorWithCapture.captureStackTrace) {
|
|
19390
|
-
ErrorWithCapture.captureStackTrace(this, _DimensionError);
|
|
19391
|
-
}
|
|
19392
|
-
}
|
|
19393
|
-
};
|
|
19394
|
-
|
|
19395
|
-
// src/utils/array.ts
|
|
19396
|
-
function arraySize(x) {
|
|
19397
|
-
const s = [];
|
|
19398
|
-
let current = x;
|
|
19399
|
-
while (Array.isArray(current)) {
|
|
19400
|
-
s.push(current.length);
|
|
19401
|
-
current = current[0];
|
|
19402
|
-
}
|
|
19403
|
-
return s;
|
|
19404
|
-
}
|
|
19405
|
-
function validateIndexSourceSize(value, index) {
|
|
19406
|
-
const valueSize = value.isMatrix ? value._size : arraySize(value);
|
|
19407
|
-
const sourceSize = index._sourceSize;
|
|
19408
|
-
sourceSize.forEach((sourceDim, i) => {
|
|
19409
|
-
if (sourceDim !== null && sourceDim !== valueSize[i]) {
|
|
19410
|
-
throw new DimensionError(sourceDim, valueSize[i]);
|
|
19411
|
-
}
|
|
19412
|
-
});
|
|
19413
|
-
}
|
|
19414
|
-
function validateIndex(index, length) {
|
|
19415
|
-
if (index !== void 0) {
|
|
19416
|
-
if (!isNumber(index) || !isInteger(index)) {
|
|
19417
|
-
throw new TypeError("Index must be an integer (value: " + index + ")");
|
|
19418
|
-
}
|
|
19419
|
-
if (index < 0 || typeof length === "number" && index >= length) {
|
|
19420
|
-
throw new IndexError(index, length);
|
|
19421
|
-
}
|
|
19422
|
-
}
|
|
19423
|
-
}
|
|
19424
|
-
function isEmptyIndex(index) {
|
|
19425
|
-
for (let i = 0; i < index._dimensions.length; ++i) {
|
|
19426
|
-
const dimension = index._dimensions[i];
|
|
19427
|
-
if (isString(dimension)) {
|
|
19428
|
-
if (dimension.length === 0) {
|
|
19429
|
-
return true;
|
|
19430
|
-
}
|
|
19431
|
-
} else {
|
|
19432
|
-
const dim = dimension;
|
|
19433
|
-
if (dim._data && isArray(dim._data)) {
|
|
19434
|
-
if (dim._size[0] === 0) {
|
|
19435
|
-
return true;
|
|
19436
|
-
}
|
|
19437
|
-
} else if (dim.isRange) {
|
|
19438
|
-
if (dim.start === dim.end) {
|
|
19439
|
-
return true;
|
|
19440
|
-
}
|
|
19441
|
-
}
|
|
19442
|
-
}
|
|
19443
|
-
}
|
|
19444
|
-
return false;
|
|
19445
|
-
}
|
|
19446
|
-
function resize(array, size2, defaultValue) {
|
|
19447
|
-
if (!Array.isArray(size2)) {
|
|
19448
|
-
throw new TypeError("Array expected");
|
|
19449
|
-
}
|
|
19450
|
-
if (size2.length === 0) {
|
|
19451
|
-
throw new Error("Resizing to scalar is not supported");
|
|
19452
|
-
}
|
|
19453
|
-
size2.forEach(function(value) {
|
|
19454
|
-
if (!isNumber(value) || !isInteger(value) || value < 0) {
|
|
19455
|
-
throw new TypeError(
|
|
19456
|
-
"Invalid size, must contain positive integers (size: " + format3(size2, {}) + ")"
|
|
19457
|
-
);
|
|
19458
|
-
}
|
|
19459
|
-
});
|
|
19460
|
-
let arr10 = array;
|
|
19461
|
-
if (isNumber(array) || isBigNumber(array)) {
|
|
19462
|
-
arr10 = [array];
|
|
19463
|
-
}
|
|
19464
|
-
const _defaultValue = defaultValue !== void 0 ? defaultValue : 0;
|
|
19465
|
-
_resize(arr10, size2, 0, _defaultValue);
|
|
19466
|
-
return arr10;
|
|
19467
|
-
}
|
|
19468
|
-
function _resize(array, size2, dim, defaultValue) {
|
|
19469
|
-
let i;
|
|
19470
|
-
let elem;
|
|
19471
|
-
const oldLen = array.length;
|
|
19472
|
-
const newLen = size2[dim];
|
|
19473
|
-
const minLen = Math.min(oldLen, newLen);
|
|
19474
|
-
array.length = newLen;
|
|
19475
|
-
if (dim < size2.length - 1) {
|
|
19476
|
-
const dimNext = dim + 1;
|
|
19477
|
-
for (i = 0; i < minLen; i++) {
|
|
19478
|
-
let current = array[i];
|
|
19479
|
-
if (!Array.isArray(current)) {
|
|
19480
|
-
current = [current];
|
|
19481
|
-
array[i] = current;
|
|
19482
|
-
}
|
|
19483
|
-
_resize(current, size2, dimNext, defaultValue);
|
|
19484
|
-
}
|
|
19485
|
-
for (i = minLen; i < newLen; i++) {
|
|
19486
|
-
elem = [];
|
|
19487
|
-
array[i] = elem;
|
|
19488
|
-
_resize(elem, size2, dimNext, defaultValue);
|
|
19489
|
-
}
|
|
19490
|
-
} else {
|
|
19491
|
-
for (i = 0; i < minLen; i++) {
|
|
19492
|
-
let value = array[i];
|
|
19493
|
-
while (Array.isArray(value)) {
|
|
19494
|
-
value = value[0];
|
|
19495
|
-
}
|
|
19496
|
-
array[i] = value;
|
|
19497
|
-
}
|
|
19498
|
-
for (i = minLen; i < newLen; i++) {
|
|
19499
|
-
array[i] = defaultValue;
|
|
19500
|
-
}
|
|
19501
|
-
}
|
|
19502
|
-
}
|
|
19503
|
-
function reshape(array, sizes) {
|
|
19504
|
-
const flatArray = flatten2(array, true);
|
|
19505
|
-
const currentLength = flatArray.length;
|
|
19506
|
-
if (!Array.isArray(array) || !Array.isArray(sizes)) {
|
|
19507
|
-
throw new TypeError("Array expected");
|
|
19508
|
-
}
|
|
19509
|
-
if (sizes.length === 0) {
|
|
19510
|
-
throw new DimensionError(0, currentLength, "!=");
|
|
19511
|
-
}
|
|
19512
|
-
const processedSizes = processSizesWildcard(sizes, currentLength);
|
|
19513
|
-
const newLength = product2(processedSizes);
|
|
19514
|
-
if (currentLength !== newLength) {
|
|
19515
|
-
throw new DimensionError(newLength, currentLength, "!=");
|
|
19516
|
-
}
|
|
19517
|
-
try {
|
|
19518
|
-
return _reshape(flatArray, processedSizes);
|
|
19519
|
-
} catch (e) {
|
|
19520
|
-
if (e instanceof DimensionError) {
|
|
19521
|
-
throw new DimensionError(newLength, currentLength, "!=");
|
|
19522
|
-
}
|
|
19523
|
-
throw e;
|
|
19524
|
-
}
|
|
19525
|
-
}
|
|
19526
|
-
function processSizesWildcard(sizes, currentLength) {
|
|
19527
|
-
const newLength = product2(sizes);
|
|
19528
|
-
const processedSizes = sizes.slice();
|
|
19529
|
-
const WILDCARD = -1;
|
|
19530
|
-
const wildCardIndex = sizes.indexOf(WILDCARD);
|
|
19531
|
-
const isMoreThanOneWildcard = sizes.indexOf(WILDCARD, wildCardIndex + 1) >= 0;
|
|
19532
|
-
if (isMoreThanOneWildcard) {
|
|
19533
|
-
throw new Error("More than one wildcard in sizes");
|
|
19534
|
-
}
|
|
19535
|
-
const hasWildcard = wildCardIndex >= 0;
|
|
19536
|
-
const canReplaceWildcard = currentLength % newLength === 0;
|
|
19537
|
-
if (hasWildcard) {
|
|
19538
|
-
if (canReplaceWildcard) {
|
|
19539
|
-
processedSizes[wildCardIndex] = -currentLength / newLength;
|
|
19540
|
-
} else {
|
|
19541
|
-
throw new Error(
|
|
19542
|
-
"Could not replace wildcard, since " + currentLength + " is no multiple of " + -newLength
|
|
19543
|
-
);
|
|
19544
|
-
}
|
|
19545
|
-
}
|
|
19546
|
-
return processedSizes;
|
|
19547
|
-
}
|
|
19548
|
-
function product2(array) {
|
|
19549
|
-
return array.reduce((prev, curr) => prev * curr, 1);
|
|
19550
|
-
}
|
|
19551
|
-
function _reshape(array, sizes) {
|
|
19552
|
-
let tmpArray = array;
|
|
19553
|
-
let tmpArray2;
|
|
19554
|
-
for (let sizeIndex = sizes.length - 1; sizeIndex > 0; sizeIndex--) {
|
|
19555
|
-
const size2 = sizes[sizeIndex];
|
|
19556
|
-
tmpArray2 = [];
|
|
19557
|
-
const length = tmpArray.length / size2;
|
|
19558
|
-
for (let i = 0; i < length; i++) {
|
|
19559
|
-
tmpArray2.push(tmpArray.slice(i * size2, (i + 1) * size2));
|
|
19560
|
-
}
|
|
19561
|
-
tmpArray = tmpArray2;
|
|
19562
|
-
}
|
|
19563
|
-
return tmpArray;
|
|
19564
|
-
}
|
|
19565
|
-
function squeeze(array, size2) {
|
|
19566
|
-
const s = size2 || arraySize(array);
|
|
19567
|
-
let arr10 = array;
|
|
19568
|
-
while (Array.isArray(arr10) && arr10.length === 1) {
|
|
19569
|
-
arr10 = arr10[0];
|
|
19570
|
-
s.shift();
|
|
19571
|
-
}
|
|
19572
|
-
let dims = s.length;
|
|
19573
|
-
while (s[dims - 1] === 1) {
|
|
19574
|
-
dims--;
|
|
19575
|
-
}
|
|
19576
|
-
if (dims < s.length) {
|
|
19577
|
-
arr10 = _squeeze(arr10, dims, 0);
|
|
19578
|
-
s.length = dims;
|
|
19579
|
-
}
|
|
19580
|
-
return arr10;
|
|
19581
|
-
}
|
|
19582
|
-
function _squeeze(array, dims, dim) {
|
|
19583
|
-
if (dim < dims) {
|
|
19584
|
-
const next = dim + 1;
|
|
19585
|
-
const arr10 = array;
|
|
19586
|
-
for (let i = 0, ii = arr10.length; i < ii; i++) {
|
|
19587
|
-
arr10[i] = _squeeze(arr10[i], dims, next);
|
|
19588
|
-
}
|
|
19589
|
-
return arr10;
|
|
19590
|
-
} else {
|
|
19591
|
-
let result = array;
|
|
19592
|
-
while (Array.isArray(result)) {
|
|
19593
|
-
result = result[0];
|
|
19594
|
-
}
|
|
19595
|
-
return result;
|
|
19596
|
-
}
|
|
19597
|
-
}
|
|
19598
|
-
function flatten2(array, isRectangular = false) {
|
|
19599
|
-
if (!Array.isArray(array)) {
|
|
19600
|
-
return array;
|
|
19601
|
-
}
|
|
19602
|
-
if (typeof isRectangular !== "boolean") {
|
|
19603
|
-
throw new TypeError("Boolean expected for second argument of flatten");
|
|
19604
|
-
}
|
|
19605
|
-
const flat = [];
|
|
19606
|
-
if (isRectangular) {
|
|
19607
|
-
_flattenRectangular(array);
|
|
19608
|
-
} else {
|
|
19609
|
-
_flatten(array);
|
|
19610
|
-
}
|
|
19611
|
-
return flat;
|
|
19612
|
-
function _flatten(arr10) {
|
|
19613
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
19614
|
-
const item = arr10[i];
|
|
19615
|
-
if (Array.isArray(item)) {
|
|
19616
|
-
_flatten(item);
|
|
19617
|
-
} else {
|
|
19618
|
-
flat.push(item);
|
|
19619
|
-
}
|
|
19620
|
-
}
|
|
19621
|
-
}
|
|
19622
|
-
function _flattenRectangular(arr10) {
|
|
19623
|
-
if (Array.isArray(arr10[0])) {
|
|
19624
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
19625
|
-
_flattenRectangular(arr10[i]);
|
|
19626
|
-
}
|
|
19627
|
-
} else {
|
|
19628
|
-
for (let i = 0; i < arr10.length; i++) {
|
|
19629
|
-
flat.push(arr10[i]);
|
|
19630
|
-
}
|
|
19631
|
-
}
|
|
19632
|
-
}
|
|
19633
|
-
}
|
|
19634
|
-
function filter(array, callback) {
|
|
19635
|
-
if (arraySize(array).length !== 1) {
|
|
19636
|
-
throw new Error("Only one dimensional matrices supported");
|
|
19637
|
-
}
|
|
19638
|
-
return Array.prototype.filter.call(array, callback);
|
|
19639
|
-
}
|
|
19640
|
-
function filterRegExp(array, regexp) {
|
|
19641
|
-
if (arraySize(array).length !== 1) {
|
|
19642
|
-
throw new Error("Only one dimensional matrices supported");
|
|
19643
|
-
}
|
|
19644
|
-
return Array.prototype.filter.call(array, (entry) => regexp.test(entry));
|
|
19645
|
-
}
|
|
19646
|
-
function identify2(a) {
|
|
19647
|
-
if (!Array.isArray(a)) {
|
|
19648
|
-
throw new TypeError("Array input expected");
|
|
19649
|
-
}
|
|
19650
|
-
if (a.length === 0) {
|
|
19651
|
-
return [];
|
|
19652
|
-
}
|
|
19653
|
-
const b = [];
|
|
19654
|
-
let count2 = 0;
|
|
19655
|
-
b[0] = { value: a[0], identifier: 0 };
|
|
19656
|
-
for (let i = 1; i < a.length; i++) {
|
|
19657
|
-
if (a[i] === a[i - 1]) {
|
|
19658
|
-
count2++;
|
|
19659
|
-
} else {
|
|
19660
|
-
count2 = 0;
|
|
19661
|
-
}
|
|
19662
|
-
b.push({ value: a[i], identifier: count2 });
|
|
19663
|
-
}
|
|
19664
|
-
return b;
|
|
19665
|
-
}
|
|
19666
|
-
function generalize(a) {
|
|
19667
|
-
if (!Array.isArray(a)) {
|
|
19668
|
-
throw new TypeError("Array input expected");
|
|
19669
|
-
}
|
|
19670
|
-
if (a.length === 0) {
|
|
19671
|
-
return [];
|
|
19672
|
-
}
|
|
19673
|
-
const b = [];
|
|
19674
|
-
for (let i = 0; i < a.length; i++) {
|
|
19675
|
-
b.push(a[i].value);
|
|
19676
|
-
}
|
|
19677
|
-
return b;
|
|
19678
|
-
}
|
|
19679
|
-
function getArrayDataType(array, typeOf3) {
|
|
19680
|
-
let type;
|
|
19681
|
-
let length = 0;
|
|
19682
|
-
for (let i = 0; i < array.length; i++) {
|
|
19683
|
-
const item = array[i];
|
|
19684
|
-
const isArray2 = Array.isArray(item);
|
|
19685
|
-
if (i === 0 && isArray2) {
|
|
19686
|
-
length = item.length;
|
|
19687
|
-
}
|
|
19688
|
-
if (isArray2 && item.length !== length) {
|
|
19689
|
-
return void 0;
|
|
19690
|
-
}
|
|
19691
|
-
const itemType = isArray2 ? getArrayDataType(item, typeOf3) : typeOf3(item);
|
|
19692
|
-
if (type === void 0) {
|
|
19693
|
-
type = itemType;
|
|
19694
|
-
} else if (type !== itemType) {
|
|
19695
|
-
return "mixed";
|
|
19696
|
-
} else {
|
|
19697
|
-
}
|
|
19698
|
-
}
|
|
19699
|
-
return type;
|
|
19700
|
-
}
|
|
19701
|
-
function concatRecursive(a, b, concatDim, dim) {
|
|
19702
|
-
if (dim < concatDim) {
|
|
19703
|
-
if (a.length !== b.length) {
|
|
19704
|
-
throw new DimensionError(a.length, b.length);
|
|
19705
|
-
}
|
|
19706
|
-
const c = [];
|
|
19707
|
-
for (let i = 0; i < a.length; i++) {
|
|
19708
|
-
c[i] = concatRecursive(
|
|
19709
|
-
a[i],
|
|
19710
|
-
b[i],
|
|
19711
|
-
concatDim,
|
|
19712
|
-
dim + 1
|
|
19713
|
-
);
|
|
19714
|
-
}
|
|
19715
|
-
return c;
|
|
19716
|
-
} else {
|
|
19717
|
-
return a.concat(b);
|
|
19718
|
-
}
|
|
19719
|
-
}
|
|
19720
|
-
function concat(...args) {
|
|
19721
|
-
const arrays = Array.prototype.slice.call(args, 0, -1);
|
|
19722
|
-
const concatDim = Array.prototype.slice.call(args, -1)[0];
|
|
19723
|
-
if (arrays.length === 1) {
|
|
19724
|
-
return arrays[0];
|
|
19725
|
-
}
|
|
19726
|
-
if (arrays.length > 1) {
|
|
19727
|
-
return arrays.slice(1).reduce(function(A, B) {
|
|
19728
|
-
return concatRecursive(A, B, concatDim, 0);
|
|
19729
|
-
}, arrays[0]);
|
|
19730
|
-
} else {
|
|
19731
|
-
throw new Error("Wrong number of arguments in function concat");
|
|
19732
|
-
}
|
|
19733
|
-
}
|
|
19734
|
-
function broadcastSizes(...sizes) {
|
|
19735
|
-
const dimensions = sizes.map((s) => s.length);
|
|
19736
|
-
const N = Math.max(...dimensions);
|
|
19737
|
-
const sizeMax = new Array(N).fill(null);
|
|
19738
|
-
for (let i = 0; i < sizes.length; i++) {
|
|
19739
|
-
const size2 = sizes[i];
|
|
19740
|
-
const dim = dimensions[i];
|
|
19741
|
-
for (let j = 0; j < dim; j++) {
|
|
19742
|
-
const n = N - dim + j;
|
|
19743
|
-
if (size2[j] > sizeMax[n]) {
|
|
19744
|
-
sizeMax[n] = size2[j];
|
|
19745
|
-
}
|
|
19746
|
-
}
|
|
19747
|
-
}
|
|
19748
|
-
for (let i = 0; i < sizes.length; i++) {
|
|
19749
|
-
checkBroadcastingRules(sizes[i], sizeMax);
|
|
19750
|
-
}
|
|
19751
|
-
return sizeMax;
|
|
19752
|
-
}
|
|
19753
|
-
function checkBroadcastingRules(size2, toSize) {
|
|
19754
|
-
const N = toSize.length;
|
|
19755
|
-
const dim = size2.length;
|
|
19756
|
-
for (let j = 0; j < dim; j++) {
|
|
19757
|
-
const n = N - dim + j;
|
|
19758
|
-
if (size2[j] < toSize[n] && size2[j] > 1 || size2[j] > toSize[n]) {
|
|
19759
|
-
throw new Error(
|
|
19760
|
-
`shape mismatch: mismatch is found in arg with shape (${size2}) not possible to broadcast dimension ${dim} with size ${size2[j]} to size ${toSize[n]}`
|
|
19761
|
-
);
|
|
19762
|
-
}
|
|
19763
|
-
}
|
|
19764
|
-
}
|
|
19765
|
-
function broadcastTo(array, toSize) {
|
|
19766
|
-
let Asize = arraySize(array);
|
|
19767
|
-
if (deepStrictEqual(Asize, toSize)) {
|
|
19768
|
-
return array;
|
|
19769
|
-
}
|
|
19770
|
-
checkBroadcastingRules(Asize, toSize);
|
|
19771
|
-
const broadcastedSize = broadcastSizes(Asize, toSize);
|
|
19772
|
-
const N = broadcastedSize.length;
|
|
19773
|
-
const paddedSize = [...Array(N - Asize.length).fill(1), ...Asize];
|
|
19774
|
-
let A = clone2(array);
|
|
19775
|
-
if (Asize.length < N) {
|
|
19776
|
-
A = reshape(A, paddedSize);
|
|
19777
|
-
Asize = arraySize(A);
|
|
19778
|
-
}
|
|
19779
|
-
for (let dim = 0; dim < N; dim++) {
|
|
19780
|
-
if (Asize[dim] < broadcastedSize[dim]) {
|
|
19781
|
-
A = stretch(A, broadcastedSize[dim], dim);
|
|
19782
|
-
Asize = arraySize(A);
|
|
19783
|
-
}
|
|
19784
|
-
}
|
|
19785
|
-
return A;
|
|
19786
|
-
}
|
|
19787
|
-
function stretch(arrayToStretch, sizeToStretch, dimToStretch) {
|
|
19788
|
-
return concat(...Array(sizeToStretch).fill(arrayToStretch), dimToStretch);
|
|
19789
|
-
}
|
|
19790
|
-
function get2(array, index) {
|
|
19791
|
-
if (!Array.isArray(array)) {
|
|
19792
|
-
throw new Error("Array expected");
|
|
19793
|
-
}
|
|
19794
|
-
const size2 = arraySize(array);
|
|
19795
|
-
if (index.length !== size2.length) {
|
|
19796
|
-
throw new DimensionError(index.length, size2.length);
|
|
19797
|
-
}
|
|
19798
|
-
for (let x = 0; x < index.length; x++) {
|
|
19799
|
-
validateIndex(index[x], size2[x]);
|
|
19800
|
-
}
|
|
19801
|
-
return index.reduce((acc, curr) => acc[curr], array);
|
|
19802
|
-
}
|
|
19803
|
-
function deepMap(array, callback, skipIndex = false) {
|
|
19804
|
-
if (Array.isArray(array) && array.length === 0) {
|
|
19805
|
-
return [];
|
|
19806
|
-
}
|
|
19807
|
-
if (skipIndex) {
|
|
19808
|
-
return recursiveMap(array);
|
|
19809
|
-
}
|
|
19810
|
-
const index = [];
|
|
19811
|
-
return recursiveMapWithIndex(array, 0);
|
|
19812
|
-
function recursiveMapWithIndex(value, depth) {
|
|
19813
|
-
if (Array.isArray(value)) {
|
|
19814
|
-
const N = value.length;
|
|
19815
|
-
const result = Array(N);
|
|
19816
|
-
for (let i = 0; i < N; i++) {
|
|
19817
|
-
index[depth] = i;
|
|
19818
|
-
result[i] = recursiveMapWithIndex(value[i], depth + 1);
|
|
19819
|
-
}
|
|
19820
|
-
return result;
|
|
19821
|
-
} else {
|
|
19822
|
-
return callback(
|
|
19823
|
-
value,
|
|
19824
|
-
index.slice(0, depth),
|
|
19825
|
-
array
|
|
19826
|
-
);
|
|
19827
|
-
}
|
|
19828
|
-
}
|
|
19829
|
-
function recursiveMap(value) {
|
|
19830
|
-
if (Array.isArray(value)) {
|
|
19831
|
-
const N = value.length;
|
|
19832
|
-
const result = Array(N);
|
|
19833
|
-
for (let i = 0; i < N; i++) {
|
|
19834
|
-
result[i] = recursiveMap(value[i]);
|
|
19835
|
-
}
|
|
19836
|
-
return result;
|
|
19837
|
-
} else {
|
|
19838
|
-
return callback(value);
|
|
19839
|
-
}
|
|
19840
|
-
}
|
|
19841
|
-
}
|
|
19842
|
-
function deepForEach(array, callback, skipIndex = false) {
|
|
19843
|
-
if (Array.isArray(array) && array.length === 0) {
|
|
19844
|
-
return;
|
|
19845
|
-
}
|
|
19846
|
-
if (skipIndex) {
|
|
19847
|
-
recursiveForEach(array);
|
|
19848
|
-
return;
|
|
19849
|
-
}
|
|
19850
|
-
const index = [];
|
|
19851
|
-
recursiveForEachWithIndex(array, 0);
|
|
19852
|
-
function recursiveForEachWithIndex(value, depth) {
|
|
19853
|
-
if (Array.isArray(value)) {
|
|
19854
|
-
const N = value.length;
|
|
19855
|
-
for (let i = 0; i < N; i++) {
|
|
19856
|
-
index[depth] = i;
|
|
19857
|
-
recursiveForEachWithIndex(value[i], depth + 1);
|
|
19858
|
-
}
|
|
19859
|
-
} else {
|
|
19860
|
-
callback(
|
|
19861
|
-
value,
|
|
19862
|
-
index.slice(0, depth),
|
|
19863
|
-
array
|
|
19864
|
-
);
|
|
19865
|
-
}
|
|
19866
|
-
}
|
|
19867
|
-
function recursiveForEach(value) {
|
|
19868
|
-
if (Array.isArray(value)) {
|
|
19869
|
-
const N = value.length;
|
|
19870
|
-
for (let i = 0; i < N; i++) {
|
|
19871
|
-
recursiveForEach(value[i]);
|
|
19872
|
-
}
|
|
19873
|
-
} else {
|
|
19874
|
-
callback(value);
|
|
19875
|
-
}
|
|
19876
|
-
}
|
|
19877
|
-
}
|
|
19878
|
-
function clone2(array) {
|
|
19879
|
-
return Object.assign([], array);
|
|
19880
|
-
}
|
|
19881
|
-
|
|
19882
|
-
// src/utils/switch.ts
|
|
19883
|
-
function _switch(mat) {
|
|
19884
|
-
const rows = mat;
|
|
19885
|
-
const I2 = rows.length;
|
|
19886
|
-
const J = rows[0].length;
|
|
19887
|
-
let i, j;
|
|
19888
|
-
const ret = [];
|
|
19889
|
-
for (j = 0; j < J; j++) {
|
|
19890
|
-
const tmp = [];
|
|
19891
|
-
for (i = 0; i < I2; i++) {
|
|
19892
|
-
tmp.push(rows[i][j]);
|
|
19893
|
-
}
|
|
19894
|
-
ret.push(tmp);
|
|
19895
|
-
}
|
|
19896
|
-
return ret;
|
|
19897
|
-
}
|
|
19898
|
-
|
|
19899
19083
|
// src/utils/collection.ts
|
|
19900
|
-
|
|
19901
|
-
|
|
19902
|
-
|
|
19903
|
-
|
|
19904
|
-
|
|
19905
|
-
|
|
19906
|
-
|
|
19907
|
-
}
|
|
19908
|
-
function deepForEach2(array, callback) {
|
|
19909
|
-
if (isMatrix(array)) {
|
|
19910
|
-
array.forEach((x) => callback(x), false, true);
|
|
19911
|
-
} else {
|
|
19912
|
-
deepForEach(array, callback, true);
|
|
19913
|
-
}
|
|
19914
|
-
}
|
|
19915
|
-
function deepMap2(array, callback, skipZeros) {
|
|
19916
|
-
if (!skipZeros) {
|
|
19917
|
-
if (isMatrix(array)) {
|
|
19918
|
-
return array.map((x) => callback(x), false, true);
|
|
19919
|
-
} else {
|
|
19920
|
-
return deepMap(array, callback, true);
|
|
19921
|
-
}
|
|
19922
|
-
}
|
|
19923
|
-
const skipZerosCallback = (x) => x === 0 ? x : callback(x);
|
|
19924
|
-
if (isMatrix(array)) {
|
|
19925
|
-
return array.map((x) => skipZerosCallback(x), false, true);
|
|
19926
|
-
} else {
|
|
19927
|
-
return deepMap(array, skipZerosCallback, true);
|
|
19928
|
-
}
|
|
19929
|
-
}
|
|
19930
|
-
function reduce2(mat, dim, callback) {
|
|
19931
|
-
const size2 = Array.isArray(mat) ? arraySize(mat) : mat.size();
|
|
19932
|
-
if (dim < 0 || dim >= size2.length) {
|
|
19933
|
-
throw new IndexError(dim, 0, size2.length);
|
|
19934
|
-
}
|
|
19935
|
-
if (isMatrix(mat)) {
|
|
19936
|
-
const reduced = _reduce(mat.valueOf(), dim, callback);
|
|
19937
|
-
return mat.create(
|
|
19938
|
-
reduced,
|
|
19939
|
-
mat.datatype()
|
|
19940
|
-
);
|
|
19941
|
-
} else {
|
|
19942
|
-
return _reduce(mat, dim, callback);
|
|
19943
|
-
}
|
|
19944
|
-
}
|
|
19945
|
-
function _reduce(mat, dim, callback) {
|
|
19946
|
-
let i;
|
|
19947
|
-
let ret;
|
|
19948
|
-
let val;
|
|
19949
|
-
let tran;
|
|
19950
|
-
if (dim <= 0) {
|
|
19951
|
-
if (!Array.isArray(mat[0])) {
|
|
19952
|
-
val = mat[0];
|
|
19953
|
-
for (i = 1; i < mat.length; i++) {
|
|
19954
|
-
val = callback(val, mat[i]);
|
|
19955
|
-
}
|
|
19956
|
-
return val;
|
|
19957
|
-
} else {
|
|
19958
|
-
tran = _switch(mat);
|
|
19959
|
-
ret = [];
|
|
19960
|
-
for (i = 0; i < tran.length; i++) {
|
|
19961
|
-
ret[i] = _reduce(tran[i], dim - 1, callback);
|
|
19962
|
-
}
|
|
19963
|
-
return ret;
|
|
19964
|
-
}
|
|
19965
|
-
} else {
|
|
19966
|
-
ret = [];
|
|
19967
|
-
for (i = 0; i < mat.length; i++) {
|
|
19968
|
-
ret[i] = _reduce(mat[i], dim - 1, callback);
|
|
19969
|
-
}
|
|
19970
|
-
return ret;
|
|
19971
|
-
}
|
|
19972
|
-
}
|
|
19973
|
-
function scatter(a, j, w, x, u, mark, cindex, f, inverse, update, value) {
|
|
19974
|
-
const avalues = a._values;
|
|
19975
|
-
const aindex = a._index;
|
|
19976
|
-
const aptr = a._ptr;
|
|
19977
|
-
let k;
|
|
19978
|
-
let k0;
|
|
19979
|
-
let k1;
|
|
19980
|
-
let i;
|
|
19981
|
-
if (x) {
|
|
19982
|
-
for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
19983
|
-
i = aindex[k];
|
|
19984
|
-
if (w[i] !== mark) {
|
|
19985
|
-
w[i] = mark;
|
|
19986
|
-
cindex.push(i);
|
|
19987
|
-
if (update && f) {
|
|
19988
|
-
x[i] = inverse ? f(avalues[k], value) : f(value, avalues[k]);
|
|
19989
|
-
u[i] = mark;
|
|
19990
|
-
} else {
|
|
19991
|
-
x[i] = avalues[k];
|
|
19992
|
-
}
|
|
19993
|
-
} else {
|
|
19994
|
-
if (f) {
|
|
19995
|
-
x[i] = inverse ? f(avalues[k], x[i]) : f(x[i], avalues[k]);
|
|
19996
|
-
}
|
|
19997
|
-
u[i] = mark;
|
|
19998
|
-
}
|
|
19999
|
-
}
|
|
20000
|
-
} else {
|
|
20001
|
-
for (k0 = aptr[j], k1 = aptr[j + 1], k = k0; k < k1; k++) {
|
|
20002
|
-
i = aindex[k];
|
|
20003
|
-
if (w[i] !== mark) {
|
|
20004
|
-
w[i] = mark;
|
|
20005
|
-
cindex.push(i);
|
|
20006
|
-
} else {
|
|
20007
|
-
u[i] = mark;
|
|
20008
|
-
}
|
|
20009
|
-
}
|
|
20010
|
-
}
|
|
20011
|
-
}
|
|
19084
|
+
import {
|
|
19085
|
+
containsCollections,
|
|
19086
|
+
deepForEach,
|
|
19087
|
+
deepMap,
|
|
19088
|
+
reduce as reduce2,
|
|
19089
|
+
scatter
|
|
19090
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
20012
19091
|
|
|
20013
19092
|
// src/arithmetic/abs.ts
|
|
20014
19093
|
var name2 = "abs";
|
|
@@ -20023,7 +19102,7 @@ var createAbs = /* @__PURE__ */ factory(
|
|
|
20023
19102
|
bigint: (x) => x < 0n ? -x : x,
|
|
20024
19103
|
// deep map collection, skip zeros since abs(0) = 0
|
|
20025
19104
|
"Array | Matrix": typed3.referToSelf(
|
|
20026
|
-
(self) => (x) =>
|
|
19105
|
+
(self) => (x) => deepMap(x, self, true)
|
|
20027
19106
|
)
|
|
20028
19107
|
});
|
|
20029
19108
|
}
|
|
@@ -20181,7 +19260,7 @@ var createLog10 = /* @__PURE__ */ factory(
|
|
|
20181
19260
|
}
|
|
20182
19261
|
},
|
|
20183
19262
|
"Array | Matrix": typed3.referToSelf(
|
|
20184
|
-
(self) => (x) =>
|
|
19263
|
+
(self) => (x) => deepMap(x, self)
|
|
20185
19264
|
)
|
|
20186
19265
|
});
|
|
20187
19266
|
}
|
|
@@ -20215,7 +19294,7 @@ var createLog2 = /* @__PURE__ */ factory(
|
|
|
20215
19294
|
}
|
|
20216
19295
|
},
|
|
20217
19296
|
"Array | Matrix": typed3.referToSelf(
|
|
20218
|
-
(self) => (x) =>
|
|
19297
|
+
(self) => (x) => deepMap(x, self)
|
|
20219
19298
|
)
|
|
20220
19299
|
});
|
|
20221
19300
|
function _log2Complex(x) {
|
|
@@ -20278,7 +19357,7 @@ var createSign = /* @__PURE__ */ factory(
|
|
|
20278
19357
|
},
|
|
20279
19358
|
// deep map collection, skip zeros since sign(0) = 0
|
|
20280
19359
|
"Array | Matrix": typed3.referToSelf(
|
|
20281
|
-
(self) => (x) =>
|
|
19360
|
+
(self) => (x) => deepMap(x, self, true)
|
|
20282
19361
|
),
|
|
20283
19362
|
Unit: typed3.referToSelf((self) => (x) => {
|
|
20284
19363
|
if (!x._isDerived() && x.units[0].unit.offset !== 0) {
|
|
@@ -20430,7 +19509,7 @@ var createUnaryMinus = /* @__PURE__ */ factory(
|
|
|
20430
19509
|
},
|
|
20431
19510
|
// deep map collection, skip zeros since unaryMinus(0) = 0
|
|
20432
19511
|
"Array | Matrix": typed3.referToSelf(
|
|
20433
|
-
(self) => (x) =>
|
|
19512
|
+
(self) => (x) => deepMap(x, self, true)
|
|
20434
19513
|
)
|
|
20435
19514
|
// TODO: add support for string
|
|
20436
19515
|
});
|
|
@@ -20716,7 +19795,7 @@ var createBitNot = /* @__PURE__ */ factory(
|
|
|
20716
19795
|
BigNumber: bitNotBigNumber,
|
|
20717
19796
|
bigint: (x) => ~x,
|
|
20718
19797
|
"Array | Matrix": typed3.referToSelf(
|
|
20719
|
-
(self) => (x) =>
|
|
19798
|
+
(self) => (x) => deepMap(x, self)
|
|
20720
19799
|
)
|
|
20721
19800
|
});
|
|
20722
19801
|
}
|
|
@@ -20741,7 +19820,7 @@ var createArg = /* @__PURE__ */ factory(
|
|
|
20741
19820
|
},
|
|
20742
19821
|
// TODO: implement BigNumber support for function arg
|
|
20743
19822
|
"Array | Matrix": typed3.referToSelf(
|
|
20744
|
-
(self) => (x) =>
|
|
19823
|
+
(self) => (x) => deepMap(x, self)
|
|
20745
19824
|
)
|
|
20746
19825
|
});
|
|
20747
19826
|
}
|
|
@@ -20764,7 +19843,7 @@ var createConj = /* @__PURE__ */ factory(
|
|
|
20764
19843
|
}
|
|
20765
19844
|
),
|
|
20766
19845
|
"Array | Matrix": typed3.referToSelf(
|
|
20767
|
-
(self) => (x) =>
|
|
19846
|
+
(self) => (x) => deepMap(x, self)
|
|
20768
19847
|
)
|
|
20769
19848
|
});
|
|
20770
19849
|
}
|
|
@@ -20779,7 +19858,7 @@ var createIm = /* @__PURE__ */ factory(name18, dependencies18, ({ typed: typed3
|
|
|
20779
19858
|
"BigNumber | Fraction": (x) => x.mul(0),
|
|
20780
19859
|
Complex: (x) => x.im,
|
|
20781
19860
|
"Array | Matrix": typed3.referToSelf(
|
|
20782
|
-
(self) => (x) =>
|
|
19861
|
+
(self) => (x) => deepMap(x, self)
|
|
20783
19862
|
)
|
|
20784
19863
|
});
|
|
20785
19864
|
});
|
|
@@ -20792,7 +19871,7 @@ var createRe = /* @__PURE__ */ factory(name19, dependencies19, ({ typed: typed3
|
|
|
20792
19871
|
"number | BigNumber | Fraction": (x) => x,
|
|
20793
19872
|
Complex: (x) => x.re,
|
|
20794
19873
|
"Array | Matrix": typed3.referToSelf(
|
|
20795
|
-
(self) => (x) =>
|
|
19874
|
+
(self) => (x) => deepMap(x, self)
|
|
20796
19875
|
)
|
|
20797
19876
|
});
|
|
20798
19877
|
});
|
|
@@ -20818,7 +19897,7 @@ var createNot = /* @__PURE__ */ factory(
|
|
|
20818
19897
|
(self) => (x) => typed3.find(self, x.valueType())(x.value)
|
|
20819
19898
|
),
|
|
20820
19899
|
"Array | Matrix": typed3.referToSelf(
|
|
20821
|
-
(self) => (x) =>
|
|
19900
|
+
(self) => (x) => deepMap(x, self)
|
|
20822
19901
|
)
|
|
20823
19902
|
});
|
|
20824
19903
|
}
|
|
@@ -20826,6 +19905,42 @@ var createNot = /* @__PURE__ */ factory(
|
|
|
20826
19905
|
|
|
20827
19906
|
// src/utils/optimizeCallback.ts
|
|
20828
19907
|
import typed2 from "typed-function";
|
|
19908
|
+
|
|
19909
|
+
// src/utils/array.ts
|
|
19910
|
+
import {
|
|
19911
|
+
arraySize,
|
|
19912
|
+
validate,
|
|
19913
|
+
validateIndexSourceSize,
|
|
19914
|
+
validateIndex,
|
|
19915
|
+
isEmptyIndex,
|
|
19916
|
+
resize,
|
|
19917
|
+
reshape,
|
|
19918
|
+
processSizesWildcard,
|
|
19919
|
+
squeeze,
|
|
19920
|
+
unsqueeze,
|
|
19921
|
+
flatten as flatten2,
|
|
19922
|
+
map,
|
|
19923
|
+
forEach,
|
|
19924
|
+
filter,
|
|
19925
|
+
filterRegExp,
|
|
19926
|
+
join,
|
|
19927
|
+
identify as identify2,
|
|
19928
|
+
generalize,
|
|
19929
|
+
getArrayDataType,
|
|
19930
|
+
last,
|
|
19931
|
+
concat,
|
|
19932
|
+
broadcastSizes,
|
|
19933
|
+
checkBroadcastingRules,
|
|
19934
|
+
broadcastTo,
|
|
19935
|
+
broadcastArrays,
|
|
19936
|
+
stretch,
|
|
19937
|
+
getArrayElement,
|
|
19938
|
+
deepMapArray as deepMapArray2,
|
|
19939
|
+
deepForEachArray,
|
|
19940
|
+
cloneArray
|
|
19941
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
19942
|
+
|
|
19943
|
+
// src/utils/optimizeCallback.ts
|
|
20829
19944
|
function optimizeCallback(callback, array, name254, isUnary) {
|
|
20830
19945
|
const typedAny = typed2;
|
|
20831
19946
|
if (typedAny.isTypedFunction(callback)) {
|
|
@@ -20839,7 +19954,7 @@ function optimizeCallback(callback, array, name254, isUnary) {
|
|
|
20839
19954
|
return { isUnary: false, fn: callback };
|
|
20840
19955
|
}
|
|
20841
19956
|
const firstIndex = size2.map(() => 0);
|
|
20842
|
-
const firstValue = array.isMatrix ? array.get(firstIndex) :
|
|
19957
|
+
const firstValue = array.isMatrix ? array.get(firstIndex) : getArrayElement(array, firstIndex);
|
|
20843
19958
|
numberOfArguments = _findNumberOfArgumentsTyped(
|
|
20844
19959
|
callback,
|
|
20845
19960
|
firstValue,
|
|
@@ -21013,7 +20128,7 @@ var createForEach = /* @__PURE__ */ factory(
|
|
|
21013
20128
|
);
|
|
21014
20129
|
function _forEach(array, callback) {
|
|
21015
20130
|
const fastCallback = optimizeCallback(callback, array, name23);
|
|
21016
|
-
|
|
20131
|
+
deepForEachArray(array, fastCallback.fn, fastCallback.isUnary);
|
|
21017
20132
|
}
|
|
21018
20133
|
|
|
21019
20134
|
// src/matrix/getMatrixDataType.ts
|
|
@@ -21062,10 +20177,10 @@ var createMap = /* @__PURE__ */ factory(
|
|
|
21062
20177
|
const sizes = Arrays.map((M) => isMat(M) ? M.size() : arraySize(M));
|
|
21063
20178
|
const newSize = broadcastSizes(...sizes);
|
|
21064
20179
|
const numberOfArrays = Arrays.length;
|
|
21065
|
-
const _get = (coll, idx) => isMat(coll) ? coll.get(idx) :
|
|
20180
|
+
const _get = (coll, idx) => isMat(coll) ? coll.get(idx) : getArrayElement(coll, idx);
|
|
21066
20181
|
const firstValues = Arrays.map((collection, i) => {
|
|
21067
20182
|
const firstIndex = sizes[i].map(() => 0);
|
|
21068
|
-
return isMat(collection) ? collection.get(firstIndex) :
|
|
20183
|
+
return isMat(collection) ? collection.get(firstIndex) : getArrayElement(collection, firstIndex);
|
|
21069
20184
|
});
|
|
21070
20185
|
const callbackArgCount = typed3.isTypedFunction(multiCallback) ? _getTypedCallbackArgCount(
|
|
21071
20186
|
multiCallback,
|
|
@@ -21182,7 +20297,7 @@ var createMap = /* @__PURE__ */ factory(
|
|
|
21182
20297
|
}
|
|
21183
20298
|
function _mapArray(array, callback) {
|
|
21184
20299
|
const fastCallback = optimizeCallback(callback, array, name25);
|
|
21185
|
-
return
|
|
20300
|
+
return deepMapArray2(
|
|
21186
20301
|
array,
|
|
21187
20302
|
fastCallback.fn,
|
|
21188
20303
|
fastCallback.isUnary
|
|
@@ -21704,7 +20819,7 @@ var createErf = /* @__PURE__ */ factory(
|
|
|
21704
20819
|
}
|
|
21705
20820
|
}
|
|
21706
20821
|
}
|
|
21707
|
-
return
|
|
20822
|
+
return deepMap(n, self);
|
|
21708
20823
|
}
|
|
21709
20824
|
)
|
|
21710
20825
|
// TODO: For complex numbers, use the approximation for the Faddeeva function
|
|
@@ -21811,8 +20926,8 @@ var createFormat = /* @__PURE__ */ factory(
|
|
|
21811
20926
|
dependencies35,
|
|
21812
20927
|
({ typed: typed3 }) => {
|
|
21813
20928
|
return typed3(name35, {
|
|
21814
|
-
any:
|
|
21815
|
-
"any, Object | function | number | BigNumber":
|
|
20929
|
+
any: formatGeneric,
|
|
20930
|
+
"any, Object | function | number | BigNumber": formatGeneric
|
|
21816
20931
|
});
|
|
21817
20932
|
}
|
|
21818
20933
|
);
|
|
@@ -21844,7 +20959,7 @@ function _print(template, values, options) {
|
|
|
21844
20959
|
}
|
|
21845
20960
|
if (value !== void 0) {
|
|
21846
20961
|
if (!isString(value)) {
|
|
21847
|
-
return
|
|
20962
|
+
return formatGeneric(value, options);
|
|
21848
20963
|
} else {
|
|
21849
20964
|
return value;
|
|
21850
20965
|
}
|
|
@@ -22432,7 +21547,7 @@ var createIsNaN = /* @__PURE__ */ factory(
|
|
|
22432
21547
|
return Number.isNaN(x.value);
|
|
22433
21548
|
},
|
|
22434
21549
|
"Array | Matrix": typed3.referToSelf(
|
|
22435
|
-
(self) => (x) =>
|
|
21550
|
+
(self) => (x) => deepMap(x, self)
|
|
22436
21551
|
)
|
|
22437
21552
|
});
|
|
22438
21553
|
}
|
|
@@ -22455,7 +21570,7 @@ var createIsNegative = /* @__PURE__ */ factory(
|
|
|
22455
21570
|
(self) => (x) => typed3.find(self, x.valueType())(x.value)
|
|
22456
21571
|
),
|
|
22457
21572
|
"Array | Matrix": typed3.referToSelf(
|
|
22458
|
-
(self) => (x) =>
|
|
21573
|
+
(self) => (x) => deepMap(x, self)
|
|
22459
21574
|
)
|
|
22460
21575
|
});
|
|
22461
21576
|
}
|
|
@@ -22472,7 +21587,7 @@ var createIsNumeric = /* @__PURE__ */ factory(
|
|
|
22472
21587
|
"number | BigNumber | bigint | Fraction | boolean": () => true,
|
|
22473
21588
|
"Complex | Unit | string | null | undefined | Node": () => false,
|
|
22474
21589
|
"Array | Matrix": typed3.referToSelf(
|
|
22475
|
-
(self) => (x) =>
|
|
21590
|
+
(self) => (x) => deepMap(x, self)
|
|
22476
21591
|
)
|
|
22477
21592
|
});
|
|
22478
21593
|
}
|
|
@@ -22494,7 +21609,7 @@ var createIsPositive = /* @__PURE__ */ factory(
|
|
|
22494
21609
|
(self) => (x) => typed3.find(self, x.valueType())(x.value)
|
|
22495
21610
|
),
|
|
22496
21611
|
"Array | Matrix": typed3.referToSelf(
|
|
22497
|
-
(self) => (x) =>
|
|
21612
|
+
(self) => (x) => deepMap(x, self)
|
|
22498
21613
|
)
|
|
22499
21614
|
});
|
|
22500
21615
|
}
|
|
@@ -22594,7 +21709,7 @@ var createIsPrime = /* @__PURE__ */ factory(
|
|
|
22594
21709
|
return true;
|
|
22595
21710
|
},
|
|
22596
21711
|
"Array | Matrix": typed3.referToSelf(
|
|
22597
|
-
(self) => (x) =>
|
|
21712
|
+
(self) => (x) => deepMap(x, self)
|
|
22598
21713
|
)
|
|
22599
21714
|
});
|
|
22600
21715
|
}
|
|
@@ -22722,7 +21837,7 @@ var createUnaryPlus = /* @__PURE__ */ factory(
|
|
|
22722
21837
|
},
|
|
22723
21838
|
// deep map collection, skip zeros since unaryPlus(0) = 0
|
|
22724
21839
|
"Array | Matrix": typed3.referToSelf(
|
|
22725
|
-
(self) => (x) =>
|
|
21840
|
+
(self) => (x) => deepMap(x, self, true)
|
|
22726
21841
|
),
|
|
22727
21842
|
boolean: function(x) {
|
|
22728
21843
|
return numeric2(x ? 1 : 0, config2.number);
|
|
@@ -23032,7 +22147,7 @@ var createProd = /* @__PURE__ */ factory(
|
|
|
23032
22147
|
}
|
|
23033
22148
|
}
|
|
23034
22149
|
let prod2;
|
|
23035
|
-
|
|
22150
|
+
deepForEach(array, function(value) {
|
|
23036
22151
|
try {
|
|
23037
22152
|
const converted = typeof value === "string" ? parseNumberWithConfig2(value) : value;
|
|
23038
22153
|
prod2 = prod2 === void 0 ? converted : multiplyScalar2(prod2, converted);
|
|
@@ -23054,13 +22169,13 @@ var dependencies77 = ["typed", "format"];
|
|
|
23054
22169
|
var createBin = /* @__PURE__ */ factory(
|
|
23055
22170
|
name77,
|
|
23056
22171
|
dependencies77,
|
|
23057
|
-
({ typed: typed3, format:
|
|
22172
|
+
({ typed: typed3, format: format4 }) => {
|
|
23058
22173
|
return typed3(name77, {
|
|
23059
22174
|
"number | BigNumber": function(n) {
|
|
23060
|
-
return
|
|
22175
|
+
return format4(n, { notation: "bin" });
|
|
23061
22176
|
},
|
|
23062
22177
|
"number | BigNumber, number | BigNumber": function(n, wordSize) {
|
|
23063
|
-
return
|
|
22178
|
+
return format4(n, { notation: "bin", wordSize });
|
|
23064
22179
|
}
|
|
23065
22180
|
});
|
|
23066
22181
|
}
|
|
@@ -23072,13 +22187,13 @@ var dependencies78 = ["typed", "format"];
|
|
|
23072
22187
|
var createHex = /* @__PURE__ */ factory(
|
|
23073
22188
|
name78,
|
|
23074
22189
|
dependencies78,
|
|
23075
|
-
({ typed: typed3, format:
|
|
22190
|
+
({ typed: typed3, format: format4 }) => {
|
|
23076
22191
|
return typed3(name78, {
|
|
23077
22192
|
"number | BigNumber": function(n) {
|
|
23078
|
-
return
|
|
22193
|
+
return format4(n, { notation: "hex" });
|
|
23079
22194
|
},
|
|
23080
22195
|
"number | BigNumber, number | BigNumber": function(n, wordSize) {
|
|
23081
|
-
return
|
|
22196
|
+
return format4(n, { notation: "hex", wordSize });
|
|
23082
22197
|
}
|
|
23083
22198
|
});
|
|
23084
22199
|
}
|
|
@@ -23090,13 +22205,13 @@ var dependencies79 = ["typed", "format"];
|
|
|
23090
22205
|
var createOct = /* @__PURE__ */ factory(
|
|
23091
22206
|
name79,
|
|
23092
22207
|
dependencies79,
|
|
23093
|
-
({ typed: typed3, format:
|
|
22208
|
+
({ typed: typed3, format: format4 }) => {
|
|
23094
22209
|
return typed3(name79, {
|
|
23095
22210
|
"number | BigNumber": function(n) {
|
|
23096
|
-
return
|
|
22211
|
+
return format4(n, { notation: "oct" });
|
|
23097
22212
|
},
|
|
23098
22213
|
"number | BigNumber, number | BigNumber": function(n, wordSize) {
|
|
23099
|
-
return
|
|
22214
|
+
return format4(n, { notation: "oct", wordSize });
|
|
23100
22215
|
}
|
|
23101
22216
|
});
|
|
23102
22217
|
}
|
|
@@ -23127,9 +22242,9 @@ var dependencies81 = ["typed", "isBounded", "map"];
|
|
|
23127
22242
|
var createIsFinite = /* @__PURE__ */ factory(
|
|
23128
22243
|
name81,
|
|
23129
22244
|
dependencies81,
|
|
23130
|
-
({ typed: typed3, isBounded: isBounded2, map:
|
|
22245
|
+
({ typed: typed3, isBounded: isBounded2, map: map3 }) => {
|
|
23131
22246
|
return typed3(name81, {
|
|
23132
|
-
"Array | Matrix": (A) =>
|
|
22247
|
+
"Array | Matrix": (A) => map3(A, isBounded2),
|
|
23133
22248
|
any: (x) => isBounded2(x)
|
|
23134
22249
|
});
|
|
23135
22250
|
}
|
|
@@ -23149,7 +22264,7 @@ var createIsZero = /* @__PURE__ */ factory(
|
|
|
23149
22264
|
(self) => (x) => typed3.find(self, x.valueType())(x.value)
|
|
23150
22265
|
),
|
|
23151
22266
|
"Array | Matrix": typed3.referToSelf(
|
|
23152
|
-
(self) => (x) =>
|
|
22267
|
+
(self) => (x) => deepMap(x, self)
|
|
23153
22268
|
)
|
|
23154
22269
|
});
|
|
23155
22270
|
}
|
|
@@ -23254,7 +22369,7 @@ var createTranspose = /* @__PURE__ */ factory(
|
|
|
23254
22369
|
const columns = size2[1];
|
|
23255
22370
|
if (columns === 0) {
|
|
23256
22371
|
throw new RangeError(
|
|
23257
|
-
"Cannot transpose a 2D matrix with no columns (size: " +
|
|
22372
|
+
"Cannot transpose a 2D matrix with no columns (size: " + formatGeneric(size2, {}) + ")"
|
|
23258
22373
|
);
|
|
23259
22374
|
}
|
|
23260
22375
|
switch (x.storage()) {
|
|
@@ -23269,7 +22384,7 @@ var createTranspose = /* @__PURE__ */ factory(
|
|
|
23269
22384
|
break;
|
|
23270
22385
|
default:
|
|
23271
22386
|
throw new RangeError(
|
|
23272
|
-
"Matrix must be a vector or two dimensional (size: " +
|
|
22387
|
+
"Matrix must be a vector or two dimensional (size: " + formatGeneric(size2, {}) + ")"
|
|
23273
22388
|
);
|
|
23274
22389
|
}
|
|
23275
22390
|
return c;
|
|
@@ -23386,47 +22501,47 @@ var createIdentity = /* @__PURE__ */ factory(
|
|
|
23386
22501
|
"": function() {
|
|
23387
22502
|
return config2.matrix === "Matrix" ? matrix2([]) : [];
|
|
23388
22503
|
},
|
|
23389
|
-
string: function(
|
|
23390
|
-
return matrix2(
|
|
22504
|
+
string: function(format4) {
|
|
22505
|
+
return matrix2(format4);
|
|
23391
22506
|
},
|
|
23392
22507
|
"number | BigNumber": function(rows) {
|
|
23393
22508
|
return _identity(rows, rows, config2.matrix === "Matrix" ? "dense" : void 0);
|
|
23394
22509
|
},
|
|
23395
|
-
"number | BigNumber, string": function(rows,
|
|
23396
|
-
return _identity(rows, rows,
|
|
22510
|
+
"number | BigNumber, string": function(rows, format4) {
|
|
22511
|
+
return _identity(rows, rows, format4);
|
|
23397
22512
|
},
|
|
23398
22513
|
"number | BigNumber, number | BigNumber": function(rows, cols) {
|
|
23399
22514
|
return _identity(rows, cols, config2.matrix === "Matrix" ? "dense" : void 0);
|
|
23400
22515
|
},
|
|
23401
|
-
"number | BigNumber, number | BigNumber, string": function(rows, cols,
|
|
23402
|
-
return _identity(rows, cols,
|
|
22516
|
+
"number | BigNumber, number | BigNumber, string": function(rows, cols, format4) {
|
|
22517
|
+
return _identity(rows, cols, format4);
|
|
23403
22518
|
},
|
|
23404
22519
|
Array: function(size2) {
|
|
23405
22520
|
return _identityVector(size2);
|
|
23406
22521
|
},
|
|
23407
|
-
"Array, string": function(size2,
|
|
23408
|
-
return _identityVector(size2,
|
|
22522
|
+
"Array, string": function(size2, format4) {
|
|
22523
|
+
return _identityVector(size2, format4);
|
|
23409
22524
|
},
|
|
23410
22525
|
Matrix: function(size2) {
|
|
23411
22526
|
return _identityVector(size2.valueOf(), size2.storage());
|
|
23412
22527
|
},
|
|
23413
|
-
"Matrix, string": function(size2,
|
|
23414
|
-
return _identityVector(size2.valueOf(),
|
|
22528
|
+
"Matrix, string": function(size2, format4) {
|
|
22529
|
+
return _identityVector(size2.valueOf(), format4);
|
|
23415
22530
|
}
|
|
23416
22531
|
});
|
|
23417
|
-
function _identityVector(size2,
|
|
22532
|
+
function _identityVector(size2, format4) {
|
|
23418
22533
|
switch (size2.length) {
|
|
23419
22534
|
case 0:
|
|
23420
|
-
return
|
|
22535
|
+
return format4 ? matrix2(format4) : [];
|
|
23421
22536
|
case 1:
|
|
23422
|
-
return _identity(size2[0], size2[0],
|
|
22537
|
+
return _identity(size2[0], size2[0], format4);
|
|
23423
22538
|
case 2:
|
|
23424
|
-
return _identity(size2[0], size2[1],
|
|
22539
|
+
return _identity(size2[0], size2[1], format4);
|
|
23425
22540
|
default:
|
|
23426
22541
|
throw new Error("Vector containing two values expected");
|
|
23427
22542
|
}
|
|
23428
22543
|
}
|
|
23429
|
-
function _identity(rows, cols,
|
|
22544
|
+
function _identity(rows, cols, format4) {
|
|
23430
22545
|
const Big = isBigNumber(rows) || isBigNumber(cols) ? BigNumber9 : null;
|
|
23431
22546
|
if (isBigNumber(rows)) rows = rows.toNumber();
|
|
23432
22547
|
if (isBigNumber(cols)) cols = cols.toNumber();
|
|
@@ -23439,14 +22554,14 @@ var createIdentity = /* @__PURE__ */ factory(
|
|
|
23439
22554
|
const one = Big ? new BigNumber9(1) : 1;
|
|
23440
22555
|
const defaultValue = Big ? new Big(0) : 0;
|
|
23441
22556
|
const size2 = [rows, cols];
|
|
23442
|
-
if (
|
|
23443
|
-
if (
|
|
22557
|
+
if (format4) {
|
|
22558
|
+
if (format4 === "sparse") {
|
|
23444
22559
|
return SparseMatrix.diagonal(size2, one, 0, defaultValue);
|
|
23445
22560
|
}
|
|
23446
|
-
if (
|
|
22561
|
+
if (format4 === "dense") {
|
|
23447
22562
|
return DenseMatrix6.diagonal(size2, one, 0, defaultValue);
|
|
23448
22563
|
}
|
|
23449
|
-
throw new TypeError(`Unknown matrix type "${
|
|
22564
|
+
throw new TypeError(`Unknown matrix type "${format4}"`);
|
|
23450
22565
|
}
|
|
23451
22566
|
const res = resize([], size2, defaultValue);
|
|
23452
22567
|
const minimum = rows < cols ? rows : cols;
|
|
@@ -23467,10 +22582,10 @@ function createZerosAndOnes(name254, defaultValue, { typed: typed3, config: conf
|
|
|
23467
22582
|
// math.zeros/ones(m, n, p, ..., format)
|
|
23468
22583
|
// TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this
|
|
23469
22584
|
"...number | BigNumber | string": function(size2) {
|
|
23470
|
-
const
|
|
23471
|
-
if (typeof
|
|
23472
|
-
const
|
|
23473
|
-
return _zerosAndOnes(size2,
|
|
22585
|
+
const last2 = size2[size2.length - 1];
|
|
22586
|
+
if (typeof last2 === "string") {
|
|
22587
|
+
const format4 = size2.pop();
|
|
22588
|
+
return _zerosAndOnes(size2, format4);
|
|
23474
22589
|
} else if (config2.matrix === "Array") {
|
|
23475
22590
|
return _zerosAndOnes(size2);
|
|
23476
22591
|
} else {
|
|
@@ -23479,20 +22594,20 @@ function createZerosAndOnes(name254, defaultValue, { typed: typed3, config: conf
|
|
|
23479
22594
|
},
|
|
23480
22595
|
Array: _zerosAndOnes,
|
|
23481
22596
|
Matrix: function(size2) {
|
|
23482
|
-
const
|
|
23483
|
-
return _zerosAndOnes(size2.valueOf(),
|
|
22597
|
+
const format4 = size2.storage();
|
|
22598
|
+
return _zerosAndOnes(size2.valueOf(), format4);
|
|
23484
22599
|
},
|
|
23485
|
-
"Array | Matrix, string": function(size2,
|
|
22600
|
+
"Array | Matrix, string": function(size2, format4) {
|
|
23486
22601
|
const sizeArray = Array.isArray(size2) ? size2 : size2.valueOf();
|
|
23487
|
-
return _zerosAndOnes(sizeArray,
|
|
22602
|
+
return _zerosAndOnes(sizeArray, format4);
|
|
23488
22603
|
}
|
|
23489
22604
|
});
|
|
23490
|
-
function _zerosAndOnes(size2,
|
|
22605
|
+
function _zerosAndOnes(size2, format4) {
|
|
23491
22606
|
const hasBigNumbers = _normalize(size2);
|
|
23492
22607
|
const dflt = hasBigNumbers ? new BigNumber9(defaultValue) : defaultValue;
|
|
23493
22608
|
_validate(size2);
|
|
23494
|
-
if (
|
|
23495
|
-
const m = matrix2(
|
|
22609
|
+
if (format4) {
|
|
22610
|
+
const m = matrix2(format4);
|
|
23496
22611
|
if (size2.length > 0) {
|
|
23497
22612
|
return m.resize(size2, dflt);
|
|
23498
22613
|
}
|
|
@@ -23564,14 +22679,14 @@ var createDiag = /* @__PURE__ */ factory(
|
|
|
23564
22679
|
"Array, BigNumber": function(x, k) {
|
|
23565
22680
|
return _diag(x, k.toNumber(), arraySize(x), null);
|
|
23566
22681
|
},
|
|
23567
|
-
"Array, string": function(x,
|
|
23568
|
-
return _diag(x, 0, arraySize(x),
|
|
22682
|
+
"Array, string": function(x, format4) {
|
|
22683
|
+
return _diag(x, 0, arraySize(x), format4);
|
|
23569
22684
|
},
|
|
23570
|
-
"Array, number, string": function(x, k,
|
|
23571
|
-
return _diag(x, k, arraySize(x),
|
|
22685
|
+
"Array, number, string": function(x, k, format4) {
|
|
22686
|
+
return _diag(x, k, arraySize(x), format4);
|
|
23572
22687
|
},
|
|
23573
|
-
"Array, BigNumber, string": function(x, k,
|
|
23574
|
-
return _diag(x, k.toNumber(), arraySize(x),
|
|
22688
|
+
"Array, BigNumber, string": function(x, k, format4) {
|
|
22689
|
+
return _diag(x, k.toNumber(), arraySize(x), format4);
|
|
23575
22690
|
},
|
|
23576
22691
|
Matrix: function(x) {
|
|
23577
22692
|
return _diag(x, 0, x.size(), x.storage());
|
|
@@ -23582,17 +22697,17 @@ var createDiag = /* @__PURE__ */ factory(
|
|
|
23582
22697
|
"Matrix, BigNumber": function(x, k) {
|
|
23583
22698
|
return _diag(x, k.toNumber(), x.size(), x.storage());
|
|
23584
22699
|
},
|
|
23585
|
-
"Matrix, string": function(x,
|
|
23586
|
-
return _diag(x, 0, x.size(),
|
|
22700
|
+
"Matrix, string": function(x, format4) {
|
|
22701
|
+
return _diag(x, 0, x.size(), format4);
|
|
23587
22702
|
},
|
|
23588
|
-
"Matrix, number, string": function(x, k,
|
|
23589
|
-
return _diag(x, k, x.size(),
|
|
22703
|
+
"Matrix, number, string": function(x, k, format4) {
|
|
22704
|
+
return _diag(x, k, x.size(), format4);
|
|
23590
22705
|
},
|
|
23591
|
-
"Matrix, BigNumber, string": function(x, k,
|
|
23592
|
-
return _diag(x, k.toNumber(), x.size(),
|
|
22706
|
+
"Matrix, BigNumber, string": function(x, k, format4) {
|
|
22707
|
+
return _diag(x, k.toNumber(), x.size(), format4);
|
|
23593
22708
|
}
|
|
23594
22709
|
});
|
|
23595
|
-
function _diag(x, k, size2,
|
|
22710
|
+
function _diag(x, k, size2, format4) {
|
|
23596
22711
|
if (!isInteger(k)) {
|
|
23597
22712
|
throw new TypeError("Second parameter in function diag must be an integer");
|
|
23598
22713
|
}
|
|
@@ -23600,26 +22715,26 @@ var createDiag = /* @__PURE__ */ factory(
|
|
|
23600
22715
|
const kSub = k < 0 ? -k : 0;
|
|
23601
22716
|
switch (size2.length) {
|
|
23602
22717
|
case 1:
|
|
23603
|
-
return _createDiagonalMatrix(x, k,
|
|
22718
|
+
return _createDiagonalMatrix(x, k, format4, size2[0], kSub, kSuper);
|
|
23604
22719
|
case 2:
|
|
23605
|
-
return _getDiagonal(x, k,
|
|
22720
|
+
return _getDiagonal(x, k, format4, size2, kSub, kSuper);
|
|
23606
22721
|
}
|
|
23607
22722
|
throw new RangeError("Matrix for function diag must be 2 dimensional");
|
|
23608
22723
|
}
|
|
23609
|
-
function _createDiagonalMatrix(x, k,
|
|
22724
|
+
function _createDiagonalMatrix(x, k, format4, l, kSub, kSuper) {
|
|
23610
22725
|
const ms = [l + kSub, l + kSuper];
|
|
23611
|
-
if (
|
|
23612
|
-
throw new TypeError(`Unknown matrix type ${
|
|
22726
|
+
if (format4 && format4 !== "sparse" && format4 !== "dense") {
|
|
22727
|
+
throw new TypeError(`Unknown matrix type ${format4}"`);
|
|
23613
22728
|
}
|
|
23614
|
-
const m =
|
|
23615
|
-
return
|
|
22729
|
+
const m = format4 === "sparse" ? SparseMatrix.diagonal(ms, x, k) : DenseMatrix6.diagonal(ms, x, k);
|
|
22730
|
+
return format4 !== null ? m : m.valueOf();
|
|
23616
22731
|
}
|
|
23617
|
-
function _getDiagonal(x, k,
|
|
22732
|
+
function _getDiagonal(x, k, format4, s, kSub, kSuper) {
|
|
23618
22733
|
if (isMatrix(x)) {
|
|
23619
22734
|
const dm = x.diagonal(k);
|
|
23620
|
-
if (
|
|
23621
|
-
if (
|
|
23622
|
-
return matrix2(dm.valueOf(),
|
|
22735
|
+
if (format4 !== null) {
|
|
22736
|
+
if (format4 !== dm.storage()) {
|
|
22737
|
+
return matrix2(dm.valueOf(), format4);
|
|
23623
22738
|
}
|
|
23624
22739
|
return dm;
|
|
23625
22740
|
}
|
|
@@ -23630,7 +22745,7 @@ var createDiag = /* @__PURE__ */ factory(
|
|
|
23630
22745
|
for (let i = 0; i < n; i++) {
|
|
23631
22746
|
vector[i] = x[i + kSub][i + kSuper];
|
|
23632
22747
|
}
|
|
23633
|
-
return
|
|
22748
|
+
return format4 !== null ? matrix2(vector) : vector;
|
|
23634
22749
|
}
|
|
23635
22750
|
}
|
|
23636
22751
|
);
|
|
@@ -23748,11 +22863,11 @@ var createMatrixFromFunction = /* @__PURE__ */ factory(
|
|
|
23748
22863
|
isZero: isZero2
|
|
23749
22864
|
}) => {
|
|
23750
22865
|
return typed3(name91, {
|
|
23751
|
-
"Array | Matrix, function, string, string": function(size2, fn,
|
|
23752
|
-
return _create(size2, fn,
|
|
22866
|
+
"Array | Matrix, function, string, string": function(size2, fn, format4, datatype) {
|
|
22867
|
+
return _create(size2, fn, format4, datatype);
|
|
23753
22868
|
},
|
|
23754
|
-
"Array | Matrix, function, string": function(size2, fn,
|
|
23755
|
-
return _create(size2, fn,
|
|
22869
|
+
"Array | Matrix, function, string": function(size2, fn, format4) {
|
|
22870
|
+
return _create(size2, fn, format4, void 0);
|
|
23756
22871
|
},
|
|
23757
22872
|
"Matrix, function": function(size2, fn) {
|
|
23758
22873
|
return _create(size2, fn, "dense", void 0);
|
|
@@ -23760,19 +22875,19 @@ var createMatrixFromFunction = /* @__PURE__ */ factory(
|
|
|
23760
22875
|
"Array, function": function(size2, fn) {
|
|
23761
22876
|
return _create(size2, fn, "dense", void 0).toArray();
|
|
23762
22877
|
},
|
|
23763
|
-
"Array | Matrix, string, function": function(size2,
|
|
23764
|
-
return _create(size2, fn,
|
|
22878
|
+
"Array | Matrix, string, function": function(size2, format4, fn) {
|
|
22879
|
+
return _create(size2, fn, format4, void 0);
|
|
23765
22880
|
},
|
|
23766
|
-
"Array | Matrix, string, string, function": function(size2,
|
|
23767
|
-
return _create(size2, fn,
|
|
22881
|
+
"Array | Matrix, string, string, function": function(size2, format4, datatype, fn) {
|
|
22882
|
+
return _create(size2, fn, format4, datatype);
|
|
23768
22883
|
}
|
|
23769
22884
|
});
|
|
23770
|
-
function _create(size2, fn,
|
|
22885
|
+
function _create(size2, fn, format4, datatype) {
|
|
23771
22886
|
let m;
|
|
23772
22887
|
if (datatype !== void 0) {
|
|
23773
|
-
m = matrix2(
|
|
22888
|
+
m = matrix2(format4, datatype);
|
|
23774
22889
|
} else {
|
|
23775
|
-
m = matrix2(
|
|
22890
|
+
m = matrix2(format4);
|
|
23776
22891
|
}
|
|
23777
22892
|
m.resize(size2);
|
|
23778
22893
|
m.forEach(function(_, index) {
|
|
@@ -23958,7 +23073,7 @@ var createTrace = /* @__PURE__ */ factory(
|
|
|
23958
23073
|
if (size2[0] === 1) {
|
|
23959
23074
|
return clone(data[0]);
|
|
23960
23075
|
}
|
|
23961
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23076
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
23962
23077
|
case 2: {
|
|
23963
23078
|
const rows = size2[0];
|
|
23964
23079
|
const cols = size2[1];
|
|
@@ -23969,11 +23084,11 @@ var createTrace = /* @__PURE__ */ factory(
|
|
|
23969
23084
|
}
|
|
23970
23085
|
return sum3;
|
|
23971
23086
|
} else {
|
|
23972
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23087
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
23973
23088
|
}
|
|
23974
23089
|
}
|
|
23975
23090
|
default:
|
|
23976
|
-
throw new RangeError("Matrix must be two dimensional (size: " +
|
|
23091
|
+
throw new RangeError("Matrix must be two dimensional (size: " + formatGeneric(size2, {}) + ")");
|
|
23977
23092
|
}
|
|
23978
23093
|
}
|
|
23979
23094
|
function _sparseTrace(m) {
|
|
@@ -24003,7 +23118,7 @@ var createTrace = /* @__PURE__ */ factory(
|
|
|
24003
23118
|
}
|
|
24004
23119
|
return sum3;
|
|
24005
23120
|
}
|
|
24006
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23121
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
24007
23122
|
}
|
|
24008
23123
|
}
|
|
24009
23124
|
);
|
|
@@ -24070,7 +23185,7 @@ var createDet = /* @__PURE__ */ factory(
|
|
|
24070
23185
|
if (size2[0] === 0) {
|
|
24071
23186
|
return 1;
|
|
24072
23187
|
} else {
|
|
24073
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23188
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
24074
23189
|
}
|
|
24075
23190
|
case 2: {
|
|
24076
23191
|
const rows = size2[0];
|
|
@@ -24081,12 +23196,12 @@ var createDet = /* @__PURE__ */ factory(
|
|
|
24081
23196
|
if (cols === 0) {
|
|
24082
23197
|
return 1;
|
|
24083
23198
|
} else {
|
|
24084
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23199
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
24085
23200
|
}
|
|
24086
23201
|
}
|
|
24087
23202
|
default:
|
|
24088
23203
|
throw new RangeError(
|
|
24089
|
-
"Matrix must be two dimensional (size: " +
|
|
23204
|
+
"Matrix must be two dimensional (size: " + formatGeneric(size2, {}) + ")"
|
|
24090
23205
|
);
|
|
24091
23206
|
}
|
|
24092
23207
|
}
|
|
@@ -24416,14 +23531,14 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24416
23531
|
const degree2 = 5 * (n + 1);
|
|
24417
23532
|
const w = 6 * (n + 1);
|
|
24418
23533
|
const hhead = 7 * (n + 1);
|
|
24419
|
-
const
|
|
23534
|
+
const last2 = P2;
|
|
24420
23535
|
let mark = _initializeQuotientGraph(
|
|
24421
23536
|
n,
|
|
24422
23537
|
cptr,
|
|
24423
23538
|
W,
|
|
24424
23539
|
len,
|
|
24425
23540
|
head,
|
|
24426
|
-
|
|
23541
|
+
last2,
|
|
24427
23542
|
next,
|
|
24428
23543
|
hhead,
|
|
24429
23544
|
nv,
|
|
@@ -24431,13 +23546,13 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24431
23546
|
elen,
|
|
24432
23547
|
degree2
|
|
24433
23548
|
);
|
|
24434
|
-
let nel = _initializeDegreeLists(n, cptr, W, degree2, elen, w, dense, nv, head,
|
|
23549
|
+
let nel = _initializeDegreeLists(n, cptr, W, degree2, elen, w, dense, nv, head, last2, next);
|
|
24435
23550
|
let mindeg = 0;
|
|
24436
23551
|
let i, j, k, k1, k2, e, pj, ln, nvi, pk, eln, p1, p2, pn, h, d;
|
|
24437
23552
|
while (nel < n) {
|
|
24438
23553
|
for (k = -1; mindeg < n && (k = W[head + mindeg]) === -1; mindeg++) ;
|
|
24439
23554
|
if (W[next + k] !== -1) {
|
|
24440
|
-
|
|
23555
|
+
last2[W[next + k]] = -1;
|
|
24441
23556
|
}
|
|
24442
23557
|
W[head + mindeg] = W[next + k];
|
|
24443
23558
|
const elenk = W[elen + k];
|
|
@@ -24467,10 +23582,10 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24467
23582
|
W[nv + i] = -nvi;
|
|
24468
23583
|
cindex[pk2++] = i;
|
|
24469
23584
|
if (W[next + i] !== -1) {
|
|
24470
|
-
|
|
23585
|
+
last2[W[next + i]] = last2[i];
|
|
24471
23586
|
}
|
|
24472
|
-
if (
|
|
24473
|
-
W[next +
|
|
23587
|
+
if (last2[i] !== -1) {
|
|
23588
|
+
W[next + last2[i]] = W[next + i];
|
|
24474
23589
|
} else {
|
|
24475
23590
|
W[head + W[degree2 + i]] = W[next + i];
|
|
24476
23591
|
}
|
|
@@ -24553,7 +23668,7 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24553
23668
|
h = (h < 0 ? -h : h) % n;
|
|
24554
23669
|
W[next + i] = W[hhead + h];
|
|
24555
23670
|
W[hhead + h] = i;
|
|
24556
|
-
|
|
23671
|
+
last2[i] = h;
|
|
24557
23672
|
}
|
|
24558
23673
|
}
|
|
24559
23674
|
W[degree2 + k] = dk;
|
|
@@ -24564,7 +23679,7 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24564
23679
|
if (W[nv + i] >= 0) {
|
|
24565
23680
|
continue;
|
|
24566
23681
|
}
|
|
24567
|
-
h =
|
|
23682
|
+
h = last2[i];
|
|
24568
23683
|
i = W[hhead + h];
|
|
24569
23684
|
W[hhead + h] = -1;
|
|
24570
23685
|
for (; i !== -1 && W[next + i] !== -1; i = W[next + i], mark++) {
|
|
@@ -24604,10 +23719,10 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24604
23719
|
d = W[degree2 + i] + dk - nvi;
|
|
24605
23720
|
d = Math.min(d, n - nel - nvi);
|
|
24606
23721
|
if (W[head + d] !== -1) {
|
|
24607
|
-
|
|
23722
|
+
last2[W[head + d]] = i;
|
|
24608
23723
|
}
|
|
24609
23724
|
W[next + i] = W[head + d];
|
|
24610
|
-
|
|
23725
|
+
last2[i] = -1;
|
|
24611
23726
|
W[head + d] = i;
|
|
24612
23727
|
mindeg = Math.min(mindeg, d);
|
|
24613
23728
|
W[degree2 + i] = d;
|
|
@@ -24677,14 +23792,14 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24677
23792
|
}
|
|
24678
23793
|
return multiply2(at, a);
|
|
24679
23794
|
}
|
|
24680
|
-
function _initializeQuotientGraph(n, cptr, W, len, head,
|
|
23795
|
+
function _initializeQuotientGraph(n, cptr, W, len, head, last2, next, hhead, nv, w, elen, degree2) {
|
|
24681
23796
|
for (let k = 0; k < n; k++) {
|
|
24682
23797
|
W[len + k] = cptr[k + 1] - cptr[k];
|
|
24683
23798
|
}
|
|
24684
23799
|
W[len + n] = 0;
|
|
24685
23800
|
for (let i = 0; i <= n; i++) {
|
|
24686
23801
|
W[head + i] = -1;
|
|
24687
|
-
|
|
23802
|
+
last2[i] = -1;
|
|
24688
23803
|
W[next + i] = -1;
|
|
24689
23804
|
W[hhead + i] = -1;
|
|
24690
23805
|
W[nv + i] = 1;
|
|
@@ -24698,7 +23813,7 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24698
23813
|
W[w + n] = 0;
|
|
24699
23814
|
return mark;
|
|
24700
23815
|
}
|
|
24701
|
-
function _initializeDegreeLists(n, cptr, W, degree2, elen, w, dense, nv, head,
|
|
23816
|
+
function _initializeDegreeLists(n, cptr, W, degree2, elen, w, dense, nv, head, last2, next) {
|
|
24702
23817
|
let nel = 0;
|
|
24703
23818
|
for (let i = 0; i < n; i++) {
|
|
24704
23819
|
const d = W[degree2 + i];
|
|
@@ -24716,7 +23831,7 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24716
23831
|
} else {
|
|
24717
23832
|
const h = W[head + d];
|
|
24718
23833
|
if (h !== -1) {
|
|
24719
|
-
|
|
23834
|
+
last2[h] = i;
|
|
24720
23835
|
}
|
|
24721
23836
|
W[next + i] = W[head + d];
|
|
24722
23837
|
W[head + d] = i;
|
|
@@ -25186,12 +24301,12 @@ function createSolveValidation({ DenseMatrix: DenseMatrix6 }) {
|
|
|
25186
24301
|
return function solveValidation(m, b, copy) {
|
|
25187
24302
|
const mSize = m.size();
|
|
25188
24303
|
if (mSize.length !== 2) {
|
|
25189
|
-
throw new RangeError("Matrix must be two dimensional (size: " +
|
|
24304
|
+
throw new RangeError("Matrix must be two dimensional (size: " + formatGeneric(mSize, {}) + ")");
|
|
25190
24305
|
}
|
|
25191
24306
|
const rows = mSize[0];
|
|
25192
24307
|
const columns = mSize[1];
|
|
25193
24308
|
if (rows !== columns) {
|
|
25194
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
24309
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(mSize, {}) + ")");
|
|
25195
24310
|
}
|
|
25196
24311
|
let data = [];
|
|
25197
24312
|
if (isMatrix(b)) {
|
|
@@ -26354,7 +25469,7 @@ var createRound = /* @__PURE__ */ factory(
|
|
|
26354
25469
|
),
|
|
26355
25470
|
"Array | Matrix, number | BigNumber, Unit": typed3.referToSelf(
|
|
26356
25471
|
(self) => (x, n, unit2) => {
|
|
26357
|
-
return
|
|
25472
|
+
return deepMap(x, (value) => self(value, n, unit2), true);
|
|
26358
25473
|
}
|
|
26359
25474
|
),
|
|
26360
25475
|
"Array | Matrix | Unit, Unit": typed3.referToSelf(
|
|
@@ -26362,7 +25477,7 @@ var createRound = /* @__PURE__ */ factory(
|
|
|
26362
25477
|
),
|
|
26363
25478
|
"Array | Matrix": typed3.referToSelf(
|
|
26364
25479
|
(self) => (x) => {
|
|
26365
|
-
return
|
|
25480
|
+
return deepMap(x, self, true);
|
|
26366
25481
|
}
|
|
26367
25482
|
),
|
|
26368
25483
|
"SparseMatrix, number | BigNumber": typed3.referToSelf(
|
|
@@ -26536,6 +25651,12 @@ var createCatalan = /* @__PURE__ */ factory(
|
|
|
26536
25651
|
}
|
|
26537
25652
|
);
|
|
26538
25653
|
|
|
25654
|
+
// src/error/IndexError.ts
|
|
25655
|
+
import { IndexError, createIndexError } from "@danielsimonjr/mathts-core/internal";
|
|
25656
|
+
|
|
25657
|
+
// src/error/DimensionError.ts
|
|
25658
|
+
import { DimensionError } from "@danielsimonjr/mathts-core/internal";
|
|
25659
|
+
|
|
26539
25660
|
// src/matrix/concat.ts
|
|
26540
25661
|
var name115 = "concat";
|
|
26541
25662
|
var dependencies115 = ["typed", "matrix", "isInteger"];
|
|
@@ -26657,7 +25778,7 @@ var createInv = /* @__PURE__ */ factory(
|
|
|
26657
25778
|
return [divideScalar2(1, x[0])];
|
|
26658
25779
|
}
|
|
26659
25780
|
} else {
|
|
26660
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
25781
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
26661
25782
|
}
|
|
26662
25783
|
case 2: {
|
|
26663
25784
|
const rows = size2[0];
|
|
@@ -26671,12 +25792,12 @@ var createInv = /* @__PURE__ */ factory(
|
|
|
26671
25792
|
return _inv4(x, rows, cols);
|
|
26672
25793
|
}
|
|
26673
25794
|
} else {
|
|
26674
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
25795
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
26675
25796
|
}
|
|
26676
25797
|
}
|
|
26677
25798
|
default:
|
|
26678
25799
|
throw new RangeError(
|
|
26679
|
-
"Matrix must be two dimensional (size: " +
|
|
25800
|
+
"Matrix must be two dimensional (size: " + formatGeneric(size2, {}) + ")"
|
|
26680
25801
|
);
|
|
26681
25802
|
}
|
|
26682
25803
|
},
|
|
@@ -26833,7 +25954,7 @@ function _mapSlices(mat, dim, callback) {
|
|
|
26833
25954
|
if (!Array.isArray(mat[0])) {
|
|
26834
25955
|
return callback(mat);
|
|
26835
25956
|
} else {
|
|
26836
|
-
tran =
|
|
25957
|
+
tran = _switch(mat);
|
|
26837
25958
|
ret = [];
|
|
26838
25959
|
for (i = 0; i < tran.length; i++) {
|
|
26839
25960
|
ret[i] = _mapSlices(tran[i], dim - 1, callback);
|
|
@@ -26848,7 +25969,7 @@ function _mapSlices(mat, dim, callback) {
|
|
|
26848
25969
|
return ret;
|
|
26849
25970
|
}
|
|
26850
25971
|
}
|
|
26851
|
-
function
|
|
25972
|
+
function _switch(mat) {
|
|
26852
25973
|
const I2 = mat.length;
|
|
26853
25974
|
const J = mat[0].length;
|
|
26854
25975
|
let i, j;
|
|
@@ -26872,13 +25993,13 @@ var createResize = /* @__PURE__ */ factory(
|
|
|
26872
25993
|
({ typed: typed3, config: config2, matrix: matrix2 }) => {
|
|
26873
25994
|
return typed3(name118, {
|
|
26874
25995
|
"any, Array | Matrix": function(x, size2) {
|
|
26875
|
-
return
|
|
25996
|
+
return _resize(x, size2);
|
|
26876
25997
|
},
|
|
26877
25998
|
"any, Array | Matrix, any": function(x, size2, defaultValue) {
|
|
26878
|
-
return
|
|
25999
|
+
return _resize(x, size2, defaultValue);
|
|
26879
26000
|
}
|
|
26880
26001
|
});
|
|
26881
|
-
function
|
|
26002
|
+
function _resize(x, size2, defaultValue) {
|
|
26882
26003
|
let sz = isMatrix(size2) ? size2.valueOf() : size2;
|
|
26883
26004
|
if (isBigNumber(sz[0])) {
|
|
26884
26005
|
sz = sz.map(function(value) {
|
|
@@ -26919,7 +26040,7 @@ var createResize = /* @__PURE__ */ factory(
|
|
|
26919
26040
|
const len = size2[0];
|
|
26920
26041
|
if (typeof len !== "number" || !isInteger(len)) {
|
|
26921
26042
|
throw new TypeError(
|
|
26922
|
-
"Invalid size, must contain positive integers (size: " +
|
|
26043
|
+
"Invalid size, must contain positive integers (size: " + formatGeneric(size2, {}) + ")"
|
|
26923
26044
|
);
|
|
26924
26045
|
}
|
|
26925
26046
|
if (str.length > len) {
|
|
@@ -27731,7 +26852,7 @@ var createIsInteger = /* @__PURE__ */ factory(
|
|
|
27731
26852
|
bigint: (_b) => true,
|
|
27732
26853
|
Fraction: (r) => r.d === 1n,
|
|
27733
26854
|
"Array | Matrix": typed3.referToSelf(
|
|
27734
|
-
(self) => (x) =>
|
|
26855
|
+
(self) => (x) => deepMap(x, self)
|
|
27735
26856
|
)
|
|
27736
26857
|
});
|
|
27737
26858
|
}
|
|
@@ -27797,6 +26918,23 @@ var createZpk2tf = /* @__PURE__ */ factory(
|
|
|
27797
26918
|
}
|
|
27798
26919
|
);
|
|
27799
26920
|
|
|
26921
|
+
// src/utils/switch.ts
|
|
26922
|
+
function _switch2(mat) {
|
|
26923
|
+
const rows = mat;
|
|
26924
|
+
const I2 = rows.length;
|
|
26925
|
+
const J = rows[0].length;
|
|
26926
|
+
let i, j;
|
|
26927
|
+
const ret = [];
|
|
26928
|
+
for (j = 0; j < J; j++) {
|
|
26929
|
+
const tmp = [];
|
|
26930
|
+
for (i = 0; i < I2; i++) {
|
|
26931
|
+
tmp.push(rows[i][j]);
|
|
26932
|
+
}
|
|
26933
|
+
ret.push(tmp);
|
|
26934
|
+
}
|
|
26935
|
+
return ret;
|
|
26936
|
+
}
|
|
26937
|
+
|
|
27800
26938
|
// src/statistics/cumsum.ts
|
|
27801
26939
|
import { neumaierCumsum as neumaierCumsum2 } from "@danielsimonjr/mathts-core";
|
|
27802
26940
|
function isFlatNumberArray2(arr10) {
|
|
@@ -27878,7 +27016,7 @@ var createCumSum = /* @__PURE__ */ factory(
|
|
|
27878
27016
|
if (!Array.isArray(initialValue)) {
|
|
27879
27017
|
return _cumsummap(mat);
|
|
27880
27018
|
} else {
|
|
27881
|
-
tran =
|
|
27019
|
+
tran = _switch2(mat);
|
|
27882
27020
|
ret = [];
|
|
27883
27021
|
for (i = 0; i < tran.length; i++) {
|
|
27884
27022
|
ret[i] = _cumsumDimensional(tran[i], dim - 1);
|
|
@@ -27934,7 +27072,7 @@ var createSum = /* @__PURE__ */ factory(
|
|
|
27934
27072
|
return pairwiseSum2(array);
|
|
27935
27073
|
}
|
|
27936
27074
|
let sum3;
|
|
27937
|
-
|
|
27075
|
+
deepForEach(array, function(value) {
|
|
27938
27076
|
try {
|
|
27939
27077
|
const converted = typeof value === "string" ? parseNumberWithConfig2(value) : value;
|
|
27940
27078
|
sum3 = sum3 === void 0 ? converted : add4(sum3, converted);
|
|
@@ -28275,7 +27413,7 @@ var createFloor = /* @__PURE__ */ factory(
|
|
|
28275
27413
|
),
|
|
28276
27414
|
"Array | Matrix, number | BigNumber, Unit": typed3.referToSelf(
|
|
28277
27415
|
(self) => (x, n, unit2) => {
|
|
28278
|
-
return
|
|
27416
|
+
return deepMap(x, (value) => self(value, n, unit2), true);
|
|
28279
27417
|
}
|
|
28280
27418
|
),
|
|
28281
27419
|
"Array | Matrix | Unit, Unit": typed3.referToSelf(
|
|
@@ -28283,12 +27421,12 @@ var createFloor = /* @__PURE__ */ factory(
|
|
|
28283
27421
|
),
|
|
28284
27422
|
"Array | Matrix": typed3.referToSelf(
|
|
28285
27423
|
(self) => (x) => {
|
|
28286
|
-
return
|
|
27424
|
+
return deepMap(x, self, true);
|
|
28287
27425
|
}
|
|
28288
27426
|
),
|
|
28289
27427
|
"Array, number | BigNumber": typed3.referToSelf(
|
|
28290
27428
|
(self) => (x, n) => {
|
|
28291
|
-
return
|
|
27429
|
+
return deepMap(x, (i) => self(i, n), true);
|
|
28292
27430
|
}
|
|
28293
27431
|
),
|
|
28294
27432
|
"SparseMatrix, number | BigNumber": typed3.referToSelf(
|
|
@@ -29020,7 +28158,7 @@ var createLog1p = /* @__PURE__ */ factory(
|
|
|
29020
28158
|
}
|
|
29021
28159
|
},
|
|
29022
28160
|
"Array | Matrix": typed3.referToSelf(
|
|
29023
|
-
(self) => (x) =>
|
|
28161
|
+
(self) => (x) => deepMap(x, self)
|
|
29024
28162
|
),
|
|
29025
28163
|
"any, any": typed3.referToSelf(
|
|
29026
28164
|
(self) => (x, base) => {
|
|
@@ -29376,7 +28514,7 @@ var createCeil = /* @__PURE__ */ factory(
|
|
|
29376
28514
|
),
|
|
29377
28515
|
"Array | Matrix, number | BigNumber, Unit": typed3.referToSelf(
|
|
29378
28516
|
(self) => (x, n, unit2) => {
|
|
29379
|
-
return
|
|
28517
|
+
return deepMap(x, (value) => self(value, n, unit2), true);
|
|
29380
28518
|
}
|
|
29381
28519
|
),
|
|
29382
28520
|
"Array | Matrix | Unit, Unit": typed3.referToSelf(
|
|
@@ -29384,12 +28522,12 @@ var createCeil = /* @__PURE__ */ factory(
|
|
|
29384
28522
|
),
|
|
29385
28523
|
"Array | Matrix": typed3.referToSelf(
|
|
29386
28524
|
(self) => (x) => {
|
|
29387
|
-
return
|
|
28525
|
+
return deepMap(x, self, true);
|
|
29388
28526
|
}
|
|
29389
28527
|
),
|
|
29390
28528
|
"Array, number | BigNumber": typed3.referToSelf(
|
|
29391
28529
|
(self) => (x, n) => {
|
|
29392
|
-
return
|
|
28530
|
+
return deepMap(x, (i) => self(i, n), true);
|
|
29393
28531
|
}
|
|
29394
28532
|
),
|
|
29395
28533
|
"SparseMatrix, number | BigNumber": typed3.referToSelf(
|
|
@@ -30565,7 +29703,7 @@ var createFix = /* @__PURE__ */ factory(
|
|
|
30565
29703
|
),
|
|
30566
29704
|
"Array | Matrix, number | BigNumber, Unit": typed3.referToSelf(
|
|
30567
29705
|
(self) => (x, n, unit2) => {
|
|
30568
|
-
return
|
|
29706
|
+
return deepMap(x, (value) => self(value, n, unit2), true);
|
|
30569
29707
|
}
|
|
30570
29708
|
),
|
|
30571
29709
|
"Array | Matrix | Unit, Unit": typed3.referToSelf(
|
|
@@ -30573,12 +29711,12 @@ var createFix = /* @__PURE__ */ factory(
|
|
|
30573
29711
|
),
|
|
30574
29712
|
"Array | Matrix": typed3.referToSelf(
|
|
30575
29713
|
(self) => (x) => {
|
|
30576
|
-
return
|
|
29714
|
+
return deepMap(x, self, true);
|
|
30577
29715
|
}
|
|
30578
29716
|
),
|
|
30579
29717
|
"Array | Matrix, number | BigNumber": typed3.referToSelf(
|
|
30580
29718
|
(self) => (x, n) => {
|
|
30581
|
-
return
|
|
29719
|
+
return deepMap(x, (i) => self(i, n), true);
|
|
30582
29720
|
}
|
|
30583
29721
|
),
|
|
30584
29722
|
"number | Complex | Fraction | BigNumber, Array": typed3.referToSelf(
|
|
@@ -30930,7 +30068,7 @@ var createPinv = /* @__PURE__ */ factory(
|
|
|
30930
30068
|
}
|
|
30931
30069
|
default:
|
|
30932
30070
|
throw new RangeError(
|
|
30933
|
-
"Matrix must be two dimensional (size: " +
|
|
30071
|
+
"Matrix must be two dimensional (size: " + formatGeneric(size2, {}) + ")"
|
|
30934
30072
|
);
|
|
30935
30073
|
}
|
|
30936
30074
|
},
|
|
@@ -31664,7 +30802,7 @@ var createMax = /* @__PURE__ */ factory(
|
|
|
31664
30802
|
}
|
|
31665
30803
|
}
|
|
31666
30804
|
let res;
|
|
31667
|
-
|
|
30805
|
+
deepForEach(array, function(value) {
|
|
31668
30806
|
try {
|
|
31669
30807
|
if (mathIsNaN(value)) {
|
|
31670
30808
|
res = value;
|
|
@@ -31743,7 +30881,7 @@ var createMin = /* @__PURE__ */ factory(
|
|
|
31743
30881
|
}
|
|
31744
30882
|
}
|
|
31745
30883
|
let min2;
|
|
31746
|
-
|
|
30884
|
+
deepForEach(array, function(value) {
|
|
31747
30885
|
try {
|
|
31748
30886
|
if (mathIsNaN(value)) {
|
|
31749
30887
|
min2 = value;
|
|
@@ -32275,7 +31413,7 @@ var createFactorial = /* @__PURE__ */ factory(
|
|
|
32275
31413
|
return gamma2(n.add(1));
|
|
32276
31414
|
},
|
|
32277
31415
|
"Array | Matrix": typed3.referToSelf(
|
|
32278
|
-
(self) => (n) =>
|
|
31416
|
+
(self) => (n) => deepMap(n, self)
|
|
32279
31417
|
)
|
|
32280
31418
|
});
|
|
32281
31419
|
}
|
|
@@ -32646,93 +31784,14 @@ var createLeafCount = /* @__PURE__ */ factory(
|
|
|
32646
31784
|
);
|
|
32647
31785
|
|
|
32648
31786
|
// src/utils/map.ts
|
|
32649
|
-
|
|
32650
|
-
|
|
32651
|
-
|
|
32652
|
-
|
|
32653
|
-
|
|
32654
|
-
|
|
32655
|
-
|
|
32656
|
-
|
|
32657
|
-
* cast. The old form satisfied the runtime but never appeared in the emitted
|
|
32658
|
-
* type, so `implements Map<K, V>` was a lie that only surfaced downstream:
|
|
32659
|
-
* consumers compiling with `skipLibCheck: false` got TS2420 ("incorrectly
|
|
32660
|
-
* implements interface 'Map'... '[Symbol.iterator]' is missing").
|
|
32661
|
-
*/
|
|
32662
|
-
[Symbol.iterator]() {
|
|
32663
|
-
return this.entries();
|
|
32664
|
-
}
|
|
32665
|
-
// @ts-expect-error: Implementation is compatible but TS can't infer it
|
|
32666
|
-
keys() {
|
|
32667
|
-
return Object.keys(this.wrappedObject).filter((key) => this.has(key)).values();
|
|
32668
|
-
}
|
|
32669
|
-
get(key) {
|
|
32670
|
-
return getSafeProperty(this.wrappedObject, key);
|
|
32671
|
-
}
|
|
32672
|
-
set(key, value) {
|
|
32673
|
-
setSafeProperty(this.wrappedObject, key, value);
|
|
32674
|
-
return this;
|
|
32675
|
-
}
|
|
32676
|
-
has(key) {
|
|
32677
|
-
return isSafeProperty(this.wrappedObject, key) && key in this.wrappedObject;
|
|
32678
|
-
}
|
|
32679
|
-
// @ts-expect-error: Implementation is compatible but TS can't infer it
|
|
32680
|
-
entries() {
|
|
32681
|
-
return mapIterator(this.keys(), (key) => [key, this.get(key)]);
|
|
32682
|
-
}
|
|
32683
|
-
// @ts-expect-error: Implementation is compatible but TS can't infer it
|
|
32684
|
-
*values() {
|
|
32685
|
-
for (const key of this.keys()) {
|
|
32686
|
-
yield this.get(key);
|
|
32687
|
-
}
|
|
32688
|
-
}
|
|
32689
|
-
forEach(callback) {
|
|
32690
|
-
for (const key of this.keys()) {
|
|
32691
|
-
callback(this.get(key), key, this);
|
|
32692
|
-
}
|
|
32693
|
-
}
|
|
32694
|
-
delete(key) {
|
|
32695
|
-
if (isSafeProperty(this.wrappedObject, key)) {
|
|
32696
|
-
delete this.wrappedObject[key];
|
|
32697
|
-
return true;
|
|
32698
|
-
}
|
|
32699
|
-
return false;
|
|
32700
|
-
}
|
|
32701
|
-
clear() {
|
|
32702
|
-
for (const key of this.keys()) {
|
|
32703
|
-
this.delete(key);
|
|
32704
|
-
}
|
|
32705
|
-
}
|
|
32706
|
-
get size() {
|
|
32707
|
-
return Object.keys(this.wrappedObject).length;
|
|
32708
|
-
}
|
|
32709
|
-
};
|
|
32710
|
-
function mapIterator(it, callback) {
|
|
32711
|
-
return {
|
|
32712
|
-
next: () => {
|
|
32713
|
-
const n = it.next();
|
|
32714
|
-
return n.done ? n : {
|
|
32715
|
-
value: callback(n.value),
|
|
32716
|
-
done: false
|
|
32717
|
-
};
|
|
32718
|
-
}
|
|
32719
|
-
};
|
|
32720
|
-
}
|
|
32721
|
-
function createEmptyMap() {
|
|
32722
|
-
return /* @__PURE__ */ new Map();
|
|
32723
|
-
}
|
|
32724
|
-
function createMap2(mapOrObject) {
|
|
32725
|
-
if (!mapOrObject) {
|
|
32726
|
-
return createEmptyMap();
|
|
32727
|
-
}
|
|
32728
|
-
if (isMap(mapOrObject)) {
|
|
32729
|
-
return mapOrObject;
|
|
32730
|
-
}
|
|
32731
|
-
if (isObject(mapOrObject)) {
|
|
32732
|
-
return new ObjectWrappingMap(mapOrObject);
|
|
32733
|
-
}
|
|
32734
|
-
throw new Error("createMap can create maps from objects or Maps");
|
|
32735
|
-
}
|
|
31787
|
+
import {
|
|
31788
|
+
ObjectWrappingMap,
|
|
31789
|
+
PartitionedMap,
|
|
31790
|
+
createEmptyMap,
|
|
31791
|
+
createMap as createMap2,
|
|
31792
|
+
assignMap,
|
|
31793
|
+
isObjectWrappingMap
|
|
31794
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
32736
31795
|
|
|
32737
31796
|
// src/algebra/resolve.ts
|
|
32738
31797
|
var name192 = "resolve";
|
|
@@ -33259,15 +32318,15 @@ var createSimplifyConstant = /* @__PURE__ */ factory(
|
|
|
33259
32318
|
const reduction = args.reduce(
|
|
33260
32319
|
(sofar, next) => {
|
|
33261
32320
|
if (!isNode(next)) {
|
|
33262
|
-
const
|
|
33263
|
-
if (isNode(
|
|
33264
|
-
return [
|
|
32321
|
+
const last2 = sofar.pop();
|
|
32322
|
+
if (isNode(last2)) {
|
|
32323
|
+
return [last2, next];
|
|
33265
32324
|
}
|
|
33266
32325
|
try {
|
|
33267
|
-
sofar.push(_eval(fn, [
|
|
32326
|
+
sofar.push(_eval(fn, [last2, next], options));
|
|
33268
32327
|
return sofar;
|
|
33269
32328
|
} catch {
|
|
33270
|
-
sofar.push(
|
|
32329
|
+
sofar.push(last2);
|
|
33271
32330
|
}
|
|
33272
32331
|
}
|
|
33273
32332
|
sofar.push(_ensureNode(sofar.pop()));
|
|
@@ -33650,7 +32709,7 @@ var createChainClass = /* @__PURE__ */ factory(
|
|
|
33650
32709
|
return this.value;
|
|
33651
32710
|
};
|
|
33652
32711
|
Chain2.prototype.toString = function() {
|
|
33653
|
-
return
|
|
32712
|
+
return formatGeneric(this.value, {});
|
|
33654
32713
|
};
|
|
33655
32714
|
Chain2.prototype.toJSON = function() {
|
|
33656
32715
|
return {
|
|
@@ -33974,7 +33033,7 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
33974
33033
|
matrix2._size = [arg3.length];
|
|
33975
33034
|
return matrix2;
|
|
33976
33035
|
}
|
|
33977
|
-
class
|
|
33036
|
+
class Index {
|
|
33978
33037
|
/**
|
|
33979
33038
|
* Type identifier
|
|
33980
33039
|
*/
|
|
@@ -33999,7 +33058,7 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
33999
33058
|
*/
|
|
34000
33059
|
_isScalar;
|
|
34001
33060
|
constructor(...ranges) {
|
|
34002
|
-
if (!(this instanceof
|
|
33061
|
+
if (!(this instanceof Index)) {
|
|
34003
33062
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
34004
33063
|
}
|
|
34005
33064
|
this._dimensions = [];
|
|
@@ -34049,7 +33108,7 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
34049
33108
|
* @return {Index} clone
|
|
34050
33109
|
*/
|
|
34051
33110
|
clone() {
|
|
34052
|
-
const index = new
|
|
33111
|
+
const index = new Index();
|
|
34053
33112
|
index._dimensions = clone(this._dimensions);
|
|
34054
33113
|
index._isScalar = this._isScalar;
|
|
34055
33114
|
index._sourceSize = this._sourceSize;
|
|
@@ -34063,7 +33122,7 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
34063
33122
|
* @private
|
|
34064
33123
|
*/
|
|
34065
33124
|
static create(ranges) {
|
|
34066
|
-
return new
|
|
33125
|
+
return new Index(...ranges);
|
|
34067
33126
|
}
|
|
34068
33127
|
/**
|
|
34069
33128
|
* Retrieve the size of the index, the number of elements for each dimension.
|
|
@@ -34216,13 +33275,13 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
34216
33275
|
* @return {Index}
|
|
34217
33276
|
*/
|
|
34218
33277
|
static fromJSON(json) {
|
|
34219
|
-
return
|
|
33278
|
+
return Index.create(json.dimensions);
|
|
34220
33279
|
}
|
|
34221
33280
|
}
|
|
34222
|
-
const indexProto =
|
|
33281
|
+
const indexProto = Index.prototype;
|
|
34223
33282
|
indexProto.type = "Index";
|
|
34224
33283
|
indexProto.isIndex = true;
|
|
34225
|
-
return
|
|
33284
|
+
return Index;
|
|
34226
33285
|
},
|
|
34227
33286
|
{ isClass: true }
|
|
34228
33287
|
);
|
|
@@ -34319,7 +33378,7 @@ var createUnitFunction = /* @__PURE__ */ factory(
|
|
|
34319
33378
|
return new Unit2(value);
|
|
34320
33379
|
},
|
|
34321
33380
|
"Array | Matrix": typed3.referToSelf(
|
|
34322
|
-
(self) => (x) =>
|
|
33381
|
+
(self) => (x) => deepMap(x, self)
|
|
34323
33382
|
)
|
|
34324
33383
|
});
|
|
34325
33384
|
}
|
|
@@ -34806,7 +33865,7 @@ var dependencies207 = ["typed", "Index", "matrix", "range"];
|
|
|
34806
33865
|
var createColumn = /* @__PURE__ */ factory(
|
|
34807
33866
|
name207,
|
|
34808
33867
|
dependencies207,
|
|
34809
|
-
({ typed: typed3, Index
|
|
33868
|
+
({ typed: typed3, Index, matrix: matrix2, range: range2 }) => {
|
|
34810
33869
|
return typed3(name207, {
|
|
34811
33870
|
"Matrix, number": _column,
|
|
34812
33871
|
"Array, number": function(value, column2) {
|
|
@@ -34819,7 +33878,7 @@ var createColumn = /* @__PURE__ */ factory(
|
|
|
34819
33878
|
}
|
|
34820
33879
|
validateIndex(column2, value.size()[1]);
|
|
34821
33880
|
const rowRange = range2(0, value.size()[0]);
|
|
34822
|
-
const index = new
|
|
33881
|
+
const index = new Index(rowRange, [column2]);
|
|
34823
33882
|
const result = value.subset(index);
|
|
34824
33883
|
return isMatrix(result) ? result : matrix2([[result]]);
|
|
34825
33884
|
}
|
|
@@ -34832,7 +33891,7 @@ var dependencies208 = ["typed", "Index", "matrix", "range"];
|
|
|
34832
33891
|
var createRow = /* @__PURE__ */ factory(
|
|
34833
33892
|
name208,
|
|
34834
33893
|
dependencies208,
|
|
34835
|
-
({ typed: typed3, Index
|
|
33894
|
+
({ typed: typed3, Index, matrix: matrix2, range: range2 }) => {
|
|
34836
33895
|
return typed3(name208, {
|
|
34837
33896
|
"Matrix, number": _row,
|
|
34838
33897
|
"Array, number": function(value, row2) {
|
|
@@ -34845,7 +33904,7 @@ var createRow = /* @__PURE__ */ factory(
|
|
|
34845
33904
|
}
|
|
34846
33905
|
validateIndex(row2, value.size()[0]);
|
|
34847
33906
|
const columnRange = range2(0, value.size()[1]);
|
|
34848
|
-
const index = new
|
|
33907
|
+
const index = new Index([row2], columnRange);
|
|
34849
33908
|
const result = value.subset(index);
|
|
34850
33909
|
return isMatrix(result) ? result : matrix2([[result]]);
|
|
34851
33910
|
}
|
|
@@ -34887,15 +33946,15 @@ var createCross = /* @__PURE__ */ factory(
|
|
|
34887
33946
|
"Vectors with length 3 expected (Size A = [" + xSize.join(", ") + "], B = [" + ySize.join(", ") + "])"
|
|
34888
33947
|
);
|
|
34889
33948
|
}
|
|
34890
|
-
const
|
|
33949
|
+
const product2 = [
|
|
34891
33950
|
subtract3(multiply2(x[1], y[2]), multiply2(x[2], y[1])),
|
|
34892
33951
|
subtract3(multiply2(x[2], y[0]), multiply2(x[0], y[2])),
|
|
34893
33952
|
subtract3(multiply2(x[0], y[1]), multiply2(x[1], y[0]))
|
|
34894
33953
|
];
|
|
34895
33954
|
if (highestDimension > 1) {
|
|
34896
|
-
return [
|
|
33955
|
+
return [product2];
|
|
34897
33956
|
} else {
|
|
34898
|
-
return
|
|
33957
|
+
return product2;
|
|
34899
33958
|
}
|
|
34900
33959
|
}
|
|
34901
33960
|
}
|
|
@@ -35008,7 +34067,7 @@ var dependencies211 = [
|
|
|
35008
34067
|
var createSqrtm = /* @__PURE__ */ factory(
|
|
35009
34068
|
name211,
|
|
35010
34069
|
dependencies211,
|
|
35011
|
-
({ typed: typed3, abs: abs2, add: add4, multiply: multiply2, map:
|
|
34070
|
+
({ typed: typed3, abs: abs2, add: add4, multiply: multiply2, map: map3, sqrt: sqrt2, subtract: subtract3, inv: inv3, size: size2, max: max2, identity: identity2 }) => {
|
|
35012
34071
|
const _maxIterations = 1e3;
|
|
35013
34072
|
const _tolerance = 1e-6;
|
|
35014
34073
|
function _tryWasmSqrtm(A, n) {
|
|
@@ -35089,10 +34148,10 @@ var createSqrtm = /* @__PURE__ */ factory(
|
|
|
35089
34148
|
switch (sizeArray.length) {
|
|
35090
34149
|
case 1:
|
|
35091
34150
|
if (sizeArray[0] === 1) {
|
|
35092
|
-
return
|
|
34151
|
+
return map3(A, sqrt2);
|
|
35093
34152
|
} else {
|
|
35094
34153
|
throw new RangeError(
|
|
35095
|
-
"Matrix must be square (size: " +
|
|
34154
|
+
"Matrix must be square (size: " + formatGeneric(sizeArray, {}) + ")"
|
|
35096
34155
|
);
|
|
35097
34156
|
}
|
|
35098
34157
|
case 2: {
|
|
@@ -35104,13 +34163,13 @@ var createSqrtm = /* @__PURE__ */ factory(
|
|
|
35104
34163
|
return _denmanBeavers(A);
|
|
35105
34164
|
} else {
|
|
35106
34165
|
throw new RangeError(
|
|
35107
|
-
"Matrix must be square (size: " +
|
|
34166
|
+
"Matrix must be square (size: " + formatGeneric(sizeArray, {}) + ")"
|
|
35108
34167
|
);
|
|
35109
34168
|
}
|
|
35110
34169
|
}
|
|
35111
34170
|
default:
|
|
35112
34171
|
throw new RangeError(
|
|
35113
|
-
"Matrix must be at most two dimensional (size: " +
|
|
34172
|
+
"Matrix must be at most two dimensional (size: " + formatGeneric(sizeArray, {}) + ")"
|
|
35114
34173
|
);
|
|
35115
34174
|
}
|
|
35116
34175
|
}
|
|
@@ -36326,7 +35385,7 @@ var createMean = /* @__PURE__ */ factory(
|
|
|
36326
35385
|
}
|
|
36327
35386
|
let sum3;
|
|
36328
35387
|
let num2 = 0;
|
|
36329
|
-
|
|
35388
|
+
deepForEach(array, function(value) {
|
|
36330
35389
|
try {
|
|
36331
35390
|
sum3 = sum3 === void 0 ? value : add4(sum3, value);
|
|
36332
35391
|
num2++;
|
|
@@ -36467,7 +35526,7 @@ var createVariance = /* @__PURE__ */ factory(
|
|
|
36467
35526
|
}
|
|
36468
35527
|
let sum3;
|
|
36469
35528
|
let num2 = 0;
|
|
36470
|
-
|
|
35529
|
+
deepForEach(array, function(value) {
|
|
36471
35530
|
try {
|
|
36472
35531
|
sum3 = sum3 === void 0 ? value : add4(sum3, value);
|
|
36473
35532
|
num2++;
|
|
@@ -36478,7 +35537,7 @@ var createVariance = /* @__PURE__ */ factory(
|
|
|
36478
35537
|
if (num2 === 0) throw new Error("Cannot calculate variance of an empty array");
|
|
36479
35538
|
const mean7 = divide2(sum3, num2);
|
|
36480
35539
|
sum3 = void 0;
|
|
36481
|
-
|
|
35540
|
+
deepForEach(array, function(value) {
|
|
36482
35541
|
const diff2 = subtract3(value, mean7);
|
|
36483
35542
|
sum3 = sum3 === void 0 ? multiply2(diff2, diff2) : add4(sum3, multiply2(diff2, diff2));
|
|
36484
35543
|
});
|
|
@@ -36696,7 +35755,7 @@ var createKldivergence = /* @__PURE__ */ factory(
|
|
|
36696
35755
|
divide: divide2,
|
|
36697
35756
|
sum: sum3,
|
|
36698
35757
|
multiply: multiply2,
|
|
36699
|
-
map:
|
|
35758
|
+
map: map3,
|
|
36700
35759
|
dotDivide: dotDivide2,
|
|
36701
35760
|
log: log3,
|
|
36702
35761
|
isNumeric: isNumeric2
|
|
@@ -36740,7 +35799,7 @@ var createKldivergence = /* @__PURE__ */ factory(
|
|
|
36740
35799
|
const result = sum3(
|
|
36741
35800
|
multiply2(
|
|
36742
35801
|
qnorm,
|
|
36743
|
-
|
|
35802
|
+
map3(dotDivide2(qnorm, pnorm), (x) => log3(x))
|
|
36744
35803
|
)
|
|
36745
35804
|
);
|
|
36746
35805
|
if (isNumeric2(result)) {
|
|
@@ -36763,7 +35822,7 @@ var createMultinomial = /* @__PURE__ */ factory(
|
|
|
36763
35822
|
"Array | Matrix": function(a) {
|
|
36764
35823
|
let sum3 = 0;
|
|
36765
35824
|
let denom = 1;
|
|
36766
|
-
|
|
35825
|
+
deepForEach(a, function(ai) {
|
|
36767
35826
|
if (!isInteger3(ai) || !isPositive2(ai)) {
|
|
36768
35827
|
throw new TypeError("Positive integer value expected in function multinomial");
|
|
36769
35828
|
}
|
|
@@ -36913,11 +35972,11 @@ var dependencies226 = ["typed", "size", "subset", "compareNatural", "Index", "De
|
|
|
36913
35972
|
var createSetCartesian = /* @__PURE__ */ factory(
|
|
36914
35973
|
name226,
|
|
36915
35974
|
dependencies226,
|
|
36916
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
35975
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
|
|
36917
35976
|
return typed3(name226, {
|
|
36918
35977
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
36919
35978
|
let result = [];
|
|
36920
|
-
if (subset2(size2(a1), new
|
|
35979
|
+
if (subset2(size2(a1), new Index(0)) !== 0 && subset2(size2(a2), new Index(0)) !== 0) {
|
|
36921
35980
|
const b1 = flatten2(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural3);
|
|
36922
35981
|
const b2 = flatten2(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural3);
|
|
36923
35982
|
result = [];
|
|
@@ -36942,13 +36001,13 @@ var dependencies227 = ["typed", "size", "subset", "compareNatural", "Index", "De
|
|
|
36942
36001
|
var createSetDifference = /* @__PURE__ */ factory(
|
|
36943
36002
|
name227,
|
|
36944
36003
|
dependencies227,
|
|
36945
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36004
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
|
|
36946
36005
|
return typed3(name227, {
|
|
36947
36006
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
36948
36007
|
let result;
|
|
36949
|
-
if (subset2(size2(a1), new
|
|
36008
|
+
if (subset2(size2(a1), new Index(0)) === 0) {
|
|
36950
36009
|
result = [];
|
|
36951
|
-
} else if (subset2(size2(a2), new
|
|
36010
|
+
} else if (subset2(size2(a2), new Index(0)) === 0) {
|
|
36952
36011
|
return flatten2(a1.toArray());
|
|
36953
36012
|
} else {
|
|
36954
36013
|
const b1 = identify2(flatten2(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural3));
|
|
@@ -36983,11 +36042,11 @@ var dependencies228 = ["typed", "size", "subset", "compareNatural", "Index", "De
|
|
|
36983
36042
|
var createSetDistinct = /* @__PURE__ */ factory(
|
|
36984
36043
|
name228,
|
|
36985
36044
|
dependencies228,
|
|
36986
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36045
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
|
|
36987
36046
|
return typed3(name228, {
|
|
36988
36047
|
"Array | Matrix": function(a) {
|
|
36989
36048
|
let result;
|
|
36990
|
-
if (subset2(size2(a), new
|
|
36049
|
+
if (subset2(size2(a), new Index(0)) === 0) {
|
|
36991
36050
|
result = [];
|
|
36992
36051
|
} else {
|
|
36993
36052
|
const b = flatten2(Array.isArray(a) ? a : a.toArray()).sort(compareNatural3);
|
|
@@ -37014,11 +36073,11 @@ var dependencies229 = ["typed", "size", "subset", "compareNatural", "Index", "De
|
|
|
37014
36073
|
var createSetIntersect = /* @__PURE__ */ factory(
|
|
37015
36074
|
name229,
|
|
37016
36075
|
dependencies229,
|
|
37017
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36076
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
|
|
37018
36077
|
return typed3(name229, {
|
|
37019
36078
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
37020
36079
|
let result;
|
|
37021
|
-
if (subset2(size2(a1), new
|
|
36080
|
+
if (subset2(size2(a1), new Index(0)) === 0 || subset2(size2(a2), new Index(0)) === 0) {
|
|
37022
36081
|
result = [];
|
|
37023
36082
|
} else {
|
|
37024
36083
|
const b1 = identify2(flatten2(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural3));
|
|
@@ -37048,12 +36107,12 @@ var dependencies230 = ["typed", "size", "subset", "compareNatural", "Index"];
|
|
|
37048
36107
|
var createSetIsSubset = /* @__PURE__ */ factory(
|
|
37049
36108
|
name230,
|
|
37050
36109
|
dependencies230,
|
|
37051
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36110
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index }) => {
|
|
37052
36111
|
return typed3(name230, {
|
|
37053
36112
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
37054
|
-
if (subset2(size2(a1), new
|
|
36113
|
+
if (subset2(size2(a1), new Index(0)) === 0) {
|
|
37055
36114
|
return true;
|
|
37056
|
-
} else if (subset2(size2(a2), new
|
|
36115
|
+
} else if (subset2(size2(a2), new Index(0)) === 0) {
|
|
37057
36116
|
return false;
|
|
37058
36117
|
}
|
|
37059
36118
|
const b1 = identify2(flatten2(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural3));
|
|
@@ -37083,10 +36142,10 @@ var dependencies231 = ["typed", "size", "subset", "compareNatural", "Index"];
|
|
|
37083
36142
|
var createSetMultiplicity = /* @__PURE__ */ factory(
|
|
37084
36143
|
name231,
|
|
37085
36144
|
dependencies231,
|
|
37086
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36145
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index }) => {
|
|
37087
36146
|
return typed3(name231, {
|
|
37088
36147
|
"number | BigNumber | Fraction | Complex, Array | Matrix": function(e, a) {
|
|
37089
|
-
if (subset2(size2(a), new
|
|
36148
|
+
if (subset2(size2(a), new Index(0)) === 0) {
|
|
37090
36149
|
return 0;
|
|
37091
36150
|
}
|
|
37092
36151
|
const b = flatten2(Array.isArray(a) ? a : a.toArray());
|
|
@@ -37108,10 +36167,10 @@ var dependencies232 = ["typed", "size", "subset", "compareNatural", "Index"];
|
|
|
37108
36167
|
var createSetPowerset = /* @__PURE__ */ factory(
|
|
37109
36168
|
name232,
|
|
37110
36169
|
dependencies232,
|
|
37111
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36170
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index }) => {
|
|
37112
36171
|
return typed3(name232, {
|
|
37113
36172
|
"Array | Matrix": function(a) {
|
|
37114
|
-
if (subset2(size2(a), new
|
|
36173
|
+
if (subset2(size2(a), new Index(0)) === 0) {
|
|
37115
36174
|
return [];
|
|
37116
36175
|
}
|
|
37117
36176
|
const b = flatten2(Array.isArray(a) ? a : a.toArray()).sort(compareNatural3);
|
|
@@ -37501,9 +36560,9 @@ var createSimplifyCore = /* @__PURE__ */ factory(
|
|
|
37501
36560
|
if (op) {
|
|
37502
36561
|
if (fnode.args.length > 2 && hasProperty(node, "associative", context)) {
|
|
37503
36562
|
while (fnode.args.length > 2) {
|
|
37504
|
-
const
|
|
36563
|
+
const last2 = fnode.args.pop();
|
|
37505
36564
|
const seclast = fnode.args.pop();
|
|
37506
|
-
fnode.args.push(new OperatorNode(op, fnode.name, [
|
|
36565
|
+
fnode.args.push(new OperatorNode(op, fnode.name, [last2, seclast]));
|
|
37507
36566
|
}
|
|
37508
36567
|
}
|
|
37509
36568
|
node = new OperatorNode(op, fnode.name, fnode.args);
|
|
@@ -37929,7 +36988,7 @@ var dependencies236 = ["typed", "Index"];
|
|
|
37929
36988
|
var createIndex = /* @__PURE__ */ factory(
|
|
37930
36989
|
name236,
|
|
37931
36990
|
dependencies236,
|
|
37932
|
-
({ typed: typed3, Index
|
|
36991
|
+
({ typed: typed3, Index }) => {
|
|
37933
36992
|
return typed3(name236, {
|
|
37934
36993
|
"...number | string | BigNumber | Range | Array | Matrix": function(args) {
|
|
37935
36994
|
const ranges = args.map(function(arg3) {
|
|
@@ -37943,7 +37002,7 @@ var createIndex = /* @__PURE__ */ factory(
|
|
|
37943
37002
|
return arg3;
|
|
37944
37003
|
}
|
|
37945
37004
|
});
|
|
37946
|
-
return new
|
|
37005
|
+
return new Index(...ranges);
|
|
37947
37006
|
}
|
|
37948
37007
|
});
|
|
37949
37008
|
}
|
|
@@ -38054,9 +37113,9 @@ function createComplexEigs({
|
|
|
38054
37113
|
if (findVectors) {
|
|
38055
37114
|
Rdiag = Array(N).fill(one);
|
|
38056
37115
|
}
|
|
38057
|
-
let
|
|
38058
|
-
while (!
|
|
38059
|
-
|
|
37116
|
+
let last2 = false;
|
|
37117
|
+
while (!last2) {
|
|
37118
|
+
last2 = true;
|
|
38060
37119
|
for (let i = 0; i < N; i++) {
|
|
38061
37120
|
let colNorm = realzero;
|
|
38062
37121
|
let rowNorm = realzero;
|
|
@@ -38083,7 +37142,7 @@ function createComplexEigs({
|
|
|
38083
37142
|
multiplyScalar2(addScalar2(colNorm, rowNorm), 0.95)
|
|
38084
37143
|
);
|
|
38085
37144
|
if (condition) {
|
|
38086
|
-
|
|
37145
|
+
last2 = false;
|
|
38087
37146
|
const g = divideScalar2(1, f);
|
|
38088
37147
|
for (let j = 0; j < N; j++) {
|
|
38089
37148
|
if (i === j) {
|
|
@@ -38949,7 +38008,7 @@ var createEigs = /* @__PURE__ */ factory(
|
|
|
38949
38008
|
const arr10 = mat.toArray();
|
|
38950
38009
|
const asize = mat.size();
|
|
38951
38010
|
if (asize.length !== 2 || asize[0] !== asize[1]) {
|
|
38952
|
-
throw new RangeError(`Matrix must be square (size: ${
|
|
38011
|
+
throw new RangeError(`Matrix must be square (size: ${formatGeneric(asize, {})})`);
|
|
38953
38012
|
}
|
|
38954
38013
|
const N = asize[0];
|
|
38955
38014
|
if (isReal(arr10, N, prec)) {
|
|
@@ -39347,7 +38406,7 @@ var dependencies240 = ["typed", "abs", "map", "median", "subtract"];
|
|
|
39347
38406
|
var createMad = /* @__PURE__ */ factory(
|
|
39348
38407
|
name240,
|
|
39349
38408
|
dependencies240,
|
|
39350
|
-
({ typed: typed3, abs: abs2, map:
|
|
38409
|
+
({ typed: typed3, abs: abs2, map: map3, median: median2, subtract: subtract3 }) => {
|
|
39351
38410
|
return typed3(name240, {
|
|
39352
38411
|
// mad([a, b, c, d, ...])
|
|
39353
38412
|
"Array | Matrix": _mad,
|
|
@@ -39377,7 +38436,7 @@ var createMad = /* @__PURE__ */ factory(
|
|
|
39377
38436
|
try {
|
|
39378
38437
|
const med = median2(flat);
|
|
39379
38438
|
return median2(
|
|
39380
|
-
|
|
38439
|
+
map3(flat, function(value) {
|
|
39381
38440
|
return abs2(subtract3(value, med));
|
|
39382
38441
|
})
|
|
39383
38442
|
);
|
|
@@ -39398,7 +38457,7 @@ var dependencies241 = ["typed", "map", "sqrt", "variance"];
|
|
|
39398
38457
|
var createStd = /* @__PURE__ */ factory(
|
|
39399
38458
|
name241,
|
|
39400
38459
|
dependencies241,
|
|
39401
|
-
({ typed: typed3, map:
|
|
38460
|
+
({ typed: typed3, map: map3, sqrt: sqrt2, variance: variance2 }) => {
|
|
39402
38461
|
return typed3(name241, {
|
|
39403
38462
|
// std([a, b, c, d, ...])
|
|
39404
38463
|
"Array | Matrix": _std,
|
|
@@ -39421,7 +38480,7 @@ var createStd = /* @__PURE__ */ factory(
|
|
|
39421
38480
|
try {
|
|
39422
38481
|
const v = variance2(...args);
|
|
39423
38482
|
if (isCollection(v)) {
|
|
39424
|
-
return
|
|
38483
|
+
return map3(v, sqrt2);
|
|
39425
38484
|
} else {
|
|
39426
38485
|
return sqrt2(v);
|
|
39427
38486
|
}
|
|
@@ -39442,12 +38501,12 @@ var dependencies242 = ["typed", "size", "concat", "subset", "setDifference", "In
|
|
|
39442
38501
|
var createSetSymDifference = /* @__PURE__ */ factory(
|
|
39443
38502
|
name242,
|
|
39444
38503
|
dependencies242,
|
|
39445
|
-
({ typed: typed3, size: size2, concat: concat3, subset: subset2, setDifference: setDifference3, Index
|
|
38504
|
+
({ typed: typed3, size: size2, concat: concat3, subset: subset2, setDifference: setDifference3, Index }) => {
|
|
39446
38505
|
return typed3(name242, {
|
|
39447
38506
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
39448
|
-
if (subset2(size2(a1), new
|
|
38507
|
+
if (subset2(size2(a1), new Index(0)) === 0) {
|
|
39449
38508
|
return flatten2(a2);
|
|
39450
|
-
} else if (subset2(size2(a2), new
|
|
38509
|
+
} else if (subset2(size2(a2), new Index(0)) === 0) {
|
|
39451
38510
|
return flatten2(a1);
|
|
39452
38511
|
}
|
|
39453
38512
|
const b1 = flatten2(a1);
|
|
@@ -41574,13 +40633,13 @@ var createSetUnion = /* @__PURE__ */ factory(
|
|
|
41574
40633
|
subset: subset2,
|
|
41575
40634
|
setIntersect: setIntersect3,
|
|
41576
40635
|
setSymDifference: setSymDifference3,
|
|
41577
|
-
Index
|
|
40636
|
+
Index
|
|
41578
40637
|
}) => {
|
|
41579
40638
|
return typed3(name247, {
|
|
41580
40639
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
41581
|
-
if (subset2(size2(a1), new
|
|
40640
|
+
if (subset2(size2(a1), new Index(0)) === 0) {
|
|
41582
40641
|
return flatten2(a2);
|
|
41583
|
-
} else if (subset2(size2(a2), new
|
|
40642
|
+
} else if (subset2(size2(a2), new Index(0)) === 0) {
|
|
41584
40643
|
return flatten2(a1);
|
|
41585
40644
|
}
|
|
41586
40645
|
const b1 = flatten2(a1);
|
|
@@ -41649,14 +40708,14 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41649
40708
|
"": function() {
|
|
41650
40709
|
return config2.matrix === "Matrix" ? matrix2([]) : [];
|
|
41651
40710
|
},
|
|
41652
|
-
string: function(
|
|
41653
|
-
return matrix2(
|
|
40711
|
+
string: function(format4) {
|
|
40712
|
+
return matrix2(format4);
|
|
41654
40713
|
},
|
|
41655
40714
|
"number | BigNumber | Complex | Unit": function(theta) {
|
|
41656
40715
|
return _rotationMatrix2x2(theta, config2.matrix === "Matrix" ? "dense" : void 0);
|
|
41657
40716
|
},
|
|
41658
|
-
"number | BigNumber | Complex | Unit, string": function(theta,
|
|
41659
|
-
return _rotationMatrix2x2(theta,
|
|
40717
|
+
"number | BigNumber | Complex | Unit, string": function(theta, format4) {
|
|
40718
|
+
return _rotationMatrix2x2(theta, format4);
|
|
41660
40719
|
},
|
|
41661
40720
|
"number | BigNumber | Complex | Unit, Array": function(theta, v) {
|
|
41662
40721
|
const matrixV = matrix2(v);
|
|
@@ -41668,17 +40727,17 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41668
40727
|
const storageType = v.storage() || (config2.matrix === "Matrix" ? "dense" : void 0);
|
|
41669
40728
|
return _rotationMatrix3x3(theta, v, storageType);
|
|
41670
40729
|
},
|
|
41671
|
-
"number | BigNumber | Complex | Unit, Array, string": function(theta, v,
|
|
40730
|
+
"number | BigNumber | Complex | Unit, Array, string": function(theta, v, format4) {
|
|
41672
40731
|
const matrixV = matrix2(v);
|
|
41673
40732
|
_validateVector(matrixV);
|
|
41674
|
-
return _rotationMatrix3x3(theta, matrixV,
|
|
40733
|
+
return _rotationMatrix3x3(theta, matrixV, format4);
|
|
41675
40734
|
},
|
|
41676
|
-
"number | BigNumber | Complex | Unit, Matrix, string": function(theta, v,
|
|
40735
|
+
"number | BigNumber | Complex | Unit, Matrix, string": function(theta, v, format4) {
|
|
41677
40736
|
_validateVector(v);
|
|
41678
|
-
return _rotationMatrix3x3(theta, v,
|
|
40737
|
+
return _rotationMatrix3x3(theta, v, format4);
|
|
41679
40738
|
}
|
|
41680
40739
|
});
|
|
41681
|
-
function _rotationMatrix2x2(theta,
|
|
40740
|
+
function _rotationMatrix2x2(theta, format4) {
|
|
41682
40741
|
const Big = isBigNumber(theta);
|
|
41683
40742
|
const minusOne = Big ? new BigNumber9(-1) : -1;
|
|
41684
40743
|
const cosTheta = cos2(theta);
|
|
@@ -41687,7 +40746,7 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41687
40746
|
[cosTheta, multiplyScalar2(minusOne, sinTheta)],
|
|
41688
40747
|
[sinTheta, cosTheta]
|
|
41689
40748
|
];
|
|
41690
|
-
return _convertToFormat(data,
|
|
40749
|
+
return _convertToFormat(data, format4);
|
|
41691
40750
|
}
|
|
41692
40751
|
function _validateVector(v) {
|
|
41693
40752
|
const size2 = v.size();
|
|
@@ -41698,19 +40757,19 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41698
40757
|
function _mul(array) {
|
|
41699
40758
|
return array.reduce((p, curr) => multiplyScalar2(p, curr));
|
|
41700
40759
|
}
|
|
41701
|
-
function _convertToFormat(data,
|
|
41702
|
-
if (
|
|
41703
|
-
if (
|
|
40760
|
+
function _convertToFormat(data, format4) {
|
|
40761
|
+
if (format4) {
|
|
40762
|
+
if (format4 === "sparse") {
|
|
41704
40763
|
return new SparseMatrix(data);
|
|
41705
40764
|
}
|
|
41706
|
-
if (
|
|
40765
|
+
if (format4 === "dense") {
|
|
41707
40766
|
return new DenseMatrix6(data);
|
|
41708
40767
|
}
|
|
41709
|
-
throw new TypeError(`Unknown matrix type "${
|
|
40768
|
+
throw new TypeError(`Unknown matrix type "${format4}"`);
|
|
41710
40769
|
}
|
|
41711
40770
|
return data;
|
|
41712
40771
|
}
|
|
41713
|
-
function _rotationMatrix3x3(theta, v,
|
|
40772
|
+
function _rotationMatrix3x3(theta, v, format4) {
|
|
41714
40773
|
const normV = norm4(v);
|
|
41715
40774
|
if (normV === 0) {
|
|
41716
40775
|
throw new RangeError("Rotation around zero vector");
|
|
@@ -41738,7 +40797,7 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41738
40797
|
[r21, r22, r23],
|
|
41739
40798
|
[r31, r32, r33]
|
|
41740
40799
|
];
|
|
41741
|
-
return _convertToFormat(data,
|
|
40800
|
+
return _convertToFormat(data, format4);
|
|
41742
40801
|
}
|
|
41743
40802
|
}
|
|
41744
40803
|
);
|
|
@@ -42258,11 +41317,11 @@ var re2 = createRe(factoryScope);
|
|
|
42258
41317
|
var not2 = createNot(factoryScope);
|
|
42259
41318
|
var filter2 = createFilter(factoryScope);
|
|
42260
41319
|
var flatten3 = createFlatten(factoryScope);
|
|
42261
|
-
var
|
|
41320
|
+
var forEach2 = createForEach(factoryScope);
|
|
42262
41321
|
var getMatrixDataType = createGetMatrixDataType(
|
|
42263
41322
|
factoryScope
|
|
42264
41323
|
);
|
|
42265
|
-
var
|
|
41324
|
+
var map2 = createMap(factoryScope);
|
|
42266
41325
|
var size = createSize(factoryScope);
|
|
42267
41326
|
var squeeze2 = createSqueeze(factoryScope);
|
|
42268
41327
|
var combinations2 = createCombinations(factoryScope);
|
|
@@ -42274,7 +41333,7 @@ var pickRandom2 = createPickRandom(factoryScope);
|
|
|
42274
41333
|
var random2 = createRandom(factoryScope);
|
|
42275
41334
|
var equalScalar2 = createEqualScalar(factoryScope);
|
|
42276
41335
|
var erf = createErf(factoryScope);
|
|
42277
|
-
var
|
|
41336
|
+
var format3 = createFormat(factoryScope);
|
|
42278
41337
|
var print2 = createPrint(factoryScope);
|
|
42279
41338
|
var acoth = createAcoth(factoryScope);
|
|
42280
41339
|
var acsch = createAcsch(factoryScope);
|
|
@@ -42283,7 +41342,7 @@ var coth = createCoth(factoryScope);
|
|
|
42283
41342
|
var csch = createCsch(factoryScope);
|
|
42284
41343
|
var sech = createSech(factoryScope);
|
|
42285
41344
|
var toBest2 = createToBest(factoryScope);
|
|
42286
|
-
var
|
|
41345
|
+
var clone2 = createClone(factoryScope);
|
|
42287
41346
|
var isBounded = createIsBounded(factoryScope);
|
|
42288
41347
|
var isNaN2 = createIsNaN(factoryScope);
|
|
42289
41348
|
var isNegative = createIsNegative(factoryScope);
|
|
@@ -42335,7 +41394,7 @@ factoryScope.asinh = factory_asinh;
|
|
|
42335
41394
|
factoryScope.atan = factory_atan;
|
|
42336
41395
|
factoryScope.atanh = factory_atanh;
|
|
42337
41396
|
factoryScope.bitNot = bitNot2;
|
|
42338
|
-
factoryScope.clone =
|
|
41397
|
+
factoryScope.clone = clone2;
|
|
42339
41398
|
factoryScope.combinations = combinations2;
|
|
42340
41399
|
factoryScope.combinationsWithRep = combinationsWithRep2;
|
|
42341
41400
|
factoryScope.conj = conj2;
|
|
@@ -42348,7 +41407,7 @@ factoryScope.equalScalar = equalScalar2;
|
|
|
42348
41407
|
factoryScope.erf = erf;
|
|
42349
41408
|
factoryScope.exp = factory_exp;
|
|
42350
41409
|
factoryScope.expm1 = factory_expm1;
|
|
42351
|
-
factoryScope.format =
|
|
41410
|
+
factoryScope.format = format3;
|
|
42352
41411
|
factoryScope.im = im2;
|
|
42353
41412
|
factoryScope.isBounded = isBounded;
|
|
42354
41413
|
factoryScope.isNaN = isNaN2;
|
|
@@ -42359,7 +41418,7 @@ factoryScope.isPrime = isPrime;
|
|
|
42359
41418
|
factoryScope.lgamma = lgamma2;
|
|
42360
41419
|
factoryScope.log2 = factory_log2;
|
|
42361
41420
|
factoryScope.log10 = factory_log10;
|
|
42362
|
-
factoryScope.map =
|
|
41421
|
+
factoryScope.map = map2;
|
|
42363
41422
|
factoryScope.multiplyScalar = multiplyScalar;
|
|
42364
41423
|
factoryScope.not = not2;
|
|
42365
41424
|
factoryScope.numeric = numeric;
|
|
@@ -42418,7 +41477,7 @@ factoryScope.isZero = isZero;
|
|
|
42418
41477
|
factoryScope.prod = prod;
|
|
42419
41478
|
factoryScope.dot = factory_dot;
|
|
42420
41479
|
factoryScope.squeeze = squeeze2;
|
|
42421
|
-
factoryScope.forEach =
|
|
41480
|
+
factoryScope.forEach = forEach2;
|
|
42422
41481
|
factoryScope.filter = filter2;
|
|
42423
41482
|
var factory_transpose = createTranspose(
|
|
42424
41483
|
factoryScope
|
|
@@ -43948,11 +43007,11 @@ function symbolicProduct(expr, varName, a, b) {
|
|
|
43948
43007
|
`symbolicProduct: bounds must be finite numbers (symbolic bounds are not supported; got lower bound ${JSON.stringify(a)}, upper bound ${JSON.stringify(b)})`
|
|
43949
43008
|
);
|
|
43950
43009
|
}
|
|
43951
|
-
let
|
|
43010
|
+
let product2 = 1;
|
|
43952
43011
|
for (let k = a; k <= b; k++) {
|
|
43953
|
-
|
|
43012
|
+
product2 *= evalAt(expr, varName, k);
|
|
43954
43013
|
}
|
|
43955
|
-
return
|
|
43014
|
+
return product2;
|
|
43956
43015
|
}
|
|
43957
43016
|
function assume(varName, property) {
|
|
43958
43017
|
const validProperties = ["real", "positive", "negative", "integer", "nonzero", "nonnegative"];
|
|
@@ -48158,7 +47217,7 @@ function linearRegression(x, y) {
|
|
|
48158
47217
|
}
|
|
48159
47218
|
|
|
48160
47219
|
// src/ml/regularized-regression.ts
|
|
48161
|
-
function
|
|
47220
|
+
function validate2(X, y, name254) {
|
|
48162
47221
|
const n = X.length;
|
|
48163
47222
|
if (n === 0) throw new Error(`${name254}: empty design matrix`);
|
|
48164
47223
|
if (y.length !== n) {
|
|
@@ -48197,7 +47256,7 @@ function softThreshold(a, lambda) {
|
|
|
48197
47256
|
return 0;
|
|
48198
47257
|
}
|
|
48199
47258
|
function ridge(X, y, alpha, opts) {
|
|
48200
|
-
const { n, p } =
|
|
47259
|
+
const { n, p } = validate2(X, y, "ridge");
|
|
48201
47260
|
if (alpha < 0) throw new Error("ridge: alpha must be non-negative");
|
|
48202
47261
|
const useIntercept = opts?.intercept !== false;
|
|
48203
47262
|
const { Xc, yc, xMean, yMean } = center(X, y, n, p, useIntercept);
|
|
@@ -48252,7 +47311,7 @@ function coordinateDescent(Xs, yc, n, p, l1, l2, maxIter, tol) {
|
|
|
48252
47311
|
return beta2;
|
|
48253
47312
|
}
|
|
48254
47313
|
function lasso(X, y, alpha, opts) {
|
|
48255
|
-
const { n, p } =
|
|
47314
|
+
const { n, p } = validate2(X, y, "lasso");
|
|
48256
47315
|
if (alpha < 0) throw new Error("lasso: alpha must be non-negative");
|
|
48257
47316
|
const useIntercept = opts?.intercept !== false;
|
|
48258
47317
|
const maxIter = opts?.maxIter ?? 1e3;
|
|
@@ -48265,7 +47324,7 @@ function lasso(X, y, alpha, opts) {
|
|
|
48265
47324
|
return { coefficients, intercept };
|
|
48266
47325
|
}
|
|
48267
47326
|
function elasticNet(X, y, alpha, l1Ratio, opts) {
|
|
48268
|
-
const { n, p } =
|
|
47327
|
+
const { n, p } = validate2(X, y, "elasticNet");
|
|
48269
47328
|
if (alpha < 0) throw new Error("elasticNet: alpha must be non-negative");
|
|
48270
47329
|
if (l1Ratio < 0 || l1Ratio > 1) throw new Error("elasticNet: l1Ratio must be in [0, 1]");
|
|
48271
47330
|
const useIntercept = opts?.intercept !== false;
|
|
@@ -52273,7 +51332,7 @@ export {
|
|
|
52273
51332
|
clamp,
|
|
52274
51333
|
classicalElectronRadius,
|
|
52275
51334
|
clearAssumptions,
|
|
52276
|
-
|
|
51335
|
+
clone2 as clone,
|
|
52277
51336
|
closenessCentrality,
|
|
52278
51337
|
cochranQ,
|
|
52279
51338
|
coefficientList,
|
|
@@ -52528,8 +51587,8 @@ export {
|
|
|
52528
51587
|
flatten3 as flatten,
|
|
52529
51588
|
floor,
|
|
52530
51589
|
floydWarshall,
|
|
52531
|
-
forEach,
|
|
52532
|
-
|
|
51590
|
+
forEach2 as forEach,
|
|
51591
|
+
format2 as format,
|
|
52533
51592
|
fourier,
|
|
52534
51593
|
fourierSeries,
|
|
52535
51594
|
fraction,
|
|
@@ -52744,7 +51803,7 @@ export {
|
|
|
52744
51803
|
mahalanobis,
|
|
52745
51804
|
manhattanDistance,
|
|
52746
51805
|
mannWhitneyTest,
|
|
52747
|
-
map,
|
|
51806
|
+
map2 as map,
|
|
52748
51807
|
mapSlices,
|
|
52749
51808
|
matmul,
|
|
52750
51809
|
matrix,
|