@danielsimonjr/mathts-functions 0.71.0 → 0.73.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.
Files changed (95) hide show
  1. package/README.md +26 -1
  2. package/dist/cas/real-roots.d.ts +30 -0
  3. package/dist/cas/real-roots.d.ts.map +1 -0
  4. package/dist/fit-scalar.d.ts +28 -0
  5. package/dist/fit-scalar.d.ts.map +1 -1
  6. package/dist/geometry/curves.d.ts +48 -0
  7. package/dist/geometry/curves.d.ts.map +1 -0
  8. package/dist/geometry/polygon-ops.d.ts +19 -0
  9. package/dist/geometry/polygon-ops.d.ts.map +1 -0
  10. package/dist/geometry/predicates.d.ts +38 -0
  11. package/dist/geometry/predicates.d.ts.map +1 -0
  12. package/dist/index.d.ts +51 -4
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +5310 -766
  15. package/dist/linalg-extra2.d.ts +36 -0
  16. package/dist/linalg-extra2.d.ts.map +1 -0
  17. package/dist/linalg-special-matrices.d.ts +62 -0
  18. package/dist/linalg-special-matrices.d.ts.map +1 -0
  19. package/dist/numbertheory/arithmetic-functions.d.ts +50 -0
  20. package/dist/numbertheory/arithmetic-functions.d.ts.map +1 -0
  21. package/dist/numbertheory/diophantine.d.ts +43 -0
  22. package/dist/numbertheory/diophantine.d.ts.map +1 -0
  23. package/dist/numbertheory/extra.d.ts +12 -6
  24. package/dist/numbertheory/extra.d.ts.map +1 -1
  25. package/dist/numbertheory/integer-matrices.d.ts +26 -0
  26. package/dist/numbertheory/integer-matrices.d.ts.map +1 -0
  27. package/dist/numbertheory/modular.d.ts +27 -0
  28. package/dist/numbertheory/modular.d.ts.map +1 -0
  29. package/dist/numbertheory/sequences.d.ts +36 -0
  30. package/dist/numbertheory/sequences.d.ts.map +1 -0
  31. package/dist/numeric/constrained.d.ts +42 -0
  32. package/dist/numeric/constrained.d.ts.map +1 -0
  33. package/dist/numeric/finite-differences.d.ts +54 -0
  34. package/dist/numeric/finite-differences.d.ts.map +1 -0
  35. package/dist/numeric/gauss-nodes-extra.d.ts +73 -0
  36. package/dist/numeric/gauss-nodes-extra.d.ts.map +1 -0
  37. package/dist/numeric/global-optimizers.d.ts +64 -0
  38. package/dist/numeric/global-optimizers.d.ts.map +1 -0
  39. package/dist/numeric/quadrature-extra.d.ts +64 -0
  40. package/dist/numeric/quadrature-extra.d.ts.map +1 -0
  41. package/dist/numeric/rational-nullspace.d.ts +2 -2
  42. package/dist/numeric/rational-nullspace.d.ts.map +1 -1
  43. package/dist/scalar-batch-parallel.d.ts +15 -9
  44. package/dist/scalar-batch-parallel.d.ts.map +1 -1
  45. package/dist/scalar-batch-parallel.js +108 -0
  46. package/dist/{scalar-batch-task-CZd6LPg9.js → scalar-batch-task-CL8ex21e.js} +33 -35
  47. package/dist/scalar-batch.worker.js +1 -1
  48. package/dist/scalar-compile.d.ts +4 -4
  49. package/dist/scalar-compile.d.ts.map +1 -1
  50. package/dist/scalar-dimension.d.ts +32 -0
  51. package/dist/scalar-dimension.d.ts.map +1 -1
  52. package/dist/scalar-eval.d.ts +4 -2
  53. package/dist/scalar-eval.d.ts.map +1 -1
  54. package/dist/scalar-node-bridge.d.ts.map +1 -1
  55. package/dist/scalar-search.d.ts +325 -14
  56. package/dist/scalar-search.d.ts.map +1 -1
  57. package/dist/signal/dtw.d.ts +32 -0
  58. package/dist/signal/dtw.d.ts.map +1 -0
  59. package/dist/signal/lomb-scargle.d.ts +25 -0
  60. package/dist/signal/lomb-scargle.d.ts.map +1 -0
  61. package/dist/signal/system-response.d.ts +82 -0
  62. package/dist/signal/system-response.d.ts.map +1 -0
  63. package/dist/signal/waveforms.d.ts +52 -0
  64. package/dist/signal/waveforms.d.ts.map +1 -0
  65. package/dist/signal/windows-extra.d.ts +52 -0
  66. package/dist/signal/windows-extra.d.ts.map +1 -0
  67. package/dist/special/angular-momentum.d.ts +38 -0
  68. package/dist/special/angular-momentum.d.ts.map +1 -0
  69. package/dist/special/erf-extra.d.ts +47 -0
  70. package/dist/special/erf-extra.d.ts.map +1 -0
  71. package/dist/special/exp-integrals.d.ts +38 -0
  72. package/dist/special/exp-integrals.d.ts.map +1 -0
  73. package/dist/special/spherical-bessel.d.ts +28 -0
  74. package/dist/special/spherical-bessel.d.ts.map +1 -0
  75. package/dist/special/zeta-extra.d.ts +36 -0
  76. package/dist/special/zeta-extra.d.ts.map +1 -0
  77. package/dist/stats/distances.d.ts +28 -0
  78. package/dist/stats/distances.d.ts.map +1 -0
  79. package/dist/stats/distributions-extra.d.ts +36 -0
  80. package/dist/stats/distributions-extra.d.ts.map +1 -0
  81. package/dist/stats/effect-sizes.d.ts +21 -0
  82. package/dist/stats/effect-sizes.d.ts.map +1 -0
  83. package/dist/stats/nonparametric-extra.d.ts +52 -0
  84. package/dist/stats/nonparametric-extra.d.ts.map +1 -0
  85. package/dist/stats/robust-stats.d.ts +38 -0
  86. package/dist/stats/robust-stats.d.ts.map +1 -0
  87. package/dist/stats/weighted-stats.d.ts +27 -0
  88. package/dist/stats/weighted-stats.d.ts.map +1 -0
  89. package/dist/typed/arithmetic.d.ts +2 -1
  90. package/dist/typed/arithmetic.d.ts.map +1 -1
  91. package/dist/typed/numeric.d.ts.map +1 -1
  92. package/dist/typed/special.d.ts.map +1 -1
  93. package/dist/wasm/special/scalars.d.ts +27 -0
  94. package/dist/wasm/special/scalars.d.ts.map +1 -1
  95. 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 @@
