@danielsimonjr/mathts-functions 0.70.1 → 0.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -1
- package/dist/algebra/decomposition/qr.d.ts.map +1 -1
- package/dist/cas/real-roots.d.ts +30 -0
- package/dist/cas/real-roots.d.ts.map +1 -0
- package/dist/descriptive-stats.d.ts +1 -1
- package/dist/descriptive-stats.d.ts.map +1 -1
- package/dist/factories/evaluate.d.ts.map +1 -1
- package/dist/factories/index.d.ts +3 -3
- package/dist/factories/index.d.ts.map +1 -1
- package/dist/fit-scalar.d.ts +28 -0
- package/dist/fit-scalar.d.ts.map +1 -1
- package/dist/geometry/curves.d.ts +48 -0
- package/dist/geometry/curves.d.ts.map +1 -0
- package/dist/geometry/polygon-ops.d.ts +19 -0
- package/dist/geometry/polygon-ops.d.ts.map +1 -0
- package/dist/geometry/predicates.d.ts +38 -0
- package/dist/geometry/predicates.d.ts.map +1 -0
- package/dist/index.d.ts +53 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5495 -892
- package/dist/linalg-extra2.d.ts +36 -0
- package/dist/linalg-extra2.d.ts.map +1 -0
- package/dist/linalg-special-matrices.d.ts +62 -0
- package/dist/linalg-special-matrices.d.ts.map +1 -0
- package/dist/numbertheory/arithmetic-functions.d.ts +50 -0
- package/dist/numbertheory/arithmetic-functions.d.ts.map +1 -0
- package/dist/numbertheory/diophantine.d.ts +43 -0
- package/dist/numbertheory/diophantine.d.ts.map +1 -0
- package/dist/numbertheory/extra.d.ts +12 -6
- package/dist/numbertheory/extra.d.ts.map +1 -1
- package/dist/numbertheory/integer-matrices.d.ts +26 -0
- package/dist/numbertheory/integer-matrices.d.ts.map +1 -0
- package/dist/numbertheory/modular.d.ts +27 -0
- package/dist/numbertheory/modular.d.ts.map +1 -0
- package/dist/numbertheory/sequences.d.ts +36 -0
- package/dist/numbertheory/sequences.d.ts.map +1 -0
- package/dist/numeric/constrained.d.ts +42 -0
- package/dist/numeric/constrained.d.ts.map +1 -0
- package/dist/numeric/finite-differences.d.ts +54 -0
- package/dist/numeric/finite-differences.d.ts.map +1 -0
- package/dist/numeric/gauss-nodes-extra.d.ts +73 -0
- package/dist/numeric/gauss-nodes-extra.d.ts.map +1 -0
- package/dist/numeric/global-optimizers.d.ts +64 -0
- package/dist/numeric/global-optimizers.d.ts.map +1 -0
- package/dist/numeric/quadrature-extra.d.ts +64 -0
- package/dist/numeric/quadrature-extra.d.ts.map +1 -0
- package/dist/numeric/solveODE.d.ts +29 -4
- package/dist/numeric/solveODE.d.ts.map +1 -1
- package/dist/probability/combinations.d.ts.map +1 -1
- package/dist/regression-extra.d.ts +6 -0
- package/dist/regression-extra.d.ts.map +1 -1
- package/dist/scalar-batch-parallel.d.ts +15 -9
- package/dist/scalar-batch-parallel.d.ts.map +1 -1
- package/dist/scalar-batch-parallel.js +108 -0
- package/dist/{scalar-batch-task-CZd6LPg9.js → scalar-batch-task-DApUqK6j.js} +21 -15
- package/dist/scalar-batch.worker.js +1 -1
- package/dist/scalar-compile.d.ts +4 -4
- package/dist/scalar-compile.d.ts.map +1 -1
- package/dist/scalar-dimension.d.ts +25 -0
- package/dist/scalar-dimension.d.ts.map +1 -1
- package/dist/scalar-eval.d.ts +4 -2
- package/dist/scalar-eval.d.ts.map +1 -1
- package/dist/scalar-node-bridge.d.ts.map +1 -1
- package/dist/scalar-search.d.ts +323 -14
- package/dist/scalar-search.d.ts.map +1 -1
- package/dist/signal/dtw.d.ts +32 -0
- package/dist/signal/dtw.d.ts.map +1 -0
- package/dist/signal/freqz.d.ts +17 -2
- package/dist/signal/freqz.d.ts.map +1 -1
- package/dist/signal/lomb-scargle.d.ts +25 -0
- package/dist/signal/lomb-scargle.d.ts.map +1 -0
- package/dist/signal/system-response.d.ts +82 -0
- package/dist/signal/system-response.d.ts.map +1 -0
- package/dist/signal/waveforms.d.ts +52 -0
- package/dist/signal/waveforms.d.ts.map +1 -0
- package/dist/signal/windows-extra.d.ts +52 -0
- package/dist/signal/windows-extra.d.ts.map +1 -0
- package/dist/signal/zpk2tf.d.ts +22 -2
- package/dist/signal/zpk2tf.d.ts.map +1 -1
- package/dist/special/angular-momentum.d.ts +38 -0
- package/dist/special/angular-momentum.d.ts.map +1 -0
- package/dist/special/erf-extra.d.ts +47 -0
- package/dist/special/erf-extra.d.ts.map +1 -0
- package/dist/special/exp-integrals.d.ts +38 -0
- package/dist/special/exp-integrals.d.ts.map +1 -0
- package/dist/special/spherical-bessel.d.ts +28 -0
- package/dist/special/spherical-bessel.d.ts.map +1 -0
- package/dist/special/zeta-extra.d.ts +36 -0
- package/dist/special/zeta-extra.d.ts.map +1 -0
- package/dist/stats/distances.d.ts +28 -0
- package/dist/stats/distances.d.ts.map +1 -0
- package/dist/stats/distributions-extra.d.ts +36 -0
- package/dist/stats/distributions-extra.d.ts.map +1 -0
- package/dist/stats/effect-sizes.d.ts +21 -0
- package/dist/stats/effect-sizes.d.ts.map +1 -0
- package/dist/stats/nonparametric-extra.d.ts +52 -0
- package/dist/stats/nonparametric-extra.d.ts.map +1 -0
- package/dist/stats/robust-stats.d.ts +38 -0
- package/dist/stats/robust-stats.d.ts.map +1 -0
- package/dist/stats/weighted-stats.d.ts +27 -0
- package/dist/stats/weighted-stats.d.ts.map +1 -0
- package/dist/typed/algebra.d.ts +7 -3
- package/dist/typed/algebra.d.ts.map +1 -1
- package/dist/typed/cas.d.ts +2 -0
- package/dist/typed/cas.d.ts.map +1 -1
- package/dist/typed/hypothesis.d.ts.map +1 -1
- package/dist/typed/probability.d.ts.map +1 -1
- package/dist/typed/signal.d.ts.map +1 -1
- package/dist/typed/special.d.ts.map +1 -1
- package/dist/typed/statistics.d.ts.map +1 -1
- package/dist/wasm/sort/wasm-bridge.d.ts +3 -13
- package/dist/wasm/sort/wasm-bridge.d.ts.map +1 -1
- package/dist/wasm/special/scalars.d.ts +27 -0
- package/dist/wasm/special/scalars.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Additional quadrature rules and multiple integrals.
|
|
3
|
+
*
|
|
4
|
+
* - {@link tanhSinh}: double-exponential (tanh-sinh) quadrature. Handles
|
|
5
|
+
* endpoint singularities well. Abscissae are computed from the distance to
|
|
6
|
+
* the nearer endpoint, so the nodes stay strictly inside `(a, b)`.
|
|
7
|
+
* - {@link clenshawCurtis}: Clenshaw–Curtis rule on Chebyshev extreme points.
|
|
8
|
+
* - {@link dblquad} / {@link tplquad}: iterated adaptive integration built on
|
|
9
|
+
* {@link quad}. The argument order matches SciPy: `f(y, x)` and `f(z, y, x)`.
|
|
10
|
+
*
|
|
11
|
+
* Infinite limits are rejected with a `RangeError` in this version.
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
import { type QuadOptions, type QuadResult } from './adaptive-quad.js';
|
|
16
|
+
/** Options for {@link tanhSinh}. */
|
|
17
|
+
export interface TanhSinhOptions {
|
|
18
|
+
/** Relative tolerance between successive levels (default 1e-12). */
|
|
19
|
+
tol?: number;
|
|
20
|
+
/** Maximum refinement level; level k uses step `2^{-k}` (default 10). */
|
|
21
|
+
maxLevel?: number;
|
|
22
|
+
}
|
|
23
|
+
/** A limit that is either a constant or a function of the outer variables. */
|
|
24
|
+
export type Limit1 = number | ((x: number) => number);
|
|
25
|
+
/** A limit that is either a constant or a function of two outer variables. */
|
|
26
|
+
export type Limit2 = number | ((x: number, y: number) => number);
|
|
27
|
+
/**
|
|
28
|
+
* Tanh-sinh (double-exponential) quadrature of `f` over `[a, b]`.
|
|
29
|
+
*
|
|
30
|
+
* Substitution `x = m + h·tanh(π/2 · sinh t)` (`m` midpoint, `h` half-width),
|
|
31
|
+
* trapezoid rule in `t` with step `2^{-k}`. Each level's error estimate is the
|
|
32
|
+
* change from the previous level.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* tanhSinh((x) => 1 / Math.sqrt(1 - x * x), -1, 1).value // ~π
|
|
36
|
+
*/
|
|
37
|
+
export declare function tanhSinh(f: (x: number) => number, a: number, b: number, opts?: TanhSinhOptions): QuadResult;
|
|
38
|
+
/**
|
|
39
|
+
* Clenshaw–Curtis quadrature of `f` over `[a, b]` with `n` intervals on the
|
|
40
|
+
* Chebyshev extreme points (exact for polynomials of degree `n`). An odd `n`
|
|
41
|
+
* is rounded up to the next even value.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* clenshawCurtis((x) => x ** 4, -1, 1, 8) // 0.4
|
|
45
|
+
*/
|
|
46
|
+
export declare function clenshawCurtis(f: (x: number) => number, a: number, b: number, n: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Iterated integral `∫_{ax}^{bx} ∫_{gy(x)}^{hy(x)} f(y, x) dy dx`, with both
|
|
49
|
+
* levels integrated by {@link quad}. Returns the outer `error` estimate, and
|
|
50
|
+
* the value is the sum of the outer integrals of the inner results.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* dblquad((y, x) => x * y, 0, 1, 0, 1).value // 0.25
|
|
54
|
+
*/
|
|
55
|
+
export declare function dblquad(f: (y: number, x: number) => number, ax: number, bx: number, gy: Limit1, hy: Limit1, opts?: QuadOptions): QuadResult;
|
|
56
|
+
/**
|
|
57
|
+
* Triple iterated integral `∫_{ax}^{bx} ∫_{gy(x)}^{hy(x)} ∫_{qz(x,y)}^{rz(x,y)}
|
|
58
|
+
* f(z, y, x) dz dy dx`, each level integrated by {@link quad}.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* tplquad((z, y, x) => x * y * z, 0, 1, 0, 1, 0, 1).value // 0.125
|
|
62
|
+
*/
|
|
63
|
+
export declare function tplquad(f: (z: number, y: number, x: number) => number, ax: number, bx: number, gy: Limit1, hy: Limit1, qz: Limit2, rz: Limit2, opts?: QuadOptions): QuadResult;
|
|
64
|
+
//# sourceMappingURL=quadrature-extra.d.ts.map
|
|
@@ -0,0 +1 @@
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MG;AACH,wBAAgB,OAAO,CACrB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,EAC9C,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,WAAW,GACjB,UAAU,CAoBZ"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MathNumericType, MathArray, Unit, TypedFunction } from '../types.js';
|
|
1
|
+
import type { MathNumericType, MathArray, Matrix, Unit, BigNumber, TypedFunction } from '../types.js';
|
|
2
2
|
/**
|
|
3
3
|
* An event function `g(t, y)` whose zero crossings `solveODE` locates. May carry scipy-style
|
|
4
4
|
* `terminal`/`direction` attributes directly on the function object.
|
|
@@ -27,7 +27,7 @@ type ODEEvents = EventFunction | EventSpec | Array<EventFunction | EventSpec>;
|
|
|
27
27
|
/**
|
|
28
28
|
* Options for ODE solver
|
|
29
29
|
*/
|
|
30
|
-
interface ODEOptions {
|
|
30
|
+
export interface ODEOptions {
|
|
31
31
|
method?: 'RK23' | 'RK45' | 'Rosenbrock' | 'RODAS' | 'BDF' | 'Radau';
|
|
32
32
|
tol?: number;
|
|
33
33
|
firstStep?: number | Unit;
|
|
@@ -50,10 +50,21 @@ interface ODEOptions {
|
|
|
50
50
|
*/
|
|
51
51
|
events?: ODEEvents;
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Solution result from ODE solver
|
|
55
|
+
*/
|
|
56
|
+
export interface SolveODESolution<T = unknown> {
|
|
57
|
+
t: T[];
|
|
58
|
+
y: T[];
|
|
59
|
+
/** Event crossing times, one array per event function (present only when `events` was given). */
|
|
60
|
+
tEvents?: number[][];
|
|
61
|
+
/** Event states, one array per event function, aligned with `tEvents`. */
|
|
62
|
+
yEvents?: T[][];
|
|
63
|
+
}
|
|
53
64
|
/**
|
|
54
65
|
* Forcing function type for ODE
|
|
55
66
|
*/
|
|
56
|
-
type ForcingFunction = (t: MathNumericType, y: MathNumericType | MathArray) => MathNumericType | MathArray;
|
|
67
|
+
export type ForcingFunction = (t: MathNumericType, y: MathNumericType | MathArray) => MathNumericType | MathArray;
|
|
57
68
|
/**
|
|
58
69
|
* Return a solver for `A·x = b` reused across the 3–6 right-hand sides a single stiff step solves
|
|
59
70
|
* against the same iteration matrix (W for Rosenbrock, E for RODAS).
|
|
@@ -132,6 +143,20 @@ export declare function radauSolve(f: ForcingFunction, tspan: unknown[], y0raw:
|
|
|
132
143
|
t: number[];
|
|
133
144
|
y: number[][];
|
|
134
145
|
};
|
|
135
|
-
|
|
146
|
+
/** Solution when the time span and state are `Matrix` values: `t` and `y` come back as matrices. */
|
|
147
|
+
export interface ODEMatrixSolution {
|
|
148
|
+
t: Matrix;
|
|
149
|
+
y: Matrix;
|
|
150
|
+
tEvents?: number[][];
|
|
151
|
+
yEvents?: unknown[][];
|
|
152
|
+
}
|
|
153
|
+
/** Call signatures of `solveODE`: array in, array solution; `Matrix` in, matrix solution. */
|
|
154
|
+
interface SolveODEOverloads {
|
|
155
|
+
(f: ForcingFunction, tspan: unknown[], y0: unknown[] | number | BigNumber | Unit, options?: ODEOptions): SolveODESolution;
|
|
156
|
+
(f: ForcingFunction, tspan: Matrix, y0: Matrix | number | BigNumber | Unit, options?: ODEOptions): ODEMatrixSolution;
|
|
157
|
+
}
|
|
158
|
+
/** `solveODE` with its precise call signatures; still a `TypedFunction`. */
|
|
159
|
+
export type SolveODEFunction = SolveODEOverloads & TypedFunction;
|
|
160
|
+
export declare const createSolveODE: import("../utils/factory.js").FactoryFunction<any, SolveODEFunction>;
|
|
136
161
|
export {};
|
|
137
162
|
//# sourceMappingURL=solveODE.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solveODE.d.ts","sourceRoot":"","sources":["../../src/numeric/solveOD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
{"version":3,"file":"combinations.d.ts","sourceRoot":"","sources":["../../src/probability/combinations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"combinations.d.ts","sourceRoot":"","sources":["../../src/probability/combinations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAW/D,UAAU,wBAAwB;IAChC,KAAK,EAAE,aAAa,CAAC;CACtB;AAKD,eAAO,MAAM,kBAAkB,wFAuD9B,CAAC"}
|
|
@@ -35,5 +35,11 @@ export interface LinregressResult {
|
|
|
35
35
|
* √(Σ(y − ŷ)² / ((n − 2)·Σ(x − x̄)²)), from the residuals. Mirrors `scipy.stats.linregress`.
|
|
36
36
|
*/
|
|
37
37
|
export declare function linearRegression(x: Vec, y: Vec): LinregressResult;
|
|
38
|
+
/**
|
|
39
|
+
* Slope inference from an existing {@link LineFit} (`sxx > 0`, `n ≥ 3`): R², the slope standard
|
|
40
|
+
* error and the two-sided slope p-value. Lets `linregress` fit once and reuse the fit for the
|
|
41
|
+
* intercept standard error instead of fitting a second time through `linearRegression`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function linregressFromFit(fit: LineFit, n: number): LinregressResult;
|
|
38
44
|
export {};
|
|
39
45
|
//# sourceMappingURL=regression-extra.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regression-extra.d.ts","sourceRoot":"","sources":["../src/regression-extra.ts"],"names":[],"mappings":"AAQA,KAAK,GAAG,GAAG,SAAS,MAAM,EAAE,GAAG,YAAY,CAAC;AAG5C,gFAAgF;AAChF,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,kBAAkB;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAC;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AC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,gBAAgB,CAUjE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAQ3E"}
|
|
@@ -14,14 +14,15 @@ import type { ScalarNode } from '@danielsimonjr/mathts-expression';
|
|
|
14
14
|
import { WorkerPool } from '@danielsimonjr/mathts-parallel';
|
|
15
15
|
import { type CompileScalarOptions, type ScalarBatchResult } from './scalar-compile.js';
|
|
16
16
|
/**
|
|
17
|
-
* Smallest row count that is sent to workers
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
17
|
+
* Smallest row count that is sent to workers when `parallel` is set. **10_000** is the
|
|
18
|
+
* SR-14 break-even on a reused `WorkerPool` (the lifetime `searchScalars` uses): case (3)
|
|
19
|
+
* of `tools/benchmark/scalar-search/` with one pool for warmup and samples, twice on Node
|
|
20
|
+
* and twice on Bun (2026-11-05, `docs/BENCHMARK_RESULTS.md`, section SR-14). At n = 1_000
|
|
21
|
+
* the reused-pool median is above 0.95× serial in at least one Bun run; at n = 10_000 all
|
|
22
|
+
* four runs are at or below 0.95×. The M3 caller-thread table at n = 100 is unrelated; a
|
|
23
|
+
* cold pool per call is not a valid threshold for the search driver.
|
|
23
24
|
*/
|
|
24
|
-
export declare const SCALAR_PARALLEL_MIN_ROWS =
|
|
25
|
+
export declare const SCALAR_PARALLEL_MIN_ROWS = 10000;
|
|
25
26
|
/** Timeout applied to every worker call when the caller does not choose one. */
|
|
26
27
|
export declare const DEFAULT_SCALAR_PARALLEL_TIMEOUT_MS = 30000;
|
|
27
28
|
/** URL of the built worker, a sibling of the module that contains this code. */
|
|
@@ -31,9 +32,12 @@ export declare function createScalarBatchPool(): WorkerPool;
|
|
|
31
32
|
/** How to run a population on workers. */
|
|
32
33
|
export interface ScalarPopulationParallelOptions {
|
|
33
34
|
/**
|
|
34
|
-
* Milliseconds a worker
|
|
35
|
+
* Milliseconds a worker task may take, queueing included, before it is cancelled, the
|
|
35
36
|
* worker replaced and the evaluation rejected. Must be positive: `0` would switch the
|
|
36
|
-
* pool's timeout off. Default 30000.
|
|
37
|
+
* pool's timeout off. Default 30000. The limit applies per {@link WorkerPool.execute}
|
|
38
|
+
* call; when several islands score in one generation, later island chunks queue behind
|
|
39
|
+
* earlier submissions on the same pool, so callers with many `populations` should scale
|
|
40
|
+
* this value.
|
|
37
41
|
*/
|
|
38
42
|
readonly timeoutMs?: number;
|
|
39
43
|
/** A pool to use, which the caller owns and terminates. Default: one for the call. */
|
|
@@ -56,6 +60,8 @@ export interface ScalarPopulationEvalResult {
|
|
|
56
60
|
}
|
|
57
61
|
/** Positive, finite timeout, or a `RangeError`: a zero would silently disable the guard. */
|
|
58
62
|
export declare function resolveParallelTimeout(timeoutMs: number | undefined): number;
|
|
63
|
+
/** @internal Worker chunk count for {@link evaluateScalarPopulation}; not on the barrel. */
|
|
64
|
+
export declare function scalarParallelWorkerCount(): number;
|
|
59
65
|
/**
|
|
60
66
|
* Evaluates every item over `columns`, in the order given.
|
|
61
67
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar-batch-parallel.d.ts","sourceRoot":"","sources":["../src/scalar-batch-parallel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAQ7B
|
|
1
|
+
{"version":3,"file":"scalar-batch-parallel.d.ts","sourceRoot":"","sources":["../src/scalar-batch-parallel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAk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AAgB,yBAAyB,IAAI,MAAM,CAElD;AA8FD;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,0BAA0B,EAAE,CAAC,CAsBvC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { i as compileScalar, r as buildTape, t as SCALAR_BATCH_MESSAGE_PREFIX } from "./scalar-batch-task-DApUqK6j.js";
|
|
2
|
+
import { WorkerPool } from "@danielsimonjr/mathts-parallel";
|
|
3
|
+
//#region src/scalar-batch-parallel.ts
|
|
4
|
+
const SCALAR_PARALLEL_MIN_ROWS = 1e4;
|
|
5
|
+
const DEFAULT_SCALAR_PARALLEL_TIMEOUT_MS = 3e4;
|
|
6
|
+
function resolveScalarBatchWorkerScript() {
|
|
7
|
+
return new URL("./scalar-batch.worker.js", import.meta.url).href;
|
|
8
|
+
}
|
|
9
|
+
function createScalarBatchPool() {
|
|
10
|
+
return new WorkerPool(resolveScalarBatchWorkerScript());
|
|
11
|
+
}
|
|
12
|
+
function resolveParallelTimeout(timeoutMs) {
|
|
13
|
+
const value = timeoutMs ?? 3e4;
|
|
14
|
+
if (!(Number.isFinite(value) && value > 0)) throw new RangeError(`parallel.timeoutMs must be a finite number > 0, got ${value}`);
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function defaultWorkerCount() {
|
|
18
|
+
if (typeof navigator !== "undefined" && navigator.hardwareConcurrency) return Math.max(2, navigator.hardwareConcurrency - 1);
|
|
19
|
+
return 4;
|
|
20
|
+
}
|
|
21
|
+
function scalarParallelWorkerCount() {
|
|
22
|
+
return defaultWorkerCount();
|
|
23
|
+
}
|
|
24
|
+
function partition(items, chunks) {
|
|
25
|
+
const k = Math.min(Math.max(1, chunks), items.length);
|
|
26
|
+
const base = Math.floor(items.length / k);
|
|
27
|
+
let extra = items.length % k;
|
|
28
|
+
const out = [];
|
|
29
|
+
let start = 0;
|
|
30
|
+
for (let c = 0; c < k; c += 1) {
|
|
31
|
+
const size = base + (extra > 0 ? 1 : 0);
|
|
32
|
+
extra -= extra > 0 ? 1 : 0;
|
|
33
|
+
out.push(items.slice(start, start + size));
|
|
34
|
+
start += size;
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
function evaluateSerial(options) {
|
|
39
|
+
const compileOptions = {
|
|
40
|
+
variables: options.variables,
|
|
41
|
+
parameters: options.parameters,
|
|
42
|
+
constants: options.constants
|
|
43
|
+
};
|
|
44
|
+
return options.items.map((item) => ({
|
|
45
|
+
index: item.index,
|
|
46
|
+
batch: compileScalar(item.node, compileOptions).evaluate(options.columns, item.params)
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
function taskItem(item, position, compileOptions) {
|
|
50
|
+
const { tape, rootReg, nRegs, parameters } = buildTape(item.node, compileOptions, SCALAR_BATCH_MESSAGE_PREFIX);
|
|
51
|
+
return {
|
|
52
|
+
candidateIndex: position,
|
|
53
|
+
tape,
|
|
54
|
+
rootReg,
|
|
55
|
+
nRegs,
|
|
56
|
+
params: item.params === void 0 ? [] : Array.from(item.params),
|
|
57
|
+
parameters
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function evaluateOnPool(pool, timeoutMs, options, rows) {
|
|
61
|
+
const compileOptions = {
|
|
62
|
+
variables: options.variables,
|
|
63
|
+
parameters: options.parameters,
|
|
64
|
+
constants: options.constants
|
|
65
|
+
};
|
|
66
|
+
const items = options.items.map((item, position) => taskItem(item, position, compileOptions));
|
|
67
|
+
const variables = options.variables.slice();
|
|
68
|
+
const replies = await Promise.all(partition(items, defaultWorkerCount()).map((chunk) => {
|
|
69
|
+
const task = {
|
|
70
|
+
items: chunk,
|
|
71
|
+
columns: options.columns,
|
|
72
|
+
variables
|
|
73
|
+
};
|
|
74
|
+
return pool.execute(task, void 0, timeoutMs);
|
|
75
|
+
}));
|
|
76
|
+
const byPosition = /* @__PURE__ */ new Map();
|
|
77
|
+
for (const reply of replies) for (const row of reply.rows) {
|
|
78
|
+
if (row.values.length !== rows || row.valid.length !== rows) throw new Error(`evaluateScalarPopulation: worker returned ${row.values.length} values for ${rows} rows`);
|
|
79
|
+
byPosition.set(row.candidateIndex, {
|
|
80
|
+
values: row.values,
|
|
81
|
+
valid: row.valid,
|
|
82
|
+
allValid: row.allValid
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return options.items.map((item, position) => {
|
|
86
|
+
const batch = byPosition.get(position);
|
|
87
|
+
if (batch === void 0) throw new Error(`evaluateScalarPopulation: no worker result for item ${position}`);
|
|
88
|
+
return {
|
|
89
|
+
index: item.index,
|
|
90
|
+
batch
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async function evaluateScalarPopulation(options) {
|
|
95
|
+
const timeoutMs = options.parallel === void 0 ? 0 : resolveParallelTimeout(options.parallel.timeoutMs);
|
|
96
|
+
const matched = options.columns.length === options.variables.length;
|
|
97
|
+
const rows = options.variables.length === 0 ? 1 : options.columns[0]?.length ?? 0;
|
|
98
|
+
if (options.parallel === void 0 || !matched || rows < 1e4 || options.items.length === 0) return evaluateSerial(options);
|
|
99
|
+
const given = options.parallel.pool;
|
|
100
|
+
const pool = given ?? createScalarBatchPool();
|
|
101
|
+
try {
|
|
102
|
+
return await evaluateOnPool(pool, timeoutMs, options, rows);
|
|
103
|
+
} finally {
|
|
104
|
+
if (given === void 0) await pool.terminate();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
export { DEFAULT_SCALAR_PARALLEL_TIMEOUT_MS, SCALAR_PARALLEL_MIN_ROWS, createScalarBatchPool, evaluateScalarPopulation, resolveParallelTimeout, resolveScalarBatchWorkerScript, scalarParallelWorkerCount };
|
|
@@ -2021,11 +2021,21 @@ const UNARY = {
|
|
|
2021
2021
|
sinh,
|
|
2022
2022
|
cosh,
|
|
2023
2023
|
tanh,
|
|
2024
|
-
abs
|
|
2024
|
+
abs,
|
|
2025
|
+
sqrt,
|
|
2026
|
+
atan
|
|
2025
2027
|
};
|
|
2026
2028
|
const NUMERIC_LITERAL = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
2029
|
+
function nonFiniteDetail(value) {
|
|
2030
|
+
if (typeof value === "number") {
|
|
2031
|
+
if (Number.isNaN(value)) return "NaN";
|
|
2032
|
+
if (value === Number.POSITIVE_INFINITY) return "Infinity";
|
|
2033
|
+
if (value === Number.NEGATIVE_INFINITY) return "-Infinity";
|
|
2034
|
+
}
|
|
2035
|
+
return "non-finite";
|
|
2036
|
+
}
|
|
2027
2037
|
function requireFinite(value, label) {
|
|
2028
|
-
if (typeof value !== "number" || !Number.isFinite(value)) throw new ScalarEvalError(`evaluateScalar: '${label}' produced a non-finite value (${
|
|
2038
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new ScalarEvalError(`evaluateScalar: '${label}' produced a non-finite value (${nonFiniteDetail(value)}).`);
|
|
2029
2039
|
return value;
|
|
2030
2040
|
}
|
|
2031
2041
|
function resolveSymbol(name, scope) {
|
|
@@ -2104,7 +2114,9 @@ const LOWERED_UNARY_RULES = {
|
|
|
2104
2114
|
sinh: DUAL_UNARY_RULES.sinh,
|
|
2105
2115
|
cosh: DUAL_UNARY_RULES.cosh,
|
|
2106
2116
|
tanh: DUAL_UNARY_RULES.tanh,
|
|
2107
|
-
abs: DUAL_UNARY_RULES.abs
|
|
2117
|
+
abs: DUAL_UNARY_RULES.abs,
|
|
2118
|
+
sqrt: DUAL_UNARY_RULES.sqrt,
|
|
2119
|
+
atan: DUAL_UNARY_RULES.atan
|
|
2108
2120
|
};
|
|
2109
2121
|
function isScalarNode(value) {
|
|
2110
2122
|
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
@@ -2217,20 +2229,16 @@ function runRow(tape, scratch, rootReg, columns, params, row, grad, nParams) {
|
|
|
2217
2229
|
if (dl !== 0) {
|
|
2218
2230
|
const factor = powBasePartial(exp, base);
|
|
2219
2231
|
if (!Number.isFinite(factor)) {
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
setRegisterGradNaN(grad, instr.dest, nParams);
|
|
2223
|
-
break;
|
|
2232
|
+
grad[destBase + p] = NaN;
|
|
2233
|
+
continue;
|
|
2224
2234
|
}
|
|
2225
2235
|
g += dl * factor;
|
|
2226
2236
|
}
|
|
2227
2237
|
if (dr !== 0) {
|
|
2228
2238
|
const factor = powExpPartial(val, base);
|
|
2229
2239
|
if (!Number.isFinite(factor)) {
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
setRegisterGradNaN(grad, instr.dest, nParams);
|
|
2233
|
-
break;
|
|
2240
|
+
grad[destBase + p] = NaN;
|
|
2241
|
+
continue;
|
|
2234
2242
|
}
|
|
2235
2243
|
g += dr * factor;
|
|
2236
2244
|
}
|
|
@@ -2285,10 +2293,8 @@ function runRow(tape, scratch, rootReg, columns, params, row, grad, nParams) {
|
|
|
2285
2293
|
}
|
|
2286
2294
|
const d = rule.deriv(x, y);
|
|
2287
2295
|
if (!Number.isFinite(d)) {
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
setRegisterGradNaN(grad, instr.dest, nParams);
|
|
2291
|
-
break;
|
|
2296
|
+
grad[destBase + p] = NaN;
|
|
2297
|
+
continue;
|
|
2292
2298
|
}
|
|
2293
2299
|
grad[destBase + p] = al * d;
|
|
2294
2300
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as runScalarBatchTask } from "./scalar-batch-task-
|
|
1
|
+
import { n as runScalarBatchTask } from "./scalar-batch-task-DApUqK6j.js";
|
|
2
2
|
//#region src/scalar-batch.worker.ts
|
|
3
3
|
const isNode = typeof process !== "undefined" && process.versions?.node !== void 0;
|
|
4
4
|
let nodeParentPort = null;
|
package/dist/scalar-compile.d.ts
CHANGED
|
@@ -161,10 +161,10 @@ export interface CompiledScalarGradient {
|
|
|
161
161
|
readonly parameters: readonly string[];
|
|
162
162
|
/**
|
|
163
163
|
* Evaluate every row. Invalid rows store `NaN` in `values` and every
|
|
164
|
-
* gradient entry for that row. The mask matches {@link compileScalar}
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
164
|
+
* gradient entry for that row. The `valid` mask matches {@link compileScalar}
|
|
165
|
+
* (primal evaluation only). When a parameter partial is not finite the row
|
|
166
|
+
* stays valid and the affected gradient entries are `NaN`; the fitter treats
|
|
167
|
+
* non-finite Jacobian entries as a failed step.
|
|
168
168
|
*
|
|
169
169
|
* @example
|
|
170
170
|
* ```ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar-compile.d.ts","sourceRoot":"","sources":["../src/scalar-compile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"scalar-compile.d.ts","sourceRoot":"","sources":["../src/scalar-compile.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAmBpG,KAAK,SAAS,GACV;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACzE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACxE;IAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC;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,SAAS,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAwBA;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,oBAAoB,GAAG,cAAc,CAyD7F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,oBAAoB,GAC5B,sBAAsB,CAmExB"}
|
|
@@ -28,6 +28,14 @@ export type ParameterDimensionResult = {
|
|
|
28
28
|
} | {
|
|
29
29
|
readonly inconsistent: true;
|
|
30
30
|
};
|
|
31
|
+
declare function validateDimensionVector(vector: RationalDimension, label?: string): void;
|
|
32
|
+
/**
|
|
33
|
+
* @internal Exported for `scalar-search.ts`'s option validation, not the package
|
|
34
|
+
* barrel. The same length-and-`Fraction` check the inference entry points run.
|
|
35
|
+
*/
|
|
36
|
+
export { validateDimensionVector };
|
|
37
|
+
/** Exact equality of two {@link RationalDimension} vectors. */
|
|
38
|
+
export declare function rationalDimensionsEqual(a: RationalDimension, b: RationalDimension): boolean;
|
|
31
39
|
/**
|
|
32
40
|
* Infer the SI dimension of a scalar tree, or report a structural violation.
|
|
33
41
|
*/
|
|
@@ -51,4 +59,21 @@ export declare function inferScalarDimension(node: ScalarNode, dims: Readonly<Re
|
|
|
51
59
|
export declare function solveParameterDimensions(node: ScalarNode, dims: Readonly<Record<string, RationalDimension>>, target: RationalDimension, parameters: readonly string[], options?: {
|
|
52
60
|
readonly dimensionlessOnly?: boolean;
|
|
53
61
|
}): ParameterDimensionResult;
|
|
62
|
+
/**
|
|
63
|
+
* The SI dimension of a unit name as a {@link RationalDimension}.
|
|
64
|
+
*
|
|
65
|
+
* Builds `new Unit(1, unitName)` and maps its length-10 exponent vector through
|
|
66
|
+
* {@link toSiDimensionVector}. Supplementary angle and solid-angle exponents
|
|
67
|
+
* (`rad`, `deg`, `sr`, …) map to a dimensionless 7-vector. Information units
|
|
68
|
+
* (`bit`, `byte`, …) are not representable in the seven SI base dimensions and
|
|
69
|
+
* throw {@link UnitParseError}. An unknown unit name throws the same
|
|
70
|
+
* {@link UnitParseError} `Unit` already throws. `unitName` must be a string.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { unitToRationalDimension } from '@danielsimonjr/mathts-functions';
|
|
75
|
+
* unitToRationalDimension('m')[0].toString(); // '1'
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function unitToRationalDimension(unitName: string): RationalDimension;
|
|
54
79
|
//# sourceMappingURL=scalar-dimension.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar-dimension.d.ts","sourceRoot":"","sources":["../src/scalar-dimension.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,
|
|
1
|
+
{"version":3,"file":"scalar-dimension.d.ts","sourceRoot":"","sources":["../src/scalar-dimension.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAML,KAAK,iBAAiB,EACvB,MAAM,4BAA4B,CAAC;AAIpC,iEAAiE;AACjE,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAElD,8CAA8C;AAC9C,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAA;CAAE,GAC5D;IACE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,SAAS,EACd,cAAc,GACd,sCAAsC,GACtC,0CAA0C,GA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8 +14,10 @@
|
|
|
14
14
|
* arguments and calls MathTS `pow`. One-argument `-` does not negate; a
|
|
15
15
|
* unary minus is `(-1) * x`.
|
|
16
16
|
*
|
|
17
|
-
* A non-finite operator or call result throws {@link ScalarEvalError}.
|
|
18
|
-
*
|
|
17
|
+
* A non-finite operator or call result throws {@link ScalarEvalError}. That
|
|
18
|
+
* includes `sqrt` of a negative argument (complex-valued in MathTS), and
|
|
19
|
+
* `sqrt(Infinity)` / `sqrt(NaN)`. A bare symbol or number is returned as
|
|
20
|
+
* stored, including a non-finite value.
|
|
19
21
|
*
|
|
20
22
|
* @packageDocumentation
|
|
21
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar-eval.d.ts","sourceRoot":"","sources":["../src/scalar-eval.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"scalar-eval.d.ts","sourceRoot":"","sources":["../src/scalar-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA2BH,gFAAgF;AAChF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3D,wFAAwF;AACxF,eAAO,MAAM,MAAM,0DAAwB,CAAC;AAE5C,4CAA4C;AAC5C,qBAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAkBD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAgD,CAAC;AAuG7E;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,GAAE,WAAgB,GAAG,MAAM,CAU7E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar-node-bridge.d.ts","sourceRoot":"","sources":["../src/scalar-node-bridge.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,QAAQ,EACR,UAAU,EACV,aAA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