universal-physics-tensor 0.7.3 → 0.14.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 (293) hide show
  1. package/README.md +147 -109
  2. package/bin/upt.mjs +508 -0
  3. package/dist/bridges/be23-planckian-confrontation.d.ts +162 -0
  4. package/dist/bridges/be23-planckian-confrontation.d.ts.map +1 -0
  5. package/dist/bridges/be23-planckian-confrontation.js +196 -0
  6. package/dist/bridges/be23-planckian-confrontation.js.map +1 -0
  7. package/dist/bridges/be36-gw170817-confrontation.d.ts +111 -0
  8. package/dist/bridges/be36-gw170817-confrontation.d.ts.map +1 -0
  9. package/dist/bridges/be36-gw170817-confrontation.js +100 -0
  10. package/dist/bridges/be36-gw170817-confrontation.js.map +1 -0
  11. package/dist/bridges/bridge-equations.d.ts +129 -0
  12. package/dist/bridges/bridge-equations.d.ts.map +1 -0
  13. package/dist/bridges/bridge-equations.js +130 -0
  14. package/dist/bridges/bridge-equations.js.map +1 -0
  15. package/dist/bridges/catalog-adapter.d.ts +1 -1
  16. package/dist/bridges/catalog-adapter.js +1 -1
  17. package/dist/bridges/confrontation-coverage.d.ts +67 -0
  18. package/dist/bridges/confrontation-coverage.d.ts.map +1 -0
  19. package/dist/bridges/confrontation-coverage.js +83 -0
  20. package/dist/bridges/confrontation-coverage.js.map +1 -0
  21. package/dist/bridges/equations/_be-helpers.d.ts +2 -1
  22. package/dist/bridges/equations/_be-helpers.d.ts.map +1 -1
  23. package/dist/bridges/equations/be-12-coherence-length.d.ts +1 -1
  24. package/dist/bridges/equations/be-13-einstein-trace.d.ts +2 -2
  25. package/dist/bridges/equations/be-13-einstein-trace.js +1 -1
  26. package/dist/bridges/equations/be-14-ryu-takayanagi.d.ts +2 -2
  27. package/dist/bridges/equations/be-15-emergence.d.ts +19 -5
  28. package/dist/bridges/equations/be-15-emergence.d.ts.map +1 -1
  29. package/dist/bridges/equations/be-15-emergence.js +18 -4
  30. package/dist/bridges/equations/be-15-emergence.js.map +1 -1
  31. package/dist/bridges/equations/be-16-landauer.d.ts +1 -1
  32. package/dist/bridges/equations/be-17-einstein-cartan.d.ts +1 -1
  33. package/dist/bridges/equations/be-18-higgs-mass.d.ts +1 -1
  34. package/dist/bridges/equations/be-19-quantum-bounce.d.ts +1 -1
  35. package/dist/bridges/equations/be-20-vacuum-energy.d.ts +4 -4
  36. package/dist/bridges/equations/be-20-vacuum-energy.d.ts.map +1 -1
  37. package/dist/bridges/equations/be-20-vacuum-energy.js +4 -2
  38. package/dist/bridges/equations/be-20-vacuum-energy.js.map +1 -1
  39. package/dist/bridges/equations/be-22-topological-entanglement.d.ts +1 -1
  40. package/dist/bridges/equations/be-23-syk-planckian.d.ts +1 -1
  41. package/dist/bridges/equations/be-24-foerster-fret.d.ts +1 -1
  42. package/dist/bridges/equations/be-25-iit-phi.d.ts +1 -1
  43. package/dist/bridges/equations/be-25-orch-or.d.ts +13 -1
  44. package/dist/bridges/equations/be-25-orch-or.d.ts.map +1 -1
  45. package/dist/bridges/equations/be-25-orch-or.js +12 -0
  46. package/dist/bridges/equations/be-25-orch-or.js.map +1 -1
  47. package/dist/bridges/equations/be-26-dna-tunneling.d.ts +2 -2
  48. package/dist/bridges/equations/be-26-dna-tunneling.js +1 -1
  49. package/dist/bridges/equations/be-27-effective-temperature.d.ts +1 -1
  50. package/dist/bridges/equations/be-28-onsager-entropy-production.d.ts +1 -1
  51. package/dist/bridges/equations/be-29-jarzynski.d.ts +1 -1
  52. package/dist/bridges/equations/be-30-flm-first-law.d.ts +2 -2
  53. package/dist/bridges/equations/be-31-causal-set-bd.d.ts +1 -1
  54. package/dist/bridges/equations/be-32-quantum-reference-frame.d.ts +1 -1
  55. package/dist/bridges/equations/be-33-hertz-millis.d.ts +1 -1
  56. package/dist/bridges/equations/be-34-kibble-zurek.d.ts +1 -1
  57. package/dist/bridges/equations/be-35-conformal-bootstrap.d.ts +1 -1
  58. package/dist/bridges/equations/be-36-gw-speed-bound.d.ts +12 -5
  59. package/dist/bridges/equations/be-36-gw-speed-bound.d.ts.map +1 -1
  60. package/dist/bridges/equations/be-36-gw-speed-bound.js +11 -4
  61. package/dist/bridges/equations/be-36-gw-speed-bound.js.map +1 -1
  62. package/dist/bridges/equations/be-38-mond.d.ts +1 -1
  63. package/dist/bridges/equations/be-39-asymptotic-safety.d.ts +2 -2
  64. package/dist/bridges/equations/be-40-composite-higgs.d.ts +1 -1
  65. package/dist/bridges/equations/be-41-swampland.d.ts +1 -1
  66. package/dist/bridges/equations/be-43-er-epr.d.ts +1 -1
  67. package/dist/bridges/equations/be-44-soft-hair.d.ts +1 -1
  68. package/dist/bridges/equations/be-45-tcc.d.ts +1 -1
  69. package/dist/bridges/equations/be-46-multiverse-measure.d.ts +1 -1
  70. package/dist/bridges/equations/be-47-bbn-dark-sector.d.ts +1 -1
  71. package/dist/bridges/equations/be-48-grw-localization.d.ts +1 -1
  72. package/dist/bridges/equations/be-49-quantum-darwinism.d.ts +1 -1
  73. package/dist/bridges/equations/be-50-wheeler-feynman.d.ts +1 -1
  74. package/dist/bridges/index.d.ts +10 -7
  75. package/dist/bridges/index.d.ts.map +1 -1
  76. package/dist/bridges/index.js +47 -34
  77. package/dist/bridges/index.js.map +1 -1
  78. package/dist/bridges/membership.d.ts +44 -0
  79. package/dist/bridges/membership.d.ts.map +1 -0
  80. package/dist/bridges/membership.js +59 -0
  81. package/dist/bridges/membership.js.map +1 -0
  82. package/dist/bridges/rejected.d.ts +40 -0
  83. package/dist/bridges/rejected.d.ts.map +1 -0
  84. package/dist/bridges/rejected.js +81 -0
  85. package/dist/bridges/rejected.js.map +1 -0
  86. package/dist/composition/bridge-analysis.d.ts +189 -0
  87. package/dist/composition/bridge-analysis.d.ts.map +1 -0
  88. package/dist/composition/bridge-analysis.js +445 -0
  89. package/dist/composition/bridge-analysis.js.map +1 -0
  90. package/dist/composition/bridge-prediction.d.ts +95 -0
  91. package/dist/composition/bridge-prediction.d.ts.map +1 -0
  92. package/dist/composition/bridge-prediction.js +0 -0
  93. package/dist/composition/bridge-prediction.js.map +1 -0
  94. package/dist/composition/catalog-graph.d.ts +20 -0
  95. package/dist/composition/catalog-graph.d.ts.map +1 -0
  96. package/dist/composition/catalog-graph.js +39 -0
  97. package/dist/composition/catalog-graph.js.map +1 -0
  98. package/dist/composition/compose-surface.d.ts +12 -0
  99. package/dist/composition/compose-surface.d.ts.map +1 -0
  100. package/dist/composition/compose-surface.js +10 -0
  101. package/dist/composition/compose-surface.js.map +1 -0
  102. package/dist/composition/compose-symbolic.d.ts +75 -0
  103. package/dist/composition/compose-symbolic.d.ts.map +1 -0
  104. package/dist/composition/compose-symbolic.js +157 -0
  105. package/dist/composition/compose-symbolic.js.map +1 -0
  106. package/dist/composition/compose.d.ts +110 -0
  107. package/dist/composition/compose.d.ts.map +1 -0
  108. package/dist/composition/compose.js +231 -0
  109. package/dist/composition/compose.js.map +1 -0
  110. package/dist/composition/consistency.d.ts +24 -0
  111. package/dist/composition/consistency.d.ts.map +1 -0
  112. package/dist/composition/consistency.js +26 -0
  113. package/dist/composition/consistency.js.map +1 -0
  114. package/dist/composition/discovery.d.ts +104 -0
  115. package/dist/composition/discovery.d.ts.map +1 -0
  116. package/dist/composition/discovery.js +165 -0
  117. package/dist/composition/discovery.js.map +1 -0
  118. package/dist/composition/edge.d.ts +139 -0
  119. package/dist/composition/edge.d.ts.map +1 -0
  120. package/dist/composition/edge.js +72 -0
  121. package/dist/composition/edge.js.map +1 -0
  122. package/dist/composition/edges/calibration.d.ts +107 -0
  123. package/dist/composition/edges/calibration.d.ts.map +1 -0
  124. package/dist/composition/edges/calibration.js +373 -0
  125. package/dist/composition/edges/calibration.js.map +1 -0
  126. package/dist/composition/edges/catalog-full.d.ts +299 -0
  127. package/dist/composition/edges/catalog-full.d.ts.map +1 -0
  128. package/dist/composition/edges/catalog-full.js +989 -0
  129. package/dist/composition/edges/catalog-full.js.map +1 -0
  130. package/dist/composition/edges/catalog-tranche.d.ts +112 -0
  131. package/dist/composition/edges/catalog-tranche.d.ts.map +1 -0
  132. package/dist/composition/edges/catalog-tranche.js +241 -0
  133. package/dist/composition/edges/catalog-tranche.js.map +1 -0
  134. package/dist/composition/enumerate.d.ts +67 -0
  135. package/dist/composition/enumerate.d.ts.map +1 -0
  136. package/dist/composition/enumerate.js +78 -0
  137. package/dist/composition/enumerate.js.map +1 -0
  138. package/dist/composition/explain.d.ts +102 -0
  139. package/dist/composition/explain.d.ts.map +1 -0
  140. package/dist/composition/explain.js +244 -0
  141. package/dist/composition/explain.js.map +1 -0
  142. package/dist/composition/expr-eval.d.ts +33 -0
  143. package/dist/composition/expr-eval.d.ts.map +1 -0
  144. package/dist/composition/expr-eval.js +95 -0
  145. package/dist/composition/expr-eval.js.map +1 -0
  146. package/dist/composition/expr-simplify.d.ts +60 -0
  147. package/dist/composition/expr-simplify.d.ts.map +1 -0
  148. package/dist/composition/expr-simplify.js +330 -0
  149. package/dist/composition/expr-simplify.js.map +1 -0
  150. package/dist/composition/expr-subst.d.ts +29 -0
  151. package/dist/composition/expr-subst.d.ts.map +1 -0
  152. package/dist/composition/expr-subst.js +60 -0
  153. package/dist/composition/expr-subst.js.map +1 -0
  154. package/dist/composition/identifiability.d.ts +103 -0
  155. package/dist/composition/identifiability.d.ts.map +1 -0
  156. package/dist/composition/identifiability.js +148 -0
  157. package/dist/composition/identifiability.js.map +1 -0
  158. package/dist/composition/index.d.ts +37 -0
  159. package/dist/composition/index.d.ts.map +1 -0
  160. package/dist/composition/index.js +27 -0
  161. package/dist/composition/index.js.map +1 -0
  162. package/dist/composition/quantities.d.ts +297 -0
  163. package/dist/composition/quantities.d.ts.map +1 -0
  164. package/dist/composition/quantities.js +1017 -0
  165. package/dist/composition/quantities.js.map +1 -0
  166. package/dist/composition/quantity.d.ts +59 -0
  167. package/dist/composition/quantity.d.ts.map +1 -0
  168. package/dist/composition/quantity.js +36 -0
  169. package/dist/composition/quantity.js.map +1 -0
  170. package/dist/composition/retrodiction.d.ts +94 -0
  171. package/dist/composition/retrodiction.d.ts.map +1 -0
  172. package/dist/composition/retrodiction.js +171 -0
  173. package/dist/composition/retrodiction.js.map +1 -0
  174. package/dist/composition/symbolic-constants.d.ts +33 -0
  175. package/dist/composition/symbolic-constants.d.ts.map +1 -0
  176. package/dist/composition/symbolic-constants.js +50 -0
  177. package/dist/composition/symbolic-constants.js.map +1 -0
  178. package/dist/composition/uncertainty.d.ts +45 -0
  179. package/dist/composition/uncertainty.d.ts.map +1 -0
  180. package/dist/composition/uncertainty.js +59 -0
  181. package/dist/composition/uncertainty.js.map +1 -0
  182. package/dist/core/axes-registry.d.ts +1 -1
  183. package/dist/core/axes-registry.js +1 -1
  184. package/dist/core/cell.d.ts +0 -8
  185. package/dist/core/cell.d.ts.map +1 -1
  186. package/dist/core/cell.js +1 -1
  187. package/dist/core/cell.js.map +1 -1
  188. package/dist/core/constants.d.ts +15 -1
  189. package/dist/core/constants.d.ts.map +1 -1
  190. package/dist/core/constants.js +15 -1
  191. package/dist/core/constants.js.map +1 -1
  192. package/dist/core/flux-rules.d.ts +10 -13
  193. package/dist/core/flux-rules.d.ts.map +1 -1
  194. package/dist/core/flux-rules.js +19 -10
  195. package/dist/core/flux-rules.js.map +1 -1
  196. package/dist/core/labeled-tensor.d.ts +80 -1
  197. package/dist/core/labeled-tensor.d.ts.map +1 -1
  198. package/dist/core/labeled-tensor.js +263 -17
  199. package/dist/core/labeled-tensor.js.map +1 -1
  200. package/dist/core/universal-index.d.ts +1 -1
  201. package/dist/core/universal-index.js +1 -1
  202. package/dist/dimensional/buckingham.d.ts +103 -0
  203. package/dist/dimensional/buckingham.d.ts.map +1 -0
  204. package/dist/dimensional/buckingham.js +284 -0
  205. package/dist/dimensional/buckingham.js.map +1 -0
  206. package/dist/dimensional/dimension-spec.d.ts +24 -0
  207. package/dist/dimensional/dimension-spec.d.ts.map +1 -0
  208. package/dist/dimensional/dimension-spec.js +110 -0
  209. package/dist/dimensional/dimension-spec.js.map +1 -0
  210. package/dist/dimensional/field-equation-helpers.d.ts +1 -1
  211. package/dist/dimensional/field-equation-helpers.js +1 -1
  212. package/dist/dimensional/friedmann-equation.d.ts +1 -1
  213. package/dist/dimensional/friedmann-equation.js +1 -1
  214. package/dist/dimensional/gauge-field.d.ts +1 -1
  215. package/dist/dimensional/gauge-field.js +1 -1
  216. package/dist/dimensional/klein-gordon-equation.d.ts +8 -5
  217. package/dist/dimensional/klein-gordon-equation.d.ts.map +1 -1
  218. package/dist/dimensional/klein-gordon-equation.js +8 -5
  219. package/dist/dimensional/klein-gordon-equation.js.map +1 -1
  220. package/dist/dimensional/tensor-trace.d.ts +1 -1
  221. package/dist/dimensional/tensor-trace.js +1 -1
  222. package/dist/dimensional/validator.d.ts +13 -3
  223. package/dist/dimensional/validator.d.ts.map +1 -1
  224. package/dist/dimensional/validator.js +129 -42
  225. package/dist/dimensional/validator.js.map +1 -1
  226. package/dist/index.d.ts +32 -2
  227. package/dist/index.d.ts.map +1 -1
  228. package/dist/index.js +63 -2
  229. package/dist/index.js.map +1 -1
  230. package/dist/numerical/be37-covariant-eikonal.d.ts.map +1 -1
  231. package/dist/numerical/be37-covariant-eikonal.js +15 -18
  232. package/dist/numerical/be37-covariant-eikonal.js.map +1 -1
  233. package/dist/numerical/curvature-lowering-helpers.d.ts +7 -13
  234. package/dist/numerical/curvature-lowering-helpers.d.ts.map +1 -1
  235. package/dist/numerical/curvature-lowering-helpers.js +1 -1
  236. package/dist/numerical/curvature-lowering-helpers.js.map +1 -1
  237. package/dist/numerical/derivative-lowering.d.ts +2 -1
  238. package/dist/numerical/derivative-lowering.d.ts.map +1 -1
  239. package/dist/numerical/formula-dimension.d.ts +40 -0
  240. package/dist/numerical/formula-dimension.d.ts.map +1 -0
  241. package/dist/numerical/formula-dimension.js +199 -0
  242. package/dist/numerical/formula-dimension.js.map +1 -0
  243. package/dist/numerical/formula-mathts.d.ts +27 -0
  244. package/dist/numerical/formula-mathts.d.ts.map +1 -0
  245. package/dist/numerical/formula-mathts.js +98 -0
  246. package/dist/numerical/formula-mathts.js.map +1 -0
  247. package/dist/numerical/formula-registry.d.ts +30 -0
  248. package/dist/numerical/formula-registry.d.ts.map +1 -0
  249. package/dist/numerical/formula-registry.js +88 -0
  250. package/dist/numerical/formula-registry.js.map +1 -0
  251. package/dist/numerical/formula.d.ts +75 -0
  252. package/dist/numerical/formula.d.ts.map +1 -0
  253. package/dist/numerical/formula.js +275 -0
  254. package/dist/numerical/formula.js.map +1 -0
  255. package/dist/numerical/geometrized.d.ts +51 -0
  256. package/dist/numerical/geometrized.d.ts.map +1 -0
  257. package/dist/numerical/geometrized.js +66 -0
  258. package/dist/numerical/geometrized.js.map +1 -0
  259. package/dist/numerical/gl4-integrator.d.ts +8 -6
  260. package/dist/numerical/gl4-integrator.d.ts.map +1 -1
  261. package/dist/numerical/gl4-integrator.js +6 -6
  262. package/dist/numerical/gl4-integrator.js.map +1 -1
  263. package/dist/numerical/klein-gordon.d.ts +145 -0
  264. package/dist/numerical/klein-gordon.d.ts.map +1 -0
  265. package/dist/numerical/klein-gordon.js +145 -0
  266. package/dist/numerical/klein-gordon.js.map +1 -0
  267. package/dist/numerical/kretschmann.d.ts +43 -12
  268. package/dist/numerical/kretschmann.d.ts.map +1 -1
  269. package/dist/numerical/kretschmann.js +116 -29
  270. package/dist/numerical/kretschmann.js.map +1 -1
  271. package/dist/numerical/lowering.d.ts +18 -0
  272. package/dist/numerical/lowering.d.ts.map +1 -1
  273. package/dist/numerical/lowering.js +54 -42
  274. package/dist/numerical/lowering.js.map +1 -1
  275. package/dist/numerical/null-ic.d.ts +1 -1
  276. package/dist/numerical/null-ic.d.ts.map +1 -1
  277. package/dist/numerical/null-ic.js +3 -2
  278. package/dist/numerical/null-ic.js.map +1 -1
  279. package/dist/numerical/painleve-gullstrand-metric.d.ts +18 -6
  280. package/dist/numerical/painleve-gullstrand-metric.d.ts.map +1 -1
  281. package/dist/numerical/painleve-gullstrand-metric.js +31 -16
  282. package/dist/numerical/painleve-gullstrand-metric.js.map +1 -1
  283. package/dist/numerical/perihelion-finder.d.ts +4 -3
  284. package/dist/numerical/perihelion-finder.d.ts.map +1 -1
  285. package/dist/numerical/perihelion-finder.js +5 -4
  286. package/dist/numerical/perihelion-finder.js.map +1 -1
  287. package/dist/numerical/types.d.ts +6 -3
  288. package/dist/numerical/types.d.ts.map +1 -1
  289. package/dist/numerical/weyl-lowering.d.ts +4 -4
  290. package/dist/numerical/weyl-lowering.d.ts.map +1 -1
  291. package/dist/numerical/weyl-lowering.js +14 -1
  292. package/dist/numerical/weyl-lowering.js.map +1 -1
  293. package/package.json +19 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula-registry.d.ts","sourceRoot":"","sources":["../../src/numerical/formula-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGtE,KAAK,iBAAiB,GAAG,QAAQ,GAAG,SAAS,CAAC;AA8C9C,4DAA4D;AAC5D,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC,CAG/D;AAED,kFAAkF;AAClF,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAGvE;AAMD;;;;;GAKG;AACH,wBAAsB,0BAA0B,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAYnF"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Formula-parser registry (Path A selector — mirrors `engine-registry.ts`).