1
+ {"version":3,"file":"quadrature-extra.d.ts","sourceRoot":"","sources":["../../src/numeric/quadrature-extra.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAQ,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAE7E,oCAAoC;AACpC,MAAM,WAAW,eAAe;IAC9B,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,8EAA8E;AAC9E,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AACtD,8EAA8E;AAC9E,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AAUjE;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CACtB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EACxB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,GAAE,eAAoB,GACzB,UAAU,CA0CZ;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAqBhG;AAMD;;;;;;;GAOG;AACH,wBAAgB,OAAO,CACrB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAAM,EACnC,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,WAAW,GACjB,UAAU,CASZ;AAED;;;;;;GAMG;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"}
@@ -37,7 +37,7 @@ export interface RationalNullspaceResult {
37
37
  *
38
38
  * Numbers are converted with {@link Fraction.fromNumber} (continued fraction,
39
39
  * denominator at most 10^6). Pass {@link Fraction} entries when the exponent
40
- * is already an exact ratio, such as `1/3`.
40
+ * is already an exact ratio, such as `1/3`. A `bigint` entry is exact.
41
41
  *
42
42
  * The numeric {@link nullspace} is unchanged. This function does not replace it.
43
43
  *
@@ -55,5 +55,5 @@ export interface RationalNullspaceResult {
55
55
  * // { rank: 2, basis: [[2, -1, 1]] }
56
56
  * ```
57
57
  */
58
- export declare function rationalNullspace(matrix: ReadonlyArray<ReadonlyArray<number | Fraction>>, options?: RationalNullspaceOptions): RationalNullspaceResult;
58
+ export declare function rationalNullspace(matrix: ReadonlyArray<ReadonlyArray<number | bigint | Fraction>>, options?: RationalNullspaceOptions): RationalNullspaceResult;
59
59
  //# sourceMappingURL=rational-nullspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rational-nullspace.d.ts","sourceRoot":"","sources":["../../src/numeric/rational-nullspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAElE,6CAA6C;AAC7C,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,uDAAuD;AACvD,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAqFD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,EACvD,OAAO,CAAC,EAAE,wBAAwB,GACjC,uBAAuB,CAgDzB"}
1
+ {"version":3,"file":"rational-nullspace.d.ts","sourceRoot":"","sources":["../../src/numeric/rational-nullspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,QAAQ,EAAc,MAAM,4BAA4B,CAAC;AAElE,6CAA6C;AAC7C,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,uDAAuD;AACvD,MAAM,WAAW,uBAAuB;IACtC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,CAAC;IAC7B,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAsFD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC,EAChE,OAAO,CAAC,EAAE,wBAAwB,GACjC,uBAAuB,CAgDzB"}
@@ -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. 100 is the `n` from which the M3 tape beats
18
- * the per-row interpreter in every run of the `scalar` benchmark (`docs/BENCHMARK_RESULTS.md`,
19
- * section "`evaluateScalar` vs `compileScalar` (M3 batch evaluator) - 2026-10-25"). That
20
- * table compares the two evaluators on the caller thread; it did not time a worker round
21
- * trip, so this is the plan's floor for using the pool and not a measured break-even. The
22
- * pool is opt-in, and nothing here claims a speed-up.
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 = 100;
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 call may take, queueing included, before it is cancelled, the
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;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAE5C,gFAAgF;AAChF,eAAO,MAAM,kCAAkC,QAAS,CAAC;AAEzD,gFAAgF;AAChF,wBAAgB,8BAA8B,IAAI,MAAM,CAEvD;AAED,2FAA2F;AAC3F,wBAAgB,qBAAqB,IAAI,UAAU,CAElD;AAED,0CAA0C;AAC1C,MAAM,WAAW,+BAA+B;IAC9C;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,sFAAsF;IACtF,QAAQ,CA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ex21e.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 };
@@ -1669,18 +1669,16 @@ const fsum = mathTyped("fsum", {
1669
1669
  });
1670
1670
  const sum = mathTyped("sum", {
1671
1671
  Array: (arr) => pairwiseSum(arr),
1672
- Float64Array: async (a) => {
1673
- return (await computePool.sum(a)).result;
1674
- }
1672
+ Float64Array: (a) => pairwiseSum(a),
1673
+ Float32Array: (a) => pairwiseSum(a)
1675
1674
  });
1676
1675
  const mean = mathTyped("mean", {
1677
1676
  Array: (arr) => {
1678
1677
  if (arr.length === 0) return NaN;
1679
1678
  return pairwiseSum(arr) / arr.length;
1680
1679
  },
1681
- Float64Array: async (a) => {
1682
- return (await computePool.mean(a)).result;
1683
- }
1680
+ Float64Array: (a) => a.length === 0 ? NaN : pairwiseSum(a) / a.length,
1681
+ Float32Array: (a) => a.length === 0 ? NaN : pairwiseSum(a) / a.length
1684
1682
  });
1685
1683
  function varianceFromM2(m2, n, norm) {
1686
1684
  if (n === 0) return NaN;
@@ -1696,24 +1694,18 @@ function m2OfArray(arr) {
1696
1694
  const variance = mathTyped("variance", {
1697
1695
  Array: (arr) => varianceFromM2(m2OfArray(arr), arr.length, "unbiased"),
1698
1696
  "Array, string": (arr, norm) => varianceFromM2(m2OfArray(arr), arr.length, norm),
1699
- Float64Array: async (a) => {
1700
- return varianceFromM2((await computePool.variance(a)).result.variance * a.length, a.length, "unbiased");
1701
- },
1702
- "Float64Array, string": async (a, norm) => {
1703
- return varianceFromM2((await computePool.variance(a)).result.variance * a.length, a.length, norm);
1704
- }
1697
+ Float64Array: (a) => varianceFromM2(sumSquaredDeviations(a), a.length, "unbiased"),
1698
+ Float32Array: (a) => varianceFromM2(sumSquaredDeviations(a), a.length, "unbiased"),
1699
+ "Float64Array, string": (a, norm) => varianceFromM2(sumSquaredDeviations(a), a.length, norm),
1700
+ "Float32Array, string": (a, norm) => varianceFromM2(sumSquaredDeviations(a), a.length, norm)
1705
1701
  });
1706
1702
  const std = mathTyped("std", {
1707
1703
  Array: (arr) => Math.sqrt(varianceFromM2(m2OfArray(arr), arr.length, "unbiased")),
1708
1704
  "Array, string": (arr, norm) => Math.sqrt(varianceFromM2(m2OfArray(arr), arr.length, norm)),
1709
- Float64Array: async (a) => {
1710
- const result = await computePool.variance(a);
1711
- return Math.sqrt(varianceFromM2(result.result.variance * a.length, a.length, "unbiased"));
1712
- },
1713
- "Float64Array, string": async (a, norm) => {
1714
- const result = await computePool.variance(a);
1715
- return Math.sqrt(varianceFromM2(result.result.variance * a.length, a.length, norm));
1716
- }
1705
+ Float64Array: (a) => Math.sqrt(varianceFromM2(sumSquaredDeviations(a), a.length, "unbiased")),
1706
+ Float32Array: (a) => Math.sqrt(varianceFromM2(sumSquaredDeviations(a), a.length, "unbiased")),
1707
+ "Float64Array, string": (a, norm) => Math.sqrt(varianceFromM2(sumSquaredDeviations(a), a.length, norm)),
1708
+ "Float32Array, string": (a, norm) => Math.sqrt(varianceFromM2(sumSquaredDeviations(a), a.length, norm))
1717
1709
  });
1718
1710
  const dot = mathTyped("dot", {
1719
1711
  "Array, Array": (a, b) => {
@@ -2021,11 +2013,21 @@ const UNARY = {
2021
2013
  sinh,
2022
2014
  cosh,
2023
2015
  tanh,
2024
- abs
2016
+ abs,
2017
+ sqrt,
2018
+ atan
2025
2019
  };
2026
2020
  const NUMERIC_LITERAL = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;
2021
+ function nonFiniteDetail(value) {
2022
+ if (typeof value === "number") {
2023
+ if (Number.isNaN(value)) return "NaN";
2024
+ if (value === Number.POSITIVE_INFINITY) return "Infinity";
2025
+ if (value === Number.NEGATIVE_INFINITY) return "-Infinity";
2026
+ }
2027
+ return "non-finite";
2028
+ }
2027
2029
  function requireFinite(value, label) {
2028
- if (typeof value !== "number" || !Number.isFinite(value)) throw new ScalarEvalError(`evaluateScalar: '${label}' produced a non-finite value (${String(value)}).`);
2030
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new ScalarEvalError(`evaluateScalar: '${label}' produced a non-finite value (${nonFiniteDetail(value)}).`);
2029
2031
  return value;
2030
2032
  }
2031
2033
  function resolveSymbol(name, scope) {
@@ -2104,7 +2106,9 @@ const LOWERED_UNARY_RULES = {
2104
2106
  sinh: DUAL_UNARY_RULES.sinh,
2105
2107
  cosh: DUAL_UNARY_RULES.cosh,
2106
2108
  tanh: DUAL_UNARY_RULES.tanh,
2107
- abs: DUAL_UNARY_RULES.abs
2109
+ abs: DUAL_UNARY_RULES.abs,
2110
+ sqrt: DUAL_UNARY_RULES.sqrt,
2111
+ atan: DUAL_UNARY_RULES.atan
2108
2112
  };
2109
2113
  function isScalarNode(value) {
2110
2114
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
@@ -2217,20 +2221,16 @@ function runRow(tape, scratch, rootReg, columns, params, row, grad, nParams) {
2217
2221
  if (dl !== 0) {
2218
2222
  const factor = powBasePartial(exp, base);
2219
2223
  if (!Number.isFinite(factor)) {
2220
- valid = false;
2221
- scratch[instr.dest] = NaN;
2222
- setRegisterGradNaN(grad, instr.dest, nParams);
2223
- break;
2224
+ grad[destBase + p] = NaN;
2225
+ continue;
2224
2226
  }
2225
2227
  g += dl * factor;
2226
2228
  }
2227
2229
  if (dr !== 0) {
2228
2230
  const factor = powExpPartial(val, base);
2229
2231
  if (!Number.isFinite(factor)) {
2230
- valid = false;
2231
- scratch[instr.dest] = NaN;
2232
- setRegisterGradNaN(grad, instr.dest, nParams);
2233
- break;
2232
+ grad[destBase + p] = NaN;
2233
+ continue;
2234
2234
  }
2235
2235
  g += dr * factor;
2236
2236
  }
@@ -2285,10 +2285,8 @@ function runRow(tape, scratch, rootReg, columns, params, row, grad, nParams) {
2285
2285
  }
2286
2286
  const d = rule.deriv(x, y);
2287
2287
  if (!Number.isFinite(d)) {
2288
- valid = false;
2289
- scratch[instr.dest] = NaN;
2290
- setRegisterGradNaN(grad, instr.dest, nParams);
2291
- break;
2288
+ grad[destBase + p] = NaN;
2289
+ continue;
2292
2290
  }
2293
2291
  grad[destBase + p] = al * d;
2294
2292
  }
@@ -1,4 +1,4 @@
1
- import { n as runScalarBatchTask } from "./scalar-batch-task-CZd6LPg9.js";
1
+ import { n as runScalarBatchTask } from "./scalar-batch-task-CL8ex21e.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;
@@ -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} except
165
- * when a consumed `^` partial is not finite (a live child lane of `0^0`, or
166
- * `ln` of a negative base with a live exponent): those rows are extra-invalid.
167
- * Throws {@link ScalarEvalError} for binding mismatches or bad `out` lengths.
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;AAiBpG,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,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AC;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,28 @@ 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
+ /** Options for {@link unitToRationalDimension}. */
63
+ export interface UnitDimensionOptions {
64
+ /** Caller map from a unit name to its seven-axis dimension. Set: no `Unit` is built and the information axis is not read. */
65
+ readonly mapUnit?: (unitName: string) => RationalDimension;
66
+ }
67
+ /**
68
+ * The SI dimension of a unit name as a {@link RationalDimension}.
69
+ *
70
+ * Builds `new Unit(1, unitName)` and maps its length-10 exponent vector through
71
+ * {@link toSiDimensionVector}. Supplementary angle and solid-angle exponents
72
+ * (`rad`, `deg`, `sr`, …) map to a dimensionless 7-vector. Information units
73
+ * (`bit`, `byte`, …) are not representable in the seven SI base dimensions and
74
+ * throw {@link UnitParseError}. An unknown unit name throws the same
75
+ * {@link UnitParseError} `Unit` already throws. `unitName` must be a string.
76
+ *
77
+ * With `options.mapUnit` the caller's map gives the dimension, so a unit such as `bit` can map to a caller-chosen vector.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * import { unitToRationalDimension } from '@danielsimonjr/mathts-functions';
82
+ * unitToRationalDimension('m')[0].toString(); // '1'
83
+ * ```
84
+ */
85
+ export declare function unitToRationalDimension(unitName: string, options?: UnitDimensionOptions): RationalDimension;
54
86
  //# 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,EAAiC,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAInG,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,GAC1C,gBAAgB,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC,CAAC;AAEN,kDAAkD;AAClD,MAAM,MAAM,wBAAwB,GAChC;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAA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E,MAAM,EAChB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,iBAAiB,CAsBnB"}
@@ -14,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}. A bare
18
- * symbol or number is returned as stored, including a non-finite value.
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;;;;;;;;;;;;;;;;;;;;GAoBG;AA0BH,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;AAgBD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAgD,CAAC;AAuF7E;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,GAAE,WAAgB,GAAG,MAAM,CAU7E"}
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,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