@danielsimonjr/mathts-functions 0.42.0 → 0.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/config.d.ts +10 -13
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/create.d.ts +2 -8
- package/dist/core/create.d.ts.map +1 -1
- 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 +498 -1462
- package/dist/numeric/matrix-functions.d.ts +7 -5
- package/dist/numeric/matrix-functions.d.ts.map +1 -1
- package/dist/signal/fft-helpers.d.ts +6 -0
- package/dist/signal/fft-helpers.d.ts.map +1 -1
- package/dist/signal/fft.d.ts +9 -0
- package/dist/signal/fft.d.ts.map +1 -1
- package/dist/type/matrix/types.d.ts +8 -35
- package/dist/type/matrix/types.d.ts.map +1 -1
- 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 +45 -70
- 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/dist/wasm/WasmLoader.d.ts +2 -10
- package/dist/wasm/WasmLoader.d.ts.map +1 -1
- package/dist/wasm/integrity.d.ts +2 -4
- package/dist/wasm/integrity.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
|
|
|
@@ -18899,35 +18670,7 @@ function initTypeBridge() {
|
|
|
18899
18670
|
}
|
|
18900
18671
|
|
|
18901
18672
|
// src/core/config.ts
|
|
18902
|
-
|
|
18903
|
-
// minimum relative difference between two compared values,
|
|
18904
|
-
// used by all comparison functions
|
|
18905
|
-
relTol: 1e-12,
|
|
18906
|
-
// minimum absolute difference between two compared values,
|
|
18907
|
-
// used by all comparison functions
|
|
18908
|
-
absTol: 1e-15,
|
|
18909
|
-
// type of default matrix output. Choose 'matrix' (default) or 'array'
|
|
18910
|
-
matrix: "Matrix",
|
|
18911
|
-
// type of default number output. Choose 'number' (default) 'BigNumber', 'bigint', or 'Fraction'
|
|
18912
|
-
number: "number",
|
|
18913
|
-
// type of fallback used for config { number: 'bigint' } when a value cannot be represented
|
|
18914
|
-
// in the configured numeric type. Choose 'number' (default) or 'BigNumber'.
|
|
18915
|
-
numberFallback: "number",
|
|
18916
|
-
// number of significant digits in BigNumbers
|
|
18917
|
-
precision: 64,
|
|
18918
|
-
// predictable output type of functions. When true, output type depends only
|
|
18919
|
-
// on the input types. When false (default), output type can vary depending
|
|
18920
|
-
// on input values. For example `math.sqrt(-4)` returns `complex('2i')` when
|
|
18921
|
-
// predictable is false, and returns `NaN` when true.
|
|
18922
|
-
predictable: false,
|
|
18923
|
-
// random seed for seeded pseudo random number generation
|
|
18924
|
-
// null = randomly seed
|
|
18925
|
-
randomSeed: null,
|
|
18926
|
-
// legacy behavior for matrix subset. When true, the subset function
|
|
18927
|
-
// returns a matrix or array with the same size as the index (except for scalars).
|
|
18928
|
-
// When false, it returns a matrix or array with a size depending on the type of index.
|
|
18929
|
-
legacySubset: false
|
|
18930
|
-
};
|
|
18673
|
+
import { DEFAULT_CONFIG } from "@danielsimonjr/mathts-core/internal";
|
|
18931
18674
|
|
|
18932
18675
|
// src/factories/scope.ts
|
|
18933
18676
|
initTypeBridge();
|
|
@@ -19072,7 +18815,7 @@ __export(factories_exports, {
|
|
|
19072
18815
|
catalan: () => catalan,
|
|
19073
18816
|
chain: () => chain,
|
|
19074
18817
|
classicalElectronRadius: () => classicalElectronRadius,
|
|
19075
|
-
clone: () =>
|
|
18818
|
+
clone: () => clone2,
|
|
19076
18819
|
column: () => column,
|
|
19077
18820
|
complex: () => complex,
|
|
19078
18821
|
composition: () => composition,
|
|
@@ -19184,7 +18927,7 @@ __export(factories_exports, {
|
|
|
19184
18927
|
fineStructure: () => fineStructure,
|
|
19185
18928
|
firstRadiation: () => firstRadiation,
|
|
19186
18929
|
flatten: () => flatten3,
|
|
19187
|
-
forEach: () =>
|
|
18930
|
+
forEach: () => forEach2,
|
|
19188
18931
|
fraction: () => fraction,
|
|
19189
18932
|
freqz: () => freqz,
|
|
19190
18933
|
gamma: () => gamma,
|
|
@@ -19225,7 +18968,7 @@ __export(factories_exports, {
|
|
|
19225
18968
|
mad: () => mad,
|
|
19226
18969
|
magneticConstant: () => magneticConstant,
|
|
19227
18970
|
magneticFluxQuantum: () => magneticFluxQuantum,
|
|
19228
|
-
map: () =>
|
|
18971
|
+
map: () => map2,
|
|
19229
18972
|
mapSlices: () => mapSlices,
|
|
19230
18973
|
matrix: () => matrix,
|
|
19231
18974
|
matrixFromColumns: () => matrixFromColumns,
|
|
@@ -19309,706 +19052,14 @@ __export(factories_exports, {
|
|
|
19309
19052
|
zpk2tf: () => zpk2tf
|
|
19310
19053
|
});
|
|
19311
19054
|
|
|
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
19055
|
// 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
|
-
}
|
|
19056
|
+
import {
|
|
19057
|
+
containsCollections,
|
|
19058
|
+
deepForEach,
|
|
19059
|
+
deepMap,
|
|
19060
|
+
reduce as reduce2,
|
|
19061
|
+
scatter
|
|
19062
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
20012
19063
|
|
|
20013
19064
|
// src/arithmetic/abs.ts
|
|
20014
19065
|
var name2 = "abs";
|
|
@@ -20023,7 +19074,7 @@ var createAbs = /* @__PURE__ */ factory(
|
|
|
20023
19074
|
bigint: (x) => x < 0n ? -x : x,
|
|
20024
19075
|
// deep map collection, skip zeros since abs(0) = 0
|
|
20025
19076
|
"Array | Matrix": typed3.referToSelf(
|
|
20026
|
-
(self) => (x) =>
|
|
19077
|
+
(self) => (x) => deepMap(x, self, true)
|
|
20027
19078
|
)
|
|
20028
19079
|
});
|
|
20029
19080
|
}
|
|
@@ -20181,7 +19232,7 @@ var createLog10 = /* @__PURE__ */ factory(
|
|
|
20181
19232
|
}
|
|
20182
19233
|
},
|
|
20183
19234
|
"Array | Matrix": typed3.referToSelf(
|
|
20184
|
-
(self) => (x) =>
|
|
19235
|
+
(self) => (x) => deepMap(x, self)
|
|
20185
19236
|
)
|
|
20186
19237
|
});
|
|
20187
19238
|
}
|
|
@@ -20215,7 +19266,7 @@ var createLog2 = /* @__PURE__ */ factory(
|
|
|
20215
19266
|
}
|
|
20216
19267
|
},
|
|
20217
19268
|
"Array | Matrix": typed3.referToSelf(
|
|
20218
|
-
(self) => (x) =>
|
|
19269
|
+
(self) => (x) => deepMap(x, self)
|
|
20219
19270
|
)
|
|
20220
19271
|
});
|
|
20221
19272
|
function _log2Complex(x) {
|
|
@@ -20278,7 +19329,7 @@ var createSign = /* @__PURE__ */ factory(
|
|
|
20278
19329
|
},
|
|
20279
19330
|
// deep map collection, skip zeros since sign(0) = 0
|
|
20280
19331
|
"Array | Matrix": typed3.referToSelf(
|
|
20281
|
-
(self) => (x) =>
|
|
19332
|
+
(self) => (x) => deepMap(x, self, true)
|
|
20282
19333
|
),
|
|
20283
19334
|
Unit: typed3.referToSelf((self) => (x) => {
|
|
20284
19335
|
if (!x._isDerived() && x.units[0].unit.offset !== 0) {
|
|
@@ -20430,7 +19481,7 @@ var createUnaryMinus = /* @__PURE__ */ factory(
|
|
|
20430
19481
|
},
|
|
20431
19482
|
// deep map collection, skip zeros since unaryMinus(0) = 0
|
|
20432
19483
|
"Array | Matrix": typed3.referToSelf(
|
|
20433
|
-
(self) => (x) =>
|
|
19484
|
+
(self) => (x) => deepMap(x, self, true)
|
|
20434
19485
|
)
|
|
20435
19486
|
// TODO: add support for string
|
|
20436
19487
|
});
|
|
@@ -20716,7 +19767,7 @@ var createBitNot = /* @__PURE__ */ factory(
|
|
|
20716
19767
|
BigNumber: bitNotBigNumber,
|
|
20717
19768
|
bigint: (x) => ~x,
|
|
20718
19769
|
"Array | Matrix": typed3.referToSelf(
|
|
20719
|
-
(self) => (x) =>
|
|
19770
|
+
(self) => (x) => deepMap(x, self)
|
|
20720
19771
|
)
|
|
20721
19772
|
});
|
|
20722
19773
|
}
|
|
@@ -20741,7 +19792,7 @@ var createArg = /* @__PURE__ */ factory(
|
|
|
20741
19792
|
},
|
|
20742
19793
|
// TODO: implement BigNumber support for function arg
|
|
20743
19794
|
"Array | Matrix": typed3.referToSelf(
|
|
20744
|
-
(self) => (x) =>
|
|
19795
|
+
(self) => (x) => deepMap(x, self)
|
|
20745
19796
|
)
|
|
20746
19797
|
});
|
|
20747
19798
|
}
|
|
@@ -20764,7 +19815,7 @@ var createConj = /* @__PURE__ */ factory(
|
|
|
20764
19815
|
}
|
|
20765
19816
|
),
|
|
20766
19817
|
"Array | Matrix": typed3.referToSelf(
|
|
20767
|
-
(self) => (x) =>
|
|
19818
|
+
(self) => (x) => deepMap(x, self)
|
|
20768
19819
|
)
|
|
20769
19820
|
});
|
|
20770
19821
|
}
|
|
@@ -20779,7 +19830,7 @@ var createIm = /* @__PURE__ */ factory(name18, dependencies18, ({ typed: typed3
|
|
|
20779
19830
|
"BigNumber | Fraction": (x) => x.mul(0),
|
|
20780
19831
|
Complex: (x) => x.im,
|
|
20781
19832
|
"Array | Matrix": typed3.referToSelf(
|
|
20782
|
-
(self) => (x) =>
|
|
19833
|
+
(self) => (x) => deepMap(x, self)
|
|
20783
19834
|
)
|
|
20784
19835
|
});
|
|
20785
19836
|
});
|
|
@@ -20792,7 +19843,7 @@ var createRe = /* @__PURE__ */ factory(name19, dependencies19, ({ typed: typed3
|
|
|
20792
19843
|
"number | BigNumber | Fraction": (x) => x,
|
|
20793
19844
|
Complex: (x) => x.re,
|
|
20794
19845
|
"Array | Matrix": typed3.referToSelf(
|
|
20795
|
-
(self) => (x) =>
|
|
19846
|
+
(self) => (x) => deepMap(x, self)
|
|
20796
19847
|
)
|
|
20797
19848
|
});
|
|
20798
19849
|
});
|
|
@@ -20818,7 +19869,7 @@ var createNot = /* @__PURE__ */ factory(
|
|
|
20818
19869
|
(self) => (x) => typed3.find(self, x.valueType())(x.value)
|
|
20819
19870
|
),
|
|
20820
19871
|
"Array | Matrix": typed3.referToSelf(
|
|
20821
|
-
(self) => (x) =>
|
|
19872
|
+
(self) => (x) => deepMap(x, self)
|
|
20822
19873
|
)
|
|
20823
19874
|
});
|
|
20824
19875
|
}
|
|
@@ -20826,6 +19877,42 @@ var createNot = /* @__PURE__ */ factory(
|
|
|
20826
19877
|
|
|
20827
19878
|
// src/utils/optimizeCallback.ts
|
|
20828
19879
|
import typed2 from "typed-function";
|
|
19880
|
+
|
|
19881
|
+
// src/utils/array.ts
|
|
19882
|
+
import {
|
|
19883
|
+
arraySize,
|
|
19884
|
+
validate,
|
|
19885
|
+
validateIndexSourceSize,
|
|
19886
|
+
validateIndex,
|
|
19887
|
+
isEmptyIndex,
|
|
19888
|
+
resize,
|
|
19889
|
+
reshape,
|
|
19890
|
+
processSizesWildcard,
|
|
19891
|
+
squeeze,
|
|
19892
|
+
unsqueeze,
|
|
19893
|
+
flatten as flatten2,
|
|
19894
|
+
map,
|
|
19895
|
+
forEach,
|
|
19896
|
+
filter,
|
|
19897
|
+
filterRegExp,
|
|
19898
|
+
join,
|
|
19899
|
+
identify as identify2,
|
|
19900
|
+
generalize,
|
|
19901
|
+
getArrayDataType,
|
|
19902
|
+
last,
|
|
19903
|
+
concat,
|
|
19904
|
+
broadcastSizes,
|
|
19905
|
+
checkBroadcastingRules,
|
|
19906
|
+
broadcastTo,
|
|
19907
|
+
broadcastArrays,
|
|
19908
|
+
stretch,
|
|
19909
|
+
getArrayElement,
|
|
19910
|
+
deepMapArray as deepMapArray2,
|
|
19911
|
+
deepForEachArray,
|
|
19912
|
+
cloneArray
|
|
19913
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
19914
|
+
|
|
19915
|
+
// src/utils/optimizeCallback.ts
|
|
20829
19916
|
function optimizeCallback(callback, array, name254, isUnary) {
|
|
20830
19917
|
const typedAny = typed2;
|
|
20831
19918
|
if (typedAny.isTypedFunction(callback)) {
|
|
@@ -20839,7 +19926,7 @@ function optimizeCallback(callback, array, name254, isUnary) {
|
|
|
20839
19926
|
return { isUnary: false, fn: callback };
|
|
20840
19927
|
}
|
|
20841
19928
|
const firstIndex = size2.map(() => 0);
|
|
20842
|
-
const firstValue = array.isMatrix ? array.get(firstIndex) :
|
|
19929
|
+
const firstValue = array.isMatrix ? array.get(firstIndex) : getArrayElement(array, firstIndex);
|
|
20843
19930
|
numberOfArguments = _findNumberOfArgumentsTyped(
|
|
20844
19931
|
callback,
|
|
20845
19932
|
firstValue,
|
|
@@ -21013,7 +20100,7 @@ var createForEach = /* @__PURE__ */ factory(
|
|
|
21013
20100
|
);
|
|
21014
20101
|
function _forEach(array, callback) {
|
|
21015
20102
|
const fastCallback = optimizeCallback(callback, array, name23);
|
|
21016
|
-
|
|
20103
|
+
deepForEachArray(array, fastCallback.fn, fastCallback.isUnary);
|
|
21017
20104
|
}
|
|
21018
20105
|
|
|
21019
20106
|
// src/matrix/getMatrixDataType.ts
|
|
@@ -21062,10 +20149,10 @@ var createMap = /* @__PURE__ */ factory(
|
|
|
21062
20149
|
const sizes = Arrays.map((M) => isMat(M) ? M.size() : arraySize(M));
|
|
21063
20150
|
const newSize = broadcastSizes(...sizes);
|
|
21064
20151
|
const numberOfArrays = Arrays.length;
|
|
21065
|
-
const _get = (coll, idx) => isMat(coll) ? coll.get(idx) :
|
|
20152
|
+
const _get = (coll, idx) => isMat(coll) ? coll.get(idx) : getArrayElement(coll, idx);
|
|
21066
20153
|
const firstValues = Arrays.map((collection, i) => {
|
|
21067
20154
|
const firstIndex = sizes[i].map(() => 0);
|
|
21068
|
-
return isMat(collection) ? collection.get(firstIndex) :
|
|
20155
|
+
return isMat(collection) ? collection.get(firstIndex) : getArrayElement(collection, firstIndex);
|
|
21069
20156
|
});
|
|
21070
20157
|
const callbackArgCount = typed3.isTypedFunction(multiCallback) ? _getTypedCallbackArgCount(
|
|
21071
20158
|
multiCallback,
|
|
@@ -21182,7 +20269,7 @@ var createMap = /* @__PURE__ */ factory(
|
|
|
21182
20269
|
}
|
|
21183
20270
|
function _mapArray(array, callback) {
|
|
21184
20271
|
const fastCallback = optimizeCallback(callback, array, name25);
|
|
21185
|
-
return
|
|
20272
|
+
return deepMapArray2(
|
|
21186
20273
|
array,
|
|
21187
20274
|
fastCallback.fn,
|
|
21188
20275
|
fastCallback.isUnary
|
|
@@ -21704,7 +20791,7 @@ var createErf = /* @__PURE__ */ factory(
|
|
|
21704
20791
|
}
|
|
21705
20792
|
}
|
|
21706
20793
|
}
|
|
21707
|
-
return
|
|
20794
|
+
return deepMap(n, self);
|
|
21708
20795
|
}
|
|
21709
20796
|
)
|
|
21710
20797
|
// TODO: For complex numbers, use the approximation for the Faddeeva function
|
|
@@ -21811,8 +20898,8 @@ var createFormat = /* @__PURE__ */ factory(
|
|
|
21811
20898
|
dependencies35,
|
|
21812
20899
|
({ typed: typed3 }) => {
|
|
21813
20900
|
return typed3(name35, {
|
|
21814
|
-
any:
|
|
21815
|
-
"any, Object | function | number | BigNumber":
|
|
20901
|
+
any: formatGeneric,
|
|
20902
|
+
"any, Object | function | number | BigNumber": formatGeneric
|
|
21816
20903
|
});
|
|
21817
20904
|
}
|
|
21818
20905
|
);
|
|
@@ -21844,7 +20931,7 @@ function _print(template, values, options) {
|
|
|
21844
20931
|
}
|
|
21845
20932
|
if (value !== void 0) {
|
|
21846
20933
|
if (!isString(value)) {
|
|
21847
|
-
return
|
|
20934
|
+
return formatGeneric(value, options);
|
|
21848
20935
|
} else {
|
|
21849
20936
|
return value;
|
|
21850
20937
|
}
|
|
@@ -22432,7 +21519,7 @@ var createIsNaN = /* @__PURE__ */ factory(
|
|
|
22432
21519
|
return Number.isNaN(x.value);
|
|
22433
21520
|
},
|
|
22434
21521
|
"Array | Matrix": typed3.referToSelf(
|
|
22435
|
-
(self) => (x) =>
|
|
21522
|
+
(self) => (x) => deepMap(x, self)
|
|
22436
21523
|
)
|
|
22437
21524
|
});
|
|
22438
21525
|
}
|
|
@@ -22455,7 +21542,7 @@ var createIsNegative = /* @__PURE__ */ factory(
|
|
|
22455
21542
|
(self) => (x) => typed3.find(self, x.valueType())(x.value)
|
|
22456
21543
|
),
|
|
22457
21544
|
"Array | Matrix": typed3.referToSelf(
|
|
22458
|
-
(self) => (x) =>
|
|
21545
|
+
(self) => (x) => deepMap(x, self)
|
|
22459
21546
|
)
|
|
22460
21547
|
});
|
|
22461
21548
|
}
|
|
@@ -22472,7 +21559,7 @@ var createIsNumeric = /* @__PURE__ */ factory(
|
|
|
22472
21559
|
"number | BigNumber | bigint | Fraction | boolean": () => true,
|
|
22473
21560
|
"Complex | Unit | string | null | undefined | Node": () => false,
|
|
22474
21561
|
"Array | Matrix": typed3.referToSelf(
|
|
22475
|
-
(self) => (x) =>
|
|
21562
|
+
(self) => (x) => deepMap(x, self)
|
|
22476
21563
|
)
|
|
22477
21564
|
});
|
|
22478
21565
|
}
|
|
@@ -22494,7 +21581,7 @@ var createIsPositive = /* @__PURE__ */ factory(
|
|
|
22494
21581
|
(self) => (x) => typed3.find(self, x.valueType())(x.value)
|
|
22495
21582
|
),
|
|
22496
21583
|
"Array | Matrix": typed3.referToSelf(
|
|
22497
|
-
(self) => (x) =>
|
|
21584
|
+
(self) => (x) => deepMap(x, self)
|
|
22498
21585
|
)
|
|
22499
21586
|
});
|
|
22500
21587
|
}
|
|
@@ -22594,7 +21681,7 @@ var createIsPrime = /* @__PURE__ */ factory(
|
|
|
22594
21681
|
return true;
|
|
22595
21682
|
},
|
|
22596
21683
|
"Array | Matrix": typed3.referToSelf(
|
|
22597
|
-
(self) => (x) =>
|
|
21684
|
+
(self) => (x) => deepMap(x, self)
|
|
22598
21685
|
)
|
|
22599
21686
|
});
|
|
22600
21687
|
}
|
|
@@ -22722,7 +21809,7 @@ var createUnaryPlus = /* @__PURE__ */ factory(
|
|
|
22722
21809
|
},
|
|
22723
21810
|
// deep map collection, skip zeros since unaryPlus(0) = 0
|
|
22724
21811
|
"Array | Matrix": typed3.referToSelf(
|
|
22725
|
-
(self) => (x) =>
|
|
21812
|
+
(self) => (x) => deepMap(x, self, true)
|
|
22726
21813
|
),
|
|
22727
21814
|
boolean: function(x) {
|
|
22728
21815
|
return numeric2(x ? 1 : 0, config2.number);
|
|
@@ -23032,7 +22119,7 @@ var createProd = /* @__PURE__ */ factory(
|
|
|
23032
22119
|
}
|
|
23033
22120
|
}
|
|
23034
22121
|
let prod2;
|
|
23035
|
-
|
|
22122
|
+
deepForEach(array, function(value) {
|
|
23036
22123
|
try {
|
|
23037
22124
|
const converted = typeof value === "string" ? parseNumberWithConfig2(value) : value;
|
|
23038
22125
|
prod2 = prod2 === void 0 ? converted : multiplyScalar2(prod2, converted);
|
|
@@ -23054,13 +22141,13 @@ var dependencies77 = ["typed", "format"];
|
|
|
23054
22141
|
var createBin = /* @__PURE__ */ factory(
|
|
23055
22142
|
name77,
|
|
23056
22143
|
dependencies77,
|
|
23057
|
-
({ typed: typed3, format:
|
|
22144
|
+
({ typed: typed3, format: format4 }) => {
|
|
23058
22145
|
return typed3(name77, {
|
|
23059
22146
|
"number | BigNumber": function(n) {
|
|
23060
|
-
return
|
|
22147
|
+
return format4(n, { notation: "bin" });
|
|
23061
22148
|
},
|
|
23062
22149
|
"number | BigNumber, number | BigNumber": function(n, wordSize) {
|
|
23063
|
-
return
|
|
22150
|
+
return format4(n, { notation: "bin", wordSize });
|
|
23064
22151
|
}
|
|
23065
22152
|
});
|
|
23066
22153
|
}
|
|
@@ -23072,13 +22159,13 @@ var dependencies78 = ["typed", "format"];
|
|
|
23072
22159
|
var createHex = /* @__PURE__ */ factory(
|
|
23073
22160
|
name78,
|
|
23074
22161
|
dependencies78,
|
|
23075
|
-
({ typed: typed3, format:
|
|
22162
|
+
({ typed: typed3, format: format4 }) => {
|
|
23076
22163
|
return typed3(name78, {
|
|
23077
22164
|
"number | BigNumber": function(n) {
|
|
23078
|
-
return
|
|
22165
|
+
return format4(n, { notation: "hex" });
|
|
23079
22166
|
},
|
|
23080
22167
|
"number | BigNumber, number | BigNumber": function(n, wordSize) {
|
|
23081
|
-
return
|
|
22168
|
+
return format4(n, { notation: "hex", wordSize });
|
|
23082
22169
|
}
|
|
23083
22170
|
});
|
|
23084
22171
|
}
|
|
@@ -23090,13 +22177,13 @@ var dependencies79 = ["typed", "format"];
|
|
|
23090
22177
|
var createOct = /* @__PURE__ */ factory(
|
|
23091
22178
|
name79,
|
|
23092
22179
|
dependencies79,
|
|
23093
|
-
({ typed: typed3, format:
|
|
22180
|
+
({ typed: typed3, format: format4 }) => {
|
|
23094
22181
|
return typed3(name79, {
|
|
23095
22182
|
"number | BigNumber": function(n) {
|
|
23096
|
-
return
|
|
22183
|
+
return format4(n, { notation: "oct" });
|
|
23097
22184
|
},
|
|
23098
22185
|
"number | BigNumber, number | BigNumber": function(n, wordSize) {
|
|
23099
|
-
return
|
|
22186
|
+
return format4(n, { notation: "oct", wordSize });
|
|
23100
22187
|
}
|
|
23101
22188
|
});
|
|
23102
22189
|
}
|
|
@@ -23127,9 +22214,9 @@ var dependencies81 = ["typed", "isBounded", "map"];
|
|
|
23127
22214
|
var createIsFinite = /* @__PURE__ */ factory(
|
|
23128
22215
|
name81,
|
|
23129
22216
|
dependencies81,
|
|
23130
|
-
({ typed: typed3, isBounded: isBounded2, map:
|
|
22217
|
+
({ typed: typed3, isBounded: isBounded2, map: map3 }) => {
|
|
23131
22218
|
return typed3(name81, {
|
|
23132
|
-
"Array | Matrix": (A) =>
|
|
22219
|
+
"Array | Matrix": (A) => map3(A, isBounded2),
|
|
23133
22220
|
any: (x) => isBounded2(x)
|
|
23134
22221
|
});
|
|
23135
22222
|
}
|
|
@@ -23149,7 +22236,7 @@ var createIsZero = /* @__PURE__ */ factory(
|
|
|
23149
22236
|
(self) => (x) => typed3.find(self, x.valueType())(x.value)
|
|
23150
22237
|
),
|
|
23151
22238
|
"Array | Matrix": typed3.referToSelf(
|
|
23152
|
-
(self) => (x) =>
|
|
22239
|
+
(self) => (x) => deepMap(x, self)
|
|
23153
22240
|
)
|
|
23154
22241
|
});
|
|
23155
22242
|
}
|
|
@@ -23254,7 +22341,7 @@ var createTranspose = /* @__PURE__ */ factory(
|
|
|
23254
22341
|
const columns = size2[1];
|
|
23255
22342
|
if (columns === 0) {
|
|
23256
22343
|
throw new RangeError(
|
|
23257
|
-
"Cannot transpose a 2D matrix with no columns (size: " +
|
|
22344
|
+
"Cannot transpose a 2D matrix with no columns (size: " + formatGeneric(size2, {}) + ")"
|
|
23258
22345
|
);
|
|
23259
22346
|
}
|
|
23260
22347
|
switch (x.storage()) {
|
|
@@ -23269,7 +22356,7 @@ var createTranspose = /* @__PURE__ */ factory(
|
|
|
23269
22356
|
break;
|
|
23270
22357
|
default:
|
|
23271
22358
|
throw new RangeError(
|
|
23272
|
-
"Matrix must be a vector or two dimensional (size: " +
|
|
22359
|
+
"Matrix must be a vector or two dimensional (size: " + formatGeneric(size2, {}) + ")"
|
|
23273
22360
|
);
|
|
23274
22361
|
}
|
|
23275
22362
|
return c;
|
|
@@ -23386,47 +22473,47 @@ var createIdentity = /* @__PURE__ */ factory(
|
|
|
23386
22473
|
"": function() {
|
|
23387
22474
|
return config2.matrix === "Matrix" ? matrix2([]) : [];
|
|
23388
22475
|
},
|
|
23389
|
-
string: function(
|
|
23390
|
-
return matrix2(
|
|
22476
|
+
string: function(format4) {
|
|
22477
|
+
return matrix2(format4);
|
|
23391
22478
|
},
|
|
23392
22479
|
"number | BigNumber": function(rows) {
|
|
23393
22480
|
return _identity(rows, rows, config2.matrix === "Matrix" ? "dense" : void 0);
|
|
23394
22481
|
},
|
|
23395
|
-
"number | BigNumber, string": function(rows,
|
|
23396
|
-
return _identity(rows, rows,
|
|
22482
|
+
"number | BigNumber, string": function(rows, format4) {
|
|
22483
|
+
return _identity(rows, rows, format4);
|
|
23397
22484
|
},
|
|
23398
22485
|
"number | BigNumber, number | BigNumber": function(rows, cols) {
|
|
23399
22486
|
return _identity(rows, cols, config2.matrix === "Matrix" ? "dense" : void 0);
|
|
23400
22487
|
},
|
|
23401
|
-
"number | BigNumber, number | BigNumber, string": function(rows, cols,
|
|
23402
|
-
return _identity(rows, cols,
|
|
22488
|
+
"number | BigNumber, number | BigNumber, string": function(rows, cols, format4) {
|
|
22489
|
+
return _identity(rows, cols, format4);
|
|
23403
22490
|
},
|
|
23404
22491
|
Array: function(size2) {
|
|
23405
22492
|
return _identityVector(size2);
|
|
23406
22493
|
},
|
|
23407
|
-
"Array, string": function(size2,
|
|
23408
|
-
return _identityVector(size2,
|
|
22494
|
+
"Array, string": function(size2, format4) {
|
|
22495
|
+
return _identityVector(size2, format4);
|
|
23409
22496
|
},
|
|
23410
22497
|
Matrix: function(size2) {
|
|
23411
22498
|
return _identityVector(size2.valueOf(), size2.storage());
|
|
23412
22499
|
},
|
|
23413
|
-
"Matrix, string": function(size2,
|
|
23414
|
-
return _identityVector(size2.valueOf(),
|
|
22500
|
+
"Matrix, string": function(size2, format4) {
|
|
22501
|
+
return _identityVector(size2.valueOf(), format4);
|
|
23415
22502
|
}
|
|
23416
22503
|
});
|
|
23417
|
-
function _identityVector(size2,
|
|
22504
|
+
function _identityVector(size2, format4) {
|
|
23418
22505
|
switch (size2.length) {
|
|
23419
22506
|
case 0:
|
|
23420
|
-
return
|
|
22507
|
+
return format4 ? matrix2(format4) : [];
|
|
23421
22508
|
case 1:
|
|
23422
|
-
return _identity(size2[0], size2[0],
|
|
22509
|
+
return _identity(size2[0], size2[0], format4);
|
|
23423
22510
|
case 2:
|
|
23424
|
-
return _identity(size2[0], size2[1],
|
|
22511
|
+
return _identity(size2[0], size2[1], format4);
|
|
23425
22512
|
default:
|
|
23426
22513
|
throw new Error("Vector containing two values expected");
|
|
23427
22514
|
}
|
|
23428
22515
|
}
|
|
23429
|
-
function _identity(rows, cols,
|
|
22516
|
+
function _identity(rows, cols, format4) {
|
|
23430
22517
|
const Big = isBigNumber(rows) || isBigNumber(cols) ? BigNumber9 : null;
|
|
23431
22518
|
if (isBigNumber(rows)) rows = rows.toNumber();
|
|
23432
22519
|
if (isBigNumber(cols)) cols = cols.toNumber();
|
|
@@ -23439,14 +22526,14 @@ var createIdentity = /* @__PURE__ */ factory(
|
|
|
23439
22526
|
const one = Big ? new BigNumber9(1) : 1;
|
|
23440
22527
|
const defaultValue = Big ? new Big(0) : 0;
|
|
23441
22528
|
const size2 = [rows, cols];
|
|
23442
|
-
if (
|
|
23443
|
-
if (
|
|
22529
|
+
if (format4) {
|
|
22530
|
+
if (format4 === "sparse") {
|
|
23444
22531
|
return SparseMatrix.diagonal(size2, one, 0, defaultValue);
|
|
23445
22532
|
}
|
|
23446
|
-
if (
|
|
22533
|
+
if (format4 === "dense") {
|
|
23447
22534
|
return DenseMatrix6.diagonal(size2, one, 0, defaultValue);
|
|
23448
22535
|
}
|
|
23449
|
-
throw new TypeError(`Unknown matrix type "${
|
|
22536
|
+
throw new TypeError(`Unknown matrix type "${format4}"`);
|
|
23450
22537
|
}
|
|
23451
22538
|
const res = resize([], size2, defaultValue);
|
|
23452
22539
|
const minimum = rows < cols ? rows : cols;
|
|
@@ -23467,10 +22554,10 @@ function createZerosAndOnes(name254, defaultValue, { typed: typed3, config: conf
|
|
|
23467
22554
|
// math.zeros/ones(m, n, p, ..., format)
|
|
23468
22555
|
// TODO: more accurate signature '...number | BigNumber, string' as soon as typed-function supports this
|
|
23469
22556
|
"...number | BigNumber | string": function(size2) {
|
|
23470
|
-
const
|
|
23471
|
-
if (typeof
|
|
23472
|
-
const
|
|
23473
|
-
return _zerosAndOnes(size2,
|
|
22557
|
+
const last2 = size2[size2.length - 1];
|
|
22558
|
+
if (typeof last2 === "string") {
|
|
22559
|
+
const format4 = size2.pop();
|
|
22560
|
+
return _zerosAndOnes(size2, format4);
|
|
23474
22561
|
} else if (config2.matrix === "Array") {
|
|
23475
22562
|
return _zerosAndOnes(size2);
|
|
23476
22563
|
} else {
|
|
@@ -23479,20 +22566,20 @@ function createZerosAndOnes(name254, defaultValue, { typed: typed3, config: conf
|
|
|
23479
22566
|
},
|
|
23480
22567
|
Array: _zerosAndOnes,
|
|
23481
22568
|
Matrix: function(size2) {
|
|
23482
|
-
const
|
|
23483
|
-
return _zerosAndOnes(size2.valueOf(),
|
|
22569
|
+
const format4 = size2.storage();
|
|
22570
|
+
return _zerosAndOnes(size2.valueOf(), format4);
|
|
23484
22571
|
},
|
|
23485
|
-
"Array | Matrix, string": function(size2,
|
|
22572
|
+
"Array | Matrix, string": function(size2, format4) {
|
|
23486
22573
|
const sizeArray = Array.isArray(size2) ? size2 : size2.valueOf();
|
|
23487
|
-
return _zerosAndOnes(sizeArray,
|
|
22574
|
+
return _zerosAndOnes(sizeArray, format4);
|
|
23488
22575
|
}
|
|
23489
22576
|
});
|
|
23490
|
-
function _zerosAndOnes(size2,
|
|
22577
|
+
function _zerosAndOnes(size2, format4) {
|
|
23491
22578
|
const hasBigNumbers = _normalize(size2);
|
|
23492
22579
|
const dflt = hasBigNumbers ? new BigNumber9(defaultValue) : defaultValue;
|
|
23493
22580
|
_validate(size2);
|
|
23494
|
-
if (
|
|
23495
|
-
const m = matrix2(
|
|
22581
|
+
if (format4) {
|
|
22582
|
+
const m = matrix2(format4);
|
|
23496
22583
|
if (size2.length > 0) {
|
|
23497
22584
|
return m.resize(size2, dflt);
|
|
23498
22585
|
}
|
|
@@ -23564,14 +22651,14 @@ var createDiag = /* @__PURE__ */ factory(
|
|
|
23564
22651
|
"Array, BigNumber": function(x, k) {
|
|
23565
22652
|
return _diag(x, k.toNumber(), arraySize(x), null);
|
|
23566
22653
|
},
|
|
23567
|
-
"Array, string": function(x,
|
|
23568
|
-
return _diag(x, 0, arraySize(x),
|
|
22654
|
+
"Array, string": function(x, format4) {
|
|
22655
|
+
return _diag(x, 0, arraySize(x), format4);
|
|
23569
22656
|
},
|
|
23570
|
-
"Array, number, string": function(x, k,
|
|
23571
|
-
return _diag(x, k, arraySize(x),
|
|
22657
|
+
"Array, number, string": function(x, k, format4) {
|
|
22658
|
+
return _diag(x, k, arraySize(x), format4);
|
|
23572
22659
|
},
|
|
23573
|
-
"Array, BigNumber, string": function(x, k,
|
|
23574
|
-
return _diag(x, k.toNumber(), arraySize(x),
|
|
22660
|
+
"Array, BigNumber, string": function(x, k, format4) {
|
|
22661
|
+
return _diag(x, k.toNumber(), arraySize(x), format4);
|
|
23575
22662
|
},
|
|
23576
22663
|
Matrix: function(x) {
|
|
23577
22664
|
return _diag(x, 0, x.size(), x.storage());
|
|
@@ -23582,17 +22669,17 @@ var createDiag = /* @__PURE__ */ factory(
|
|
|
23582
22669
|
"Matrix, BigNumber": function(x, k) {
|
|
23583
22670
|
return _diag(x, k.toNumber(), x.size(), x.storage());
|
|
23584
22671
|
},
|
|
23585
|
-
"Matrix, string": function(x,
|
|
23586
|
-
return _diag(x, 0, x.size(),
|
|
22672
|
+
"Matrix, string": function(x, format4) {
|
|
22673
|
+
return _diag(x, 0, x.size(), format4);
|
|
23587
22674
|
},
|
|
23588
|
-
"Matrix, number, string": function(x, k,
|
|
23589
|
-
return _diag(x, k, x.size(),
|
|
22675
|
+
"Matrix, number, string": function(x, k, format4) {
|
|
22676
|
+
return _diag(x, k, x.size(), format4);
|
|
23590
22677
|
},
|
|
23591
|
-
"Matrix, BigNumber, string": function(x, k,
|
|
23592
|
-
return _diag(x, k.toNumber(), x.size(),
|
|
22678
|
+
"Matrix, BigNumber, string": function(x, k, format4) {
|
|
22679
|
+
return _diag(x, k.toNumber(), x.size(), format4);
|
|
23593
22680
|
}
|
|
23594
22681
|
});
|
|
23595
|
-
function _diag(x, k, size2,
|
|
22682
|
+
function _diag(x, k, size2, format4) {
|
|
23596
22683
|
if (!isInteger(k)) {
|
|
23597
22684
|
throw new TypeError("Second parameter in function diag must be an integer");
|
|
23598
22685
|
}
|
|
@@ -23600,26 +22687,26 @@ var createDiag = /* @__PURE__ */ factory(
|
|
|
23600
22687
|
const kSub = k < 0 ? -k : 0;
|
|
23601
22688
|
switch (size2.length) {
|
|
23602
22689
|
case 1:
|
|
23603
|
-
return _createDiagonalMatrix(x, k,
|
|
22690
|
+
return _createDiagonalMatrix(x, k, format4, size2[0], kSub, kSuper);
|
|
23604
22691
|
case 2:
|
|
23605
|
-
return _getDiagonal(x, k,
|
|
22692
|
+
return _getDiagonal(x, k, format4, size2, kSub, kSuper);
|
|
23606
22693
|
}
|
|
23607
22694
|
throw new RangeError("Matrix for function diag must be 2 dimensional");
|
|
23608
22695
|
}
|
|
23609
|
-
function _createDiagonalMatrix(x, k,
|
|
22696
|
+
function _createDiagonalMatrix(x, k, format4, l, kSub, kSuper) {
|
|
23610
22697
|
const ms = [l + kSub, l + kSuper];
|
|
23611
|
-
if (
|
|
23612
|
-
throw new TypeError(`Unknown matrix type ${
|
|
22698
|
+
if (format4 && format4 !== "sparse" && format4 !== "dense") {
|
|
22699
|
+
throw new TypeError(`Unknown matrix type ${format4}"`);
|
|
23613
22700
|
}
|
|
23614
|
-
const m =
|
|
23615
|
-
return
|
|
22701
|
+
const m = format4 === "sparse" ? SparseMatrix.diagonal(ms, x, k) : DenseMatrix6.diagonal(ms, x, k);
|
|
22702
|
+
return format4 !== null ? m : m.valueOf();
|
|
23616
22703
|
}
|
|
23617
|
-
function _getDiagonal(x, k,
|
|
22704
|
+
function _getDiagonal(x, k, format4, s, kSub, kSuper) {
|
|
23618
22705
|
if (isMatrix(x)) {
|
|
23619
22706
|
const dm = x.diagonal(k);
|
|
23620
|
-
if (
|
|
23621
|
-
if (
|
|
23622
|
-
return matrix2(dm.valueOf(),
|
|
22707
|
+
if (format4 !== null) {
|
|
22708
|
+
if (format4 !== dm.storage()) {
|
|
22709
|
+
return matrix2(dm.valueOf(), format4);
|
|
23623
22710
|
}
|
|
23624
22711
|
return dm;
|
|
23625
22712
|
}
|
|
@@ -23630,7 +22717,7 @@ var createDiag = /* @__PURE__ */ factory(
|
|
|
23630
22717
|
for (let i = 0; i < n; i++) {
|
|
23631
22718
|
vector[i] = x[i + kSub][i + kSuper];
|
|
23632
22719
|
}
|
|
23633
|
-
return
|
|
22720
|
+
return format4 !== null ? matrix2(vector) : vector;
|
|
23634
22721
|
}
|
|
23635
22722
|
}
|
|
23636
22723
|
);
|
|
@@ -23748,11 +22835,11 @@ var createMatrixFromFunction = /* @__PURE__ */ factory(
|
|
|
23748
22835
|
isZero: isZero2
|
|
23749
22836
|
}) => {
|
|
23750
22837
|
return typed3(name91, {
|
|
23751
|
-
"Array | Matrix, function, string, string": function(size2, fn,
|
|
23752
|
-
return _create(size2, fn,
|
|
22838
|
+
"Array | Matrix, function, string, string": function(size2, fn, format4, datatype) {
|
|
22839
|
+
return _create(size2, fn, format4, datatype);
|
|
23753
22840
|
},
|
|
23754
|
-
"Array | Matrix, function, string": function(size2, fn,
|
|
23755
|
-
return _create(size2, fn,
|
|
22841
|
+
"Array | Matrix, function, string": function(size2, fn, format4) {
|
|
22842
|
+
return _create(size2, fn, format4, void 0);
|
|
23756
22843
|
},
|
|
23757
22844
|
"Matrix, function": function(size2, fn) {
|
|
23758
22845
|
return _create(size2, fn, "dense", void 0);
|
|
@@ -23760,19 +22847,19 @@ var createMatrixFromFunction = /* @__PURE__ */ factory(
|
|
|
23760
22847
|
"Array, function": function(size2, fn) {
|
|
23761
22848
|
return _create(size2, fn, "dense", void 0).toArray();
|
|
23762
22849
|
},
|
|
23763
|
-
"Array | Matrix, string, function": function(size2,
|
|
23764
|
-
return _create(size2, fn,
|
|
22850
|
+
"Array | Matrix, string, function": function(size2, format4, fn) {
|
|
22851
|
+
return _create(size2, fn, format4, void 0);
|
|
23765
22852
|
},
|
|
23766
|
-
"Array | Matrix, string, string, function": function(size2,
|
|
23767
|
-
return _create(size2, fn,
|
|
22853
|
+
"Array | Matrix, string, string, function": function(size2, format4, datatype, fn) {
|
|
22854
|
+
return _create(size2, fn, format4, datatype);
|
|
23768
22855
|
}
|
|
23769
22856
|
});
|
|
23770
|
-
function _create(size2, fn,
|
|
22857
|
+
function _create(size2, fn, format4, datatype) {
|
|
23771
22858
|
let m;
|
|
23772
22859
|
if (datatype !== void 0) {
|
|
23773
|
-
m = matrix2(
|
|
22860
|
+
m = matrix2(format4, datatype);
|
|
23774
22861
|
} else {
|
|
23775
|
-
m = matrix2(
|
|
22862
|
+
m = matrix2(format4);
|
|
23776
22863
|
}
|
|
23777
22864
|
m.resize(size2);
|
|
23778
22865
|
m.forEach(function(_, index) {
|
|
@@ -23958,7 +23045,7 @@ var createTrace = /* @__PURE__ */ factory(
|
|
|
23958
23045
|
if (size2[0] === 1) {
|
|
23959
23046
|
return clone(data[0]);
|
|
23960
23047
|
}
|
|
23961
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23048
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
23962
23049
|
case 2: {
|
|
23963
23050
|
const rows = size2[0];
|
|
23964
23051
|
const cols = size2[1];
|
|
@@ -23969,11 +23056,11 @@ var createTrace = /* @__PURE__ */ factory(
|
|
|
23969
23056
|
}
|
|
23970
23057
|
return sum3;
|
|
23971
23058
|
} else {
|
|
23972
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23059
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
23973
23060
|
}
|
|
23974
23061
|
}
|
|
23975
23062
|
default:
|
|
23976
|
-
throw new RangeError("Matrix must be two dimensional (size: " +
|
|
23063
|
+
throw new RangeError("Matrix must be two dimensional (size: " + formatGeneric(size2, {}) + ")");
|
|
23977
23064
|
}
|
|
23978
23065
|
}
|
|
23979
23066
|
function _sparseTrace(m) {
|
|
@@ -24003,7 +23090,7 @@ var createTrace = /* @__PURE__ */ factory(
|
|
|
24003
23090
|
}
|
|
24004
23091
|
return sum3;
|
|
24005
23092
|
}
|
|
24006
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23093
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
24007
23094
|
}
|
|
24008
23095
|
}
|
|
24009
23096
|
);
|
|
@@ -24070,7 +23157,7 @@ var createDet = /* @__PURE__ */ factory(
|
|
|
24070
23157
|
if (size2[0] === 0) {
|
|
24071
23158
|
return 1;
|
|
24072
23159
|
} else {
|
|
24073
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23160
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
24074
23161
|
}
|
|
24075
23162
|
case 2: {
|
|
24076
23163
|
const rows = size2[0];
|
|
@@ -24081,12 +23168,12 @@ var createDet = /* @__PURE__ */ factory(
|
|
|
24081
23168
|
if (cols === 0) {
|
|
24082
23169
|
return 1;
|
|
24083
23170
|
} else {
|
|
24084
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
23171
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
24085
23172
|
}
|
|
24086
23173
|
}
|
|
24087
23174
|
default:
|
|
24088
23175
|
throw new RangeError(
|
|
24089
|
-
"Matrix must be two dimensional (size: " +
|
|
23176
|
+
"Matrix must be two dimensional (size: " + formatGeneric(size2, {}) + ")"
|
|
24090
23177
|
);
|
|
24091
23178
|
}
|
|
24092
23179
|
}
|
|
@@ -24416,14 +23503,14 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24416
23503
|
const degree2 = 5 * (n + 1);
|
|
24417
23504
|
const w = 6 * (n + 1);
|
|
24418
23505
|
const hhead = 7 * (n + 1);
|
|
24419
|
-
const
|
|
23506
|
+
const last2 = P2;
|
|
24420
23507
|
let mark = _initializeQuotientGraph(
|
|
24421
23508
|
n,
|
|
24422
23509
|
cptr,
|
|
24423
23510
|
W,
|
|
24424
23511
|
len,
|
|
24425
23512
|
head,
|
|
24426
|
-
|
|
23513
|
+
last2,
|
|
24427
23514
|
next,
|
|
24428
23515
|
hhead,
|
|
24429
23516
|
nv,
|
|
@@ -24431,13 +23518,13 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24431
23518
|
elen,
|
|
24432
23519
|
degree2
|
|
24433
23520
|
);
|
|
24434
|
-
let nel = _initializeDegreeLists(n, cptr, W, degree2, elen, w, dense, nv, head,
|
|
23521
|
+
let nel = _initializeDegreeLists(n, cptr, W, degree2, elen, w, dense, nv, head, last2, next);
|
|
24435
23522
|
let mindeg = 0;
|
|
24436
23523
|
let i, j, k, k1, k2, e, pj, ln, nvi, pk, eln, p1, p2, pn, h, d;
|
|
24437
23524
|
while (nel < n) {
|
|
24438
23525
|
for (k = -1; mindeg < n && (k = W[head + mindeg]) === -1; mindeg++) ;
|
|
24439
23526
|
if (W[next + k] !== -1) {
|
|
24440
|
-
|
|
23527
|
+
last2[W[next + k]] = -1;
|
|
24441
23528
|
}
|
|
24442
23529
|
W[head + mindeg] = W[next + k];
|
|
24443
23530
|
const elenk = W[elen + k];
|
|
@@ -24467,10 +23554,10 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24467
23554
|
W[nv + i] = -nvi;
|
|
24468
23555
|
cindex[pk2++] = i;
|
|
24469
23556
|
if (W[next + i] !== -1) {
|
|
24470
|
-
|
|
23557
|
+
last2[W[next + i]] = last2[i];
|
|
24471
23558
|
}
|
|
24472
|
-
if (
|
|
24473
|
-
W[next +
|
|
23559
|
+
if (last2[i] !== -1) {
|
|
23560
|
+
W[next + last2[i]] = W[next + i];
|
|
24474
23561
|
} else {
|
|
24475
23562
|
W[head + W[degree2 + i]] = W[next + i];
|
|
24476
23563
|
}
|
|
@@ -24553,7 +23640,7 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24553
23640
|
h = (h < 0 ? -h : h) % n;
|
|
24554
23641
|
W[next + i] = W[hhead + h];
|
|
24555
23642
|
W[hhead + h] = i;
|
|
24556
|
-
|
|
23643
|
+
last2[i] = h;
|
|
24557
23644
|
}
|
|
24558
23645
|
}
|
|
24559
23646
|
W[degree2 + k] = dk;
|
|
@@ -24564,7 +23651,7 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24564
23651
|
if (W[nv + i] >= 0) {
|
|
24565
23652
|
continue;
|
|
24566
23653
|
}
|
|
24567
|
-
h =
|
|
23654
|
+
h = last2[i];
|
|
24568
23655
|
i = W[hhead + h];
|
|
24569
23656
|
W[hhead + h] = -1;
|
|
24570
23657
|
for (; i !== -1 && W[next + i] !== -1; i = W[next + i], mark++) {
|
|
@@ -24604,10 +23691,10 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24604
23691
|
d = W[degree2 + i] + dk - nvi;
|
|
24605
23692
|
d = Math.min(d, n - nel - nvi);
|
|
24606
23693
|
if (W[head + d] !== -1) {
|
|
24607
|
-
|
|
23694
|
+
last2[W[head + d]] = i;
|
|
24608
23695
|
}
|
|
24609
23696
|
W[next + i] = W[head + d];
|
|
24610
|
-
|
|
23697
|
+
last2[i] = -1;
|
|
24611
23698
|
W[head + d] = i;
|
|
24612
23699
|
mindeg = Math.min(mindeg, d);
|
|
24613
23700
|
W[degree2 + i] = d;
|
|
@@ -24677,14 +23764,14 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24677
23764
|
}
|
|
24678
23765
|
return multiply2(at, a);
|
|
24679
23766
|
}
|
|
24680
|
-
function _initializeQuotientGraph(n, cptr, W, len, head,
|
|
23767
|
+
function _initializeQuotientGraph(n, cptr, W, len, head, last2, next, hhead, nv, w, elen, degree2) {
|
|
24681
23768
|
for (let k = 0; k < n; k++) {
|
|
24682
23769
|
W[len + k] = cptr[k + 1] - cptr[k];
|
|
24683
23770
|
}
|
|
24684
23771
|
W[len + n] = 0;
|
|
24685
23772
|
for (let i = 0; i <= n; i++) {
|
|
24686
23773
|
W[head + i] = -1;
|
|
24687
|
-
|
|
23774
|
+
last2[i] = -1;
|
|
24688
23775
|
W[next + i] = -1;
|
|
24689
23776
|
W[hhead + i] = -1;
|
|
24690
23777
|
W[nv + i] = 1;
|
|
@@ -24698,7 +23785,7 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24698
23785
|
W[w + n] = 0;
|
|
24699
23786
|
return mark;
|
|
24700
23787
|
}
|
|
24701
|
-
function _initializeDegreeLists(n, cptr, W, degree2, elen, w, dense, nv, head,
|
|
23788
|
+
function _initializeDegreeLists(n, cptr, W, degree2, elen, w, dense, nv, head, last2, next) {
|
|
24702
23789
|
let nel = 0;
|
|
24703
23790
|
for (let i = 0; i < n; i++) {
|
|
24704
23791
|
const d = W[degree2 + i];
|
|
@@ -24716,7 +23803,7 @@ var createCsAmd = /* @__PURE__ */ factory(
|
|
|
24716
23803
|
} else {
|
|
24717
23804
|
const h = W[head + d];
|
|
24718
23805
|
if (h !== -1) {
|
|
24719
|
-
|
|
23806
|
+
last2[h] = i;
|
|
24720
23807
|
}
|
|
24721
23808
|
W[next + i] = W[head + d];
|
|
24722
23809
|
W[head + d] = i;
|
|
@@ -25186,12 +24273,12 @@ function createSolveValidation({ DenseMatrix: DenseMatrix6 }) {
|
|
|
25186
24273
|
return function solveValidation(m, b, copy) {
|
|
25187
24274
|
const mSize = m.size();
|
|
25188
24275
|
if (mSize.length !== 2) {
|
|
25189
|
-
throw new RangeError("Matrix must be two dimensional (size: " +
|
|
24276
|
+
throw new RangeError("Matrix must be two dimensional (size: " + formatGeneric(mSize, {}) + ")");
|
|
25190
24277
|
}
|
|
25191
24278
|
const rows = mSize[0];
|
|
25192
24279
|
const columns = mSize[1];
|
|
25193
24280
|
if (rows !== columns) {
|
|
25194
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
24281
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(mSize, {}) + ")");
|
|
25195
24282
|
}
|
|
25196
24283
|
let data = [];
|
|
25197
24284
|
if (isMatrix(b)) {
|
|
@@ -26354,7 +25441,7 @@ var createRound = /* @__PURE__ */ factory(
|
|
|
26354
25441
|
),
|
|
26355
25442
|
"Array | Matrix, number | BigNumber, Unit": typed3.referToSelf(
|
|
26356
25443
|
(self) => (x, n, unit2) => {
|
|
26357
|
-
return
|
|
25444
|
+
return deepMap(x, (value) => self(value, n, unit2), true);
|
|
26358
25445
|
}
|
|
26359
25446
|
),
|
|
26360
25447
|
"Array | Matrix | Unit, Unit": typed3.referToSelf(
|
|
@@ -26362,7 +25449,7 @@ var createRound = /* @__PURE__ */ factory(
|
|
|
26362
25449
|
),
|
|
26363
25450
|
"Array | Matrix": typed3.referToSelf(
|
|
26364
25451
|
(self) => (x) => {
|
|
26365
|
-
return
|
|
25452
|
+
return deepMap(x, self, true);
|
|
26366
25453
|
}
|
|
26367
25454
|
),
|
|
26368
25455
|
"SparseMatrix, number | BigNumber": typed3.referToSelf(
|
|
@@ -26536,6 +25623,12 @@ var createCatalan = /* @__PURE__ */ factory(
|
|
|
26536
25623
|
}
|
|
26537
25624
|
);
|
|
26538
25625
|
|
|
25626
|
+
// src/error/IndexError.ts
|
|
25627
|
+
import { IndexError, createIndexError } from "@danielsimonjr/mathts-core/internal";
|
|
25628
|
+
|
|
25629
|
+
// src/error/DimensionError.ts
|
|
25630
|
+
import { DimensionError } from "@danielsimonjr/mathts-core/internal";
|
|
25631
|
+
|
|
26539
25632
|
// src/matrix/concat.ts
|
|
26540
25633
|
var name115 = "concat";
|
|
26541
25634
|
var dependencies115 = ["typed", "matrix", "isInteger"];
|
|
@@ -26657,7 +25750,7 @@ var createInv = /* @__PURE__ */ factory(
|
|
|
26657
25750
|
return [divideScalar2(1, x[0])];
|
|
26658
25751
|
}
|
|
26659
25752
|
} else {
|
|
26660
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
25753
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
26661
25754
|
}
|
|
26662
25755
|
case 2: {
|
|
26663
25756
|
const rows = size2[0];
|
|
@@ -26671,12 +25764,12 @@ var createInv = /* @__PURE__ */ factory(
|
|
|
26671
25764
|
return _inv4(x, rows, cols);
|
|
26672
25765
|
}
|
|
26673
25766
|
} else {
|
|
26674
|
-
throw new RangeError("Matrix must be square (size: " +
|
|
25767
|
+
throw new RangeError("Matrix must be square (size: " + formatGeneric(size2, {}) + ")");
|
|
26675
25768
|
}
|
|
26676
25769
|
}
|
|
26677
25770
|
default:
|
|
26678
25771
|
throw new RangeError(
|
|
26679
|
-
"Matrix must be two dimensional (size: " +
|
|
25772
|
+
"Matrix must be two dimensional (size: " + formatGeneric(size2, {}) + ")"
|
|
26680
25773
|
);
|
|
26681
25774
|
}
|
|
26682
25775
|
},
|
|
@@ -26833,7 +25926,7 @@ function _mapSlices(mat, dim, callback) {
|
|
|
26833
25926
|
if (!Array.isArray(mat[0])) {
|
|
26834
25927
|
return callback(mat);
|
|
26835
25928
|
} else {
|
|
26836
|
-
tran =
|
|
25929
|
+
tran = _switch(mat);
|
|
26837
25930
|
ret = [];
|
|
26838
25931
|
for (i = 0; i < tran.length; i++) {
|
|
26839
25932
|
ret[i] = _mapSlices(tran[i], dim - 1, callback);
|
|
@@ -26848,7 +25941,7 @@ function _mapSlices(mat, dim, callback) {
|
|
|
26848
25941
|
return ret;
|
|
26849
25942
|
}
|
|
26850
25943
|
}
|
|
26851
|
-
function
|
|
25944
|
+
function _switch(mat) {
|
|
26852
25945
|
const I2 = mat.length;
|
|
26853
25946
|
const J = mat[0].length;
|
|
26854
25947
|
let i, j;
|
|
@@ -26872,13 +25965,13 @@ var createResize = /* @__PURE__ */ factory(
|
|
|
26872
25965
|
({ typed: typed3, config: config2, matrix: matrix2 }) => {
|
|
26873
25966
|
return typed3(name118, {
|
|
26874
25967
|
"any, Array | Matrix": function(x, size2) {
|
|
26875
|
-
return
|
|
25968
|
+
return _resize(x, size2);
|
|
26876
25969
|
},
|
|
26877
25970
|
"any, Array | Matrix, any": function(x, size2, defaultValue) {
|
|
26878
|
-
return
|
|
25971
|
+
return _resize(x, size2, defaultValue);
|
|
26879
25972
|
}
|
|
26880
25973
|
});
|
|
26881
|
-
function
|
|
25974
|
+
function _resize(x, size2, defaultValue) {
|
|
26882
25975
|
let sz = isMatrix(size2) ? size2.valueOf() : size2;
|
|
26883
25976
|
if (isBigNumber(sz[0])) {
|
|
26884
25977
|
sz = sz.map(function(value) {
|
|
@@ -26919,7 +26012,7 @@ var createResize = /* @__PURE__ */ factory(
|
|
|
26919
26012
|
const len = size2[0];
|
|
26920
26013
|
if (typeof len !== "number" || !isInteger(len)) {
|
|
26921
26014
|
throw new TypeError(
|
|
26922
|
-
"Invalid size, must contain positive integers (size: " +
|
|
26015
|
+
"Invalid size, must contain positive integers (size: " + formatGeneric(size2, {}) + ")"
|
|
26923
26016
|
);
|
|
26924
26017
|
}
|
|
26925
26018
|
if (str.length > len) {
|
|
@@ -27731,7 +26824,7 @@ var createIsInteger = /* @__PURE__ */ factory(
|
|
|
27731
26824
|
bigint: (_b) => true,
|
|
27732
26825
|
Fraction: (r) => r.d === 1n,
|
|
27733
26826
|
"Array | Matrix": typed3.referToSelf(
|
|
27734
|
-
(self) => (x) =>
|
|
26827
|
+
(self) => (x) => deepMap(x, self)
|
|
27735
26828
|
)
|
|
27736
26829
|
});
|
|
27737
26830
|
}
|
|
@@ -27797,6 +26890,23 @@ var createZpk2tf = /* @__PURE__ */ factory(
|
|
|
27797
26890
|
}
|
|
27798
26891
|
);
|
|
27799
26892
|
|
|
26893
|
+
// src/utils/switch.ts
|
|
26894
|
+
function _switch2(mat) {
|
|
26895
|
+
const rows = mat;
|
|
26896
|
+
const I2 = rows.length;
|
|
26897
|
+
const J = rows[0].length;
|
|
26898
|
+
let i, j;
|
|
26899
|
+
const ret = [];
|
|
26900
|
+
for (j = 0; j < J; j++) {
|
|
26901
|
+
const tmp = [];
|
|
26902
|
+
for (i = 0; i < I2; i++) {
|
|
26903
|
+
tmp.push(rows[i][j]);
|
|
26904
|
+
}
|
|
26905
|
+
ret.push(tmp);
|
|
26906
|
+
}
|
|
26907
|
+
return ret;
|
|
26908
|
+
}
|
|
26909
|
+
|
|
27800
26910
|
// src/statistics/cumsum.ts
|
|
27801
26911
|
import { neumaierCumsum as neumaierCumsum2 } from "@danielsimonjr/mathts-core";
|
|
27802
26912
|
function isFlatNumberArray2(arr10) {
|
|
@@ -27878,7 +26988,7 @@ var createCumSum = /* @__PURE__ */ factory(
|
|
|
27878
26988
|
if (!Array.isArray(initialValue)) {
|
|
27879
26989
|
return _cumsummap(mat);
|
|
27880
26990
|
} else {
|
|
27881
|
-
tran =
|
|
26991
|
+
tran = _switch2(mat);
|
|
27882
26992
|
ret = [];
|
|
27883
26993
|
for (i = 0; i < tran.length; i++) {
|
|
27884
26994
|
ret[i] = _cumsumDimensional(tran[i], dim - 1);
|
|
@@ -27934,7 +27044,7 @@ var createSum = /* @__PURE__ */ factory(
|
|
|
27934
27044
|
return pairwiseSum2(array);
|
|
27935
27045
|
}
|
|
27936
27046
|
let sum3;
|
|
27937
|
-
|
|
27047
|
+
deepForEach(array, function(value) {
|
|
27938
27048
|
try {
|
|
27939
27049
|
const converted = typeof value === "string" ? parseNumberWithConfig2(value) : value;
|
|
27940
27050
|
sum3 = sum3 === void 0 ? converted : add4(sum3, converted);
|
|
@@ -28275,7 +27385,7 @@ var createFloor = /* @__PURE__ */ factory(
|
|
|
28275
27385
|
),
|
|
28276
27386
|
"Array | Matrix, number | BigNumber, Unit": typed3.referToSelf(
|
|
28277
27387
|
(self) => (x, n, unit2) => {
|
|
28278
|
-
return
|
|
27388
|
+
return deepMap(x, (value) => self(value, n, unit2), true);
|
|
28279
27389
|
}
|
|
28280
27390
|
),
|
|
28281
27391
|
"Array | Matrix | Unit, Unit": typed3.referToSelf(
|
|
@@ -28283,12 +27393,12 @@ var createFloor = /* @__PURE__ */ factory(
|
|
|
28283
27393
|
),
|
|
28284
27394
|
"Array | Matrix": typed3.referToSelf(
|
|
28285
27395
|
(self) => (x) => {
|
|
28286
|
-
return
|
|
27396
|
+
return deepMap(x, self, true);
|
|
28287
27397
|
}
|
|
28288
27398
|
),
|
|
28289
27399
|
"Array, number | BigNumber": typed3.referToSelf(
|
|
28290
27400
|
(self) => (x, n) => {
|
|
28291
|
-
return
|
|
27401
|
+
return deepMap(x, (i) => self(i, n), true);
|
|
28292
27402
|
}
|
|
28293
27403
|
),
|
|
28294
27404
|
"SparseMatrix, number | BigNumber": typed3.referToSelf(
|
|
@@ -29020,7 +28130,7 @@ var createLog1p = /* @__PURE__ */ factory(
|
|
|
29020
28130
|
}
|
|
29021
28131
|
},
|
|
29022
28132
|
"Array | Matrix": typed3.referToSelf(
|
|
29023
|
-
(self) => (x) =>
|
|
28133
|
+
(self) => (x) => deepMap(x, self)
|
|
29024
28134
|
),
|
|
29025
28135
|
"any, any": typed3.referToSelf(
|
|
29026
28136
|
(self) => (x, base) => {
|
|
@@ -29376,7 +28486,7 @@ var createCeil = /* @__PURE__ */ factory(
|
|
|
29376
28486
|
),
|
|
29377
28487
|
"Array | Matrix, number | BigNumber, Unit": typed3.referToSelf(
|
|
29378
28488
|
(self) => (x, n, unit2) => {
|
|
29379
|
-
return
|
|
28489
|
+
return deepMap(x, (value) => self(value, n, unit2), true);
|
|
29380
28490
|
}
|
|
29381
28491
|
),
|
|
29382
28492
|
"Array | Matrix | Unit, Unit": typed3.referToSelf(
|
|
@@ -29384,12 +28494,12 @@ var createCeil = /* @__PURE__ */ factory(
|
|
|
29384
28494
|
),
|
|
29385
28495
|
"Array | Matrix": typed3.referToSelf(
|
|
29386
28496
|
(self) => (x) => {
|
|
29387
|
-
return
|
|
28497
|
+
return deepMap(x, self, true);
|
|
29388
28498
|
}
|
|
29389
28499
|
),
|
|
29390
28500
|
"Array, number | BigNumber": typed3.referToSelf(
|
|
29391
28501
|
(self) => (x, n) => {
|
|
29392
|
-
return
|
|
28502
|
+
return deepMap(x, (i) => self(i, n), true);
|
|
29393
28503
|
}
|
|
29394
28504
|
),
|
|
29395
28505
|
"SparseMatrix, number | BigNumber": typed3.referToSelf(
|
|
@@ -30565,7 +29675,7 @@ var createFix = /* @__PURE__ */ factory(
|
|
|
30565
29675
|
),
|
|
30566
29676
|
"Array | Matrix, number | BigNumber, Unit": typed3.referToSelf(
|
|
30567
29677
|
(self) => (x, n, unit2) => {
|
|
30568
|
-
return
|
|
29678
|
+
return deepMap(x, (value) => self(value, n, unit2), true);
|
|
30569
29679
|
}
|
|
30570
29680
|
),
|
|
30571
29681
|
"Array | Matrix | Unit, Unit": typed3.referToSelf(
|
|
@@ -30573,12 +29683,12 @@ var createFix = /* @__PURE__ */ factory(
|
|
|
30573
29683
|
),
|
|
30574
29684
|
"Array | Matrix": typed3.referToSelf(
|
|
30575
29685
|
(self) => (x) => {
|
|
30576
|
-
return
|
|
29686
|
+
return deepMap(x, self, true);
|
|
30577
29687
|
}
|
|
30578
29688
|
),
|
|
30579
29689
|
"Array | Matrix, number | BigNumber": typed3.referToSelf(
|
|
30580
29690
|
(self) => (x, n) => {
|
|
30581
|
-
return
|
|
29691
|
+
return deepMap(x, (i) => self(i, n), true);
|
|
30582
29692
|
}
|
|
30583
29693
|
),
|
|
30584
29694
|
"number | Complex | Fraction | BigNumber, Array": typed3.referToSelf(
|
|
@@ -30930,7 +30040,7 @@ var createPinv = /* @__PURE__ */ factory(
|
|
|
30930
30040
|
}
|
|
30931
30041
|
default:
|
|
30932
30042
|
throw new RangeError(
|
|
30933
|
-
"Matrix must be two dimensional (size: " +
|
|
30043
|
+
"Matrix must be two dimensional (size: " + formatGeneric(size2, {}) + ")"
|
|
30934
30044
|
);
|
|
30935
30045
|
}
|
|
30936
30046
|
},
|
|
@@ -31664,7 +30774,7 @@ var createMax = /* @__PURE__ */ factory(
|
|
|
31664
30774
|
}
|
|
31665
30775
|
}
|
|
31666
30776
|
let res;
|
|
31667
|
-
|
|
30777
|
+
deepForEach(array, function(value) {
|
|
31668
30778
|
try {
|
|
31669
30779
|
if (mathIsNaN(value)) {
|
|
31670
30780
|
res = value;
|
|
@@ -31743,7 +30853,7 @@ var createMin = /* @__PURE__ */ factory(
|
|
|
31743
30853
|
}
|
|
31744
30854
|
}
|
|
31745
30855
|
let min2;
|
|
31746
|
-
|
|
30856
|
+
deepForEach(array, function(value) {
|
|
31747
30857
|
try {
|
|
31748
30858
|
if (mathIsNaN(value)) {
|
|
31749
30859
|
min2 = value;
|
|
@@ -32275,7 +31385,7 @@ var createFactorial = /* @__PURE__ */ factory(
|
|
|
32275
31385
|
return gamma2(n.add(1));
|
|
32276
31386
|
},
|
|
32277
31387
|
"Array | Matrix": typed3.referToSelf(
|
|
32278
|
-
(self) => (n) =>
|
|
31388
|
+
(self) => (n) => deepMap(n, self)
|
|
32279
31389
|
)
|
|
32280
31390
|
});
|
|
32281
31391
|
}
|
|
@@ -32646,93 +31756,14 @@ var createLeafCount = /* @__PURE__ */ factory(
|
|
|
32646
31756
|
);
|
|
32647
31757
|
|
|
32648
31758
|
// 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
|
-
}
|
|
31759
|
+
import {
|
|
31760
|
+
ObjectWrappingMap,
|
|
31761
|
+
PartitionedMap,
|
|
31762
|
+
createEmptyMap,
|
|
31763
|
+
createMap as createMap2,
|
|
31764
|
+
assignMap,
|
|
31765
|
+
isObjectWrappingMap
|
|
31766
|
+
} from "@danielsimonjr/mathts-core/internal";
|
|
32736
31767
|
|
|
32737
31768
|
// src/algebra/resolve.ts
|
|
32738
31769
|
var name192 = "resolve";
|
|
@@ -33259,15 +32290,15 @@ var createSimplifyConstant = /* @__PURE__ */ factory(
|
|
|
33259
32290
|
const reduction = args.reduce(
|
|
33260
32291
|
(sofar, next) => {
|
|
33261
32292
|
if (!isNode(next)) {
|
|
33262
|
-
const
|
|
33263
|
-
if (isNode(
|
|
33264
|
-
return [
|
|
32293
|
+
const last2 = sofar.pop();
|
|
32294
|
+
if (isNode(last2)) {
|
|
32295
|
+
return [last2, next];
|
|
33265
32296
|
}
|
|
33266
32297
|
try {
|
|
33267
|
-
sofar.push(_eval(fn, [
|
|
32298
|
+
sofar.push(_eval(fn, [last2, next], options));
|
|
33268
32299
|
return sofar;
|
|
33269
32300
|
} catch {
|
|
33270
|
-
sofar.push(
|
|
32301
|
+
sofar.push(last2);
|
|
33271
32302
|
}
|
|
33272
32303
|
}
|
|
33273
32304
|
sofar.push(_ensureNode(sofar.pop()));
|
|
@@ -33650,7 +32681,7 @@ var createChainClass = /* @__PURE__ */ factory(
|
|
|
33650
32681
|
return this.value;
|
|
33651
32682
|
};
|
|
33652
32683
|
Chain2.prototype.toString = function() {
|
|
33653
|
-
return
|
|
32684
|
+
return formatGeneric(this.value, {});
|
|
33654
32685
|
};
|
|
33655
32686
|
Chain2.prototype.toJSON = function() {
|
|
33656
32687
|
return {
|
|
@@ -33974,7 +33005,7 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
33974
33005
|
matrix2._size = [arg3.length];
|
|
33975
33006
|
return matrix2;
|
|
33976
33007
|
}
|
|
33977
|
-
class
|
|
33008
|
+
class Index {
|
|
33978
33009
|
/**
|
|
33979
33010
|
* Type identifier
|
|
33980
33011
|
*/
|
|
@@ -33999,7 +33030,7 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
33999
33030
|
*/
|
|
34000
33031
|
_isScalar;
|
|
34001
33032
|
constructor(...ranges) {
|
|
34002
|
-
if (!(this instanceof
|
|
33033
|
+
if (!(this instanceof Index)) {
|
|
34003
33034
|
throw new SyntaxError("Constructor must be called with the new operator");
|
|
34004
33035
|
}
|
|
34005
33036
|
this._dimensions = [];
|
|
@@ -34049,7 +33080,7 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
34049
33080
|
* @return {Index} clone
|
|
34050
33081
|
*/
|
|
34051
33082
|
clone() {
|
|
34052
|
-
const index = new
|
|
33083
|
+
const index = new Index();
|
|
34053
33084
|
index._dimensions = clone(this._dimensions);
|
|
34054
33085
|
index._isScalar = this._isScalar;
|
|
34055
33086
|
index._sourceSize = this._sourceSize;
|
|
@@ -34063,7 +33094,7 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
34063
33094
|
* @private
|
|
34064
33095
|
*/
|
|
34065
33096
|
static create(ranges) {
|
|
34066
|
-
return new
|
|
33097
|
+
return new Index(...ranges);
|
|
34067
33098
|
}
|
|
34068
33099
|
/**
|
|
34069
33100
|
* Retrieve the size of the index, the number of elements for each dimension.
|
|
@@ -34216,13 +33247,13 @@ var createIndexClass = /* @__PURE__ */ factory(
|
|
|
34216
33247
|
* @return {Index}
|
|
34217
33248
|
*/
|
|
34218
33249
|
static fromJSON(json) {
|
|
34219
|
-
return
|
|
33250
|
+
return Index.create(json.dimensions);
|
|
34220
33251
|
}
|
|
34221
33252
|
}
|
|
34222
|
-
const indexProto =
|
|
33253
|
+
const indexProto = Index.prototype;
|
|
34223
33254
|
indexProto.type = "Index";
|
|
34224
33255
|
indexProto.isIndex = true;
|
|
34225
|
-
return
|
|
33256
|
+
return Index;
|
|
34226
33257
|
},
|
|
34227
33258
|
{ isClass: true }
|
|
34228
33259
|
);
|
|
@@ -34319,7 +33350,7 @@ var createUnitFunction = /* @__PURE__ */ factory(
|
|
|
34319
33350
|
return new Unit2(value);
|
|
34320
33351
|
},
|
|
34321
33352
|
"Array | Matrix": typed3.referToSelf(
|
|
34322
|
-
(self) => (x) =>
|
|
33353
|
+
(self) => (x) => deepMap(x, self)
|
|
34323
33354
|
)
|
|
34324
33355
|
});
|
|
34325
33356
|
}
|
|
@@ -34806,7 +33837,7 @@ var dependencies207 = ["typed", "Index", "matrix", "range"];
|
|
|
34806
33837
|
var createColumn = /* @__PURE__ */ factory(
|
|
34807
33838
|
name207,
|
|
34808
33839
|
dependencies207,
|
|
34809
|
-
({ typed: typed3, Index
|
|
33840
|
+
({ typed: typed3, Index, matrix: matrix2, range: range2 }) => {
|
|
34810
33841
|
return typed3(name207, {
|
|
34811
33842
|
"Matrix, number": _column,
|
|
34812
33843
|
"Array, number": function(value, column2) {
|
|
@@ -34819,7 +33850,7 @@ var createColumn = /* @__PURE__ */ factory(
|
|
|
34819
33850
|
}
|
|
34820
33851
|
validateIndex(column2, value.size()[1]);
|
|
34821
33852
|
const rowRange = range2(0, value.size()[0]);
|
|
34822
|
-
const index = new
|
|
33853
|
+
const index = new Index(rowRange, [column2]);
|
|
34823
33854
|
const result = value.subset(index);
|
|
34824
33855
|
return isMatrix(result) ? result : matrix2([[result]]);
|
|
34825
33856
|
}
|
|
@@ -34832,7 +33863,7 @@ var dependencies208 = ["typed", "Index", "matrix", "range"];
|
|
|
34832
33863
|
var createRow = /* @__PURE__ */ factory(
|
|
34833
33864
|
name208,
|
|
34834
33865
|
dependencies208,
|
|
34835
|
-
({ typed: typed3, Index
|
|
33866
|
+
({ typed: typed3, Index, matrix: matrix2, range: range2 }) => {
|
|
34836
33867
|
return typed3(name208, {
|
|
34837
33868
|
"Matrix, number": _row,
|
|
34838
33869
|
"Array, number": function(value, row2) {
|
|
@@ -34845,7 +33876,7 @@ var createRow = /* @__PURE__ */ factory(
|
|
|
34845
33876
|
}
|
|
34846
33877
|
validateIndex(row2, value.size()[0]);
|
|
34847
33878
|
const columnRange = range2(0, value.size()[1]);
|
|
34848
|
-
const index = new
|
|
33879
|
+
const index = new Index([row2], columnRange);
|
|
34849
33880
|
const result = value.subset(index);
|
|
34850
33881
|
return isMatrix(result) ? result : matrix2([[result]]);
|
|
34851
33882
|
}
|
|
@@ -34887,15 +33918,15 @@ var createCross = /* @__PURE__ */ factory(
|
|
|
34887
33918
|
"Vectors with length 3 expected (Size A = [" + xSize.join(", ") + "], B = [" + ySize.join(", ") + "])"
|
|
34888
33919
|
);
|
|
34889
33920
|
}
|
|
34890
|
-
const
|
|
33921
|
+
const product2 = [
|
|
34891
33922
|
subtract3(multiply2(x[1], y[2]), multiply2(x[2], y[1])),
|
|
34892
33923
|
subtract3(multiply2(x[2], y[0]), multiply2(x[0], y[2])),
|
|
34893
33924
|
subtract3(multiply2(x[0], y[1]), multiply2(x[1], y[0]))
|
|
34894
33925
|
];
|
|
34895
33926
|
if (highestDimension > 1) {
|
|
34896
|
-
return [
|
|
33927
|
+
return [product2];
|
|
34897
33928
|
} else {
|
|
34898
|
-
return
|
|
33929
|
+
return product2;
|
|
34899
33930
|
}
|
|
34900
33931
|
}
|
|
34901
33932
|
}
|
|
@@ -35008,7 +34039,7 @@ var dependencies211 = [
|
|
|
35008
34039
|
var createSqrtm = /* @__PURE__ */ factory(
|
|
35009
34040
|
name211,
|
|
35010
34041
|
dependencies211,
|
|
35011
|
-
({ typed: typed3, abs: abs2, add: add4, multiply: multiply2, map:
|
|
34042
|
+
({ typed: typed3, abs: abs2, add: add4, multiply: multiply2, map: map3, sqrt: sqrt2, subtract: subtract3, inv: inv3, size: size2, max: max2, identity: identity2 }) => {
|
|
35012
34043
|
const _maxIterations = 1e3;
|
|
35013
34044
|
const _tolerance = 1e-6;
|
|
35014
34045
|
function _tryWasmSqrtm(A, n) {
|
|
@@ -35089,10 +34120,10 @@ var createSqrtm = /* @__PURE__ */ factory(
|
|
|
35089
34120
|
switch (sizeArray.length) {
|
|
35090
34121
|
case 1:
|
|
35091
34122
|
if (sizeArray[0] === 1) {
|
|
35092
|
-
return
|
|
34123
|
+
return map3(A, sqrt2);
|
|
35093
34124
|
} else {
|
|
35094
34125
|
throw new RangeError(
|
|
35095
|
-
"Matrix must be square (size: " +
|
|
34126
|
+
"Matrix must be square (size: " + formatGeneric(sizeArray, {}) + ")"
|
|
35096
34127
|
);
|
|
35097
34128
|
}
|
|
35098
34129
|
case 2: {
|
|
@@ -35104,13 +34135,13 @@ var createSqrtm = /* @__PURE__ */ factory(
|
|
|
35104
34135
|
return _denmanBeavers(A);
|
|
35105
34136
|
} else {
|
|
35106
34137
|
throw new RangeError(
|
|
35107
|
-
"Matrix must be square (size: " +
|
|
34138
|
+
"Matrix must be square (size: " + formatGeneric(sizeArray, {}) + ")"
|
|
35108
34139
|
);
|
|
35109
34140
|
}
|
|
35110
34141
|
}
|
|
35111
34142
|
default:
|
|
35112
34143
|
throw new RangeError(
|
|
35113
|
-
"Matrix must be at most two dimensional (size: " +
|
|
34144
|
+
"Matrix must be at most two dimensional (size: " + formatGeneric(sizeArray, {}) + ")"
|
|
35114
34145
|
);
|
|
35115
34146
|
}
|
|
35116
34147
|
}
|
|
@@ -36326,7 +35357,7 @@ var createMean = /* @__PURE__ */ factory(
|
|
|
36326
35357
|
}
|
|
36327
35358
|
let sum3;
|
|
36328
35359
|
let num2 = 0;
|
|
36329
|
-
|
|
35360
|
+
deepForEach(array, function(value) {
|
|
36330
35361
|
try {
|
|
36331
35362
|
sum3 = sum3 === void 0 ? value : add4(sum3, value);
|
|
36332
35363
|
num2++;
|
|
@@ -36467,7 +35498,7 @@ var createVariance = /* @__PURE__ */ factory(
|
|
|
36467
35498
|
}
|
|
36468
35499
|
let sum3;
|
|
36469
35500
|
let num2 = 0;
|
|
36470
|
-
|
|
35501
|
+
deepForEach(array, function(value) {
|
|
36471
35502
|
try {
|
|
36472
35503
|
sum3 = sum3 === void 0 ? value : add4(sum3, value);
|
|
36473
35504
|
num2++;
|
|
@@ -36478,7 +35509,7 @@ var createVariance = /* @__PURE__ */ factory(
|
|
|
36478
35509
|
if (num2 === 0) throw new Error("Cannot calculate variance of an empty array");
|
|
36479
35510
|
const mean7 = divide2(sum3, num2);
|
|
36480
35511
|
sum3 = void 0;
|
|
36481
|
-
|
|
35512
|
+
deepForEach(array, function(value) {
|
|
36482
35513
|
const diff2 = subtract3(value, mean7);
|
|
36483
35514
|
sum3 = sum3 === void 0 ? multiply2(diff2, diff2) : add4(sum3, multiply2(diff2, diff2));
|
|
36484
35515
|
});
|
|
@@ -36696,7 +35727,7 @@ var createKldivergence = /* @__PURE__ */ factory(
|
|
|
36696
35727
|
divide: divide2,
|
|
36697
35728
|
sum: sum3,
|
|
36698
35729
|
multiply: multiply2,
|
|
36699
|
-
map:
|
|
35730
|
+
map: map3,
|
|
36700
35731
|
dotDivide: dotDivide2,
|
|
36701
35732
|
log: log3,
|
|
36702
35733
|
isNumeric: isNumeric2
|
|
@@ -36740,7 +35771,7 @@ var createKldivergence = /* @__PURE__ */ factory(
|
|
|
36740
35771
|
const result = sum3(
|
|
36741
35772
|
multiply2(
|
|
36742
35773
|
qnorm,
|
|
36743
|
-
|
|
35774
|
+
map3(dotDivide2(qnorm, pnorm), (x) => log3(x))
|
|
36744
35775
|
)
|
|
36745
35776
|
);
|
|
36746
35777
|
if (isNumeric2(result)) {
|
|
@@ -36763,7 +35794,7 @@ var createMultinomial = /* @__PURE__ */ factory(
|
|
|
36763
35794
|
"Array | Matrix": function(a) {
|
|
36764
35795
|
let sum3 = 0;
|
|
36765
35796
|
let denom = 1;
|
|
36766
|
-
|
|
35797
|
+
deepForEach(a, function(ai) {
|
|
36767
35798
|
if (!isInteger3(ai) || !isPositive2(ai)) {
|
|
36768
35799
|
throw new TypeError("Positive integer value expected in function multinomial");
|
|
36769
35800
|
}
|
|
@@ -36913,11 +35944,11 @@ var dependencies226 = ["typed", "size", "subset", "compareNatural", "Index", "De
|
|
|
36913
35944
|
var createSetCartesian = /* @__PURE__ */ factory(
|
|
36914
35945
|
name226,
|
|
36915
35946
|
dependencies226,
|
|
36916
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
35947
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
|
|
36917
35948
|
return typed3(name226, {
|
|
36918
35949
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
36919
35950
|
let result = [];
|
|
36920
|
-
if (subset2(size2(a1), new
|
|
35951
|
+
if (subset2(size2(a1), new Index(0)) !== 0 && subset2(size2(a2), new Index(0)) !== 0) {
|
|
36921
35952
|
const b1 = flatten2(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural3);
|
|
36922
35953
|
const b2 = flatten2(Array.isArray(a2) ? a2 : a2.toArray()).sort(compareNatural3);
|
|
36923
35954
|
result = [];
|
|
@@ -36942,13 +35973,13 @@ var dependencies227 = ["typed", "size", "subset", "compareNatural", "Index", "De
|
|
|
36942
35973
|
var createSetDifference = /* @__PURE__ */ factory(
|
|
36943
35974
|
name227,
|
|
36944
35975
|
dependencies227,
|
|
36945
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
35976
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
|
|
36946
35977
|
return typed3(name227, {
|
|
36947
35978
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
36948
35979
|
let result;
|
|
36949
|
-
if (subset2(size2(a1), new
|
|
35980
|
+
if (subset2(size2(a1), new Index(0)) === 0) {
|
|
36950
35981
|
result = [];
|
|
36951
|
-
} else if (subset2(size2(a2), new
|
|
35982
|
+
} else if (subset2(size2(a2), new Index(0)) === 0) {
|
|
36952
35983
|
return flatten2(a1.toArray());
|
|
36953
35984
|
} else {
|
|
36954
35985
|
const b1 = identify2(flatten2(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural3));
|
|
@@ -36983,11 +36014,11 @@ var dependencies228 = ["typed", "size", "subset", "compareNatural", "Index", "De
|
|
|
36983
36014
|
var createSetDistinct = /* @__PURE__ */ factory(
|
|
36984
36015
|
name228,
|
|
36985
36016
|
dependencies228,
|
|
36986
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36017
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
|
|
36987
36018
|
return typed3(name228, {
|
|
36988
36019
|
"Array | Matrix": function(a) {
|
|
36989
36020
|
let result;
|
|
36990
|
-
if (subset2(size2(a), new
|
|
36021
|
+
if (subset2(size2(a), new Index(0)) === 0) {
|
|
36991
36022
|
result = [];
|
|
36992
36023
|
} else {
|
|
36993
36024
|
const b = flatten2(Array.isArray(a) ? a : a.toArray()).sort(compareNatural3);
|
|
@@ -37014,11 +36045,11 @@ var dependencies229 = ["typed", "size", "subset", "compareNatural", "Index", "De
|
|
|
37014
36045
|
var createSetIntersect = /* @__PURE__ */ factory(
|
|
37015
36046
|
name229,
|
|
37016
36047
|
dependencies229,
|
|
37017
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36048
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index, DenseMatrix: DenseMatrix6 }) => {
|
|
37018
36049
|
return typed3(name229, {
|
|
37019
36050
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
37020
36051
|
let result;
|
|
37021
|
-
if (subset2(size2(a1), new
|
|
36052
|
+
if (subset2(size2(a1), new Index(0)) === 0 || subset2(size2(a2), new Index(0)) === 0) {
|
|
37022
36053
|
result = [];
|
|
37023
36054
|
} else {
|
|
37024
36055
|
const b1 = identify2(flatten2(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural3));
|
|
@@ -37048,12 +36079,12 @@ var dependencies230 = ["typed", "size", "subset", "compareNatural", "Index"];
|
|
|
37048
36079
|
var createSetIsSubset = /* @__PURE__ */ factory(
|
|
37049
36080
|
name230,
|
|
37050
36081
|
dependencies230,
|
|
37051
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36082
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index }) => {
|
|
37052
36083
|
return typed3(name230, {
|
|
37053
36084
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
37054
|
-
if (subset2(size2(a1), new
|
|
36085
|
+
if (subset2(size2(a1), new Index(0)) === 0) {
|
|
37055
36086
|
return true;
|
|
37056
|
-
} else if (subset2(size2(a2), new
|
|
36087
|
+
} else if (subset2(size2(a2), new Index(0)) === 0) {
|
|
37057
36088
|
return false;
|
|
37058
36089
|
}
|
|
37059
36090
|
const b1 = identify2(flatten2(Array.isArray(a1) ? a1 : a1.toArray()).sort(compareNatural3));
|
|
@@ -37083,10 +36114,10 @@ var dependencies231 = ["typed", "size", "subset", "compareNatural", "Index"];
|
|
|
37083
36114
|
var createSetMultiplicity = /* @__PURE__ */ factory(
|
|
37084
36115
|
name231,
|
|
37085
36116
|
dependencies231,
|
|
37086
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36117
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index }) => {
|
|
37087
36118
|
return typed3(name231, {
|
|
37088
36119
|
"number | BigNumber | Fraction | Complex, Array | Matrix": function(e, a) {
|
|
37089
|
-
if (subset2(size2(a), new
|
|
36120
|
+
if (subset2(size2(a), new Index(0)) === 0) {
|
|
37090
36121
|
return 0;
|
|
37091
36122
|
}
|
|
37092
36123
|
const b = flatten2(Array.isArray(a) ? a : a.toArray());
|
|
@@ -37108,10 +36139,10 @@ var dependencies232 = ["typed", "size", "subset", "compareNatural", "Index"];
|
|
|
37108
36139
|
var createSetPowerset = /* @__PURE__ */ factory(
|
|
37109
36140
|
name232,
|
|
37110
36141
|
dependencies232,
|
|
37111
|
-
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index
|
|
36142
|
+
({ typed: typed3, size: size2, subset: subset2, compareNatural: compareNatural3, Index }) => {
|
|
37112
36143
|
return typed3(name232, {
|
|
37113
36144
|
"Array | Matrix": function(a) {
|
|
37114
|
-
if (subset2(size2(a), new
|
|
36145
|
+
if (subset2(size2(a), new Index(0)) === 0) {
|
|
37115
36146
|
return [];
|
|
37116
36147
|
}
|
|
37117
36148
|
const b = flatten2(Array.isArray(a) ? a : a.toArray()).sort(compareNatural3);
|
|
@@ -37501,9 +36532,9 @@ var createSimplifyCore = /* @__PURE__ */ factory(
|
|
|
37501
36532
|
if (op) {
|
|
37502
36533
|
if (fnode.args.length > 2 && hasProperty(node, "associative", context)) {
|
|
37503
36534
|
while (fnode.args.length > 2) {
|
|
37504
|
-
const
|
|
36535
|
+
const last2 = fnode.args.pop();
|
|
37505
36536
|
const seclast = fnode.args.pop();
|
|
37506
|
-
fnode.args.push(new OperatorNode(op, fnode.name, [
|
|
36537
|
+
fnode.args.push(new OperatorNode(op, fnode.name, [last2, seclast]));
|
|
37507
36538
|
}
|
|
37508
36539
|
}
|
|
37509
36540
|
node = new OperatorNode(op, fnode.name, fnode.args);
|
|
@@ -37929,7 +36960,7 @@ var dependencies236 = ["typed", "Index"];
|
|
|
37929
36960
|
var createIndex = /* @__PURE__ */ factory(
|
|
37930
36961
|
name236,
|
|
37931
36962
|
dependencies236,
|
|
37932
|
-
({ typed: typed3, Index
|
|
36963
|
+
({ typed: typed3, Index }) => {
|
|
37933
36964
|
return typed3(name236, {
|
|
37934
36965
|
"...number | string | BigNumber | Range | Array | Matrix": function(args) {
|
|
37935
36966
|
const ranges = args.map(function(arg3) {
|
|
@@ -37943,7 +36974,7 @@ var createIndex = /* @__PURE__ */ factory(
|
|
|
37943
36974
|
return arg3;
|
|
37944
36975
|
}
|
|
37945
36976
|
});
|
|
37946
|
-
return new
|
|
36977
|
+
return new Index(...ranges);
|
|
37947
36978
|
}
|
|
37948
36979
|
});
|
|
37949
36980
|
}
|
|
@@ -38054,9 +37085,9 @@ function createComplexEigs({
|
|
|
38054
37085
|
if (findVectors) {
|
|
38055
37086
|
Rdiag = Array(N).fill(one);
|
|
38056
37087
|
}
|
|
38057
|
-
let
|
|
38058
|
-
while (!
|
|
38059
|
-
|
|
37088
|
+
let last2 = false;
|
|
37089
|
+
while (!last2) {
|
|
37090
|
+
last2 = true;
|
|
38060
37091
|
for (let i = 0; i < N; i++) {
|
|
38061
37092
|
let colNorm = realzero;
|
|
38062
37093
|
let rowNorm = realzero;
|
|
@@ -38083,7 +37114,7 @@ function createComplexEigs({
|
|
|
38083
37114
|
multiplyScalar2(addScalar2(colNorm, rowNorm), 0.95)
|
|
38084
37115
|
);
|
|
38085
37116
|
if (condition) {
|
|
38086
|
-
|
|
37117
|
+
last2 = false;
|
|
38087
37118
|
const g = divideScalar2(1, f);
|
|
38088
37119
|
for (let j = 0; j < N; j++) {
|
|
38089
37120
|
if (i === j) {
|
|
@@ -38949,7 +37980,7 @@ var createEigs = /* @__PURE__ */ factory(
|
|
|
38949
37980
|
const arr10 = mat.toArray();
|
|
38950
37981
|
const asize = mat.size();
|
|
38951
37982
|
if (asize.length !== 2 || asize[0] !== asize[1]) {
|
|
38952
|
-
throw new RangeError(`Matrix must be square (size: ${
|
|
37983
|
+
throw new RangeError(`Matrix must be square (size: ${formatGeneric(asize, {})})`);
|
|
38953
37984
|
}
|
|
38954
37985
|
const N = asize[0];
|
|
38955
37986
|
if (isReal(arr10, N, prec)) {
|
|
@@ -39347,7 +38378,7 @@ var dependencies240 = ["typed", "abs", "map", "median", "subtract"];
|
|
|
39347
38378
|
var createMad = /* @__PURE__ */ factory(
|
|
39348
38379
|
name240,
|
|
39349
38380
|
dependencies240,
|
|
39350
|
-
({ typed: typed3, abs: abs2, map:
|
|
38381
|
+
({ typed: typed3, abs: abs2, map: map3, median: median2, subtract: subtract3 }) => {
|
|
39351
38382
|
return typed3(name240, {
|
|
39352
38383
|
// mad([a, b, c, d, ...])
|
|
39353
38384
|
"Array | Matrix": _mad,
|
|
@@ -39377,7 +38408,7 @@ var createMad = /* @__PURE__ */ factory(
|
|
|
39377
38408
|
try {
|
|
39378
38409
|
const med = median2(flat);
|
|
39379
38410
|
return median2(
|
|
39380
|
-
|
|
38411
|
+
map3(flat, function(value) {
|
|
39381
38412
|
return abs2(subtract3(value, med));
|
|
39382
38413
|
})
|
|
39383
38414
|
);
|
|
@@ -39398,7 +38429,7 @@ var dependencies241 = ["typed", "map", "sqrt", "variance"];
|
|
|
39398
38429
|
var createStd = /* @__PURE__ */ factory(
|
|
39399
38430
|
name241,
|
|
39400
38431
|
dependencies241,
|
|
39401
|
-
({ typed: typed3, map:
|
|
38432
|
+
({ typed: typed3, map: map3, sqrt: sqrt2, variance: variance2 }) => {
|
|
39402
38433
|
return typed3(name241, {
|
|
39403
38434
|
// std([a, b, c, d, ...])
|
|
39404
38435
|
"Array | Matrix": _std,
|
|
@@ -39421,7 +38452,7 @@ var createStd = /* @__PURE__ */ factory(
|
|
|
39421
38452
|
try {
|
|
39422
38453
|
const v = variance2(...args);
|
|
39423
38454
|
if (isCollection(v)) {
|
|
39424
|
-
return
|
|
38455
|
+
return map3(v, sqrt2);
|
|
39425
38456
|
} else {
|
|
39426
38457
|
return sqrt2(v);
|
|
39427
38458
|
}
|
|
@@ -39442,12 +38473,12 @@ var dependencies242 = ["typed", "size", "concat", "subset", "setDifference", "In
|
|
|
39442
38473
|
var createSetSymDifference = /* @__PURE__ */ factory(
|
|
39443
38474
|
name242,
|
|
39444
38475
|
dependencies242,
|
|
39445
|
-
({ typed: typed3, size: size2, concat: concat3, subset: subset2, setDifference: setDifference3, Index
|
|
38476
|
+
({ typed: typed3, size: size2, concat: concat3, subset: subset2, setDifference: setDifference3, Index }) => {
|
|
39446
38477
|
return typed3(name242, {
|
|
39447
38478
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
39448
|
-
if (subset2(size2(a1), new
|
|
38479
|
+
if (subset2(size2(a1), new Index(0)) === 0) {
|
|
39449
38480
|
return flatten2(a2);
|
|
39450
|
-
} else if (subset2(size2(a2), new
|
|
38481
|
+
} else if (subset2(size2(a2), new Index(0)) === 0) {
|
|
39451
38482
|
return flatten2(a1);
|
|
39452
38483
|
}
|
|
39453
38484
|
const b1 = flatten2(a1);
|
|
@@ -41574,13 +40605,13 @@ var createSetUnion = /* @__PURE__ */ factory(
|
|
|
41574
40605
|
subset: subset2,
|
|
41575
40606
|
setIntersect: setIntersect3,
|
|
41576
40607
|
setSymDifference: setSymDifference3,
|
|
41577
|
-
Index
|
|
40608
|
+
Index
|
|
41578
40609
|
}) => {
|
|
41579
40610
|
return typed3(name247, {
|
|
41580
40611
|
"Array | Matrix, Array | Matrix": function(a1, a2) {
|
|
41581
|
-
if (subset2(size2(a1), new
|
|
40612
|
+
if (subset2(size2(a1), new Index(0)) === 0) {
|
|
41582
40613
|
return flatten2(a2);
|
|
41583
|
-
} else if (subset2(size2(a2), new
|
|
40614
|
+
} else if (subset2(size2(a2), new Index(0)) === 0) {
|
|
41584
40615
|
return flatten2(a1);
|
|
41585
40616
|
}
|
|
41586
40617
|
const b1 = flatten2(a1);
|
|
@@ -41649,14 +40680,14 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41649
40680
|
"": function() {
|
|
41650
40681
|
return config2.matrix === "Matrix" ? matrix2([]) : [];
|
|
41651
40682
|
},
|
|
41652
|
-
string: function(
|
|
41653
|
-
return matrix2(
|
|
40683
|
+
string: function(format4) {
|
|
40684
|
+
return matrix2(format4);
|
|
41654
40685
|
},
|
|
41655
40686
|
"number | BigNumber | Complex | Unit": function(theta) {
|
|
41656
40687
|
return _rotationMatrix2x2(theta, config2.matrix === "Matrix" ? "dense" : void 0);
|
|
41657
40688
|
},
|
|
41658
|
-
"number | BigNumber | Complex | Unit, string": function(theta,
|
|
41659
|
-
return _rotationMatrix2x2(theta,
|
|
40689
|
+
"number | BigNumber | Complex | Unit, string": function(theta, format4) {
|
|
40690
|
+
return _rotationMatrix2x2(theta, format4);
|
|
41660
40691
|
},
|
|
41661
40692
|
"number | BigNumber | Complex | Unit, Array": function(theta, v) {
|
|
41662
40693
|
const matrixV = matrix2(v);
|
|
@@ -41668,17 +40699,17 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41668
40699
|
const storageType = v.storage() || (config2.matrix === "Matrix" ? "dense" : void 0);
|
|
41669
40700
|
return _rotationMatrix3x3(theta, v, storageType);
|
|
41670
40701
|
},
|
|
41671
|
-
"number | BigNumber | Complex | Unit, Array, string": function(theta, v,
|
|
40702
|
+
"number | BigNumber | Complex | Unit, Array, string": function(theta, v, format4) {
|
|
41672
40703
|
const matrixV = matrix2(v);
|
|
41673
40704
|
_validateVector(matrixV);
|
|
41674
|
-
return _rotationMatrix3x3(theta, matrixV,
|
|
40705
|
+
return _rotationMatrix3x3(theta, matrixV, format4);
|
|
41675
40706
|
},
|
|
41676
|
-
"number | BigNumber | Complex | Unit, Matrix, string": function(theta, v,
|
|
40707
|
+
"number | BigNumber | Complex | Unit, Matrix, string": function(theta, v, format4) {
|
|
41677
40708
|
_validateVector(v);
|
|
41678
|
-
return _rotationMatrix3x3(theta, v,
|
|
40709
|
+
return _rotationMatrix3x3(theta, v, format4);
|
|
41679
40710
|
}
|
|
41680
40711
|
});
|
|
41681
|
-
function _rotationMatrix2x2(theta,
|
|
40712
|
+
function _rotationMatrix2x2(theta, format4) {
|
|
41682
40713
|
const Big = isBigNumber(theta);
|
|
41683
40714
|
const minusOne = Big ? new BigNumber9(-1) : -1;
|
|
41684
40715
|
const cosTheta = cos2(theta);
|
|
@@ -41687,7 +40718,7 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41687
40718
|
[cosTheta, multiplyScalar2(minusOne, sinTheta)],
|
|
41688
40719
|
[sinTheta, cosTheta]
|
|
41689
40720
|
];
|
|
41690
|
-
return _convertToFormat(data,
|
|
40721
|
+
return _convertToFormat(data, format4);
|
|
41691
40722
|
}
|
|
41692
40723
|
function _validateVector(v) {
|
|
41693
40724
|
const size2 = v.size();
|
|
@@ -41698,19 +40729,19 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41698
40729
|
function _mul(array) {
|
|
41699
40730
|
return array.reduce((p, curr) => multiplyScalar2(p, curr));
|
|
41700
40731
|
}
|
|
41701
|
-
function _convertToFormat(data,
|
|
41702
|
-
if (
|
|
41703
|
-
if (
|
|
40732
|
+
function _convertToFormat(data, format4) {
|
|
40733
|
+
if (format4) {
|
|
40734
|
+
if (format4 === "sparse") {
|
|
41704
40735
|
return new SparseMatrix(data);
|
|
41705
40736
|
}
|
|
41706
|
-
if (
|
|
40737
|
+
if (format4 === "dense") {
|
|
41707
40738
|
return new DenseMatrix6(data);
|
|
41708
40739
|
}
|
|
41709
|
-
throw new TypeError(`Unknown matrix type "${
|
|
40740
|
+
throw new TypeError(`Unknown matrix type "${format4}"`);
|
|
41710
40741
|
}
|
|
41711
40742
|
return data;
|
|
41712
40743
|
}
|
|
41713
|
-
function _rotationMatrix3x3(theta, v,
|
|
40744
|
+
function _rotationMatrix3x3(theta, v, format4) {
|
|
41714
40745
|
const normV = norm4(v);
|
|
41715
40746
|
if (normV === 0) {
|
|
41716
40747
|
throw new RangeError("Rotation around zero vector");
|
|
@@ -41738,7 +40769,7 @@ var createRotationMatrix = /* @__PURE__ */ factory(
|
|
|
41738
40769
|
[r21, r22, r23],
|
|
41739
40770
|
[r31, r32, r33]
|
|
41740
40771
|
];
|
|
41741
|
-
return _convertToFormat(data,
|
|
40772
|
+
return _convertToFormat(data, format4);
|
|
41742
40773
|
}
|
|
41743
40774
|
}
|
|
41744
40775
|
);
|
|
@@ -42258,11 +41289,11 @@ var re2 = createRe(factoryScope);
|
|
|
42258
41289
|
var not2 = createNot(factoryScope);
|
|
42259
41290
|
var filter2 = createFilter(factoryScope);
|
|
42260
41291
|
var flatten3 = createFlatten(factoryScope);
|
|
42261
|
-
var
|
|
41292
|
+
var forEach2 = createForEach(factoryScope);
|
|
42262
41293
|
var getMatrixDataType = createGetMatrixDataType(
|
|
42263
41294
|
factoryScope
|
|
42264
41295
|
);
|
|
42265
|
-
var
|
|
41296
|
+
var map2 = createMap(factoryScope);
|
|
42266
41297
|
var size = createSize(factoryScope);
|
|
42267
41298
|
var squeeze2 = createSqueeze(factoryScope);
|
|
42268
41299
|
var combinations2 = createCombinations(factoryScope);
|
|
@@ -42274,7 +41305,7 @@ var pickRandom2 = createPickRandom(factoryScope);
|
|
|
42274
41305
|
var random2 = createRandom(factoryScope);
|
|
42275
41306
|
var equalScalar2 = createEqualScalar(factoryScope);
|
|
42276
41307
|
var erf = createErf(factoryScope);
|
|
42277
|
-
var
|
|
41308
|
+
var format3 = createFormat(factoryScope);
|
|
42278
41309
|
var print2 = createPrint(factoryScope);
|
|
42279
41310
|
var acoth = createAcoth(factoryScope);
|
|
42280
41311
|
var acsch = createAcsch(factoryScope);
|
|
@@ -42283,7 +41314,7 @@ var coth = createCoth(factoryScope);
|
|
|
42283
41314
|
var csch = createCsch(factoryScope);
|
|
42284
41315
|
var sech = createSech(factoryScope);
|
|
42285
41316
|
var toBest2 = createToBest(factoryScope);
|
|
42286
|
-
var
|
|
41317
|
+
var clone2 = createClone(factoryScope);
|
|
42287
41318
|
var isBounded = createIsBounded(factoryScope);
|
|
42288
41319
|
var isNaN2 = createIsNaN(factoryScope);
|
|
42289
41320
|
var isNegative = createIsNegative(factoryScope);
|
|
@@ -42335,7 +41366,7 @@ factoryScope.asinh = factory_asinh;
|
|
|
42335
41366
|
factoryScope.atan = factory_atan;
|
|
42336
41367
|
factoryScope.atanh = factory_atanh;
|
|
42337
41368
|
factoryScope.bitNot = bitNot2;
|
|
42338
|
-
factoryScope.clone =
|
|
41369
|
+
factoryScope.clone = clone2;
|
|
42339
41370
|
factoryScope.combinations = combinations2;
|
|
42340
41371
|
factoryScope.combinationsWithRep = combinationsWithRep2;
|
|
42341
41372
|
factoryScope.conj = conj2;
|
|
@@ -42348,7 +41379,7 @@ factoryScope.equalScalar = equalScalar2;
|
|
|
42348
41379
|
factoryScope.erf = erf;
|
|
42349
41380
|
factoryScope.exp = factory_exp;
|
|
42350
41381
|
factoryScope.expm1 = factory_expm1;
|
|
42351
|
-
factoryScope.format =
|
|
41382
|
+
factoryScope.format = format3;
|
|
42352
41383
|
factoryScope.im = im2;
|
|
42353
41384
|
factoryScope.isBounded = isBounded;
|
|
42354
41385
|
factoryScope.isNaN = isNaN2;
|
|
@@ -42359,7 +41390,7 @@ factoryScope.isPrime = isPrime;
|
|
|
42359
41390
|
factoryScope.lgamma = lgamma2;
|
|
42360
41391
|
factoryScope.log2 = factory_log2;
|
|
42361
41392
|
factoryScope.log10 = factory_log10;
|
|
42362
|
-
factoryScope.map =
|
|
41393
|
+
factoryScope.map = map2;
|
|
42363
41394
|
factoryScope.multiplyScalar = multiplyScalar;
|
|
42364
41395
|
factoryScope.not = not2;
|
|
42365
41396
|
factoryScope.numeric = numeric;
|
|
@@ -42418,7 +41449,7 @@ factoryScope.isZero = isZero;
|
|
|
42418
41449
|
factoryScope.prod = prod;
|
|
42419
41450
|
factoryScope.dot = factory_dot;
|
|
42420
41451
|
factoryScope.squeeze = squeeze2;
|
|
42421
|
-
factoryScope.forEach =
|
|
41452
|
+
factoryScope.forEach = forEach2;
|
|
42422
41453
|
factoryScope.filter = filter2;
|
|
42423
41454
|
var factory_transpose = createTranspose(
|
|
42424
41455
|
factoryScope
|
|
@@ -43948,11 +42979,11 @@ function symbolicProduct(expr, varName, a, b) {
|
|
|
43948
42979
|
`symbolicProduct: bounds must be finite numbers (symbolic bounds are not supported; got lower bound ${JSON.stringify(a)}, upper bound ${JSON.stringify(b)})`
|
|
43949
42980
|
);
|
|
43950
42981
|
}
|
|
43951
|
-
let
|
|
42982
|
+
let product2 = 1;
|
|
43952
42983
|
for (let k = a; k <= b; k++) {
|
|
43953
|
-
|
|
42984
|
+
product2 *= evalAt(expr, varName, k);
|
|
43954
42985
|
}
|
|
43955
|
-
return
|
|
42986
|
+
return product2;
|
|
43956
42987
|
}
|
|
43957
42988
|
function assume(varName, property) {
|
|
43958
42989
|
const validProperties = ["real", "positive", "negative", "integer", "nonzero", "nonnegative"];
|
|
@@ -48158,7 +47189,7 @@ function linearRegression(x, y) {
|
|
|
48158
47189
|
}
|
|
48159
47190
|
|
|
48160
47191
|
// src/ml/regularized-regression.ts
|
|
48161
|
-
function
|
|
47192
|
+
function validate2(X, y, name254) {
|
|
48162
47193
|
const n = X.length;
|
|
48163
47194
|
if (n === 0) throw new Error(`${name254}: empty design matrix`);
|
|
48164
47195
|
if (y.length !== n) {
|
|
@@ -48197,7 +47228,7 @@ function softThreshold(a, lambda) {
|
|
|
48197
47228
|
return 0;
|
|
48198
47229
|
}
|
|
48199
47230
|
function ridge(X, y, alpha, opts) {
|
|
48200
|
-
const { n, p } =
|
|
47231
|
+
const { n, p } = validate2(X, y, "ridge");
|
|
48201
47232
|
if (alpha < 0) throw new Error("ridge: alpha must be non-negative");
|
|
48202
47233
|
const useIntercept = opts?.intercept !== false;
|
|
48203
47234
|
const { Xc, yc, xMean, yMean } = center(X, y, n, p, useIntercept);
|
|
@@ -48252,7 +47283,7 @@ function coordinateDescent(Xs, yc, n, p, l1, l2, maxIter, tol) {
|
|
|
48252
47283
|
return beta2;
|
|
48253
47284
|
}
|
|
48254
47285
|
function lasso(X, y, alpha, opts) {
|
|
48255
|
-
const { n, p } =
|
|
47286
|
+
const { n, p } = validate2(X, y, "lasso");
|
|
48256
47287
|
if (alpha < 0) throw new Error("lasso: alpha must be non-negative");
|
|
48257
47288
|
const useIntercept = opts?.intercept !== false;
|
|
48258
47289
|
const maxIter = opts?.maxIter ?? 1e3;
|
|
@@ -48265,7 +47296,7 @@ function lasso(X, y, alpha, opts) {
|
|
|
48265
47296
|
return { coefficients, intercept };
|
|
48266
47297
|
}
|
|
48267
47298
|
function elasticNet(X, y, alpha, l1Ratio, opts) {
|
|
48268
|
-
const { n, p } =
|
|
47299
|
+
const { n, p } = validate2(X, y, "elasticNet");
|
|
48269
47300
|
if (alpha < 0) throw new Error("elasticNet: alpha must be non-negative");
|
|
48270
47301
|
if (l1Ratio < 0 || l1Ratio > 1) throw new Error("elasticNet: l1Ratio must be in [0, 1]");
|
|
48271
47302
|
const useIntercept = opts?.intercept !== false;
|
|
@@ -49432,6 +48463,97 @@ function butter(N, Wn, btype = "low") {
|
|
|
49432
48463
|
return analogToDigital(buttap(N), Wn, btype);
|
|
49433
48464
|
}
|
|
49434
48465
|
|
|
48466
|
+
// src/signal/fft.ts
|
|
48467
|
+
function complex2(re3, im3 = 0) {
|
|
48468
|
+
return { re: re3, im: im3 };
|
|
48469
|
+
}
|
|
48470
|
+
function isPowerOf25(n) {
|
|
48471
|
+
return n > 0 && (n & n - 1) === 0;
|
|
48472
|
+
}
|
|
48473
|
+
function nextPowerOf22(n) {
|
|
48474
|
+
if (n <= 1) return 1;
|
|
48475
|
+
return Math.pow(2, Math.ceil(Math.log2(n)));
|
|
48476
|
+
}
|
|
48477
|
+
function fftCore(data, inverse = false) {
|
|
48478
|
+
const n = data.length;
|
|
48479
|
+
if (!isPowerOf25(n)) {
|
|
48480
|
+
throw new Error(`FFT length must be power of 2, got ${n}`);
|
|
48481
|
+
}
|
|
48482
|
+
if (n === 1) {
|
|
48483
|
+
return [{ ...data[0] }];
|
|
48484
|
+
}
|
|
48485
|
+
const real = new Float64Array(n);
|
|
48486
|
+
const imag = new Float64Array(n);
|
|
48487
|
+
for (let i = 0; i < n; i++) {
|
|
48488
|
+
real[i] = data[i].re;
|
|
48489
|
+
imag[i] = data[i].im;
|
|
48490
|
+
}
|
|
48491
|
+
const out = fftCoreFloat64(real, imag, inverse);
|
|
48492
|
+
const spectrum = new Array(n);
|
|
48493
|
+
for (let i = 0; i < n; i++) {
|
|
48494
|
+
spectrum[i] = { re: out.real[i], im: out.imag[i] };
|
|
48495
|
+
}
|
|
48496
|
+
return spectrum;
|
|
48497
|
+
}
|
|
48498
|
+
function fft2(signal) {
|
|
48499
|
+
const originalLength = signal.length;
|
|
48500
|
+
if (originalLength === 0) {
|
|
48501
|
+
return {
|
|
48502
|
+
spectrum: [],
|
|
48503
|
+
originalLength: 0,
|
|
48504
|
+
paddedLength: 0
|
|
48505
|
+
};
|
|
48506
|
+
}
|
|
48507
|
+
let complexSignal;
|
|
48508
|
+
if (signal instanceof Float64Array) {
|
|
48509
|
+
complexSignal = Array.from(signal).map((x) => complex2(x, 0));
|
|
48510
|
+
} else if (typeof signal[0] === "number") {
|
|
48511
|
+
complexSignal = signal.map((x) => complex2(x, 0));
|
|
48512
|
+
} else {
|
|
48513
|
+
complexSignal = signal;
|
|
48514
|
+
}
|
|
48515
|
+
const paddedLength = nextPowerOf22(originalLength);
|
|
48516
|
+
if (paddedLength > originalLength) {
|
|
48517
|
+
const padding = new Array(paddedLength - originalLength).fill(complex2(0, 0));
|
|
48518
|
+
complexSignal = [...complexSignal, ...padding];
|
|
48519
|
+
}
|
|
48520
|
+
const spectrum = fftCore(complexSignal, false);
|
|
48521
|
+
return {
|
|
48522
|
+
spectrum,
|
|
48523
|
+
originalLength,
|
|
48524
|
+
paddedLength
|
|
48525
|
+
};
|
|
48526
|
+
}
|
|
48527
|
+
function ifft2(spectrum, originalLength) {
|
|
48528
|
+
if (spectrum.length === 0) {
|
|
48529
|
+
return [];
|
|
48530
|
+
}
|
|
48531
|
+
const paddedLength = nextPowerOf22(spectrum.length);
|
|
48532
|
+
let paddedSpectrum = spectrum;
|
|
48533
|
+
if (paddedLength > spectrum.length) {
|
|
48534
|
+
const padding = new Array(paddedLength - spectrum.length).fill(complex2(0, 0));
|
|
48535
|
+
paddedSpectrum = [...spectrum, ...padding];
|
|
48536
|
+
}
|
|
48537
|
+
const result = fftCore(paddedSpectrum, true);
|
|
48538
|
+
if (originalLength !== void 0 && originalLength < result.length) {
|
|
48539
|
+
return result.slice(0, originalLength);
|
|
48540
|
+
}
|
|
48541
|
+
return result;
|
|
48542
|
+
}
|
|
48543
|
+
function ifftReal(spectrum, originalLength) {
|
|
48544
|
+
const complex3 = ifft2(spectrum, originalLength);
|
|
48545
|
+
return complex3.map((c) => c.re);
|
|
48546
|
+
}
|
|
48547
|
+
function rollBy(arr10, count2) {
|
|
48548
|
+
return [...arr10.slice(count2), ...arr10.slice(0, count2)];
|
|
48549
|
+
}
|
|
48550
|
+
function fftshift(spectrum) {
|
|
48551
|
+
return rollBy(spectrum, Math.floor(spectrum.length / 2));
|
|
48552
|
+
}
|
|
48553
|
+
function ifftshift(spectrum) {
|
|
48554
|
+
return rollBy(spectrum, Math.ceil(spectrum.length / 2));
|
|
48555
|
+
}
|
|
48556
|
+
|
|
49435
48557
|
// src/signal/fft-helpers.ts
|
|
49436
48558
|
var callFft = fft;
|
|
49437
48559
|
var callIfft = ifft;
|
|
@@ -49468,15 +48590,11 @@ function irfft(spec, n) {
|
|
|
49468
48590
|
const result = callIfft(full);
|
|
49469
48591
|
return result.map((v) => toReIm(v).re);
|
|
49470
48592
|
}
|
|
49471
|
-
function
|
|
49472
|
-
|
|
49473
|
-
const half = Math.floor(n / 2);
|
|
49474
|
-
return [...x.slice(half), ...x.slice(0, half)];
|
|
48593
|
+
function fftshift2(x) {
|
|
48594
|
+
return fftshift(x);
|
|
49475
48595
|
}
|
|
49476
|
-
function
|
|
49477
|
-
|
|
49478
|
-
const half = Math.ceil(n / 2);
|
|
49479
|
-
return [...x.slice(half), ...x.slice(0, half)];
|
|
48596
|
+
function ifftshift2(x) {
|
|
48597
|
+
return ifftshift(x);
|
|
49480
48598
|
}
|
|
49481
48599
|
function fftfreq(n, d = 1) {
|
|
49482
48600
|
const result = new Array(n);
|
|
@@ -49854,88 +48972,6 @@ function sosfilt(sos, x) {
|
|
|
49854
48972
|
return y;
|
|
49855
48973
|
}
|
|
49856
48974
|
|
|
49857
|
-
// src/signal/fft.ts
|
|
49858
|
-
function complex2(re3, im3 = 0) {
|
|
49859
|
-
return { re: re3, im: im3 };
|
|
49860
|
-
}
|
|
49861
|
-
function isPowerOf25(n) {
|
|
49862
|
-
return n > 0 && (n & n - 1) === 0;
|
|
49863
|
-
}
|
|
49864
|
-
function nextPowerOf22(n) {
|
|
49865
|
-
if (n <= 1) return 1;
|
|
49866
|
-
return Math.pow(2, Math.ceil(Math.log2(n)));
|
|
49867
|
-
}
|
|
49868
|
-
function fftCore(data, inverse = false) {
|
|
49869
|
-
const n = data.length;
|
|
49870
|
-
if (!isPowerOf25(n)) {
|
|
49871
|
-
throw new Error(`FFT length must be power of 2, got ${n}`);
|
|
49872
|
-
}
|
|
49873
|
-
if (n === 1) {
|
|
49874
|
-
return [{ ...data[0] }];
|
|
49875
|
-
}
|
|
49876
|
-
const real = new Float64Array(n);
|
|
49877
|
-
const imag = new Float64Array(n);
|
|
49878
|
-
for (let i = 0; i < n; i++) {
|
|
49879
|
-
real[i] = data[i].re;
|
|
49880
|
-
imag[i] = data[i].im;
|
|
49881
|
-
}
|
|
49882
|
-
const out = fftCoreFloat64(real, imag, inverse);
|
|
49883
|
-
const spectrum = new Array(n);
|
|
49884
|
-
for (let i = 0; i < n; i++) {
|
|
49885
|
-
spectrum[i] = { re: out.real[i], im: out.imag[i] };
|
|
49886
|
-
}
|
|
49887
|
-
return spectrum;
|
|
49888
|
-
}
|
|
49889
|
-
function fft2(signal) {
|
|
49890
|
-
const originalLength = signal.length;
|
|
49891
|
-
if (originalLength === 0) {
|
|
49892
|
-
return {
|
|
49893
|
-
spectrum: [],
|
|
49894
|
-
originalLength: 0,
|
|
49895
|
-
paddedLength: 0
|
|
49896
|
-
};
|
|
49897
|
-
}
|
|
49898
|
-
let complexSignal;
|
|
49899
|
-
if (signal instanceof Float64Array) {
|
|
49900
|
-
complexSignal = Array.from(signal).map((x) => complex2(x, 0));
|
|
49901
|
-
} else if (typeof signal[0] === "number") {
|
|
49902
|
-
complexSignal = signal.map((x) => complex2(x, 0));
|
|
49903
|
-
} else {
|
|
49904
|
-
complexSignal = signal;
|
|
49905
|
-
}
|
|
49906
|
-
const paddedLength = nextPowerOf22(originalLength);
|
|
49907
|
-
if (paddedLength > originalLength) {
|
|
49908
|
-
const padding = new Array(paddedLength - originalLength).fill(complex2(0, 0));
|
|
49909
|
-
complexSignal = [...complexSignal, ...padding];
|
|
49910
|
-
}
|
|
49911
|
-
const spectrum = fftCore(complexSignal, false);
|
|
49912
|
-
return {
|
|
49913
|
-
spectrum,
|
|
49914
|
-
originalLength,
|
|
49915
|
-
paddedLength
|
|
49916
|
-
};
|
|
49917
|
-
}
|
|
49918
|
-
function ifft2(spectrum, originalLength) {
|
|
49919
|
-
if (spectrum.length === 0) {
|
|
49920
|
-
return [];
|
|
49921
|
-
}
|
|
49922
|
-
const paddedLength = nextPowerOf22(spectrum.length);
|
|
49923
|
-
let paddedSpectrum = spectrum;
|
|
49924
|
-
if (paddedLength > spectrum.length) {
|
|
49925
|
-
const padding = new Array(paddedLength - spectrum.length).fill(complex2(0, 0));
|
|
49926
|
-
paddedSpectrum = [...spectrum, ...padding];
|
|
49927
|
-
}
|
|
49928
|
-
const result = fftCore(paddedSpectrum, true);
|
|
49929
|
-
if (originalLength !== void 0 && originalLength < result.length) {
|
|
49930
|
-
return result.slice(0, originalLength);
|
|
49931
|
-
}
|
|
49932
|
-
return result;
|
|
49933
|
-
}
|
|
49934
|
-
function ifftReal(spectrum, originalLength) {
|
|
49935
|
-
const complex3 = ifft2(spectrum, originalLength);
|
|
49936
|
-
return complex3.map((c) => c.re);
|
|
49937
|
-
}
|
|
49938
|
-
|
|
49939
48975
|
// src/signal/conv.ts
|
|
49940
48976
|
function convDirect(x, h, mode2 = "full") {
|
|
49941
48977
|
const xArr = Array.isArray(x) ? x : Array.from(x);
|
|
@@ -52273,7 +51309,7 @@ export {
|
|
|
52273
51309
|
clamp,
|
|
52274
51310
|
classicalElectronRadius,
|
|
52275
51311
|
clearAssumptions,
|
|
52276
|
-
|
|
51312
|
+
clone2 as clone,
|
|
52277
51313
|
closenessCentrality,
|
|
52278
51314
|
cochranQ,
|
|
52279
51315
|
coefficientList,
|
|
@@ -52511,7 +51547,7 @@ export {
|
|
|
52511
51547
|
fftGpuDispatch,
|
|
52512
51548
|
fftfreq,
|
|
52513
51549
|
fftn,
|
|
52514
|
-
fftshift,
|
|
51550
|
+
fftshift2 as fftshift,
|
|
52515
51551
|
fibonacci,
|
|
52516
51552
|
filter2 as filter,
|
|
52517
51553
|
filtfilt,
|
|
@@ -52528,8 +51564,8 @@ export {
|
|
|
52528
51564
|
flatten3 as flatten,
|
|
52529
51565
|
floor,
|
|
52530
51566
|
floydWarshall,
|
|
52531
|
-
forEach,
|
|
52532
|
-
|
|
51567
|
+
forEach2 as forEach,
|
|
51568
|
+
format2 as format,
|
|
52533
51569
|
fourier,
|
|
52534
51570
|
fourierSeries,
|
|
52535
51571
|
fraction,
|
|
@@ -52611,7 +51647,7 @@ export {
|
|
|
52611
51647
|
idst,
|
|
52612
51648
|
idwt,
|
|
52613
51649
|
ifft,
|
|
52614
|
-
ifftshift,
|
|
51650
|
+
ifftshift2 as ifftshift,
|
|
52615
51651
|
im,
|
|
52616
51652
|
implicitDiff,
|
|
52617
51653
|
indexFn as index,
|
|
@@ -52744,7 +51780,7 @@ export {
|
|
|
52744
51780
|
mahalanobis,
|
|
52745
51781
|
manhattanDistance,
|
|
52746
51782
|
mannWhitneyTest,
|
|
52747
|
-
map,
|
|
51783
|
+
map2 as map,
|
|
52748
51784
|
mapSlices,
|
|
52749
51785
|
matmul,
|
|
52750
51786
|
matrix,
|