3
+ *
4
+ * `getFormulaParser()` returns the MathTS-backed parser when the optional
5
+ * peer is installed AND actually assembles and evaluates (smoke-tested),
6
+ * otherwise the self-contained Path B parser. The choice is detected once
7
+ * and cached. A broken or absent MathTS never breaks the caller — it falls
8
+ * back silently to Path B.
9
+ *
10
+ * The CLI and any inference code depend only on the {@link FormulaParser}
11
+ * interface, so swapping Path B ↔ Path A is transparent.
12
+ *
13
+ * @module numerical/formula-registry
14
+ */
15
+ import { defaultFormulaParser } from './formula.js';
16
+ import { loadMathtsFormulaParser } from './formula-mathts.js';
17
+ import { loadFormulaDimensionChecker, builtinFormulaDimensionChecker } from './formula-dimension.js';
18
+ let cached;
19
+ /** A formula MathTS must reproduce to be accepted (the §1-gate smoke test). */
20
+ const SMOKE_EXPR = 'a*b^2 + 1';
21
+ const SMOKE_SCOPE = { a: 3, b: 4 };
22
+ const SMOKE_EXPECTED = 49; // 3*16 + 1
23
+ /** Run `fn` with MathTS's import-time WASM-fallback chatter suppressed. */
24
+ async function quietly(fn) {
25
+ const origWarn = console.warn;
26
+ const origError = console.error;
27
+ const origWrite = process.stderr.write.bind(process.stderr);
28
+ console.warn = () => { };
29
+ console.error = () => { };
30
+ // mathts prints some notices via process.stderr.write directly.
31
+ process.stderr.write = () => true;
32
+ try {
33
+ return await fn();
34
+ }
35
+ finally {
36
+ console.warn = origWarn;
37
+ console.error = origError;
38
+ process.stderr.write = origWrite;
39
+ }
40
+ }
41
+ async function detect() {
42
+ try {
43
+ const parser = await quietly(loadMathtsFormulaParser);
44
+ // Smoke test: it must actually assemble AND evaluate correctly.
45
+ const v = parser.parse(SMOKE_EXPR).evaluate(SMOKE_SCOPE);
46
+ if (Math.abs(v - SMOKE_EXPECTED) < 1e-9) {
47
+ return { parser, kind: 'mathts' };
48
+ }
49
+ }
50
+ catch {
51
+ /* peer absent or failed to assemble — fall through */
52
+ }
53
+ return { parser: defaultFormulaParser, kind: 'builtin' };
54
+ }
55
+ /** Resolve the active formula parser (cached). @internal */
56
+ export async function getFormulaParser() {
57
+ cached ??= detect();
58
+ return (await cached).parser;
59
+ }
60
+ /** Which parser is active — `mathts` (Path A) or `builtin` (Path B). @internal */
61
+ export async function getFormulaParserKind() {
62
+ cached ??= detect();
63
+ return (await cached).kind;
64
+ }
65
+ let cachedChecker;
66
+ const LENGTH_DIM = { L: 1, M: 0, T: 0, I: 0, Theta: 0, N: 0, J: 0 };
67
+ /**
68
+ * The dimensional checker for user formulas (MathTS Phase 2). Always
69
+ * available: it uses the MathTS AST when the peer is installed and
70
+ * smoke-tests clean, else the self-contained Path B AST — both transpile to
71
+ * the same `ExprNode`, so the dimensional verdict is identical. @internal
72
+ */
73
+ export async function getFormulaDimensionChecker() {
74
+ cachedChecker ??= (async () => {
75
+ try {
76
+ const checker = await quietly(loadFormulaDimensionChecker);
77
+ // smoke test: a dimensionless ratio is homogeneous and dimensionless.
78
+ if (checker.check('a/a', { a: LENGTH_DIM }).ok)
79
+ return checker;
80
+ }
81
+ catch {
82
+ /* peer absent or failed — fall back to the built-in checker */
83
+ }
84
+ return builtinFormulaDimensionChecker();
85
+ })();
86
+ return cachedChecker;
87
+ }
88
+ //# sourceMappingURL=formula-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula-registry.js","sourceRoot":"","sources":["../../src/numerical/formula-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAE,2BAA2B,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AASrG,IAAI,MAAqC,CAAC;AAE1C,+EAA+E;AAC/E,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,WAAW,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AACnC,MAAM,cAAc,GAAG,EAAE,CAAC,CAAC,WAAW;AAEtC,2EAA2E;AAC3E,KAAK,UAAU,OAAO,CAAI,EAAoB;IAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAC9B,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;IAChC,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC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AM,CAAC,CAAC,IAAI,CAAC;AAC7B,CAAC;AAED,IAAI,aAA2D,CAAC;AAEhE,MAAM,UAAU,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B;IAC9C,aAAa,KAAK,CAAC,KAAK,IAAI,EAAE;QAC5B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,2BAA2B,CAAC,CAAC;YAC3D,sEAAsE;YACtE,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE;gBAAE,OAAO,OAAO,CAAC;QACjE,CAAC;QAAC,MAAM,CAAC;YACP,+DAA+D;QACjE,CAAC;QACD,OAAO,8BAA8B,EAAE,CAAC;IAC1C,CAAC,CAAC,EAAE,CAAC;IACL,OAAO,aAAa,CAAC;AACvB,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Self-contained scalar-formula parser/evaluator (Path B).
3
+ *
4
+ * A small, dependency-free recursive-descent parser for closed-form
5
+ * scalar physics expressions — `hbar*c^3/(8*pi*G*M*k_B)` and the like —
6
+ * so non-TypeScript users can supply their OWN equation to the CLI
7
+ * without UPT shipping a code evaluator. It is SAFE: there is no `eval`,
8
+ * no function constructor, no property access — only arithmetic over
9
+ * numbers, a fixed whitelist of math functions, and the variables the
10
+ * caller explicitly supplies. An unknown symbol is an error, never an
11
+ * implicit global.
12
+ *
13
+ * It sits behind the {@link FormulaParser} interface so a MathTS-backed
14
+ * parser (Path A) can be dropped in later by implementing the same
15
+ * contract — the inference/CLI code depends only on the interface.
16
+ *
17
+ * Grammar (standard precedence; `^` is right-associative; unary minus
18
+ * binds looser than `^`, so `-2^2 = -4` and `2^-2` parses):
19
+ * expr → term (('+'|'-') term)*
20
+ * term → unary (('*'|'/') unary)*
21
+ * unary → ('+'|'-') unary | power
22
+ * power → atom ('^' unary)?
23
+ * atom → NUMBER | NAME | NAME '(' args ')' | '(' expr ')'
24
+ *
25
+ * @module numerical/formula
26
+ */
27
+ /** A parse or evaluation failure (bad syntax, unknown symbol, arity). */
28
+ export declare class FormulaError extends Error {
29
+ constructor(message: string);
30
+ }
31
+ /** A parsed formula: its free variables and a safe evaluator. @internal */
32
+ export interface CompiledFormula {
33
+ /** The original source string. */
34
+ readonly source: string;
35
+ /** Free variable names (excludes built-in constants and functions). */
36
+ readonly variables: readonly string[];
37
+ /** Evaluate against a `name → value` scope. Throws on a missing var. */
38
+ evaluate(scope: Record<string, number>): number;
39
+ }
40
+ /** The swap point for Path A (a MathTS-backed parser implements this). */
41
+ export interface FormulaParser {
42
+ parse(expr: string): CompiledFormula;
43
+ }
44
+ type Node = {
45
+ kind: 'num';
46
+ value: number;
47
+ } | {
48
+ kind: 'sym';
49
+ name: string;
50
+ } | {
51
+ kind: 'unary';
52
+ op: '+' | '-';
53
+ arg: Node;
54
+ } | {
55
+ kind: 'bin';
56
+ op: '+' | '-' | '*' | '/' | '^';
57
+ left: Node;
58
+ right: Node;
59
+ } | {
60
+ kind: 'call';
61
+ fn: string;
62
+ args: Node[];
63
+ };
64
+ /** The self-contained Path B parser. @internal */
65
+ export declare const defaultFormulaParser: FormulaParser;
66
+ /** Parse a scalar formula with the default (self-contained) parser. @internal */
67
+ export declare function parseFormula(expr: string): CompiledFormula;
68
+ /** The Path B formula AST node. @internal */
69
+ export type FormulaAstNode = Node;
70
+ /** Parse a formula to its Path B AST. @internal */
71
+ export declare const parseFormulaToAst: (expr: string) => FormulaAstNode;
72
+ /** Evaluate a Path B AST node against a scope. @internal */
73
+ export declare const evalFormulaAst: (node: FormulaAstNode, scope: Record<string, number>) => number;
74
+ export {};
75
+ //# source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C,CAAC;AAEF,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAE1D;AAQD,6CAA6C;AAC7C,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC;AAClC,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,cAA2B,CAAC;AAC9E,4DAA4D;AAC5D,eAAO,MAAM,cAAc,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAiB,CAAC"}
@@ -0,0 +1,275 @@
1
+ /**
2
+ * Self-contained scalar-formula parser/evaluator (Path B).
3
+ *
4
+ * A small, dependency-free recursive-descent parser for closed-form
5
+ * scalar physics expressions — `hbar*c^3/(8*pi*G*M*k_B)` and the like —
6
+ * so non-TypeScript users can supply their OWN equation to the CLI
7
+ * without UPT shipping a code evaluator. It is SAFE: there is no `eval`,
8
+ * no function constructor, no property access — only arithmetic over
9
+ * numbers, a fixed whitelist of math functions, and the variables the
10
+ * caller explicitly supplies. An unknown symbol is an error, never an
11
+ * implicit global.
12
+ *
13
+ * It sits behind the {@link FormulaParser} interface so a MathTS-backed
14
+ * parser (Path A) can be dropped in later by implementing the same
15
+ * contract — the inference/CLI code depends only on the interface.
16
+ *
17
+ * Grammar (standard precedence; `^` is right-associative; unary minus
18
+ * binds looser than `^`, so `-2^2 = -4` and `2^-2` parses):
19
+ * expr → term (('+'|'-') term)*
20
+ * term → unary (('*'|'/') unary)*
21
+ * unary → ('+'|'-') unary | power
22
+ * power → atom ('^' unary)?
23
+ * atom → NUMBER | NAME | NAME '(' args ')' | '(' expr ')'
24
+ *
25
+ * @module numerical/formula
26
+ */
27
+ /** A parse or evaluation failure (bad syntax, unknown symbol, arity). */
28
+ export class FormulaError extends Error {
29
+ constructor(message) {
30
+ super(message);
31
+ this.name = 'FormulaError';
32
+ }
33
+ }
34
+ // --- built-ins ------------------------------------------------------------
35
+ const CONSTANTS = {
36
+ pi: Math.PI,
37
+ tau: 2 * Math.PI,
38
+ };
39
+ const arity1 = (f) => (a) => {
40
+ if (a.length !== 1)
41
+ throw new FormulaError('expected 1 argument');
42
+ return f(a[0]);
43
+ };
44
+ const FUNCTIONS = {
45
+ sqrt: arity1(Math.sqrt),
46
+ cbrt: arity1(Math.cbrt),
47
+ exp: arity1(Math.exp),
48
+ ln: arity1(Math.log),
49
+ log: arity1(Math.log), // natural log (physics convention)
50
+ log10: arity1(Math.log10),
51
+ log2: arity1(Math.log2),
52
+ abs: arity1(Math.abs),
53
+ sin: arity1(Math.sin),
54
+ cos: arity1(Math.cos),
55
+ tan: arity1(Math.tan),
56
+ asin: arity1(Math.asin),
57
+ acos: arity1(Math.acos),
58
+ atan: arity1(Math.atan),
59
+ sinh: arity1(Math.sinh),
60
+ cosh: arity1(Math.cosh),
61
+ tanh: arity1(Math.tanh),
62
+ pow: (a) => {
63
+ if (a.length !== 2)
64
+ throw new FormulaError('pow expects 2 arguments');
65
+ return Math.pow(a[0], a[1]);
66
+ },
67
+ atan2: (a) => {
68
+ if (a.length !== 2)
69
+ throw new FormulaError('atan2 expects 2 arguments');
70
+ return Math.atan2(a[0], a[1]);
71
+ },
72
+ };
73
+ const NUM_RE = /^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/;
74
+ const NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*/;
75
+ function tokenize(src) {
76
+ const toks = [];
77
+ let s = src;
78
+ while (s.length) {
79
+ const ch = s[0];
80
+ if (ch === ' ' || ch === '\t' || ch === '\n') {
81
+ s = s.slice(1);
82
+ continue;
83
+ }
84
+ if ('+-*/^(),'.includes(ch)) {
85
+ toks.push({ t: 'op', v: ch });
86
+ s = s.slice(1);
87
+ continue;
88
+ }
89
+ const num = NUM_RE.exec(s);
90
+ if (num) {
91
+ toks.push({ t: 'num', v: Number(num[0]) });
92
+ s = s.slice(num[0].length);
93
+ continue;
94
+ }
95
+ const name = NAME_RE.exec(s);
96
+ if (name) {
97
+ toks.push({ t: 'name', v: name[0] });
98
+ s = s.slice(name[0].length);
99
+ continue;
100
+ }
101
+ throw new FormulaError(`unexpected character '${ch}' in formula`);
102
+ }
103
+ return toks;
104
+ }
105
+ // --- parser (recursive descent) ------------------------------------------
106
+ function parseToAst(src) {
107
+ const toks = tokenize(src);
108
+ let i = 0;
109
+ const peek = () => toks[i];
110
+ const eat = (v) => {
111
+ const tk = toks[i];
112
+ if (!tk)
113
+ throw new FormulaError('unexpected end of formula');
114
+ if (v !== undefined && !(tk.t === 'op' && tk.v === v)) {
115
+ throw new FormulaError(`expected '${v}'`);
116
+ }
117
+ i++;
118
+ return tk;
119
+ };
120
+ const isOp = (v) => {
121
+ const tk = peek();
122
+ return !!tk && tk.t === 'op' && tk.v === v;
123
+ };
124
+ function expr() {
125
+ let node = term();
126
+ while (isOp('+') || isOp('-')) {
127
+ const op = eat().v;
128
+ node = { kind: 'bin', op, left: node, right: term() };
129
+ }
130
+ return node;
131
+ }
132
+ function term() {
133
+ let node = unary();
134
+ while (isOp('*') || isOp('/')) {
135
+ const op = eat().v;
136
+ node = { kind: 'bin', op, left: node, right: unary() };
137
+ }
138
+ return node;
139
+ }
140
+ function unary() {
141
+ if (isOp('+') || isOp('-')) {
142
+ const op = eat().v;
143
+ return { kind: 'unary', op, arg: unary() };
144
+ }
145
+ return power();
146
+ }
147
+ function power() {
148
+ const base = atom();
149
+ if (isOp('^')) {
150
+ eat('^');
151
+ return { kind: 'bin', op: '^', left: base, right: unary() };
152
+ }
153
+ return base;
154
+ }
155
+ function atom() {
156
+ const tk = peek();
157
+ if (!tk)
158
+ throw new FormulaError('unexpected end of formula');
159
+ if (tk.t === 'num') {
160
+ eat();
161
+ return { kind: 'num', value: tk.v };
162
+ }
163
+ if (tk.t === 'name') {
164
+ eat();
165
+ if (isOp('(')) {
166
+ eat('(');
167
+ const args = [];
168
+ if (!isOp(')')) {
169
+ args.push(expr());
170
+ while (isOp(',')) {
171
+ eat(',');
172
+ args.push(expr());
173
+ }
174
+ }
175
+ eat(')');
176
+ return { kind: 'call', fn: tk.v, args };
177
+ }
178
+ return { kind: 'sym', name: tk.v };
179
+ }
180
+ if (tk.t === 'op' && tk.v === '(') {
181
+ eat('(');
182
+ const node = expr();
183
+ eat(')');
184
+ return node;
185
+ }
186
+ throw new FormulaError(`unexpected token '${tk.v}'`);
187
+ }
188
+ const node = expr();
189
+ if (i !== toks.length) {
190
+ throw new FormulaError(`unexpected trailing input in formula`);
191
+ }
192
+ return node;
193
+ }
194
+ function collectSymbols(node, out) {
195
+ switch (node.kind) {
196
+ case 'num':
197
+ return;
198
+ case 'sym':
199
+ if (!(node.name in CONSTANTS))
200
+ out.add(node.name);
201
+ return;
202
+ case 'unary':
203
+ collectSymbols(node.arg, out);
204
+ return;
205
+ case 'bin':
206
+ collectSymbols(node.left, out);
207
+ collectSymbols(node.right, out);
208
+ return;
209
+ case 'call':
210
+ for (const a of node.args)
211
+ collectSymbols(a, out);
212
+ return;
213
+ }
214
+ }
215
+ function evalNode(node, scope) {
216
+ switch (node.kind) {
217
+ case 'num':
218
+ return node.value;
219
+ case 'sym': {
220
+ if (node.name in CONSTANTS)
221
+ return CONSTANTS[node.name];
222
+ const v = scope[node.name];
223
+ if (v === undefined)
224
+ throw new FormulaError(`unknown variable '${node.name}'`);
225
+ return v;
226
+ }
227
+ case 'unary': {
228
+ const a = evalNode(node.arg, scope);
229
+ return node.op === '-' ? -a : a;
230
+ }
231
+ case 'bin': {
232
+ const l = evalNode(node.left, scope);
233
+ const r = evalNode(node.right, scope);
234
+ switch (node.op) {
235
+ case '+': return l + r;
236
+ case '-': return l - r;
237
+ case '*': return l * r;
238
+ case '/': return l / r;
239
+ case '^': return Math.pow(l, r);
240
+ }
241
+ }
242
+ // eslint-disable-next-line no-fallthrough
243
+ case 'call': {
244
+ const fn = FUNCTIONS[node.fn];
245
+ if (!fn)
246
+ throw new FormulaError(`unknown function '${node.fn}'`);
247
+ return fn(node.args.map((a) => evalNode(a, scope)));
248
+ }
249
+ }
250
+ }
251
+ /** The self-contained Path B parser. @internal */
252
+ export const defaultFormulaParser = {
253
+ parse(expr) {
254
+ if (!expr || !expr.trim())
255
+ throw new FormulaError('empty formula');
256
+ const ast = parseToAst(expr);
257
+ const syms = new Set();
258
+ collectSymbols(ast, syms);
259
+ const variables = [...syms].sort();
260
+ return {
261
+ source: expr,
262
+ variables,
263
+ evaluate: (scope) => evalNode(ast, scope),
264
+ };
265
+ },
266
+ };
267
+ /** Parse a scalar formula with the default (self-contained) parser. @internal */
268
+ export function parseFormula(expr) {
269
+ return defaultFormulaParser.parse(expr);
270
+ }
271
+ /** Parse a formula to its Path B AST. @internal */
272
+ export const parseFormulaToAst = parseToAst;
273
+ /** Evaluate a Path B AST node against a scope. @internal */
274
+ export const evalFormulaAst = evalNode;
275
+ //# sourceMappingURL=formula.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula.js","sourceRoot":"","sources":["../../src/numerical/formula.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,yEAAyE;AACzE,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAiBD,6EAA6E;AAE7E,MAAM,SAAS,GAAqC;IAClD,EAAE,EAAE,IAAI,CAAC,EAAE;IACX,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;CACjB,CAAC;AAGF,MAAM,MAAM,GAAG,CAAC,CAAwB,EAAM,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;IACrD,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,YAAY,CAAC,qBAAqB,CAAC,CAAC;IAClE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACjB,C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,QAAQ,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Geometrized-units boundary adapters (G-9 increment 1).
3
+ *
4
+ * Converts a scalar between SI and geometrized (G = c = 1) units, driven
5
+ * MECHANICALLY by the `Dimension` exponent vector — the dimension functor
6
+ * earning its keep. For an SI quantity of dimension L^l M^m T^t the single
7
+ * conversion factor is `G^m · c^(t − 2m)` (each kg → G/c² metres, each second
8
+ * → c metres); the geometrized quantity is a pure length L^(l+m+t).
9
+ *
10
+ * This is the self-contained FOUNDATION of the units-normalization layer
11
+ * (design: docs/planning/v0.10.0-Units-Normalization-Design-Note.md, Adam-
12
+ * vetted r2; plan: docs/planning/v0.13-G9-Adapters-Plan.md, Eve-vetted). Only c
13
+ * and G are in scope: a nonzero electromagnetic / thermal / molar / luminous
14
+ * exponent (I/Θ/N/J) throws.
15
+ *
16
+ * PUBLIC boundary API (G-9 increment 2): a consumer running the GR pipeline in
17
+ * geometrized (G = c = 1) units converts scalars at the boundary with these
18
+ * adapters. The consumer-wide DEFAULT-pipeline migration (increment 3) was
19
+ * DECLINED after adversarial review — it is measured to give no precision win
20
+ * (and far worse far-field; see docs/planning/v0.14-G9-Increment3-Disposition.md).
21
+ * The SI pipeline stays the default; this geometrized layer is the optional
22
+ * boundary API.
23
+ *
24
+ * @module numerical/geometrized
25
+ */
26
+ import type { Dimension } from '../dimensional/types.js';
27
+ import { UPTError } from '../dimensional/errors.js';
28
+ /**
29
+ * A dimension carries a non-c/G base (I/Θ/N/J ≠ 0) and cannot be geometrized
30
+ * by c and G alone (k_B / ε₀ extensions are out of scope for this increment).
31
+ *
32
+ * @public
33
+ */
34
+ export declare class NonGeometrizableDimensionError extends UPTError {
35
+ constructor(message: string);
36
+ }
37
+ /**
38
+ * The single SI→geometrized conversion factor for `dim`: `G^M · c^(T − 2M)`
39
+ * (only the mass and time exponents enter). Shared by `toGeometrized` /
40
+ * `fromGeometrized` so the round-trip is a clean inverse. A nonzero I/Θ/N/J
41
+ * exponent throws `NonGeometrizableDimensionError` BEFORE any factor is
42
+ * computed.
43
+ *
44
+ * @public
45
+ */
46
+ export declare function geometrizedFactor(dim: Dimension): number;
47
+ /** SI → geometrized (G = c = 1). @public */
48
+ export declare function toGeometrized(valueSI: number, dim: Dimension): number;
49
+ /** Geometrized (G = c = 1) → SI. @public */
50
+ export declare function fromGeometrized(valueGeom: number, dim: Dimension): number;
51
+ //# sourceMappingURL=geometrized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometrized.d.ts","sourceRoot":"","sources":["../../src/numerical/geometrized.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD;;;;;GAKG;AACH,qBAAa,8BAA+B,SAAQ,QAAQ;gBAC9C,OAAO,EAAE,MAAM;CAK5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CASxD;AAED,4CAA4C;AAC5C,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,MAAM,CAErE;AAED,4CAA4C;AAC5C,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,MAAM,CAEzE"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Geometrized-units boundary adapters (G-9 increment 1).
3
+ *
4
+ * Converts a scalar between SI and geometrized (G = c = 1) units, driven
5
+ * MECHANICALLY by the `Dimension` exponent vector — the dimension functor
6
+ * earning its keep. For an SI quantity of dimension L^l M^m T^t the single
7
+ * conversion factor is `G^m · c^(t − 2m)` (each kg → G/c² metres, each second
8
+ * → c metres); the geometrized quantity is a pure length L^(l+m+t).
9
+ *
10
+ * This is the self-contained FOUNDATION of the units-normalization layer
11
+ * (design: docs/planning/v0.10.0-Units-Normalization-Design-Note.md, Adam-
12
+ * vetted r2; plan: docs/planning/v0.13-G9-Adapters-Plan.md, Eve-vetted). Only c
13
+ * and G are in scope: a nonzero electromagnetic / thermal / molar / luminous
14
+ * exponent (I/Θ/N/J) throws.
15
+ *
16
+ * PUBLIC boundary API (G-9 increment 2): a consumer running the GR pipeline in
17
+ * geometrized (G = c = 1) units converts scalars at the boundary with these
18
+ * adapters. The consumer-wide DEFAULT-pipeline migration (increment 3) was
19
+ * DECLINED after adversarial review — it is measured to give no precision win
20
+ * (and far worse far-field; see docs/planning/v0.14-G9-Increment3-Disposition.md).
21
+ * The SI pipeline stays the default; this geometrized layer is the optional
22
+ * boundary API.
23
+ *
24
+ * @module numerical/geometrized
25
+ */
26
+ import { UPTError } from '../dimensional/errors.js';
27
+ import { C_SI, G_SI } from '../core/constants.js';
28
+ /**
29
+ * A dimension carries a non-c/G base (I/Θ/N/J ≠ 0) and cannot be geometrized
30
+ * by c and G alone (k_B / ε₀ extensions are out of scope for this increment).
31
+ *
32
+ * @public
33
+ */
34
+ export class NonGeometrizableDimensionError extends UPTError {
35
+ constructor(message) {
36
+ super(message);
37
+ this.name = 'NonGeometrizableDimensionError';
38
+ Object.setPrototypeOf(this, NonGeometrizableDimensionError.prototype);
39
+ }
40
+ }
41
+ /**
42
+ * The single SI→geometrized conversion factor for `dim`: `G^M · c^(T − 2M)`
43
+ * (only the mass and time exponents enter). Shared by `toGeometrized` /
44
+ * `fromGeometrized` so the round-trip is a clean inverse. A nonzero I/Θ/N/J
45
+ * exponent throws `NonGeometrizableDimensionError` BEFORE any factor is
46
+ * computed.
47
+ *
48
+ * @public
49
+ */
50
+ export function geometrizedFactor(dim) {
51
+ if (dim.I !== 0 || dim.Theta !== 0 || dim.N !== 0 || dim.J !== 0) {
52
+ throw new NonGeometrizableDimensionError(`geometrizedFactor: only c and G are in scope; this dimension has a ` +
53
+ `nonzero non-mechanizable exponent (I=${dim.I}, Θ=${dim.Theta}, ` +
54
+ `N=${dim.N}, J=${dim.J}). Geometrization handles length / mass / time.`);
55
+ }
56
+ return Math.pow(G_SI, dim.M) * Math.pow(C_SI, dim.T - 2 * dim.M);
57
+ }
58
+ /** SI → geometrized (G = c = 1). @public */
59
+ export function toGeometrized(valueSI, dim) {
60
+ return valueSI * geometrizedFactor(dim);
61
+ }
62
+ /** Geometrized (G = c = 1) → SI. @public */
63
+ export function fromGeometrized(valueGeom, dim) {
64
+ return valueGeom / geometrizedFactor(dim);
65
+ }
66
+ //# sourceMappingURL=geometrized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometrized.js","sourceRoot":"","sources":["../../src/numerical/geometrized.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,OAAO,8BAA+B,SAAQ,QAAQ;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;QAC7C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,8BAA8B,CAAC,SAAS,CAAC,CAAC;IACxE,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAc;IAC9C,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,8BAA8B,CACtC,qEAAqE;YACnE,wCAAwC,GAAG,CAAC,CAAC,OAAO,GAAG,CAAC,KAAK,IAAI;YACjE,KAAK,GAAG,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,iDAAiD,CAC1E,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,GAAc;IAC3D,OAAO,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,GAAc;IAC/D,OAAO,SAAS,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC"}
@@ -71,14 +71,16 @@ export interface GL4Options {
71
71
  readonly steps: number;
72
72
  /** Final proper time τ_max (initial τ = 0). */
73
73
  readonly tauMax: number;
74
- /** Inverse-metric closure: `gInverseFn(x)[μ][ν] = g^{μν}(x)`. */
75
- readonly gInverseFn: (x: readonly number[]) => readonly (readonly number[])[];
74
+ /** Inverse-metric closure (v0.9.0 O-1 flat layout):
75
+ * `gInverseFn(x)[μ*dim + ν] = g^{μν}(x)`, row-major Float64Array(dim²). */
76
+ readonly gInverseFn: (x: readonly number[]) => Float64Array;
76
77
  /**
77
78
  * Partial derivatives of the inverse metric.
78
- * Index order: `dgInverseFn(x)[lambda][mu][nu] = ∂_lambda g^{mu nu}` at coords x.
79
+ * Index order (v0.9.0 O-1 flat layout):
80
+ * `dgInverseFn(x)[lambda*dim² + mu*dim + nu] = ∂_lambda g^{mu nu}` at coords x.
79
81
  * (I2: axis semantics pinned here to prevent silent transposition bugs.)
80
82
  */
81
- readonly dgInverseFn: (x: readonly number[]) => readonly (readonly (readonly number[])[])[];
83
+ readonly dgInverseFn: (x: readonly number[]) => Float64Array;
82
84
  /** Picard fixed-point tolerance (default chosen in Task 2). */
83
85
  readonly picardTol?: number;
84
86
  /** Picard fixed-point iteration cap (default chosen in Task 2). */
@@ -141,7 +143,7 @@ interface StageSolveResult {
141
143
  * The `dgInverseFn` index order is `dg[λ][μ][ν] = ∂_λ g^{μν}` (Task 0 I2
142
144
  * pin, also recorded on `GL4Options.dgInverseFn`). When we evaluate
143
145
  * `dp_μ = −½ (∂_μ g^{νρ}) P_ν P_ρ` we therefore read
144
- * `dgInvAtXj[mu][nu][rho]` — `mu` is the differentiation axis (λ in the
146
+ * `dgInvAtXj[mu*dim²+nu*dim+rho]` — `mu` is the differentiation axis (λ in the
145
147
  * pinned order) and `(nu, rho)` are the upper metric indices.
146
148
  *
147
149
  * Throws `GL4ConvergenceError` with message matching
@@ -149,7 +151,7 @@ interface StageSolveResult {
149
151
  *
150
152
  * @internal
151
153
  */
152
- export declare function solveGL4Stage(state: GL4State, h: number, gInverseFn: (x: readonly number[]) => readonly (readonly number[])[], dgInverseFn: (x: readonly number[]) => readonly (readonly (readonly number[])[])[], opts: {
154
+ export declare function solveGL4Stage(state: GL4State, h: number, gInverseFn: (x: readonly number[]) => Float64Array, dgInverseFn: (x: readonly number[]) => Float64Array, opts: {
153
155
  picardTol: number;
154
156
  picardMaxIter: number;
155
157
  }): StageSolveResult;
@@ -1 +1 @@
1
- {"version":3,"file":"gl4-integrator.d.ts","sourceRoot":"","sources":["../../src/numerical/gl4-integrator.ts"],"names":[],"mappings":"AA6BA;;;;;;;;GAQG;AACH,eAAO,MAAM,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAA4C,CAAC;AAEzF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAGjF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAc,CAAC;AAE3D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,QAAQ;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