universal-physics-tensor 8.0.0 → 10.0.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 (916) hide show
  1. package/README.md +26 -21
  2. package/data/atlas/atlas.json +75 -64
  3. package/data/atlas/atlas.jsonld +1 -1
  4. package/data/atlas/diffusion.json +23 -22
  5. package/data/atlas/oscillators.json +21 -16
  6. package/data/atlas/waves.json +33 -28
  7. package/data/bridge-catalog.json +1356 -1791
  8. package/data/bridge-catalog.schema.json +789 -46
  9. package/data/quantities.json +280 -234
  10. package/data/quantities.schema.json +52 -0
  11. package/data/schemas/atlas-record.v0.json +184 -46
  12. package/data/units.json +1178 -0
  13. package/data/units.schema.json +124 -0
  14. package/dist/atlas/applicability.d.ts.map +1 -1
  15. package/dist/atlas/applicability.js +14 -3
  16. package/dist/atlas/applicability.js.map +1 -1
  17. package/dist/atlas/association.d.ts +1 -1
  18. package/dist/atlas/association.js.map +1 -1
  19. package/dist/atlas/benchmark/backend-shapes.d.ts.map +1 -1
  20. package/dist/atlas/benchmark/backend-shapes.js +5 -1
  21. package/dist/atlas/benchmark/backend-shapes.js.map +1 -1
  22. package/dist/atlas/benchmark/baselines.d.ts.map +1 -1
  23. package/dist/atlas/benchmark/baselines.js +8 -0
  24. package/dist/atlas/benchmark/baselines.js.map +1 -1
  25. package/dist/atlas/benchmark/hybrid-retrieval.d.ts +3 -2
  26. package/dist/atlas/benchmark/hybrid-retrieval.d.ts.map +1 -1
  27. package/dist/atlas/benchmark/hybrid-retrieval.js +16 -12
  28. package/dist/atlas/benchmark/hybrid-retrieval.js.map +1 -1
  29. package/dist/atlas/benchmark/leakage.js.map +1 -1
  30. package/dist/atlas/benchmark/loader.js.map +1 -1
  31. package/dist/atlas/benchmark/run-atlas.d.ts.map +1 -1
  32. package/dist/atlas/benchmark/run-atlas.js +14 -2
  33. package/dist/atlas/benchmark/run-atlas.js.map +1 -1
  34. package/dist/atlas/benchmark/stats.d.ts +1 -1
  35. package/dist/atlas/benchmark/stats.d.ts.map +1 -1
  36. package/dist/atlas/benchmark/stats.js +1 -1
  37. package/dist/atlas/benchmark/stats.js.map +1 -1
  38. package/dist/atlas/benchmark/study.js.map +1 -1
  39. package/dist/atlas/benchmark/types.js.map +1 -1
  40. package/dist/atlas/bridge-record.d.ts +4 -4
  41. package/dist/atlas/bridge-record.d.ts.map +1 -1
  42. package/dist/atlas/bridge-record.js +6 -6
  43. package/dist/atlas/bridge-record.js.map +1 -1
  44. package/dist/atlas/catalog-formal-ref.js.map +1 -1
  45. package/dist/atlas/chain-pipeline.d.ts +0 -11
  46. package/dist/atlas/chain-pipeline.d.ts.map +1 -1
  47. package/dist/atlas/chain-pipeline.js +5 -16
  48. package/dist/atlas/chain-pipeline.js.map +1 -1
  49. package/dist/atlas/composition-table.js.map +1 -1
  50. package/dist/atlas/conventions.js.map +1 -1
  51. package/dist/atlas/coverage.d.ts +2 -2
  52. package/dist/atlas/coverage.js.map +1 -1
  53. package/dist/atlas/derivation.js.map +1 -1
  54. package/dist/atlas/derive-evidence.d.ts +6 -4
  55. package/dist/atlas/derive-evidence.d.ts.map +1 -1
  56. package/dist/atlas/derive-evidence.js +7 -2
  57. package/dist/atlas/derive-evidence.js.map +1 -1
  58. package/dist/atlas/diffusion/bridges-closure.d.ts.map +1 -1
  59. package/dist/atlas/diffusion/bridges-closure.js +0 -5
  60. package/dist/atlas/diffusion/bridges-closure.js.map +1 -1
  61. package/dist/atlas/diffusion/bridges.d.ts.map +1 -1
  62. package/dist/atlas/diffusion/bridges.js +0 -3
  63. package/dist/atlas/diffusion/bridges.js.map +1 -1
  64. package/dist/atlas/diffusion/dimensions.js.map +1 -1
  65. package/dist/atlas/diffusion/index.d.ts +1 -1
  66. package/dist/atlas/diffusion/index.d.ts.map +1 -1
  67. package/dist/atlas/diffusion/index.js.map +1 -1
  68. package/dist/atlas/diffusion/models.js.map +1 -1
  69. package/dist/atlas/diffusion/numerics.js.map +1 -1
  70. package/dist/atlas/error-algebra.d.ts +6 -0
  71. package/dist/atlas/error-algebra.d.ts.map +1 -1
  72. package/dist/atlas/error-algebra.js +26 -0
  73. package/dist/atlas/error-algebra.js.map +1 -1
  74. package/dist/atlas/export.d.ts +18 -2
  75. package/dist/atlas/export.d.ts.map +1 -1
  76. package/dist/atlas/export.js +9 -3
  77. package/dist/atlas/export.js.map +1 -1
  78. package/dist/atlas/families.d.ts +19 -2
  79. package/dist/atlas/families.d.ts.map +1 -1
  80. package/dist/atlas/families.js +26 -3
  81. package/dist/atlas/families.js.map +1 -1
  82. package/dist/atlas/family.d.ts +27 -0
  83. package/dist/atlas/family.d.ts.map +1 -0
  84. package/dist/atlas/family.js +12 -0
  85. package/dist/atlas/family.js.map +1 -0
  86. package/dist/atlas/index.d.ts +3 -2
  87. package/dist/atlas/index.d.ts.map +1 -1
  88. package/dist/atlas/index.js +2 -1
  89. package/dist/atlas/index.js.map +1 -1
  90. package/dist/atlas/link-prediction.d.ts +1 -1
  91. package/dist/atlas/link-prediction.d.ts.map +1 -1
  92. package/dist/atlas/link-prediction.js.map +1 -1
  93. package/dist/atlas/model.js.map +1 -1
  94. package/dist/atlas/oscillators/bridges-coarse.d.ts.map +1 -1
  95. package/dist/atlas/oscillators/bridges-coarse.js +0 -1
  96. package/dist/atlas/oscillators/bridges-coarse.js.map +1 -1
  97. package/dist/atlas/oscillators/bridges-exact.d.ts.map +1 -1
  98. package/dist/atlas/oscillators/bridges-exact.js +0 -3
  99. package/dist/atlas/oscillators/bridges-exact.js.map +1 -1
  100. package/dist/atlas/oscillators/bridges-limits.d.ts.map +1 -1
  101. package/dist/atlas/oscillators/bridges-limits.js +0 -2
  102. package/dist/atlas/oscillators/bridges-limits.js.map +1 -1
  103. package/dist/atlas/oscillators/dimensions.js.map +1 -1
  104. package/dist/atlas/oscillators/index.d.ts +1 -16
  105. package/dist/atlas/oscillators/index.d.ts.map +1 -1
  106. package/dist/atlas/oscillators/index.js.map +1 -1
  107. package/dist/atlas/oscillators/limit-witnesses.js.map +1 -1
  108. package/dist/atlas/oscillators/models.js.map +1 -1
  109. package/dist/atlas/oscillators/norm-transport-witness.js.map +1 -1
  110. package/dist/atlas/oscillators/norm-transport.js.map +1 -1
  111. package/dist/atlas/oscillators/norms.js.map +1 -1
  112. package/dist/atlas/oscillators/pendulum-motion.js.map +1 -1
  113. package/dist/atlas/oscillators/phase-carriage.js.map +1 -1
  114. package/dist/atlas/oscillators/phase-translation.js.map +1 -1
  115. package/dist/atlas/oscillators/position-translation.js.map +1 -1
  116. package/dist/atlas/oscillators/rejections.js.map +1 -1
  117. package/dist/atlas/path-bound.js.map +1 -1
  118. package/dist/atlas/physjs-entries.generated.d.ts +1601 -220
  119. package/dist/atlas/physjs-entries.generated.d.ts.map +1 -1
  120. package/dist/atlas/physjs-entries.generated.js +1854 -345
  121. package/dist/atlas/physjs-entries.generated.js.map +1 -1
  122. package/dist/atlas/physjs-ref.d.ts +151 -117
  123. package/dist/atlas/physjs-ref.d.ts.map +1 -1
  124. package/dist/atlas/physjs-ref.js +244 -211
  125. package/dist/atlas/physjs-ref.js.map +1 -1
  126. package/dist/atlas/physjs-reviewed.d.ts +31 -0
  127. package/dist/atlas/physjs-reviewed.d.ts.map +1 -0
  128. package/dist/atlas/physjs-reviewed.js +194 -0
  129. package/dist/atlas/physjs-reviewed.js.map +1 -0
  130. package/dist/atlas/poster/associations.js.map +1 -1
  131. package/dist/atlas/poster/derivations.js.map +1 -1
  132. package/dist/atlas/poster/statements.js.map +1 -1
  133. package/dist/atlas/proof-target.d.ts +16 -8
  134. package/dist/atlas/proof-target.d.ts.map +1 -1
  135. package/dist/atlas/proof-target.js +34 -31
  136. package/dist/atlas/proof-target.js.map +1 -1
  137. package/dist/atlas/public.d.ts +2 -1
  138. package/dist/atlas/public.d.ts.map +1 -1
  139. package/dist/atlas/public.js +2 -1
  140. package/dist/atlas/public.js.map +1 -1
  141. package/dist/atlas/regime.js.map +1 -1
  142. package/dist/atlas/serialize.d.ts +18 -12
  143. package/dist/atlas/serialize.d.ts.map +1 -1
  144. package/dist/atlas/serialize.js +28 -18
  145. package/dist/atlas/serialize.js.map +1 -1
  146. package/dist/atlas/statement.js.map +1 -1
  147. package/dist/atlas/translation-registry.js.map +1 -1
  148. package/dist/atlas/translation.js.map +1 -1
  149. package/dist/atlas/types.d.ts +9 -2
  150. package/dist/atlas/types.d.ts.map +1 -1
  151. package/dist/atlas/types.js +1 -1
  152. package/dist/atlas/types.js.map +1 -1
  153. package/dist/atlas/waves/bridges-closure.d.ts.map +1 -1
  154. package/dist/atlas/waves/bridges-closure.js +0 -3
  155. package/dist/atlas/waves/bridges-closure.js.map +1 -1
  156. package/dist/atlas/waves/bridges.d.ts.map +1 -1
  157. package/dist/atlas/waves/bridges.js +0 -4
  158. package/dist/atlas/waves/bridges.js.map +1 -1
  159. package/dist/atlas/waves/index.d.ts +1 -1
  160. package/dist/atlas/waves/index.d.ts.map +1 -1
  161. package/dist/atlas/waves/index.js.map +1 -1
  162. package/dist/atlas/waves/models.js.map +1 -1
  163. package/dist/atlas/waves/numerics.js.map +1 -1
  164. package/dist/atlas/witness-artifact.js.map +1 -1
  165. package/dist/atlas/witness-dominance.d.ts +4 -3
  166. package/dist/atlas/witness-dominance.d.ts.map +1 -1
  167. package/dist/atlas/witness-dominance.js +15 -5
  168. package/dist/atlas/witness-dominance.js.map +1 -1
  169. package/dist/atlas/witness-numeric.d.ts +8 -4
  170. package/dist/atlas/witness-numeric.d.ts.map +1 -1
  171. package/dist/atlas/witness-numeric.js +27 -2
  172. package/dist/atlas/witness-numeric.js.map +1 -1
  173. package/dist/atlas/witness-result.d.ts +7 -1
  174. package/dist/atlas/witness-result.d.ts.map +1 -1
  175. package/dist/atlas/witness-result.js.map +1 -1
  176. package/dist/atlas/witness-specs.js.map +1 -1
  177. package/dist/atlas/witness-symbolic.js.map +1 -1
  178. package/dist/atlas/witnesses/quantum-support.js.map +1 -1
  179. package/dist/bridges/caller-table.d.ts +1 -1
  180. package/dist/bridges/caller-table.d.ts.map +1 -1
  181. package/dist/bridges/caller-table.js.map +1 -1
  182. package/dist/bridges/carrier-sign.d.ts.map +1 -1
  183. package/dist/bridges/carrier-sign.js +8 -3
  184. package/dist/bridges/carrier-sign.js.map +1 -1
  185. package/dist/bridges/catalog-adapter.d.ts +12 -3
  186. package/dist/bridges/catalog-adapter.d.ts.map +1 -1
  187. package/dist/bridges/catalog-adapter.js +22 -14
  188. package/dist/bridges/catalog-adapter.js.map +1 -1
  189. package/dist/bridges/catalog-load.d.ts +19 -2
  190. package/dist/bridges/catalog-load.d.ts.map +1 -1
  191. package/dist/bridges/catalog-load.js +233 -14
  192. package/dist/bridges/catalog-load.js.map +1 -1
  193. package/dist/bridges/catalog-types.d.ts +96 -27
  194. package/dist/bridges/catalog-types.d.ts.map +1 -1
  195. package/dist/bridges/catalog-types.js.map +1 -1
  196. package/dist/bridges/coefficient-statement.js +1 -5
  197. package/dist/bridges/coefficient-statement.js.map +1 -1
  198. package/dist/bridges/confrontation-coverage.js.map +1 -1
  199. package/dist/bridges/confrontations.d.ts +1 -1
  200. package/dist/bridges/confrontations.d.ts.map +1 -1
  201. package/dist/bridges/confrontations.js +1 -1
  202. package/dist/bridges/confrontations.js.map +1 -1
  203. package/dist/bridges/evaluation-errors.d.ts +89 -0
  204. package/dist/bridges/evaluation-errors.d.ts.map +1 -0
  205. package/dist/bridges/evaluation-errors.js +136 -0
  206. package/dist/bridges/evaluation-errors.js.map +1 -0
  207. package/dist/bridges/evaluator-inputs.d.ts +5 -3
  208. package/dist/bridges/evaluator-inputs.d.ts.map +1 -1
  209. package/dist/bridges/evaluator-inputs.js +24 -24
  210. package/dist/bridges/evaluator-inputs.js.map +1 -1
  211. package/dist/bridges/evaluators.d.ts +48 -8
  212. package/dist/bridges/evaluators.d.ts.map +1 -1
  213. package/dist/bridges/evaluators.js +173 -38
  214. package/dist/bridges/evaluators.js.map +1 -1
  215. package/dist/bridges/expr-parse.d.ts +38 -7
  216. package/dist/bridges/expr-parse.d.ts.map +1 -1
  217. package/dist/bridges/expr-parse.js +129 -156
  218. package/dist/bridges/expr-parse.js.map +1 -1
  219. package/dist/bridges/holds.d.ts +16 -8
  220. package/dist/bridges/holds.d.ts.map +1 -1
  221. package/dist/bridges/holds.js +130 -236
  222. package/dist/bridges/holds.js.map +1 -1
  223. package/dist/bridges/index.d.ts +15 -14
  224. package/dist/bridges/index.d.ts.map +1 -1
  225. package/dist/bridges/index.js +14 -15
  226. package/dist/bridges/index.js.map +1 -1
  227. package/dist/bridges/input-contract.d.ts +65 -0
  228. package/dist/bridges/input-contract.d.ts.map +1 -0
  229. package/dist/bridges/input-contract.js +97 -0
  230. package/dist/bridges/input-contract.js.map +1 -0
  231. package/dist/bridges/membership.d.ts +5 -3
  232. package/dist/bridges/membership.d.ts.map +1 -1
  233. package/dist/bridges/membership.js +5 -6
  234. package/dist/bridges/membership.js.map +1 -1
  235. package/dist/bridges/notices.d.ts +11 -0
  236. package/dist/bridges/notices.d.ts.map +1 -0
  237. package/dist/bridges/notices.js +22 -0
  238. package/dist/bridges/notices.js.map +1 -0
  239. package/dist/bridges/observations/types.js.map +1 -1
  240. package/dist/bridges/rejected.d.ts +11 -17
  241. package/dist/bridges/rejected.d.ts.map +1 -1
  242. package/dist/bridges/rejected.js +13 -68
  243. package/dist/bridges/rejected.js.map +1 -1
  244. package/dist/bridges/relation-eval.d.ts +5 -6
  245. package/dist/bridges/relation-eval.d.ts.map +1 -1
  246. package/dist/bridges/relation-eval.js +9 -38
  247. package/dist/bridges/relation-eval.js.map +1 -1
  248. package/dist/bridges/rhs-registry.js.map +1 -1
  249. package/dist/bridges/sensitivity.d.ts +11 -3
  250. package/dist/bridges/sensitivity.d.ts.map +1 -1
  251. package/dist/bridges/sensitivity.js +24 -10
  252. package/dist/bridges/sensitivity.js.map +1 -1
  253. package/dist/bridges/tensor-index.js.map +1 -1
  254. package/dist/bridges/types.d.ts +1 -7
  255. package/dist/bridges/types.d.ts.map +1 -1
  256. package/dist/bridges/types.js +1 -4
  257. package/dist/bridges/types.js.map +1 -1
  258. package/dist/canonical/canonical-equation.d.ts +31 -0
  259. package/dist/canonical/canonical-equation.d.ts.map +1 -1
  260. package/dist/canonical/canonical-equation.js.map +1 -1
  261. package/dist/canonical/dimensional-fields.js.map +1 -1
  262. package/dist/canonical/entries/_l1-build.js.map +1 -1
  263. package/dist/canonical/entries/atomic.d.ts.map +1 -1
  264. package/dist/canonical/entries/atomic.js +11 -1
  265. package/dist/canonical/entries/atomic.js.map +1 -1
  266. package/dist/canonical/entries/condensed-matter.d.ts.map +1 -1
  267. package/dist/canonical/entries/condensed-matter.js +7 -4
  268. package/dist/canonical/entries/condensed-matter.js.map +1 -1
  269. package/dist/canonical/entries/dimensional-classics.d.ts.map +1 -1
  270. package/dist/canonical/entries/dimensional-classics.js +50 -2
  271. package/dist/canonical/entries/dimensional-classics.js.map +1 -1
  272. package/dist/canonical/entries/electromagnetism.d.ts.map +1 -1
  273. package/dist/canonical/entries/electromagnetism.js +32 -2
  274. package/dist/canonical/entries/electromagnetism.js.map +1 -1
  275. package/dist/canonical/entries/fluids-waves.d.ts.map +1 -1
  276. package/dist/canonical/entries/fluids-waves.js +34 -0
  277. package/dist/canonical/entries/fluids-waves.js.map +1 -1
  278. package/dist/canonical/entries/mechanics.d.ts.map +1 -1
  279. package/dist/canonical/entries/mechanics.js +24 -0
  280. package/dist/canonical/entries/mechanics.js.map +1 -1
  281. package/dist/canonical/entries/nonmonomial.d.ts.map +1 -1
  282. package/dist/canonical/entries/nonmonomial.js +42 -24
  283. package/dist/canonical/entries/nonmonomial.js.map +1 -1
  284. package/dist/canonical/entries/relativity.d.ts.map +1 -1
  285. package/dist/canonical/entries/relativity.js +6 -0
  286. package/dist/canonical/entries/relativity.js.map +1 -1
  287. package/dist/canonical/entries/statistical-mechanics.d.ts.map +1 -1
  288. package/dist/canonical/entries/statistical-mechanics.js +24 -5
  289. package/dist/canonical/entries/statistical-mechanics.js.map +1 -1
  290. package/dist/canonical/entries/thermo-nuclear-cosmo.d.ts.map +1 -1
  291. package/dist/canonical/entries/thermo-nuclear-cosmo.js +15 -0
  292. package/dist/canonical/entries/thermo-nuclear-cosmo.js.map +1 -1
  293. package/dist/canonical/linkage.d.ts +29 -4
  294. package/dist/canonical/linkage.d.ts.map +1 -1
  295. package/dist/canonical/linkage.js +31 -29
  296. package/dist/canonical/linkage.js.map +1 -1
  297. package/dist/canonical/normal-form.d.ts +0 -8
  298. package/dist/canonical/normal-form.d.ts.map +1 -1
  299. package/dist/canonical/normal-form.js +17 -12
  300. package/dist/canonical/normal-form.js.map +1 -1
  301. package/dist/canonical/registry.js.map +1 -1
  302. package/dist/canonical/residual.js.map +1 -1
  303. package/dist/canonical/seed-l-layer.d.ts +7 -1
  304. package/dist/canonical/seed-l-layer.d.ts.map +1 -1
  305. package/dist/canonical/seed-l-layer.js +7 -1
  306. package/dist/canonical/seed-l-layer.js.map +1 -1
  307. package/dist/canonical/structural.d.ts +21 -0
  308. package/dist/canonical/structural.d.ts.map +1 -1
  309. package/dist/canonical/structural.js +24 -4
  310. package/dist/canonical/structural.js.map +1 -1
  311. package/dist/cases/brownian-sphere.js +4 -4
  312. package/dist/cases/brownian-sphere.js.map +1 -1
  313. package/dist/cases/damped-resonator.js +2 -2
  314. package/dist/cases/damped-resonator.js.map +1 -1
  315. package/dist/cases/index.d.ts +9 -2
  316. package/dist/cases/index.d.ts.map +1 -1
  317. package/dist/cases/index.js +26 -7
  318. package/dist/cases/index.js.map +1 -1
  319. package/dist/cases/kepler-rv.js +6 -6
  320. package/dist/cases/kepler-rv.js.map +1 -1
  321. package/dist/cases/lumped-cooling.js +1 -1
  322. package/dist/cases/lumped-cooling.js.map +1 -1
  323. package/dist/cases/quadrature.js.map +1 -1
  324. package/dist/cases/resistor-noise.js +3 -3
  325. package/dist/cases/resistor-noise.js.map +1 -1
  326. package/dist/cases/skin-depth.js.map +1 -1
  327. package/dist/cases/types.js.map +1 -1
  328. package/dist/cli/args.d.ts +7 -2
  329. package/dist/cli/args.d.ts.map +1 -1
  330. package/dist/cli/args.js +18 -2
  331. package/dist/cli/args.js.map +1 -1
  332. package/dist/cli/bindings.d.ts +13 -0
  333. package/dist/cli/bindings.d.ts.map +1 -0
  334. package/dist/cli/bindings.js +32 -0
  335. package/dist/cli/bindings.js.map +1 -0
  336. package/dist/cli/closed-form-range.js.map +1 -1
  337. package/dist/cli/command.js.map +1 -1
  338. package/dist/cli/commands/_atlas-map.d.ts +3 -3
  339. package/dist/cli/commands/_atlas-map.d.ts.map +1 -1
  340. package/dist/cli/commands/_atlas-map.js +43 -18
  341. package/dist/cli/commands/_atlas-map.js.map +1 -1
  342. package/dist/cli/commands/_atlas-route.js.map +1 -1
  343. package/dist/cli/commands/_discovery-opts.d.ts +2 -1
  344. package/dist/cli/commands/_discovery-opts.d.ts.map +1 -1
  345. package/dist/cli/commands/_discovery-opts.js +48 -18
  346. package/dist/cli/commands/_discovery-opts.js.map +1 -1
  347. package/dist/cli/commands/atlas.d.ts.map +1 -1
  348. package/dist/cli/commands/atlas.js +7 -12
  349. package/dist/cli/commands/atlas.js.map +1 -1
  350. package/dist/cli/commands/audit.d.ts.map +1 -1
  351. package/dist/cli/commands/audit.js +13 -21
  352. package/dist/cli/commands/audit.js.map +1 -1
  353. package/dist/cli/commands/axes.js.map +1 -1
  354. package/dist/cli/commands/candidates.d.ts.map +1 -1
  355. package/dist/cli/commands/candidates.js +16 -8
  356. package/dist/cli/commands/candidates.js.map +1 -1
  357. package/dist/cli/commands/canonical.js.map +1 -1
  358. package/dist/cli/commands/chain.js +1 -1
  359. package/dist/cli/commands/chain.js.map +1 -1
  360. package/dist/cli/commands/confront.d.ts.map +1 -1
  361. package/dist/cli/commands/confront.js +22 -14
  362. package/dist/cli/commands/confront.js.map +1 -1
  363. package/dist/cli/commands/connectors.d.ts.map +1 -1
  364. package/dist/cli/commands/connectors.js +8 -9
  365. package/dist/cli/commands/connectors.js.map +1 -1
  366. package/dist/cli/commands/coverage.js.map +1 -1
  367. package/dist/cli/commands/derive.d.ts.map +1 -1
  368. package/dist/cli/commands/derive.js +50 -26
  369. package/dist/cli/commands/derive.js.map +1 -1
  370. package/dist/cli/commands/discover.d.ts.map +1 -1
  371. package/dist/cli/commands/discover.js +18 -13
  372. package/dist/cli/commands/discover.js.map +1 -1
  373. package/dist/cli/commands/eval.d.ts.map +1 -1
  374. package/dist/cli/commands/eval.js +29 -26
  375. package/dist/cli/commands/eval.js.map +1 -1
  376. package/dist/cli/commands/evaluate.d.ts +1 -35
  377. package/dist/cli/commands/evaluate.d.ts.map +1 -1
  378. package/dist/cli/commands/evaluate.js +99 -208
  379. package/dist/cli/commands/evaluate.js.map +1 -1
  380. package/dist/cli/commands/explain.d.ts.map +1 -1
  381. package/dist/cli/commands/explain.js +57 -45
  382. package/dist/cli/commands/explain.js.map +1 -1
  383. package/dist/cli/commands/frontier.js.map +1 -1
  384. package/dist/cli/commands/ground.d.ts.map +1 -1
  385. package/dist/cli/commands/ground.js +41 -11
  386. package/dist/cli/commands/ground.js.map +1 -1
  387. package/dist/cli/commands/index.js.map +1 -1
  388. package/dist/cli/commands/map.d.ts.map +1 -1
  389. package/dist/cli/commands/map.js +84 -92
  390. package/dist/cli/commands/map.js.map +1 -1
  391. package/dist/cli/commands/metric.d.ts.map +1 -1
  392. package/dist/cli/commands/metric.js +53 -15
  393. package/dist/cli/commands/metric.js.map +1 -1
  394. package/dist/cli/commands/path.js +4 -4
  395. package/dist/cli/commands/path.js.map +1 -1
  396. package/dist/cli/commands/predict.js.map +1 -1
  397. package/dist/cli/commands/priority.js.map +1 -1
  398. package/dist/cli/commands/probe.d.ts.map +1 -1
  399. package/dist/cli/commands/probe.js +50 -26
  400. package/dist/cli/commands/probe.js.map +1 -1
  401. package/dist/cli/commands/recover.js +1 -1
  402. package/dist/cli/commands/recover.js.map +1 -1
  403. package/dist/cli/commands/regime.d.ts +5 -4
  404. package/dist/cli/commands/regime.d.ts.map +1 -1
  405. package/dist/cli/commands/regime.js +25 -27
  406. package/dist/cli/commands/regime.js.map +1 -1
  407. package/dist/cli/commands/retrieve.d.ts.map +1 -1
  408. package/dist/cli/commands/retrieve.js +22 -14
  409. package/dist/cli/commands/retrieve.js.map +1 -1
  410. package/dist/cli/commands/search.d.ts.map +1 -1
  411. package/dist/cli/commands/search.js +8 -4
  412. package/dist/cli/commands/search.js.map +1 -1
  413. package/dist/cli/commands/symbolic.d.ts.map +1 -1
  414. package/dist/cli/commands/symbolic.js +14 -7
  415. package/dist/cli/commands/symbolic.js.map +1 -1
  416. package/dist/cli/commands/testplan.js +4 -4
  417. package/dist/cli/commands/testplan.js.map +1 -1
  418. package/dist/cli/conventions.d.ts +6 -7
  419. package/dist/cli/conventions.d.ts.map +1 -1
  420. package/dist/cli/conventions.js +19 -28
  421. package/dist/cli/conventions.js.map +1 -1
  422. package/dist/cli/determination.js.map +1 -1
  423. package/dist/cli/errors.js.map +1 -1
  424. package/dist/cli/euler-guard.d.ts +13 -2
  425. package/dist/cli/euler-guard.d.ts.map +1 -1
  426. package/dist/cli/euler-guard.js +17 -3
  427. package/dist/cli/euler-guard.js.map +1 -1
  428. package/dist/cli/eval-numbers.d.ts +4 -9
  429. package/dist/cli/eval-numbers.d.ts.map +1 -1
  430. package/dist/cli/eval-numbers.js +11 -41
  431. package/dist/cli/eval-numbers.js.map +1 -1
  432. package/dist/cli/expr-print.d.ts +29 -2
  433. package/dist/cli/expr-print.d.ts.map +1 -1
  434. package/dist/cli/expr-print.js +46 -2
  435. package/dist/cli/expr-print.js.map +1 -1
  436. package/dist/cli/flag-help.js.map +1 -1
  437. package/dist/cli/graphs.js.map +1 -1
  438. package/dist/cli/library-defaults.d.ts +19 -0
  439. package/dist/cli/library-defaults.d.ts.map +1 -0
  440. package/dist/cli/library-defaults.js +22 -0
  441. package/dist/cli/library-defaults.js.map +1 -0
  442. package/dist/cli/main.js +7 -3
  443. package/dist/cli/main.js.map +1 -1
  444. package/dist/cli/map-evidence.js.map +1 -1
  445. package/dist/cli/output.d.ts +3 -6
  446. package/dist/cli/output.d.ts.map +1 -1
  447. package/dist/cli/output.js.map +1 -1
  448. package/dist/cli/published-url.d.ts +2 -0
  449. package/dist/cli/published-url.d.ts.map +1 -1
  450. package/dist/cli/published-url.js +5 -0
  451. package/dist/cli/published-url.js.map +1 -1
  452. package/dist/cli/record-reach.d.ts +6 -0
  453. package/dist/cli/record-reach.d.ts.map +1 -1
  454. package/dist/cli/record-reach.js +16 -10
  455. package/dist/cli/record-reach.js.map +1 -1
  456. package/dist/cli/record-tables.d.ts +2 -1
  457. package/dist/cli/record-tables.d.ts.map +1 -1
  458. package/dist/cli/record-tables.js +8 -3
  459. package/dist/cli/record-tables.js.map +1 -1
  460. package/dist/cli/record.d.ts.map +1 -1
  461. package/dist/cli/record.js +31 -12
  462. package/dist/cli/record.js.map +1 -1
  463. package/dist/cli/search-index.d.ts +5 -0
  464. package/dist/cli/search-index.d.ts.map +1 -1
  465. package/dist/cli/search-index.js +12 -1
  466. package/dist/cli/search-index.js.map +1 -1
  467. package/dist/cli/statuses.js.map +1 -1
  468. package/dist/cli/top-level-help.js.map +1 -1
  469. package/dist/cli/version.js.map +1 -1
  470. package/dist/cli-api.d.ts +57 -18
  471. package/dist/cli-api.d.ts.map +1 -1
  472. package/dist/cli-api.js +49 -21
  473. package/dist/cli-api.js.map +1 -1
  474. package/dist/composition/adjudication.d.ts +8 -30
  475. package/dist/composition/adjudication.d.ts.map +1 -1
  476. package/dist/composition/adjudication.js +15 -67
  477. package/dist/composition/adjudication.js.map +1 -1
  478. package/dist/composition/aliases.d.ts +1 -1
  479. package/dist/composition/aliases.d.ts.map +1 -1
  480. package/dist/composition/aliases.js +10 -20
  481. package/dist/composition/aliases.js.map +1 -1
  482. package/dist/composition/audit-coverage.d.ts +2 -0
  483. package/dist/composition/audit-coverage.d.ts.map +1 -1
  484. package/dist/composition/audit-coverage.js.map +1 -1
  485. package/dist/composition/axes.d.ts +12 -0
  486. package/dist/composition/axes.d.ts.map +1 -1
  487. package/dist/composition/axes.js +18 -6
  488. package/dist/composition/axes.js.map +1 -1
  489. package/dist/composition/axis-audit.js.map +1 -1
  490. package/dist/composition/bridge-analysis.d.ts +0 -14
  491. package/dist/composition/bridge-analysis.d.ts.map +1 -1
  492. package/dist/composition/bridge-analysis.js +66 -57
  493. package/dist/composition/bridge-analysis.js.map +1 -1
  494. package/dist/composition/bridge-prediction.d.ts +5 -1
  495. package/dist/composition/bridge-prediction.d.ts.map +1 -1
  496. package/dist/composition/bridge-prediction.js +12 -16
  497. package/dist/composition/bridge-prediction.js.map +1 -1
  498. package/dist/composition/buckingham-filter.js.map +1 -1
  499. package/dist/composition/canonical-compare.d.ts.map +1 -1
  500. package/dist/composition/canonical-compare.js +12 -2
  501. package/dist/composition/canonical-compare.js.map +1 -1
  502. package/dist/composition/canonical-graph.d.ts +15 -18
  503. package/dist/composition/canonical-graph.d.ts.map +1 -1
  504. package/dist/composition/canonical-graph.js +59 -85
  505. package/dist/composition/canonical-graph.js.map +1 -1
  506. package/dist/composition/canonical-json.js.map +1 -1
  507. package/dist/composition/canonical-prefactors.d.ts +10 -29
  508. package/dist/composition/canonical-prefactors.d.ts.map +1 -1
  509. package/dist/composition/canonical-prefactors.js +15 -202
  510. package/dist/composition/canonical-prefactors.js.map +1 -1
  511. package/dist/composition/catalog-graph.d.ts.map +1 -1
  512. package/dist/composition/catalog-graph.js +6 -20
  513. package/dist/composition/catalog-graph.js.map +1 -1
  514. package/dist/composition/chain-candidate.d.ts +2 -0
  515. package/dist/composition/chain-candidate.d.ts.map +1 -1
  516. package/dist/composition/chain-candidate.js +2 -0
  517. package/dist/composition/chain-candidate.js.map +1 -1
  518. package/dist/composition/chain-match.js.map +1 -1
  519. package/dist/composition/chain-regime.js.map +1 -1
  520. package/dist/composition/chain-result.js.map +1 -1
  521. package/dist/composition/compose-surface.js.map +1 -1
  522. package/dist/composition/compose-symbolic.js.map +1 -1
  523. package/dist/composition/compose.d.ts.map +1 -1
  524. package/dist/composition/compose.js +154 -36
  525. package/dist/composition/compose.js.map +1 -1
  526. package/dist/composition/composition-recovery.js.map +1 -1
  527. package/dist/composition/consequence.d.ts.map +1 -1
  528. package/dist/composition/consequence.js +15 -6
  529. package/dist/composition/consequence.js.map +1 -1
  530. package/dist/composition/consistency.js.map +1 -1
  531. package/dist/composition/descriptor.d.ts +1 -1
  532. package/dist/composition/descriptor.d.ts.map +1 -1
  533. package/dist/composition/descriptor.js.map +1 -1
  534. package/dist/composition/dimension-adjacency.js.map +1 -1
  535. package/dist/composition/discovery.d.ts +67 -7
  536. package/dist/composition/discovery.d.ts.map +1 -1
  537. package/dist/composition/discovery.js +83 -23
  538. package/dist/composition/discovery.js.map +1 -1
  539. package/dist/composition/edge.d.ts +19 -22
  540. package/dist/composition/edge.d.ts.map +1 -1
  541. package/dist/composition/edge.js +25 -28
  542. package/dist/composition/edge.js.map +1 -1
  543. package/dist/composition/enumerate.d.ts +2 -2
  544. package/dist/composition/enumerate.d.ts.map +1 -1
  545. package/dist/composition/enumerate.js.map +1 -1
  546. package/dist/composition/evaluate-relation.d.ts +29 -5
  547. package/dist/composition/evaluate-relation.d.ts.map +1 -1
  548. package/dist/composition/evaluate-relation.js +100 -72
  549. package/dist/composition/evaluate-relation.js.map +1 -1
  550. package/dist/composition/explain.d.ts +14 -4
  551. package/dist/composition/explain.d.ts.map +1 -1
  552. package/dist/composition/explain.js +53 -19
  553. package/dist/composition/explain.js.map +1 -1
  554. package/dist/composition/expr-eval.d.ts.map +1 -1
  555. package/dist/composition/expr-eval.js +2 -1
  556. package/dist/composition/expr-eval.js.map +1 -1
  557. package/dist/composition/expr-simplify.d.ts.map +1 -1
  558. package/dist/composition/expr-simplify.js +9 -39
  559. package/dist/composition/expr-simplify.js.map +1 -1
  560. package/dist/composition/expr-subst.js.map +1 -1
  561. package/dist/composition/formula-shape.d.ts +9 -0
  562. package/dist/composition/formula-shape.d.ts.map +1 -1
  563. package/dist/composition/formula-shape.js +54 -0
  564. package/dist/composition/formula-shape.js.map +1 -1
  565. package/dist/composition/frontier-account.d.ts +3 -2
  566. package/dist/composition/frontier-account.d.ts.map +1 -1
  567. package/dist/composition/frontier-account.js +7 -3
  568. package/dist/composition/frontier-account.js.map +1 -1
  569. package/dist/composition/graph-viz-svg.js.map +1 -1
  570. package/dist/composition/graph-viz.js.map +1 -1
  571. package/dist/composition/grounding.js.map +1 -1
  572. package/dist/composition/identifiability.js.map +1 -1
  573. package/dist/composition/index.d.ts +9 -5
  574. package/dist/composition/index.d.ts.map +1 -1
  575. package/dist/composition/index.js +7 -4
  576. package/dist/composition/index.js.map +1 -1
  577. package/dist/composition/mathts-quiet.d.ts +28 -0
  578. package/dist/composition/mathts-quiet.d.ts.map +1 -0
  579. package/dist/composition/mathts-quiet.js +56 -0
  580. package/dist/composition/mathts-quiet.js.map +1 -0
  581. package/dist/composition/mathts-scalar-symbols.d.ts.map +1 -1
  582. package/dist/composition/mathts-scalar-symbols.js +18 -34
  583. package/dist/composition/mathts-scalar-symbols.js.map +1 -1
  584. package/dist/composition/not-composable-seeds.d.ts +3 -1
  585. package/dist/composition/not-composable-seeds.d.ts.map +1 -1
  586. package/dist/composition/not-composable-seeds.js +2 -0
  587. package/dist/composition/not-composable-seeds.js.map +1 -1
  588. package/dist/composition/probe/backend-protocol.js.map +1 -1
  589. package/dist/composition/probe/candidate-store.js.map +1 -1
  590. package/dist/composition/probe/corpus.js.map +1 -1
  591. package/dist/composition/probe/dataset.js.map +1 -1
  592. package/dist/composition/probe/experiment-design.js.map +1 -1
  593. package/dist/composition/probe/expression-gaps.js.map +1 -1
  594. package/dist/composition/probe/falsify.d.ts +14 -3
  595. package/dist/composition/probe/falsify.d.ts.map +1 -1
  596. package/dist/composition/probe/falsify.js +14 -27
  597. package/dist/composition/probe/falsify.js.map +1 -1
  598. package/dist/composition/probe/fingerprint.js.map +1 -1
  599. package/dist/composition/probe/fit.d.ts +1 -1
  600. package/dist/composition/probe/fit.d.ts.map +1 -1
  601. package/dist/composition/probe/fit.js +2 -1
  602. package/dist/composition/probe/fit.js.map +1 -1
  603. package/dist/composition/probe/frontier.js.map +1 -1
  604. package/dist/composition/probe/generator.js.map +1 -1
  605. package/dist/composition/probe/index.d.ts +4 -2
  606. package/dist/composition/probe/index.d.ts.map +1 -1
  607. package/dist/composition/probe/index.js +4 -2
  608. package/dist/composition/probe/index.js.map +1 -1
  609. package/dist/composition/probe/limits.js.map +1 -1
  610. package/dist/composition/probe/metadata.js.map +1 -1
  611. package/dist/composition/probe/pipeline.d.ts +5 -0
  612. package/dist/composition/probe/pipeline.d.ts.map +1 -1
  613. package/dist/composition/probe/pipeline.js +13 -6
  614. package/dist/composition/probe/pipeline.js.map +1 -1
  615. package/dist/composition/probe/problem.d.ts +8 -0
  616. package/dist/composition/probe/problem.d.ts.map +1 -1
  617. package/dist/composition/probe/problem.js +78 -12
  618. package/dist/composition/probe/problem.js.map +1 -1
  619. package/dist/composition/probe/report.js.map +1 -1
  620. package/dist/composition/probe/residual.js.map +1 -1
  621. package/dist/composition/probe/run-manifest.js +2 -2
  622. package/dist/composition/probe/run-manifest.js.map +1 -1
  623. package/dist/composition/probe/scoring.d.ts +2 -1
  624. package/dist/composition/probe/scoring.d.ts.map +1 -1
  625. package/dist/composition/probe/scoring.js +21 -7
  626. package/dist/composition/probe/scoring.js.map +1 -1
  627. package/dist/composition/probe/search-budget.js.map +1 -1
  628. package/dist/composition/probe/serialize.js.map +1 -1
  629. package/dist/composition/probe/structure.js.map +1 -1
  630. package/dist/composition/probe/study.d.ts +4 -3
  631. package/dist/composition/probe/study.d.ts.map +1 -1
  632. package/dist/composition/probe/study.js +5 -3
  633. package/dist/composition/probe/study.js.map +1 -1
  634. package/dist/composition/probe/types.d.ts +3 -1
  635. package/dist/composition/probe/types.d.ts.map +1 -1
  636. package/dist/composition/probe/types.js +2 -0
  637. package/dist/composition/probe/types.js.map +1 -1
  638. package/dist/composition/proposed-bridges.d.ts +11 -4
  639. package/dist/composition/proposed-bridges.d.ts.map +1 -1
  640. package/dist/composition/proposed-bridges.js +14 -6
  641. package/dist/composition/proposed-bridges.js.map +1 -1
  642. package/dist/composition/quantities.d.ts +0 -4
  643. package/dist/composition/quantities.d.ts.map +1 -1
  644. package/dist/composition/quantities.js +5 -5
  645. package/dist/composition/quantities.js.map +1 -1
  646. package/dist/composition/quantity.d.ts +18 -2
  647. package/dist/composition/quantity.d.ts.map +1 -1
  648. package/dist/composition/quantity.js +35 -6
  649. package/dist/composition/quantity.js.map +1 -1
  650. package/dist/composition/representative-values.js.map +1 -1
  651. package/dist/composition/retrodiction.d.ts +18 -0
  652. package/dist/composition/retrodiction.d.ts.map +1 -1
  653. package/dist/composition/retrodiction.js +37 -7
  654. package/dist/composition/retrodiction.js.map +1 -1
  655. package/dist/composition/uncertainty.js.map +1 -1
  656. package/dist/composition/user-equation.d.ts +11 -7
  657. package/dist/composition/user-equation.d.ts.map +1 -1
  658. package/dist/composition/user-equation.js +24 -26
  659. package/dist/composition/user-equation.js.map +1 -1
  660. package/dist/core/axes-registry.d.ts +8 -5
  661. package/dist/core/axes-registry.d.ts.map +1 -1
  662. package/dist/core/axes-registry.js.map +1 -1
  663. package/dist/core/cell.js.map +1 -1
  664. package/dist/core/constants.d.ts +35 -12
  665. package/dist/core/constants.d.ts.map +1 -1
  666. package/dist/core/constants.js +46 -15
  667. package/dist/core/constants.js.map +1 -1
  668. package/dist/core/data-file.d.ts +27 -0
  669. package/dist/core/data-file.d.ts.map +1 -0
  670. package/dist/core/data-file.js +48 -0
  671. package/dist/core/data-file.js.map +1 -0
  672. package/dist/core/flux-rules.js +1 -1
  673. package/dist/core/flux-rules.js.map +1 -1
  674. package/dist/core/json-schema.d.ts +27 -0
  675. package/dist/core/json-schema.d.ts.map +1 -0
  676. package/dist/core/json-schema.js +177 -0
  677. package/dist/core/json-schema.js.map +1 -0
  678. package/dist/core/labeled-tensor.d.ts +6 -1
  679. package/dist/core/labeled-tensor.d.ts.map +1 -1
  680. package/dist/core/labeled-tensor.js +18 -8
  681. package/dist/core/labeled-tensor.js.map +1 -1
  682. package/dist/core/regime-registry.d.ts +6 -2
  683. package/dist/core/regime-registry.d.ts.map +1 -1
  684. package/dist/core/regime-registry.js.map +1 -1
  685. package/dist/core/regime-rule-install.js.map +1 -1
  686. package/dist/core/regimes-builtins.js.map +1 -1
  687. package/dist/core/tensor.d.ts +7 -4
  688. package/dist/core/tensor.d.ts.map +1 -1
  689. package/dist/core/tensor.js +40 -8
  690. package/dist/core/tensor.js.map +1 -1
  691. package/dist/core/types.d.ts +3 -2
  692. package/dist/core/types.d.ts.map +1 -1
  693. package/dist/core/types.js +16 -14
  694. package/dist/core/types.js.map +1 -1
  695. package/dist/core/universal-index.js.map +1 -1
  696. package/dist/diff/bridge-ast-gradient.d.ts +4 -5
  697. package/dist/diff/bridge-ast-gradient.d.ts.map +1 -1
  698. package/dist/diff/bridge-ast-gradient.js +16 -23
  699. package/dist/diff/bridge-ast-gradient.js.map +1 -1
  700. package/dist/diff/bridge-gradient.d.ts +24 -80
  701. package/dist/diff/bridge-gradient.d.ts.map +1 -1
  702. package/dist/diff/bridge-gradient.js +21 -98
  703. package/dist/diff/bridge-gradient.js.map +1 -1
  704. package/dist/diff/bridge-specs.d.ts +18 -6
  705. package/dist/diff/bridge-specs.d.ts.map +1 -1
  706. package/dist/diff/bridge-specs.js +17 -5
  707. package/dist/diff/bridge-specs.js.map +1 -1
  708. package/dist/dimensional/algebra.js.map +1 -1
  709. package/dist/dimensional/ast-builders.d.ts +5 -4
  710. package/dist/dimensional/ast-builders.d.ts.map +1 -1
  711. package/dist/dimensional/ast-builders.js +6 -5
  712. package/dist/dimensional/ast-builders.js.map +1 -1
  713. package/dist/dimensional/ast-types.js.map +1 -1
  714. package/dist/dimensional/bridge-check.d.ts.map +1 -1
  715. package/dist/dimensional/bridge-check.js +3 -5
  716. package/dist/dimensional/bridge-check.js.map +1 -1
  717. package/dist/dimensional/buckingham.js.map +1 -1
  718. package/dist/dimensional/connection-validators.d.ts +2 -1
  719. package/dist/dimensional/connection-validators.d.ts.map +1 -1
  720. package/dist/dimensional/connection-validators.js.map +1 -1
  721. package/dist/dimensional/connection.js.map +1 -1
  722. package/dist/dimensional/constant-rows.d.ts +54 -0
  723. package/dist/dimensional/constant-rows.d.ts.map +1 -0
  724. package/dist/dimensional/constant-rows.js +115 -0
  725. package/dist/dimensional/constant-rows.js.map +1 -0
  726. package/dist/dimensional/constants.d.ts +7 -17
  727. package/dist/dimensional/constants.d.ts.map +1 -1
  728. package/dist/dimensional/constants.js +12 -21
  729. package/dist/dimensional/constants.js.map +1 -1
  730. package/dist/dimensional/curvature-composite.js.map +1 -1
  731. package/dist/dimensional/curvature-invariants.js.map +1 -1
  732. package/dist/dimensional/curvature.js.map +1 -1
  733. package/dist/dimensional/dimension-inference.js.map +1 -1
  734. package/dist/dimensional/dimension-spec.d.ts +21 -6
  735. package/dist/dimensional/dimension-spec.d.ts.map +1 -1
  736. package/dist/dimensional/dimension-spec.js +150 -160
  737. package/dist/dimensional/dimension-spec.js.map +1 -1
  738. package/dist/dimensional/einstein-equation.js.map +1 -1
  739. package/dist/dimensional/errors.d.ts +3 -1
  740. package/dist/dimensional/errors.d.ts.map +1 -1
  741. package/dist/dimensional/errors.js +2 -2
  742. package/dist/dimensional/errors.js.map +1 -1
  743. package/dist/dimensional/exact-scale.d.ts +79 -0
  744. package/dist/dimensional/exact-scale.d.ts.map +1 -0
  745. package/dist/dimensional/exact-scale.js +222 -0
  746. package/dist/dimensional/exact-scale.js.map +1 -0
  747. package/dist/dimensional/field-equation-helpers.js.map +1 -1
  748. package/dist/dimensional/formula-names.d.ts +13 -12
  749. package/dist/dimensional/formula-names.d.ts.map +1 -1
  750. package/dist/dimensional/formula-names.js +28 -51
  751. package/dist/dimensional/formula-names.js.map +1 -1
  752. package/dist/dimensional/fresh-label.js.map +1 -1
  753. package/dist/dimensional/friedmann-equation.d.ts +3 -3
  754. package/dist/dimensional/friedmann-equation.js +3 -3
  755. package/dist/dimensional/friedmann-equation.js.map +1 -1
  756. package/dist/dimensional/gauge-field.d.ts +2 -3
  757. package/dist/dimensional/gauge-field.d.ts.map +1 -1
  758. package/dist/dimensional/gauge-field.js +0 -1
  759. package/dist/dimensional/gauge-field.js.map +1 -1
  760. package/dist/dimensional/hyphen-names.d.ts.map +1 -1
  761. package/dist/dimensional/hyphen-names.js +8 -0
  762. package/dist/dimensional/hyphen-names.js.map +1 -1
  763. package/dist/dimensional/killing-validators.js.map +1 -1
  764. package/dist/dimensional/klein-gordon-equation.js.map +1 -1
  765. package/dist/dimensional/metric-validators.d.ts +2 -1
  766. package/dist/dimensional/metric-validators.d.ts.map +1 -1
  767. package/dist/dimensional/metric-validators.js.map +1 -1
  768. package/dist/dimensional/metric.js.map +1 -1
  769. package/dist/dimensional/natural-units.js.map +1 -1
  770. package/dist/dimensional/quantity-registry.d.ts +23 -1
  771. package/dist/dimensional/quantity-registry.d.ts.map +1 -1
  772. package/dist/dimensional/quantity-registry.js +55 -18
  773. package/dist/dimensional/quantity-registry.js.map +1 -1
  774. package/dist/dimensional/rg-flow.js.map +1 -1
  775. package/dist/dimensional/stress-energy-validators.js.map +1 -1
  776. package/dist/dimensional/symbolic-constants.d.ts +63 -19
  777. package/dist/dimensional/symbolic-constants.d.ts.map +1 -1
  778. package/dist/dimensional/symbolic-constants.js +114 -92
  779. package/dist/dimensional/symbolic-constants.js.map +1 -1
  780. package/dist/dimensional/tensor-trace.js.map +1 -1
  781. package/dist/dimensional/tensor.js.map +1 -1
  782. package/dist/dimensional/types.js.map +1 -1
  783. package/dist/dimensional/unit-convention.d.ts +0 -2
  784. package/dist/dimensional/unit-convention.d.ts.map +1 -1
  785. package/dist/dimensional/unit-convention.js +2 -2
  786. package/dist/dimensional/unit-convention.js.map +1 -1
  787. package/dist/dimensional/unit-data.d.ts +70 -0
  788. package/dist/dimensional/unit-data.d.ts.map +1 -0
  789. package/dist/dimensional/unit-data.js +139 -0
  790. package/dist/dimensional/unit-data.js.map +1 -0
  791. package/dist/dimensional/units.d.ts +87 -24
  792. package/dist/dimensional/units.d.ts.map +1 -1
  793. package/dist/dimensional/units.js +290 -295
  794. package/dist/dimensional/units.js.map +1 -1
  795. package/dist/dimensional/validator-registry.js.map +1 -1
  796. package/dist/dimensional/validator.d.ts +0 -16
  797. package/dist/dimensional/validator.d.ts.map +1 -1
  798. package/dist/dimensional/validator.js +65 -29
  799. package/dist/dimensional/validator.js.map +1 -1
  800. package/dist/dimensional/weyl-validators.js.map +1 -1
  801. package/dist/index.d.ts +65 -18
  802. package/dist/index.d.ts.map +1 -1
  803. package/dist/index.js +19 -24
  804. package/dist/index.js.map +1 -1
  805. package/dist/numerical/bianchi-residual.js.map +1 -1
  806. package/dist/numerical/binding-value.d.ts +32 -7
  807. package/dist/numerical/binding-value.d.ts.map +1 -1
  808. package/dist/numerical/binding-value.js +218 -209
  809. package/dist/numerical/binding-value.js.map +1 -1
  810. package/dist/numerical/christoffel-flat.js.map +1 -1
  811. package/dist/numerical/connection-lowering-helpers.js.map +1 -1
  812. package/dist/numerical/covariant-eikonal.d.ts.map +1 -1
  813. package/dist/numerical/covariant-eikonal.js +2 -2
  814. package/dist/numerical/covariant-eikonal.js.map +1 -1
  815. package/dist/numerical/curvature-lowering-helpers.d.ts +20 -0
  816. package/dist/numerical/curvature-lowering-helpers.d.ts.map +1 -1
  817. package/dist/numerical/curvature-lowering-helpers.js +6 -3
  818. package/dist/numerical/curvature-lowering-helpers.js.map +1 -1
  819. package/dist/numerical/derivative-lowering.js.map +1 -1
  820. package/dist/numerical/einstein-equation.js.map +1 -1
  821. package/dist/numerical/engine-registry.js.map +1 -1
  822. package/dist/numerical/errors.d.ts +7 -3
  823. package/dist/numerical/errors.d.ts.map +1 -1
  824. package/dist/numerical/errors.js +5 -5
  825. package/dist/numerical/errors.js.map +1 -1
  826. package/dist/numerical/evaluator-uncertainty.d.ts +34 -0
  827. package/dist/numerical/evaluator-uncertainty.d.ts.map +1 -0
  828. package/dist/numerical/evaluator-uncertainty.js +134 -0
  829. package/dist/numerical/evaluator-uncertainty.js.map +1 -0
  830. package/dist/numerical/formula-contract.d.ts +67 -7
  831. package/dist/numerical/formula-contract.d.ts.map +1 -1
  832. package/dist/numerical/formula-contract.js +68 -42
  833. package/dist/numerical/formula-contract.js.map +1 -1
  834. package/dist/numerical/formula-dimension.d.ts +17 -7
  835. package/dist/numerical/formula-dimension.d.ts.map +1 -1
  836. package/dist/numerical/formula-dimension.js +120 -44
  837. package/dist/numerical/formula-dimension.js.map +1 -1
  838. package/dist/numerical/formula-mathts.d.ts.map +1 -1
  839. package/dist/numerical/formula-mathts.js +10 -3
  840. package/dist/numerical/formula-mathts.js.map +1 -1
  841. package/dist/numerical/formula-registry.d.ts +13 -3
  842. package/dist/numerical/formula-registry.d.ts.map +1 -1
  843. package/dist/numerical/formula-registry.js +7 -2
  844. package/dist/numerical/formula-registry.js.map +1 -1
  845. package/dist/numerical/geodesic-integrator.js.map +1 -1
  846. package/dist/numerical/geometrized.js.map +1 -1
  847. package/dist/numerical/gl4-integrator.d.ts +28 -27
  848. package/dist/numerical/gl4-integrator.d.ts.map +1 -1
  849. package/dist/numerical/gl4-integrator.js +44 -45
  850. package/dist/numerical/gl4-integrator.js.map +1 -1
  851. package/dist/numerical/grid-field.js.map +1 -1
  852. package/dist/numerical/index.js.map +1 -1
  853. package/dist/numerical/input-validation.d.ts +3 -6
  854. package/dist/numerical/input-validation.d.ts.map +1 -1
  855. package/dist/numerical/input-validation.js +4 -8
  856. package/dist/numerical/input-validation.js.map +1 -1
  857. package/dist/numerical/killing.d.ts +8 -5
  858. package/dist/numerical/killing.d.ts.map +1 -1
  859. package/dist/numerical/killing.js.map +1 -1
  860. package/dist/numerical/klein-gordon.js.map +1 -1
  861. package/dist/numerical/kretschmann.js.map +1 -1
  862. package/dist/numerical/lowering-utils.js.map +1 -1
  863. package/dist/numerical/lowering.d.ts.map +1 -1
  864. package/dist/numerical/lowering.js +7 -17
  865. package/dist/numerical/lowering.js.map +1 -1
  866. package/dist/numerical/mathts-engine.d.ts.map +1 -1
  867. package/dist/numerical/mathts-engine.js +11 -6
  868. package/dist/numerical/mathts-engine.js.map +1 -1
  869. package/dist/numerical/metric-inverse.js.map +1 -1
  870. package/dist/numerical/null-ic.js.map +1 -1
  871. package/dist/numerical/null-ray-integrator.js +4 -4
  872. package/dist/numerical/null-ray-integrator.js.map +1 -1
  873. package/dist/numerical/painleve-gullstrand-metric.js.map +1 -1
  874. package/dist/numerical/pderiv.d.ts.map +1 -1
  875. package/dist/numerical/pderiv.js +9 -2
  876. package/dist/numerical/pderiv.js.map +1 -1
  877. package/dist/numerical/perihelion-finder.js.map +1 -1
  878. package/dist/numerical/quadrature.d.ts +5 -2
  879. package/dist/numerical/quadrature.d.ts.map +1 -1
  880. package/dist/numerical/quadrature.js +20 -3
  881. package/dist/numerical/quadrature.js.map +1 -1
  882. package/dist/numerical/spacetime-metrics.d.ts +17 -19
  883. package/dist/numerical/spacetime-metrics.d.ts.map +1 -1
  884. package/dist/numerical/spacetime-metrics.js +158 -250
  885. package/dist/numerical/spacetime-metrics.js.map +1 -1
  886. package/dist/numerical/strides.js.map +1 -1
  887. package/dist/numerical/tensor-engine.d.ts +9 -5
  888. package/dist/numerical/tensor-engine.d.ts.map +1 -1
  889. package/dist/numerical/tensor-engine.js.map +1 -1
  890. package/dist/numerical/types.js.map +1 -1
  891. package/dist/numerical/weyl-lowering.js.map +1 -1
  892. package/dist/relations/category.js.map +1 -1
  893. package/dist/relations/composition-table.d.ts +4 -4
  894. package/dist/relations/composition-table.js +4 -4
  895. package/dist/relations/composition-table.js.map +1 -1
  896. package/dist/relations/conventions.js.map +1 -1
  897. package/dist/relations/domain-regimes.js.map +1 -1
  898. package/dist/relations/regime-registration.js.map +1 -1
  899. package/dist/relations/regime-vocabularies.js.map +1 -1
  900. package/dist/relations/regime.d.ts +18 -8
  901. package/dist/relations/regime.d.ts.map +1 -1
  902. package/dist/relations/regime.js +26 -14
  903. package/dist/relations/regime.js.map +1 -1
  904. package/dist/relations/types.d.ts +26 -6
  905. package/dist/relations/types.d.ts.map +1 -1
  906. package/dist/relations/types.js +15 -3
  907. package/dist/relations/types.js.map +1 -1
  908. package/package.json +10 -14
  909. package/dist/bridges/registry.d.ts +0 -60
  910. package/dist/bridges/registry.d.ts.map +0 -1
  911. package/dist/bridges/registry.js +0 -87
  912. package/dist/bridges/registry.js.map +0 -1
  913. package/dist/cli/poster-source.d.ts +0 -154
  914. package/dist/cli/poster-source.d.ts.map +0 -1
  915. package/dist/cli/poster-source.js +0 -184
  916. package/dist/cli/poster-source.js.map +0 -1
@@ -21,27 +21,32 @@
21
21
  * wins on a bare token, so `ms` stays a millisecond, `mm` a millimetre,
22
22
  * `mK` a millikelvin, and `Ts` a terasecond. Inside a larger expression the
23
23
  * prefixed reading competes with a heterogeneous product (`mK` is millikelvin
24
- * or metre·kelvin; `ms` is millisecond or metre·second). A homogeneous power
25
- * does not compete (`mm` is a millimetre, not metre·metre). `parseUnit` names
24
+ * or metre·kelvin; `ms` is millisecond or metre·second). A split that puts
25
+ * a prefix letter's own unit twice in a row is never a reading, because a
26
+ * power is written `m2` or `m^2`: `mm` is a millimetre, not metre·metre,
27
+ * and `mmin` is metre·minute or millimetre·inch, not metre·metre·inch.
28
+ * A unit that is not a prefix letter still juxtaposes with itself (`NN` is
29
+ * N·N). `parseUnit` names
26
30
  * every remaining reading and refuses. `convertValue` keeps the one reading
27
31
  * whose dimension is the declared unit. A token that is not one factor is a
28
32
  * product when exactly one split exists: `m2K` is `m^2·K`, `Vs` is `V·s`,
29
33
  * and `cm^2/Vs` is `cm^2/(V·s)`. Zero splits are an unknown unit. Two or more
30
34
  * splits name each reading and are refused (`mAs` is milliampere·second or
31
35
  * metre·ampere·second). An unknown token that ends in a digit stays unknown
32
- * when it is not that product.
33
- * `AU` is the same exact metre count as `au`. `Msun` is `M_SUN_SI` kilograms; `Msun_iau` is
34
- * `GM_SUN_SI / G_SI`. `myr` is a milliyear because `m` is the SI prefix.
35
- * `eV` takes an SI prefix, so `GeV` is 10⁹ eV in joules. `nat` is the
36
- * coherent information unit (scale 1); `bit` is ln 2 nat. Neither takes a
37
- * prefix.
36
+ * when it is not that product. A numerator that is the single token `1` is
37
+ * the dimensionless unit, so `1/s` is a reciprocal second and `1/m^3` a
38
+ * number density; `1` is not a symbol anywhere else.
39
+ * The table is data: `data/units.json`, loaded and validated by
40
+ * `unit-data.ts`. Every row, prefix, refused spelling, prefix letter, affine
41
+ * scale and spelling note is a row there, with the reason as its `comment`;
42
+ * this module holds the grammar. `myr` is a milliyear because `m` is the SI
43
+ * prefix, and `eV` takes one, so `GeV` is 10⁹ eV in joules.
38
44
  *
39
45
  * @module dimensional/units
40
46
  */
41
- import { toSiDimensionVector } from '@danielsimonjr/mathts-core';
42
- import { unit } from '@danielsimonjr/mathts-functions';
43
47
  import { equals, format, multiply, power } from './algebra.js';
44
- import { C_SI, E_SI, G_SI, GM_SUN_SI, M_SUN_SI } from '../core/constants.js';
48
+ import { addScales, decimalScale, divideScales, multiplyScales, powerScale, ratioScale, scaleToNumber, solidusSides, UNIT_SCALE, } from './exact-scale.js';
49
+ import { UNIT_DATA } from './unit-data.js';
45
50
  /** Thrown for any input that does not parse as a value with a known unit. @public */
46
51
  export class UnitError extends Error {
47
52
  constructor(message) {
@@ -49,126 +54,93 @@ export class UnitError extends Error {
49
54
  this.name = 'UnitError';
50
55
  }
51
56
  }
57
+ /** A symbol no table row and no prefix spells. @public */
58
+ export class UnknownUnitError extends UnitError {
59
+ symbol;
60
+ constructor(symbol) {
61
+ super(`unknown unit '${symbol}'`);
62
+ this.symbol = symbol;
63
+ this.name = 'UnknownUnitError';
64
+ }
65
+ }
66
+ /**
67
+ * A unit the reader recognizes and refuses: a logarithmic or ratio unit, an
68
+ * ambiguous name such as `ton`, or an affine temperature inside a compound.
69
+ * @public
70
+ */
71
+ export class UnitRefusedError extends UnitError {
72
+ constructor(message) {
73
+ super(message);
74
+ this.name = 'UnitRefusedError';
75
+ }
76
+ }
77
+ /** A unit expression with more than one dimensionally distinct reading. @public */
78
+ export class AmbiguousUnitError extends UnitError {
79
+ text;
80
+ readings;
81
+ constructor(text, readings) {
82
+ super(`'${text}' is ambiguous: ${readings.join(' or ')}`);
83
+ this.text = text;
84
+ this.readings = readings;
85
+ this.name = 'AmbiguousUnitError';
86
+ }
87
+ }
52
88
  const D = (p) => ({ L: 0, M: 0, T: 0, I: 0, Theta: 0, N: 0, J: 0, ...p });
53
- const JOULE = D({ L: 2, M: 1, T: -2 });
54
89
  const DIMENSIONLESS = D({});
55
- /** symbol → [scale to SI base, dimension, takes an SI prefix]. */
56
- const UNITS = new Map([
57
- ['m', [1, D({ L: 1 }), true]],
58
- ['g', [1e-3, D({ M: 1 }), true]],
59
- ['s', [1, D({ T: 1 }), true]],
60
- ['K', [1, D({ Theta: 1 }), true]],
61
- ['A', [1, D({ I: 1 }), true]],
62
- ['mol', [1, D({ N: 1 }), true]],
63
- ['Hz', [1, D({ T: -1 }), true]],
64
- ['N', [1, D({ L: 1, M: 1, T: -2 }), true]],
65
- ['Pa', [1, D({ L: -1, M: 1, T: -2 }), true]],
66
- ['J', [1, JOULE, true]],
67
- ['W', [1, D({ L: 2, M: 1, T: -3 }), true]],
68
- ['C', [1, D({ T: 1, I: 1 }), true]],
69
- ['V', [1, D({ L: 2, M: 1, T: -3, I: -1 }), true]],
70
- ['ohm', [1, D({ L: 2, M: 1, T: -3, I: -2 }), true]],
71
- ['Ω', [1, D({ L: 2, M: 1, T: -3, I: -2 }), true]],
72
- ['S', [1, D({ L: -2, M: -1, T: 3, I: 2 }), true]],
73
- ['F', [1, D({ L: -2, M: -1, T: 4, I: 2 }), true]],
74
- ['eV', [E_SI, JOULE, true]],
75
- // Information. A nat is the coherent dimensionless unit; a bit is ln 2 nat.
76
- // Exact, so neither takes a prefix (`kbit` is not a kilobit).
77
- ['nat', [1, DIMENSIONLESS, false]],
78
- ['bit', [Math.LN2, DIMENSIONLESS, false]],
79
- ['rad', [1, DIMENSIONLESS, true]],
80
- ['deg', [Math.PI / 180, DIMENSIONLESS, false]],
81
- ['min', [60, D({ T: 1 }), false]],
82
- ['h', [3600, D({ T: 1 }), false]],
83
- ['d', [86400, D({ T: 1 }), false]],
84
- // The Julian year, the year the orbital evaluators take.
85
- ['yr', [365.25 * 86400, D({ T: 1 }), true]],
86
- ['au', [149597870700, D({ L: 1 }), false]],
87
- ['AU', [149597870700, D({ L: 1 }), false]],
88
- // The solar mass the evaluators use, not the IAU nominal value.
89
- ['Msun', [M_SUN_SI, D({ M: 1 }), false]],
90
- // GM☉/G, so G × Msun_iau is the IAU solar mass parameter.
91
- ['Msun_iau', [GM_SUN_SI / G_SI, D({ M: 1 }), false]],
92
- // Tesla. An exact `T` still wins over the tera prefix, so `Ts` is a
93
- // terasecond. The prefix flag is what lets `nT` and `uT` parse.
94
- ['T', [1, D({ M: 1, T: -2, I: -1 }), true]],
95
- // Gauss = 10⁻⁴ T. Exact, so `GPa` stays gigapascal (prefix G + Pa) and bare `G` is gauss.
96
- // The spelled name is the same unit. It does not take a prefix (`kgauss` is not a kilogauss).
97
- ['G', [1e-4, D({ M: 1, T: -2, I: -1 }), false]],
98
- ['gauss', [1e-4, D({ M: 1, T: -2, I: -1 }), false]],
99
- ['Gauss', [1e-4, D({ M: 1, T: -2, I: -1 }), false]],
100
- ['bar', [1e5, D({ L: -1, M: 1, T: -2 }), true]],
101
- ['atm', [101325, D({ L: -1, M: 1, T: -2 }), false]],
102
- ['angstrom', [1e-10, D({ L: 1 }), false]],
103
- ['Angstrom', [1e-10, D({ L: 1 }), false]],
104
- ['Å', [1e-10, D({ L: 1 }), false]],
105
- // IAU-style parsec; the prefix applies, so `Mpc` is a megaparsec.
106
- ['pc', [3.0856775814913673e16, D({ L: 1 }), true]],
107
- ['ly', [C_SI * 365.25 * 86400, D({ L: 1 }), false]],
108
- // CGPM 1964: 1 L = 1 dm³ = 10⁻³ m³ exactly. Prefixable, so mL is a millilitre.
109
- // `l` is the same litre. Bare `mL` stays the prefix; `mol/mL` competes with metre·litre.
110
- ['L', [1e-3, D({ L: 3 }), true]],
111
- ['l', [1e-3, D({ L: 3 }), true]],
112
- // Thermochemical calorie: 1 cal_th = 4.184 J exactly (NIST). Not cal_IT = 4.1868 J.
113
- // Prefixable, so kcal is 4184 J.
114
- ['cal', [4.184, JOULE, true]],
115
- // International Steam Table BTU: cal_IT × (lb/g) / (°F per 1.8 °C).
116
- // 4.1868 × 453.59237 / 1.8 J exactly. Not the thermochemical calorie.
117
- ['BTU', [(4.1868 * 453.59237) / 1.8, JOULE, false]],
118
- // psi = lbf/in². lbf = 0.45359237 kg × 9.80665 m/s² (1959 pound × standard gravity).
119
- // inch = 0.0254 m exactly.
120
- ['psi', [(0.45359237 * 9.80665) / (0.0254 * 0.0254), D({ L: -1, M: 1, T: -2 }), false]],
121
- // torr = 1/760 of a standard atmosphere = 101325/760 Pa exactly. Prefixable (mtorr).
122
- ['torr', [101325 / 760, D({ L: -1, M: 1, T: -2 }), true]],
123
- // Conventional millimetre of mercury, 133.322387415 Pa exactly (NIST SP 811).
124
- // Not the torr, and not `mm` × `Hg`.
125
- ['mmHg', [133.322387415, D({ L: -1, M: 1, T: -2 }), false]],
126
- // Poise = 0.1 Pa·s exactly. Prefixable, so cP = 10⁻³ Pa·s. Exact `P` wins over peta.
127
- ['P', [0.1, D({ L: -1, M: 1, T: -1 }), true]],
128
- // Rankine is proportional: K = °R × 5/9. Not affine.
129
- ['degR', [5 / 9, D({ Theta: 1 }), false]],
130
- ['°R', [5 / 9, D({ Theta: 1 }), false]],
131
- // Revolutions per minute = 1/60 Hz. Prefixable, so krpm is a kilorevolution per minute.
132
- ['rpm', [1 / 60, D({ T: -1 }), true]],
133
- // Mechanical horsepower = 550 ft·lbf/s. ft = 0.3048 m.
134
- ['hp', [550 * 0.3048 * 0.45359237 * 9.80665, D({ L: 2, M: 1, T: -3 }), false]],
135
- ]);
136
- const CELSIUS_OFFSET_K = 273.15;
137
- const FAHRENHEIT_SCALE = 5 / 9;
138
- /** Lone spellings. A compound that contains one is refused. */
139
- const AFFINE = [
140
- { id: 'celsius', scale: 1, offset: CELSIUS_OFFSET_K, symbols: ['degC', '°C'] },
141
- {
142
- id: 'fahrenheit',
143
- scale: FAHRENHEIT_SCALE,
144
- offset: CELSIUS_OFFSET_K - 32 * FAHRENHEIT_SCALE,
145
- symbols: ['degF', '°F'],
146
- },
147
- ];
90
+ /** symbol → exact scale to SI base, dimension, prefixability, cycle count. Rows are `data/units.json`. */
91
+ const UNITS = UNIT_DATA.units;
92
+ /** Units that are a ratio or a log scale, and the reason each is not a plain factor. */
93
+ const REFUSED_UNITS = UNIT_DATA.refused;
94
+ /**
95
+ * Letters that are both an SI prefix and a unit of their own. Such a token
96
+ * reads as the prefix reading and not as the unit times the rest: `Gyr` is a
97
+ * gigayear. The file's `prefixLetterUnits.comment` says why `m` is not one.
98
+ */
99
+ const PREFIX_LETTER_UNITS = UNIT_DATA.prefixLetterUnits;
100
+ /** Kelvin at 0 °C, exactly. */
101
+ const CELSIUS_OFFSET_K = UNIT_DATA.iceKelvin;
102
+ /**
103
+ * Lone spellings. A compound that contains one is refused. The schema's `id`
104
+ * enum is {@link AffineTemperature}, held equal by a test: the public type
105
+ * promises callers these ids, so a new affine scale is an API change.
106
+ */
107
+ const AFFINE = UNIT_DATA.affine;
108
+ /** Kelvin at a reading of zero, exactly: 273.15 − icePoint × scale. */
109
+ function affineOffset(row) {
110
+ return addScales(CELSIUS_OFFSET_K, multiplyScales(ratioScale(-1, 1), row.icePoint, row.scale));
111
+ }
112
+ const fractionText = (s) => (s.den === 1n ? String(s.num) : `${s.num}/${s.den}`);
113
+ /**
114
+ * How a reading on an affine scale becomes kelvin, from the row's scale and
115
+ * ice point: `absolute: (degF − 32) × 5/9 + 273.15`, `a difference: × 5/9, no offset`.
116
+ * @internal
117
+ */
118
+ export function affineReadingNote(affine, reading) {
119
+ const row = AFFINE.find((candidate) => candidate.id === affine);
120
+ const unitScale = row.scale.num === row.scale.den;
121
+ if (reading === 'difference')
122
+ return unitScale ? 'a difference: no offset' : `a difference: × ${fractionText(row.scale)}, no offset`;
123
+ const kelvin = String(scaleToNumber(CELSIUS_OFFSET_K));
124
+ if (unitScale && row.icePoint.num === 0n)
125
+ return `absolute: + ${kelvin}`;
126
+ const shifted = row.icePoint.num === 0n ? row.symbols[0] : `(${row.symbols[0]} − ${fractionText(row.icePoint)})`;
127
+ return `absolute: ${unitScale ? shifted : `${shifted} × ${fractionText(row.scale)}`} + ${kelvin}`;
128
+ }
148
129
  function affineRow(text) {
149
- return AFFINE.find((row) => row.symbols.includes(text));
150
- }
151
- const PREFIXES = new Map([
152
- ['Y', 1e24], ['Z', 1e21], ['E', 1e18], ['P', 1e15], ['T', 1e12], ['G', 1e9], ['M', 1e6], ['k', 1e3],
153
- ['h', 1e2], ['da', 1e1], ['d', 1e-1], ['c', 1e-2], ['m', 1e-3], ['u', 1e-6], ['µ', 1e-6], ['μ', 1e-6],
154
- ['n', 1e-9], ['p', 1e-12], ['f', 1e-15], ['a', 1e-18], ['z', 1e-21], ['y', 1e-24],
155
- ]);
156
- function parseSymbol(sym) {
157
- const parsed = trySymbol(sym);
158
- if (parsed !== null)
159
- return parsed;
160
- throw new UnitError(`unknown unit '${sym}'`);
130
+ return AFFINE.find((candidate) => candidate.symbols.includes(text));
161
131
  }
132
+ const PREFIXES = UNIT_DATA.prefixes;
162
133
  function trySymbol(sym) {
163
134
  const exact = UNITS.get(sym);
164
135
  if (exact !== undefined)
165
- return [exact[0], exact[1]];
136
+ return { scale: exact.scale, dim: exact.dim, cycles: exact.cycles === true ? 1 : 0 };
166
137
  for (const [p, f] of PREFIXES) {
167
138
  if (!sym.startsWith(p) || sym.length === p.length)
168
139
  continue;
169
140
  const base = UNITS.get(sym.slice(p.length));
170
- if (base !== undefined && base[2])
171
- return [f * base[0], base[1]];
141
+ if (base !== undefined && base.prefixable) {
142
+ return { scale: multiplyScales(f, base.scale), dim: base.dim, cycles: base.cycles === true ? 1 : 0 };
143
+ }
172
144
  }
173
145
  return null;
174
146
  }
@@ -182,7 +154,7 @@ function tryOneFactor(token) {
182
154
  exp = Number(caret[2]);
183
155
  }
184
156
  else {
185
- const uni = /^(.*?)([¹²³])$/.exec(token);
157
+ const uni = /^(.*?)(⁻?[¹²³])$/.exec(token);
186
158
  const superExp = uni === null ? undefined : SUPERSCRIPT[uni[2]];
187
159
  if (uni !== null && superExp !== undefined && uni[1].length > 0) {
188
160
  base = uni[1];
@@ -199,7 +171,7 @@ function tryOneFactor(token) {
199
171
  const parsed = trySymbol(base);
200
172
  if (parsed === null || !Number.isFinite(exp))
201
173
  return null;
202
- return { base, exp, scale: parsed[0], dim: parsed[1] };
174
+ return { base, exp, scale: parsed.scale, dim: parsed.dim, cycles: parsed.cycles };
203
175
  }
204
176
  function formatReading(factors) {
205
177
  return factors.map((factor) => (factor.exp === 1 ? factor.base : `${factor.base}^${factor.exp}`)).join('·');
@@ -212,24 +184,25 @@ function attachedUnit(symbol) {
212
184
  if (!symbol.startsWith(prefix) || symbol.length === prefix.length)
213
185
  continue;
214
186
  const base = symbol.slice(prefix.length);
215
- const row = UNITS.get(base);
216
- if (row !== undefined && row[2])
187
+ const unitRow = UNITS.get(base);
188
+ if (unitRow !== undefined && unitRow.prefixable)
217
189
  return base;
218
190
  }
219
191
  return null;
220
192
  }
221
193
  /**
222
- * A product of the same unprefixed unit the prefix attaches to (`mm` = m·m,
223
- * `mm2` = m·m²). Powers are written `m2` / `m^2`, so this reading does not
224
- * compete with the prefix.
194
+ * `X·X` where `XX` is X's own prefix spelling (`m·m` beside `mm`, `d·d`
195
+ * beside `dd`): not a split, because a power is written `X2` or `X^2`. A
196
+ * run of a unit that is not also a prefix letter (`N·N`) stays a product.
225
197
  */
226
- function homogeneousPower(single, product) {
227
- const unit = attachedUnit(single.base);
228
- if (unit === null)
229
- return false;
230
- return product.every((factor) => factor.base === unit && attachedUnit(factor.base) === null);
198
+ function prefixRun(last, next) {
199
+ return last.base === next.base && attachedUnit(last.base + next.base) === last.base;
231
200
  }
232
- /** Every way to split `token` into one or more factors. A one-factor token is included. */
201
+ /**
202
+ * Every way to split `token` into one or more factors. A one-factor token is
203
+ * included. A split that puts a prefix letter's own unit twice in a row
204
+ * (`m·m`, `m·m²`, `m·m·in`) is not a way, inside any split.
205
+ */
233
206
  function segmentations(token) {
234
207
  const ways = Array.from({ length: token.length + 1 }, () => []);
235
208
  ways[0].push([]);
@@ -240,8 +213,11 @@ function segmentations(token) {
240
213
  const factor = tryOneFactor(token.slice(i, j));
241
214
  if (factor === null)
242
215
  continue;
243
- for (const prev of ways[i])
216
+ for (const prev of ways[i]) {
217
+ if (prev.length > 0 && prefixRun(prev[prev.length - 1], factor))
218
+ continue;
244
219
  ways[j].push([...prev, factor]);
220
+ }
245
221
  }
246
222
  }
247
223
  const unique = new Map();
@@ -252,25 +228,35 @@ function segmentations(token) {
252
228
  /**
253
229
  * Ways to read one token. A bare expression keeps a one-factor reading and
254
230
  * does not also split it. Inside a compound, a prefixed factor also competes
255
- * with each heterogeneous product. A homogeneous power does not.
231
+ * with each heterogeneous product; `segmentations` has already dropped the
232
+ * homogeneous runs.
256
233
  */
257
- function tokenWays(token, compete) {
234
+ function tokenWays(token, compete, side) {
235
+ const refused = REFUSED_UNITS.get(token);
236
+ if (refused !== undefined)
237
+ throw new UnitRefusedError(refused);
258
238
  const single = tryOneFactor(token);
259
239
  if (single !== null && !compete)
260
240
  return [[single]];
261
- const products = segmentations(token).filter((way) => way.length > 1);
262
- const extra = single === null ? products : products.filter((way) => !homogeneousPower(single, way));
241
+ // A prefixed numerator token is the prefix reading: `mN/m` is millinewton per metre.
242
+ // A denominator keeps the product readings (`W/mK`), and a target dimension chooses.
243
+ if (single !== null && side === 'numerator')
244
+ return [[single]];
245
+ const prefixWins = single !== null && PREFIX_LETTER_UNITS.has(token[0]) && attachedUnit(single.base) !== null;
246
+ const products = segmentations(token)
247
+ .filter((way) => way.length > 1)
248
+ .filter(() => !prefixWins);
263
249
  const ways = [];
264
250
  if (single !== null)
265
251
  ways.push([single]);
266
- for (const way of extra)
252
+ for (const way of products)
267
253
  ways.push(way);
268
254
  const unique = new Map();
269
255
  for (const way of ways)
270
256
  unique.set(formatReading(way), way);
271
257
  const list = [...unique.values()];
272
258
  if (list.length === 0)
273
- throw new UnitError(`unknown unit '${token}'`);
259
+ throw new UnknownUnitError(token);
274
260
  return list;
275
261
  }
276
262
  function cartesian(lists) {
@@ -285,55 +271,82 @@ function cartesian(lists) {
285
271
  return acc;
286
272
  }
287
273
  function sideTokens(text) {
288
- return text.split(/[*·\s]+/).filter((part) => part.length > 0);
274
+ return text.split(/[*·\s]+|(?<=[A-Za-zµμΩ])\.(?=[A-Za-zµμΩ])/).filter((part) => part.length > 0);
289
275
  }
290
276
  function formatSide(tokens) {
291
277
  return tokens.map((factors) => formatReading(factors)).join('·');
292
278
  }
293
279
  function formatExpression(num, den) {
294
- const numerator = formatSide(num);
280
+ // An empty numerator over a denominator is the dimensionless 1: `1/s`.
281
+ const numerator = num.length === 0 ? '1' : formatSide(num);
295
282
  if (den.length === 0)
296
283
  return numerator;
297
284
  const denominator = formatSide(den);
298
285
  return denominator.includes('·') ? `${numerator}/(${denominator})` : `${numerator}/${denominator}`;
299
286
  }
300
287
  function accumulate(tokens, sign) {
301
- let scale = 1;
288
+ let scale = UNIT_SCALE;
302
289
  let dim = DIMENSIONLESS;
290
+ let cycles = 0;
303
291
  for (const factors of tokens) {
304
292
  for (const factor of factors) {
305
293
  const n = sign * factor.exp;
306
- scale *= factor.scale ** n;
294
+ scale = multiplyScales(scale, powerScale(factor.scale, n));
307
295
  dim = multiply(dim, power(factor.dim, n));
296
+ cycles += factor.cycles * n;
308
297
  }
309
298
  }
310
- return { scale, dim };
299
+ return { scale, dim, cycles };
300
+ }
301
+ function reading(exact, dim, label, cycles, affine) {
302
+ return {
303
+ scale: scaleToNumber(exact),
304
+ exact,
305
+ dim,
306
+ label,
307
+ cycles,
308
+ ...(affine === undefined ? {} : { affine }),
309
+ };
311
310
  }
312
- /** Every dimensionally distinct spelling of one unit expression. */
311
+ /**
312
+ * Every dimensionally distinct reading of one unit expression.
313
+ *
314
+ * The unit grammar is not the formula grammar, and the difference is
315
+ * deliberate: a unit symbol is not an identifier (a prefix, a glued product
316
+ * or a glued power lives inside one token: `mN`, `m2K`, `Vs`, `K²`, `°C`,
317
+ * `%`), and everything after the first `/` is the denominator, the
318
+ * single-solidus convention of ISO 80000-1 (`W/m*K` is W·m⁻¹·K⁻¹), where the
319
+ * formula grammar would read `(W/m)·K`.
320
+ * @internal
321
+ */
313
322
  function unitReadings(text) {
314
323
  const t = text.trim();
315
324
  if (t === '' || t === '1')
316
- return [{ scale: 1, dim: DIMENSIONLESS, label: '1' }];
325
+ return [reading(UNIT_SCALE, DIMENSIONLESS, '1', 0)];
317
326
  const affine = affineRow(t);
318
- if (affine !== undefined) {
319
- return [{ scale: affine.scale, dim: D({ Theta: 1 }), affine: affine.id, label: t }];
320
- }
321
- if (AFFINE.some((row) => row.symbols.some((symbol) => t.includes(symbol))) ||
327
+ if (affine !== undefined)
328
+ return [reading(affine.scale, D({ Theta: 1 }), t, 0, affine.id)];
329
+ if (AFFINE.some((candidate) => candidate.symbols.some((symbol) => t.includes(symbol))) ||
322
330
  /deg\s+[CFcf]|°\s*[CFcf]/.test(t)) {
323
- throw new UnitError('an affine temperature cannot be part of a compound unit; give K');
331
+ throw new UnitRefusedError('an affine temperature cannot be part of a compound unit; give K');
324
332
  }
325
- const parts = t.split('/');
326
- if (parts.length > 2)
327
- throw new UnitError(`'${t}' has more than one '/'; put the whole denominator after one '/'`);
333
+ // An operator with nothing on one side (`m/`, `m//s`, `m*`, `*m`, `m/*s`) is not a unit
334
+ // text; it was read as if the empty factor were 1 (Tom's second round). A leading `/`
335
+ // (`/s`) stays the dimensionless numerator.
336
+ if (/[*·/]\s*$|^\s*[*·]|[*·/]\s*[*·/]/.test(t))
337
+ throw new UnknownUnitError(t);
338
+ // A chain is one denominator: `km/s/Mpc` is km/(s·Mpc), the way the Hubble constant is written.
339
+ const sides = solidusSides(t);
328
340
  const compete = /[*·/\s]/.test(t);
329
- const numerator = sideTokens(parts[0]);
330
- const denominatorText = parts.length === 1 ? '' : parts[1].replace(/^\((.*)\)$/, '$1');
331
- const denominator = denominatorText === '' ? [] : sideTokens(denominatorText);
341
+ const numeratorTokens = sideTokens(sides.numerator);
342
+ // A numerator that is the single token `1` is the dimensionless unit: `1/s`, `1/m^3`.
343
+ const numerator = numeratorTokens.length === 1 && numeratorTokens[0] === '1' ? [] : numeratorTokens;
344
+ const denominator = sides.denominator === '' ? [] : sideTokens(sides.denominator);
332
345
  // `/s` is a dimensionless numerator over seconds. A bare `/` is not a unit.
333
346
  if (numerator.length === 0 && denominator.length === 0)
334
- throw new UnitError(`unknown unit '${t}'`);
335
- const numWays = numerator.map((token) => tokenWays(token, compete));
336
- const denWays = denominator.map((token) => tokenWays(token, compete));
347
+ throw new UnknownUnitError(t);
348
+ const numWays = numerator.map((token) => tokenWays(token, compete, 'numerator'));
349
+ const denWays = denominator.map((token) => tokenWays(token, compete, 'denominator'));
337
350
  const numCombos = numerator.length === 0 ? [[]] : cartesian(numWays);
338
351
  const denCombos = denominator.length === 0 ? [[]] : cartesian(denWays);
339
352
  const unique = new Map();
@@ -342,180 +355,162 @@ function unitReadings(text) {
342
355
  const n = accumulate(num, 1);
343
356
  const d = accumulate(den, -1);
344
357
  const label = formatExpression(num, den);
345
- unique.set(label, { scale: n.scale * d.scale, dim: multiply(n.dim, d.dim), label });
358
+ unique.set(label, reading(multiplyScales(n.scale, d.scale), multiply(n.dim, d.dim), label, n.cycles + d.cycles));
346
359
  }
347
360
  }
348
361
  return [...unique.values()];
349
362
  }
350
- function ambiguousMessage(text, readings) {
351
- return `'${text}' is ambiguous: ${readings.map((reading) => reading.label).join(' or ')}`;
352
- }
353
- const SUPERSCRIPT = { '¹': 1, '²': 2, '³': 3 };
363
+ const SUPERSCRIPT = { '¹': 1, '²': 2, '³': 3, '⁻¹': -1, '⁻²': -2, '⁻³': -3 };
354
364
  /**
355
- * Spellings that convert correctly and still mean something else to a reader.
356
- * `myr` is a milliyear, `Msun` is `M_SUN_SI`, bare `G` is the gauss, bare `T`
357
- * is the tesla, and bare `A` is the ampere rather than the angstrom.
365
+ * Spellings that convert correctly and still mean something else to a reader:
366
+ * the `spellingNotes` of `data/units.json` for each symbol in `given`, in file
367
+ * order. `myr` is a milliyear, bare `G` is the gauss, bare `A` the ampere.
358
368
  * @internal
359
369
  */
360
370
  export function unitConventionNotes(given) {
361
- const notes = [];
362
- const symbols = given.split(/[*·/\s^0-9()+-]+/).filter((s) => s.length > 0);
363
- if (symbols.includes('myr')) {
364
- notes.push('myr is a milliyear (the SI prefix m on yr = 0.001 yr), not a million years; a million years is Myr');
365
- }
366
- if (symbols.includes('Msun')) {
367
- notes.push(`Msun is ${M_SUN_SI} kg (M_SUN_SI), not GM☉/G; G×Msun is about 3.0e-4 high versus the IAU GM☉. Use the unit Msun_iau, or the eval name GM_sun, for GM_SUN_SI`);
368
- }
369
- if (symbols.includes('G'))
370
- notes.push('bare G is the gauss (1e-4 T); GPa is still a gigapascal');
371
- if (symbols.includes('T'))
372
- notes.push('bare T is the tesla; Ts is a terasecond');
373
- if (symbols.includes('A'))
374
- notes.push('bare A is the ampere, not the angstrom; write angstrom or Å for 10^-10 m');
375
- if (symbols.includes('P'))
376
- notes.push('bare P is the poise (0.1 Pa·s); PV is still a petavolt');
377
- return notes;
371
+ const symbols = new Set(given.split(/[*·/\s^0-9()+-]+/).filter((s) => s.length > 0));
372
+ return [...UNIT_DATA.spellingNotes].filter(([spelling]) => symbols.has(spelling)).map(([, note]) => note);
378
373
  }
379
- /** Parse a unit expression; the empty string is dimensionless. @public */
380
- export function parseUnit(text) {
374
+ /** The one reading of a unit expression; more than one is refused. @internal */
375
+ export function readUnit(text) {
381
376
  const t = text.trim();
382
377
  const readings = unitReadings(t);
383
378
  if (readings.length !== 1)
384
- throw new UnitError(ambiguousMessage(t, readings));
385
- const reading = readings[0];
386
- return {
387
- scale: reading.scale,
388
- dim: reading.dim,
389
- ...(reading.affine !== undefined ? { affine: reading.affine } : {}),
390
- };
379
+ throw new AmbiguousUnitError(t, readings.map((r) => r.label));
380
+ return readings[0];
391
381
  }
392
- /** Kelvin added when this affine unit is an absolute point. @internal */
393
- export function affineAbsoluteOffsetK(id) {
394
- const row = AFFINE.find((candidate) => candidate.id === id);
395
- if (row === undefined)
396
- throw new UnitError(`unknown affine temperature '${id}'`);
397
- return row.offset;
382
+ /** Parse a unit expression; the empty string is dimensionless. @public */
383
+ export function parseUnit(text) {
384
+ const r = readUnit(text);
385
+ return { scale: r.scale, dim: r.dim, ...(r.affine !== undefined ? { affine: r.affine } : {}) };
398
386
  }
399
- /** Kelvin from an affine or proportional reading. A difference drops the offset. */
400
- function kelvinFrom(value, unit, reading) {
387
+ /** The SI magnitude of `magnitude` in `unit`, exactly. An absolute affine reading adds its offset. */
388
+ function siMagnitude(magnitude, unit, temperature) {
389
+ const scaled = multiplyScales(magnitude, unit.exact);
401
390
  const row = unit.affine === undefined ? undefined : AFFINE.find((candidate) => candidate.id === unit.affine);
402
- const offset = row !== undefined && reading === 'absolute' ? row.offset : 0;
403
- return value * unit.scale + offset;
391
+ return row !== undefined && temperature === 'absolute' ? addScales(scaled, affineOffset(row)) : scaled;
392
+ }
393
+ const FRACTION = /^\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*\/\s*((?:\d+\.?\d*|\.\d+))\s*$/;
394
+ const NUMBER_THEN_REST = /^\s*([+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)\s*(.*?)\s*$/;
395
+ /**
396
+ * `raw` split into an exact decimal magnitude and the unit text after it, or
397
+ * null when `raw` is not a number followed by an optional unit. A plain
398
+ * fraction (`1/3`) is a number. Text that begins with an operator (`*h`,
399
+ * `·c`) is an expression, not a unit.
400
+ * @internal
401
+ */
402
+ function splitQuantityLiteral(raw) {
403
+ const fraction = FRACTION.exec(raw);
404
+ if (fraction !== null) {
405
+ const den = decimalScale(fraction[2]);
406
+ if (den.num !== 0n)
407
+ return { magnitude: divideScales(decimalScale(fraction[1]), den), unit: '' };
408
+ }
409
+ const m = NUMBER_THEN_REST.exec(raw);
410
+ if (m === null)
411
+ return null;
412
+ const unit = m[2];
413
+ if (unit.startsWith('*') || unit.startsWith('·'))
414
+ return null;
415
+ const magnitude = decimalScale(m[1]);
416
+ return magnitude === null ? null : { magnitude, unit };
417
+ }
418
+ function finiteLiteral(raw, value) {
419
+ if (!Number.isFinite(value))
420
+ throw new UnitError(`'${raw}' is not a finite number`);
421
+ return value;
422
+ }
423
+ /**
424
+ * Read `raw` as one number with an optional unit, in SI. Null when `raw` is
425
+ * not that form or names a unit no row spells, so the caller can read it as
426
+ * an expression. A refused unit and an ambiguous one throw. The value may be
427
+ * non-finite (`1e999`); the caller owns that refusal and its error class.
428
+ * @internal
429
+ */
430
+ export function readQuantityLiteral(raw, temperature = 'absolute') {
431
+ const literal = splitQuantityLiteral(raw);
432
+ if (literal === null)
433
+ return null;
434
+ if (literal.unit === '') {
435
+ return { value: scaleToNumber(literal.magnitude), dim: DIMENSIONLESS, unit: '', cycles: 0 };
436
+ }
437
+ let unit;
438
+ try {
439
+ unit = readUnit(literal.unit);
440
+ }
441
+ catch (error) {
442
+ if (error instanceof UnknownUnitError)
443
+ return null;
444
+ throw error;
445
+ }
446
+ return {
447
+ value: scaleToNumber(siMagnitude(literal.magnitude, unit, temperature)),
448
+ dim: unit.dim,
449
+ unit: literal.unit,
450
+ cycles: unit.cycles,
451
+ ...(unit.affine === undefined ? {} : { affine: unit.affine }),
452
+ };
404
453
  }
405
454
  /**
406
455
  * Convert `raw` (`<number>[unit]`) into `target` (a unit expression). A bare
407
456
  * number is taken to be in `target` already. The dimensions must agree.
408
457
  *
458
+ * The magnitude, the unit scales and the target scale are multiplied as
459
+ * exact rationals and rounded once, so `1 g/cm^3` in `kg/m^3` is 1000.
460
+ *
409
461
  * @returns the value in `target`, and the unit the user gave (`''` for none).
410
462
  * @public
411
463
  */
412
- export function convertValue(raw, target, reading = 'absolute') {
413
- const m = /^\s*([+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)\s*(.*?)\s*$/.exec(raw);
414
- if (m === null)
464
+ export function convertValue(raw, target, temperature = 'absolute') {
465
+ const literal = splitQuantityLiteral(raw);
466
+ if (literal === null)
415
467
  throw new UnitError(`'${raw}' is not a number with an optional unit`);
416
- const v = Number(m[1]);
417
- const given = m[2];
418
- if (!Number.isFinite(v))
419
- throw new UnitError(`'${raw}' is not a finite number`);
420
- if (given === '')
421
- return { value: v, given };
468
+ if (literal.unit === '')
469
+ return { value: finiteLiteral(raw, scaleToNumber(literal.magnitude)), given: '' };
470
+ const given = literal.unit;
422
471
  const readings = unitReadings(given);
423
- const to = parseUnit(target);
472
+ const to = readUnit(target);
424
473
  if (to.affine !== undefined)
425
474
  throw new UnitError(`a declared unit cannot be affine ('${target}')`);
426
475
  const matched = readings.filter((candidate) => equals(candidate.dim, to.dim));
427
476
  if (matched.length !== 1) {
428
477
  if (readings.length > 1)
429
- throw new UnitError(ambiguousMessage(given, readings));
478
+ throw new AmbiguousUnitError(given, readings.map((r) => r.label));
430
479
  const from = readings[0];
431
480
  if (from === undefined)
432
- throw new UnitError(`unknown unit '${given}'`);
481
+ throw new UnknownUnitError(given);
433
482
  throw new UnitError(`'${given}' is ${format(from.dim)}, but this input is ${format(to.dim)} (${target || 'dimensionless'})`);
434
483
  }
435
484
  const from = matched[0];
436
- const local = kelvinFrom(v, from, reading) / to.scale;
437
- // MathTS `unit` + `toSI` is the conversion when it reads the same quantity.
438
- // A temperature difference must not take the absolute offset `toSI` adds.
439
- // `bit` is ln 2 nat here; MathTS reads `bit` as 1. Symbols MathTS does not
440
- // have (a solar mass, a Julian year, the gauss) stay on the table above.
441
- const via = mathTsRatio(v, given, target);
442
- if (via !== undefined && sameQuantity(via, local))
443
- return { value: via, given };
444
- return { value: local, given };
445
- }
446
- /** Spellings MathTS's unit parser accepts for the same UPT symbol. */
447
- function mathTsSpelling(text) {
448
- return text
449
- .replaceAll('µ', 'u')
450
- .replaceAll('μ', 'u')
451
- .replaceAll('Ω', 'ohm')
452
- .replaceAll('Å', 'angstrom')
453
- .replaceAll('°C', 'degC');
454
- }
455
- /** The 7-base record for a MathTS length-10 exponent vector. Angle, bit, and solid angle are dropped. */
456
- function dimensionFromUnitVector(vector) {
457
- const v = toSiDimensionVector(vector, { ignoreExtra: true });
458
- return { L: v[0], M: v[1], T: v[2], I: v[3], Theta: v[4], N: v[5], J: v[6] };
459
- }
460
- function mathTsReading(value, unitText) {
461
- // `unit` is a typed-function; its declared return is `unknown`.
462
- const created = unit(value, mathTsSpelling(unitText));
463
- const n = Number(created.toSI().value);
464
- if (!Number.isFinite(n))
465
- throw new Error('non-finite SI magnitude');
466
- return { si: n, dim: dimensionFromUnitVector(created.dimensions) };
467
- }
468
- function mathTsRatio(value, given, target) {
469
- try {
470
- const from = mathTsReading(value, given);
471
- const to = mathTsReading(1, target);
472
- if (to.si === 0)
473
- return undefined;
474
- // A scale match is not enough when the 7-base dimensions differ.
475
- if (!equals(from.dim, parseUnit(given).dim))
476
- return undefined;
477
- if (!equals(to.dim, parseUnit(target).dim))
478
- return undefined;
479
- return from.si / to.si;
480
- }
481
- catch {
482
- return undefined;
483
- }
484
- }
485
- /**
486
- * MathTS's SI value for `magnitude` of `unitText`, when that value and the
487
- * 7-base dimension agree with `local`. Affine °C stays on the local offset.
488
- * A symbol MathTS lacks, or a scale it disagrees with (`bit` is 1 there and
489
- * ln 2 here; a solar mass, a Julian year, and the gauss are absent), returns
490
- * undefined so the caller keeps the local table.
491
- *
492
- * @internal
493
- */
494
- export function mathTsAgreedQuantity(magnitude, unitText, local) {
495
- if (local.affine !== undefined)
496
- return undefined;
497
- try {
498
- const read = mathTsReading(magnitude, unitText);
499
- if (!sameQuantity(read.si, magnitude * local.scale))
500
- return undefined;
501
- if (!equals(read.dim, local.dim))
502
- return undefined;
503
- return { value: read.si, dim: read.dim };
504
- }
505
- catch {
506
- return undefined;
507
- }
508
- }
509
- function sameQuantity(got, expected) {
510
- const scale = Math.max(Math.abs(got), Math.abs(expected));
511
- return Math.abs(got - expected) <= 1e-9 * scale;
485
+ const value = scaleToNumber(divideScales(siMagnitude(literal.magnitude, from, temperature), to.exact));
486
+ return {
487
+ value: finiteLiteral(raw, value),
488
+ given,
489
+ ...(from.cycles === 0 ? {} : { cycles: from.cycles }),
490
+ ...(from.affine === undefined ? {} : { affine: from.affine }),
491
+ };
512
492
  }
513
493
  /** The dimension of a declared unit expression. @internal */
514
494
  export function unitDimension(unit) {
515
495
  return parseUnit(unit).dim;
516
496
  }
517
- /** The tables conversion reads, for the CLI record's fingerprint (`src/cli/record-tables.ts`). @internal */
497
+ /** The symbols the unit table spells, with their exact scales, for the agreement test against MathTS. @internal */
498
+ export function unitRows() {
499
+ return UNITS;
500
+ }
501
+ /**
502
+ * The tables conversion reads, for the CLI record's fingerprint (`src/cli/record-tables.ts`):
503
+ * each row's scale, dimension, prefixability and `cycles` flag (which multiplies an angular
504
+ * input by 2π), the prefixes, the Celsius offset, and the SHA-256 of `data/units.json`, so a
505
+ * refused spelling, a prefix letter, an affine row or a note that changes changes the fingerprint too.
506
+ * @internal
507
+ */
518
508
  export function unitTables() {
519
- return { units: UNITS, prefixes: PREFIXES, celsiusOffsetK: CELSIUS_OFFSET_K };
509
+ return {
510
+ units: new Map([...UNITS].map(([symbol, r]) => [symbol, [scaleToNumber(r.scale), r.dim, r.prefixable, r.cycles === true]])),
511
+ prefixes: new Map([...PREFIXES].map(([prefix, f]) => [prefix, scaleToNumber(f)])),
512
+ celsiusOffsetK: scaleToNumber(CELSIUS_OFFSET_K),
513
+ sourceSha256: UNIT_DATA.sha256,
514
+ };
520
515
  }
521
516
  //# sourceMappingURL=units.js.map