universal-physics-tensor 10.0.0 → 12.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.
- package/README.md +39 -36
- package/bin/upt.mjs +13 -1
- package/data/applied-cases.json +1892 -0
- package/data/applied-cases.schema.json +194 -0
- package/data/atlas/atlas.json +25 -25
- package/data/atlas/atlas.jsonld +1 -1
- package/data/atlas/diffusion.json +6 -6
- package/data/atlas/oscillators.json +7 -7
- package/data/atlas/waves.json +14 -14
- package/data/atlas/witness-results.json +11 -11
- package/data/bridge-catalog.json +389 -230
- package/data/bridge-catalog.schema.json +45 -7
- package/data/units.json +6 -25
- package/dist/atlas/applicability.d.ts.map +1 -1
- package/dist/atlas/applicability.js +21 -15
- package/dist/atlas/applicability.js.map +1 -1
- package/dist/atlas/benchmark/hybrid-retrieval.d.ts +9 -1
- package/dist/atlas/benchmark/hybrid-retrieval.d.ts.map +1 -1
- package/dist/atlas/benchmark/hybrid-retrieval.js +15 -13
- package/dist/atlas/benchmark/hybrid-retrieval.js.map +1 -1
- package/dist/atlas/benchmark/loader.js +2 -2
- package/dist/atlas/benchmark/loader.js.map +1 -1
- package/dist/atlas/benchmark/stats.d.ts +2 -2
- package/dist/atlas/benchmark/stats.d.ts.map +1 -1
- package/dist/atlas/benchmark/stats.js +9 -15
- package/dist/atlas/benchmark/stats.js.map +1 -1
- package/dist/atlas/catalog-formal-ref.d.ts +26 -3
- package/dist/atlas/catalog-formal-ref.d.ts.map +1 -1
- package/dist/atlas/catalog-formal-ref.js +52 -5
- package/dist/atlas/catalog-formal-ref.js.map +1 -1
- package/dist/atlas/chain-pipeline.d.ts.map +1 -1
- package/dist/atlas/chain-pipeline.js +7 -8
- package/dist/atlas/chain-pipeline.js.map +1 -1
- package/dist/atlas/diffusion/bridges-closure.d.ts +0 -4
- package/dist/atlas/diffusion/bridges-closure.d.ts.map +1 -1
- package/dist/atlas/diffusion/bridges-closure.js +8 -12
- package/dist/atlas/diffusion/bridges-closure.js.map +1 -1
- package/dist/atlas/diffusion/bridges.d.ts.map +1 -1
- package/dist/atlas/diffusion/bridges.js +27 -39
- package/dist/atlas/diffusion/bridges.js.map +1 -1
- package/dist/atlas/diffusion/dimensions.d.ts +6 -14
- package/dist/atlas/diffusion/dimensions.d.ts.map +1 -1
- package/dist/atlas/diffusion/dimensions.js +8 -16
- package/dist/atlas/diffusion/dimensions.js.map +1 -1
- package/dist/atlas/diffusion/models.d.ts +3 -3
- package/dist/atlas/diffusion/models.d.ts.map +1 -1
- package/dist/atlas/diffusion/models.js +5 -10
- package/dist/atlas/diffusion/models.js.map +1 -1
- package/dist/atlas/diffusion/numerics.d.ts +16 -4
- package/dist/atlas/diffusion/numerics.d.ts.map +1 -1
- package/dist/atlas/diffusion/numerics.js +38 -24
- package/dist/atlas/diffusion/numerics.js.map +1 -1
- package/dist/atlas/link-prediction.d.ts +106 -3
- package/dist/atlas/link-prediction.d.ts.map +1 -1
- package/dist/atlas/link-prediction.js +212 -66
- package/dist/atlas/link-prediction.js.map +1 -1
- package/dist/atlas/oscillators/bridges-coarse.d.ts.map +1 -1
- package/dist/atlas/oscillators/bridges-coarse.js +7 -11
- package/dist/atlas/oscillators/bridges-coarse.js.map +1 -1
- package/dist/atlas/oscillators/bridges-exact.d.ts.map +1 -1
- package/dist/atlas/oscillators/bridges-exact.js +6 -7
- package/dist/atlas/oscillators/bridges-exact.js.map +1 -1
- package/dist/atlas/oscillators/bridges-limits.d.ts +3 -16
- package/dist/atlas/oscillators/bridges-limits.d.ts.map +1 -1
- package/dist/atlas/oscillators/bridges-limits.js +23 -34
- package/dist/atlas/oscillators/bridges-limits.js.map +1 -1
- package/dist/atlas/oscillators/dimensions.d.ts +9 -21
- package/dist/atlas/oscillators/dimensions.d.ts.map +1 -1
- package/dist/atlas/oscillators/dimensions.js +9 -21
- package/dist/atlas/oscillators/dimensions.js.map +1 -1
- package/dist/atlas/oscillators/limit-witnesses.d.ts +2 -2
- package/dist/atlas/oscillators/limit-witnesses.d.ts.map +1 -1
- package/dist/atlas/oscillators/limit-witnesses.js +17 -15
- package/dist/atlas/oscillators/limit-witnesses.js.map +1 -1
- package/dist/atlas/oscillators/models.d.ts.map +1 -1
- package/dist/atlas/oscillators/models.js +2 -6
- package/dist/atlas/oscillators/models.js.map +1 -1
- package/dist/atlas/oscillators/pendulum-motion.d.ts +29 -6
- package/dist/atlas/oscillators/pendulum-motion.d.ts.map +1 -1
- package/dist/atlas/oscillators/pendulum-motion.js +60 -40
- package/dist/atlas/oscillators/pendulum-motion.js.map +1 -1
- package/dist/atlas/oscillators/phase-translation.d.ts +0 -11
- package/dist/atlas/oscillators/phase-translation.d.ts.map +1 -1
- package/dist/atlas/oscillators/phase-translation.js +3 -4
- package/dist/atlas/oscillators/phase-translation.js.map +1 -1
- package/dist/atlas/oscillators/position-translation.d.ts +68 -7
- package/dist/atlas/oscillators/position-translation.d.ts.map +1 -1
- package/dist/atlas/oscillators/position-translation.js +123 -12
- package/dist/atlas/oscillators/position-translation.js.map +1 -1
- package/dist/atlas/oscillators/rejections.d.ts +0 -2
- package/dist/atlas/oscillators/rejections.d.ts.map +1 -1
- package/dist/atlas/oscillators/rejections.js +0 -7
- package/dist/atlas/oscillators/rejections.js.map +1 -1
- package/dist/atlas/physjs-entries.generated.d.ts +35 -25
- package/dist/atlas/physjs-entries.generated.d.ts.map +1 -1
- package/dist/atlas/physjs-entries.generated.js +37 -25
- package/dist/atlas/physjs-entries.generated.js.map +1 -1
- package/dist/atlas/physjs-ref.d.ts +34 -31
- package/dist/atlas/physjs-ref.d.ts.map +1 -1
- package/dist/atlas/physjs-ref.js +55 -53
- package/dist/atlas/physjs-ref.js.map +1 -1
- package/dist/atlas/physjs-reviewed.d.ts +1 -1
- package/dist/atlas/physjs-reviewed.js +15 -15
- package/dist/atlas/physjs-reviewed.js.map +1 -1
- package/dist/atlas/poster/statements.d.ts +0 -19
- package/dist/atlas/poster/statements.d.ts.map +1 -1
- package/dist/atlas/poster/statements.js +1 -1
- package/dist/atlas/poster/statements.js.map +1 -1
- package/dist/atlas/proof-target.d.ts +1 -1
- package/dist/atlas/proof-target.js +1 -1
- package/dist/atlas/proof-target.js.map +1 -1
- package/dist/atlas/regime.d.ts +1 -1
- package/dist/atlas/regime.d.ts.map +1 -1
- package/dist/atlas/regime.js +1 -1
- package/dist/atlas/regime.js.map +1 -1
- package/dist/atlas/text-overlap.d.ts +23 -0
- package/dist/atlas/text-overlap.d.ts.map +1 -0
- package/dist/atlas/text-overlap.js +41 -0
- package/dist/atlas/text-overlap.js.map +1 -0
- package/dist/atlas/waves/bridges-closure.d.ts.map +1 -1
- package/dist/atlas/waves/bridges-closure.js +2 -6
- package/dist/atlas/waves/bridges-closure.js.map +1 -1
- package/dist/atlas/waves/bridges.d.ts.map +1 -1
- package/dist/atlas/waves/bridges.js +32 -48
- package/dist/atlas/waves/bridges.js.map +1 -1
- package/dist/atlas/waves/models.d.ts +5 -6
- package/dist/atlas/waves/models.d.ts.map +1 -1
- package/dist/atlas/waves/models.js +7 -13
- package/dist/atlas/waves/models.js.map +1 -1
- package/dist/atlas/waves/numerics.d.ts.map +1 -1
- package/dist/atlas/waves/numerics.js +10 -3
- package/dist/atlas/waves/numerics.js.map +1 -1
- package/dist/atlas/witness-numeric.d.ts +30 -0
- package/dist/atlas/witness-numeric.d.ts.map +1 -1
- package/dist/atlas/witness-numeric.js +53 -0
- package/dist/atlas/witness-numeric.js.map +1 -1
- package/dist/atlas/witness-specs.d.ts.map +1 -1
- package/dist/atlas/witness-specs.js +19 -0
- package/dist/atlas/witness-specs.js.map +1 -1
- package/dist/atlas/witness-symbolic.d.ts +75 -3
- package/dist/atlas/witness-symbolic.d.ts.map +1 -1
- package/dist/atlas/witness-symbolic.js +116 -10
- package/dist/atlas/witness-symbolic.js.map +1 -1
- package/dist/bridges/catalog-load.d.ts.map +1 -1
- package/dist/bridges/catalog-load.js +13 -8
- package/dist/bridges/catalog-load.js.map +1 -1
- package/dist/bridges/catalog-types.d.ts +26 -2
- package/dist/bridges/catalog-types.d.ts.map +1 -1
- package/dist/bridges/catalog-types.js +11 -1
- package/dist/bridges/catalog-types.js.map +1 -1
- package/dist/bridges/evaluation-errors.d.ts +31 -1
- package/dist/bridges/evaluation-errors.d.ts.map +1 -1
- package/dist/bridges/evaluation-errors.js +20 -2
- package/dist/bridges/evaluation-errors.js.map +1 -1
- package/dist/bridges/evaluator-inputs.d.ts.map +1 -1
- package/dist/bridges/evaluator-inputs.js +7 -5
- package/dist/bridges/evaluator-inputs.js.map +1 -1
- package/dist/bridges/evaluators.d.ts.map +1 -1
- package/dist/bridges/evaluators.js +27 -12
- package/dist/bridges/evaluators.js.map +1 -1
- package/dist/bridges/expr-parse.d.ts +11 -0
- package/dist/bridges/expr-parse.d.ts.map +1 -1
- package/dist/bridges/expr-parse.js +14 -5
- package/dist/bridges/expr-parse.js.map +1 -1
- package/dist/bridges/holds.d.ts +35 -3
- package/dist/bridges/holds.d.ts.map +1 -1
- package/dist/bridges/holds.js +117 -23
- package/dist/bridges/holds.js.map +1 -1
- package/dist/bridges/notices.d.ts.map +1 -1
- package/dist/bridges/notices.js +5 -5
- package/dist/bridges/notices.js.map +1 -1
- package/dist/bridges/relation-eval.d.ts +4 -4
- package/dist/bridges/relation-eval.d.ts.map +1 -1
- package/dist/bridges/relation-eval.js +15 -16
- package/dist/bridges/relation-eval.js.map +1 -1
- package/dist/bridges/sensitivity.d.ts.map +1 -1
- package/dist/bridges/sensitivity.js +3 -3
- package/dist/bridges/sensitivity.js.map +1 -1
- package/dist/bridges/validity.d.ts +33 -0
- package/dist/bridges/validity.d.ts.map +1 -0
- package/dist/bridges/validity.js +67 -0
- package/dist/bridges/validity.js.map +1 -0
- package/dist/canonical/entries/atomic.js +1 -3
- package/dist/canonical/entries/atomic.js.map +1 -1
- package/dist/canonical/entries/condensed-matter.d.ts.map +1 -1
- package/dist/canonical/entries/condensed-matter.js +4 -5
- package/dist/canonical/entries/condensed-matter.js.map +1 -1
- package/dist/canonical/entries/dimensional-classics.d.ts.map +1 -1
- package/dist/canonical/entries/dimensional-classics.js +3 -4
- package/dist/canonical/entries/dimensional-classics.js.map +1 -1
- package/dist/canonical/entries/electromagnetism.d.ts.map +1 -1
- package/dist/canonical/entries/electromagnetism.js +4 -10
- package/dist/canonical/entries/electromagnetism.js.map +1 -1
- package/dist/canonical/entries/fluids-waves.d.ts.map +1 -1
- package/dist/canonical/entries/fluids-waves.js +3 -7
- package/dist/canonical/entries/fluids-waves.js.map +1 -1
- package/dist/canonical/entries/mechanics.d.ts.map +1 -1
- package/dist/canonical/entries/mechanics.js +4 -6
- package/dist/canonical/entries/mechanics.js.map +1 -1
- package/dist/canonical/entries/nonmonomial.d.ts.map +1 -1
- package/dist/canonical/entries/nonmonomial.js +9 -17
- package/dist/canonical/entries/nonmonomial.js.map +1 -1
- package/dist/canonical/entries/relativity.d.ts.map +1 -1
- package/dist/canonical/entries/relativity.js +6 -6
- package/dist/canonical/entries/relativity.js.map +1 -1
- package/dist/canonical/entries/thermo-nuclear-cosmo.d.ts.map +1 -1
- package/dist/canonical/entries/thermo-nuclear-cosmo.js +6 -10
- package/dist/canonical/entries/thermo-nuclear-cosmo.js.map +1 -1
- package/dist/canonical/fixed-points.d.ts +94 -0
- package/dist/canonical/fixed-points.d.ts.map +1 -0
- package/dist/canonical/fixed-points.js +81 -0
- package/dist/canonical/fixed-points.js.map +1 -0
- package/dist/canonical/linkage.d.ts.map +1 -1
- package/dist/canonical/linkage.js +25 -44
- package/dist/canonical/linkage.js.map +1 -1
- package/dist/canonical/normal-form.d.ts.map +1 -1
- package/dist/canonical/normal-form.js +5 -11
- package/dist/canonical/normal-form.js.map +1 -1
- package/dist/canonical/structural.d.ts +21 -21
- package/dist/canonical/structural.d.ts.map +1 -1
- package/dist/canonical/structural.js +40 -19
- package/dist/canonical/structural.js.map +1 -1
- package/dist/cases/catalog-checks.d.ts +10 -0
- package/dist/cases/catalog-checks.d.ts.map +1 -0
- package/dist/cases/catalog-checks.js +241 -0
- package/dist/cases/catalog-checks.js.map +1 -0
- package/dist/cases/catalog.d.ts +83 -0
- package/dist/cases/catalog.d.ts.map +1 -0
- package/dist/cases/catalog.js +118 -0
- package/dist/cases/catalog.js.map +1 -0
- package/dist/cases/engine.d.ts +13 -0
- package/dist/cases/engine.d.ts.map +1 -0
- package/dist/cases/engine.js +179 -0
- package/dist/cases/engine.js.map +1 -0
- package/dist/cases/index.d.ts.map +1 -1
- package/dist/cases/index.js +5 -7
- package/dist/cases/index.js.map +1 -1
- package/dist/cases/methods.d.ts +215 -0
- package/dist/cases/methods.d.ts.map +1 -0
- package/dist/cases/methods.js +743 -0
- package/dist/cases/methods.js.map +1 -0
- package/dist/cases/quadrature.d.ts +7 -9
- package/dist/cases/quadrature.d.ts.map +1 -1
- package/dist/cases/quadrature.js +28 -32
- package/dist/cases/quadrature.js.map +1 -1
- package/dist/cases/types.d.ts +12 -0
- package/dist/cases/types.d.ts.map +1 -1
- package/dist/cases/types.js.map +1 -1
- package/dist/cli/args.d.ts +25 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +30 -8
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/bindings.d.ts.map +1 -1
- package/dist/cli/bindings.js +5 -4
- package/dist/cli/bindings.js.map +1 -1
- package/dist/cli/command.d.ts +11 -1
- package/dist/cli/command.d.ts.map +1 -1
- package/dist/cli/command.js.map +1 -1
- package/dist/cli/commands/_atlas-map.d.ts +0 -9
- package/dist/cli/commands/_atlas-map.d.ts.map +1 -1
- package/dist/cli/commands/_atlas-map.js +8 -18
- package/dist/cli/commands/_atlas-map.js.map +1 -1
- package/dist/cli/commands/_atlas-route.d.ts.map +1 -1
- package/dist/cli/commands/_atlas-route.js +6 -2
- package/dist/cli/commands/_atlas-route.js.map +1 -1
- package/dist/cli/commands/_discovery-opts.d.ts +1 -0
- package/dist/cli/commands/_discovery-opts.d.ts.map +1 -1
- package/dist/cli/commands/_discovery-opts.js +9 -9
- package/dist/cli/commands/_discovery-opts.js.map +1 -1
- package/dist/cli/commands/atlas.d.ts.map +1 -1
- package/dist/cli/commands/atlas.js +8 -5
- package/dist/cli/commands/atlas.js.map +1 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +8 -1
- package/dist/cli/commands/audit.js.map +1 -1
- package/dist/cli/commands/axes.d.ts.map +1 -1
- package/dist/cli/commands/axes.js +20 -1
- package/dist/cli/commands/axes.js.map +1 -1
- package/dist/cli/commands/confront.d.ts.map +1 -1
- package/dist/cli/commands/confront.js +8 -14
- package/dist/cli/commands/confront.js.map +1 -1
- package/dist/cli/commands/derive.d.ts.map +1 -1
- package/dist/cli/commands/derive.js +22 -22
- package/dist/cli/commands/derive.js.map +1 -1
- package/dist/cli/commands/discover.d.ts.map +1 -1
- package/dist/cli/commands/discover.js +122 -73
- package/dist/cli/commands/discover.js.map +1 -1
- package/dist/cli/commands/eval.d.ts.map +1 -1
- package/dist/cli/commands/eval.js +1 -0
- package/dist/cli/commands/eval.js.map +1 -1
- package/dist/cli/commands/evaluate.d.ts.map +1 -1
- package/dist/cli/commands/evaluate.js +67 -39
- package/dist/cli/commands/evaluate.js.map +1 -1
- package/dist/cli/commands/explain.d.ts.map +1 -1
- package/dist/cli/commands/explain.js +24 -3
- package/dist/cli/commands/explain.js.map +1 -1
- package/dist/cli/commands/ground.d.ts.map +1 -1
- package/dist/cli/commands/ground.js +7 -1
- package/dist/cli/commands/ground.js.map +1 -1
- package/dist/cli/commands/map.d.ts.map +1 -1
- package/dist/cli/commands/map.js +84 -11
- package/dist/cli/commands/map.js.map +1 -1
- package/dist/cli/commands/metric.d.ts.map +1 -1
- package/dist/cli/commands/metric.js +12 -9
- package/dist/cli/commands/metric.js.map +1 -1
- package/dist/cli/commands/path.d.ts +10 -0
- package/dist/cli/commands/path.d.ts.map +1 -1
- package/dist/cli/commands/path.js +25 -3
- package/dist/cli/commands/path.js.map +1 -1
- package/dist/cli/commands/probe.d.ts.map +1 -1
- package/dist/cli/commands/probe.js +59 -16
- package/dist/cli/commands/probe.js.map +1 -1
- package/dist/cli/commands/regime.d.ts.map +1 -1
- package/dist/cli/commands/regime.js +1 -0
- package/dist/cli/commands/regime.js.map +1 -1
- package/dist/cli/commands/retrieve.d.ts.map +1 -1
- package/dist/cli/commands/retrieve.js +1 -0
- package/dist/cli/commands/retrieve.js.map +1 -1
- package/dist/cli/commands/search.d.ts.map +1 -1
- package/dist/cli/commands/search.js +1 -0
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/symbolic.d.ts.map +1 -1
- package/dist/cli/commands/symbolic.js +19 -28
- package/dist/cli/commands/symbolic.js.map +1 -1
- package/dist/cli/commands/testplan.d.ts.map +1 -1
- package/dist/cli/commands/testplan.js +4 -2
- package/dist/cli/commands/testplan.js.map +1 -1
- package/dist/cli/determination.d.ts +1 -0
- package/dist/cli/determination.d.ts.map +1 -1
- package/dist/cli/determination.js.map +1 -1
- package/dist/cli/expr-print.d.ts +0 -2
- package/dist/cli/expr-print.d.ts.map +1 -1
- package/dist/cli/expr-print.js +7 -31
- package/dist/cli/expr-print.js.map +1 -1
- package/dist/cli/flag-help.d.ts +1 -0
- package/dist/cli/flag-help.d.ts.map +1 -1
- package/dist/cli/flag-help.js +1 -0
- package/dist/cli/flag-help.js.map +1 -1
- package/dist/cli/graphs.d.ts +2 -0
- package/dist/cli/graphs.d.ts.map +1 -1
- package/dist/cli/graphs.js +1 -0
- package/dist/cli/graphs.js.map +1 -1
- package/dist/cli/main.d.ts +8 -0
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +19 -3
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/numeric-flag.d.ts +12 -0
- package/dist/cli/numeric-flag.d.ts.map +1 -0
- package/dist/cli/numeric-flag.js +44 -0
- package/dist/cli/numeric-flag.js.map +1 -0
- package/dist/cli/output.d.ts +28 -0
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +23 -0
- package/dist/cli/output.js.map +1 -1
- package/dist/cli/record-reach.js +2 -2
- package/dist/cli/record-reach.js.map +1 -1
- package/dist/cli/record-tables.d.ts.map +1 -1
- package/dist/cli/record-tables.js +6 -5
- package/dist/cli/record-tables.js.map +1 -1
- package/dist/cli/record.d.ts +1 -5
- package/dist/cli/record.d.ts.map +1 -1
- package/dist/cli/record.js +9 -8
- package/dist/cli/record.js.map +1 -1
- package/dist/cli/search-index.d.ts.map +1 -1
- package/dist/cli/search-index.js +7 -6
- package/dist/cli/search-index.js.map +1 -1
- package/dist/cli/statuses.d.ts +0 -2
- package/dist/cli/statuses.d.ts.map +1 -1
- package/dist/cli/statuses.js +12 -9
- package/dist/cli/statuses.js.map +1 -1
- package/dist/cli/stored-results.d.ts +7 -0
- package/dist/cli/stored-results.d.ts.map +1 -0
- package/dist/cli/stored-results.js +23 -0
- package/dist/cli/stored-results.js.map +1 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/cli/version.d.ts.map +1 -1
- package/dist/cli/version.js +8 -5
- package/dist/cli/version.js.map +1 -1
- package/dist/cli-api.d.ts +36 -5
- package/dist/cli-api.d.ts.map +1 -1
- package/dist/cli-api.js +30 -4
- package/dist/cli-api.js.map +1 -1
- package/dist/composition/algebraic-equivalence.d.ts +43 -0
- package/dist/composition/algebraic-equivalence.d.ts.map +1 -0
- package/dist/composition/algebraic-equivalence.js +115 -0
- package/dist/composition/algebraic-equivalence.js.map +1 -0
- package/dist/composition/axes.d.ts +0 -6
- package/dist/composition/axes.d.ts.map +1 -1
- package/dist/composition/axes.js +6 -6
- package/dist/composition/axes.js.map +1 -1
- package/dist/composition/axis-audit.d.ts +47 -20
- package/dist/composition/axis-audit.d.ts.map +1 -1
- package/dist/composition/axis-audit.js +82 -9
- package/dist/composition/axis-audit.js.map +1 -1
- package/dist/composition/bridge-analysis.d.ts +17 -0
- package/dist/composition/bridge-analysis.d.ts.map +1 -1
- package/dist/composition/bridge-analysis.js +102 -55
- package/dist/composition/bridge-analysis.js.map +1 -1
- package/dist/composition/canonical-compare.d.ts +40 -0
- package/dist/composition/canonical-compare.d.ts.map +1 -1
- package/dist/composition/canonical-compare.js +122 -24
- package/dist/composition/canonical-compare.js.map +1 -1
- package/dist/composition/canonical-graph.d.ts +3 -3
- package/dist/composition/canonical-graph.d.ts.map +1 -1
- package/dist/composition/canonical-graph.js +11 -38
- package/dist/composition/canonical-graph.js.map +1 -1
- package/dist/composition/canonical-json.js +2 -2
- package/dist/composition/canonical-json.js.map +1 -1
- package/dist/composition/catalog-graph.d.ts.map +1 -1
- package/dist/composition/catalog-graph.js +2 -5
- package/dist/composition/catalog-graph.js.map +1 -1
- package/dist/composition/chain-candidate.d.ts +8 -0
- package/dist/composition/chain-candidate.d.ts.map +1 -1
- package/dist/composition/chain-candidate.js +9 -2
- package/dist/composition/chain-candidate.js.map +1 -1
- package/dist/composition/chain-match.d.ts +6 -3
- package/dist/composition/chain-match.d.ts.map +1 -1
- package/dist/composition/chain-match.js +4 -1
- package/dist/composition/chain-match.js.map +1 -1
- package/dist/composition/chain-result.d.ts.map +1 -1
- package/dist/composition/chain-result.js +2 -14
- package/dist/composition/chain-result.js.map +1 -1
- package/dist/composition/compose-symbolic.d.ts.map +1 -1
- package/dist/composition/compose-symbolic.js +3 -2
- package/dist/composition/compose-symbolic.js.map +1 -1
- package/dist/composition/compose.d.ts.map +1 -1
- package/dist/composition/compose.js +13 -5
- package/dist/composition/compose.js.map +1 -1
- package/dist/composition/composition-recovery.d.ts.map +1 -1
- package/dist/composition/composition-recovery.js +4 -7
- package/dist/composition/composition-recovery.js.map +1 -1
- package/dist/composition/consequence.d.ts +15 -5
- package/dist/composition/consequence.d.ts.map +1 -1
- package/dist/composition/consequence.js +6 -4
- package/dist/composition/consequence.js.map +1 -1
- package/dist/composition/discovery.d.ts +129 -9
- package/dist/composition/discovery.d.ts.map +1 -1
- package/dist/composition/discovery.js +171 -67
- package/dist/composition/discovery.js.map +1 -1
- package/dist/composition/edge.d.ts +21 -2
- package/dist/composition/edge.d.ts.map +1 -1
- package/dist/composition/edge.js +23 -1
- package/dist/composition/edge.js.map +1 -1
- package/dist/composition/enumerate.d.ts.map +1 -1
- package/dist/composition/enumerate.js +18 -3
- package/dist/composition/enumerate.js.map +1 -1
- package/dist/composition/evaluate-relation.d.ts +35 -11
- package/dist/composition/evaluate-relation.d.ts.map +1 -1
- package/dist/composition/evaluate-relation.js +60 -39
- package/dist/composition/evaluate-relation.js.map +1 -1
- package/dist/composition/explain.d.ts +3 -12
- package/dist/composition/explain.d.ts.map +1 -1
- package/dist/composition/explain.js +7 -20
- package/dist/composition/explain.js.map +1 -1
- package/dist/composition/expr-eval.d.ts +1 -1
- package/dist/composition/expr-eval.d.ts.map +1 -1
- package/dist/composition/expr-eval.js +6 -15
- package/dist/composition/expr-eval.js.map +1 -1
- package/dist/composition/expr-simplify.d.ts +26 -14
- package/dist/composition/expr-simplify.d.ts.map +1 -1
- package/dist/composition/expr-simplify.js +64 -72
- package/dist/composition/expr-simplify.js.map +1 -1
- package/dist/composition/formula-shape.d.ts +23 -4
- package/dist/composition/formula-shape.d.ts.map +1 -1
- package/dist/composition/formula-shape.js +57 -17
- package/dist/composition/formula-shape.js.map +1 -1
- package/dist/composition/graph-structure.d.ts +98 -0
- package/dist/composition/graph-structure.d.ts.map +1 -0
- package/dist/composition/graph-structure.js +167 -0
- package/dist/composition/graph-structure.js.map +1 -0
- package/dist/composition/graph-viz-svg.d.ts.map +1 -1
- package/dist/composition/graph-viz-svg.js +1 -1
- package/dist/composition/graph-viz-svg.js.map +1 -1
- package/dist/composition/graph-viz.d.ts.map +1 -1
- package/dist/composition/graph-viz.js +8 -37
- package/dist/composition/graph-viz.js.map +1 -1
- package/dist/composition/grounding.d.ts.map +1 -1
- package/dist/composition/grounding.js +19 -7
- package/dist/composition/grounding.js.map +1 -1
- package/dist/composition/identifiability.d.ts +91 -4
- package/dist/composition/identifiability.d.ts.map +1 -1
- package/dist/composition/identifiability.js +363 -6
- package/dist/composition/identifiability.js.map +1 -1
- package/dist/composition/index.d.ts +8 -4
- package/dist/composition/index.d.ts.map +1 -1
- package/dist/composition/index.js +3 -2
- package/dist/composition/index.js.map +1 -1
- package/dist/composition/mathts-quiet.d.ts +7 -8
- package/dist/composition/mathts-quiet.d.ts.map +1 -1
- package/dist/composition/mathts-quiet.js +7 -16
- package/dist/composition/mathts-quiet.js.map +1 -1
- package/dist/composition/mathts-scalar-symbols.d.ts.map +1 -1
- package/dist/composition/mathts-scalar-symbols.js +2 -1
- package/dist/composition/mathts-scalar-symbols.js.map +1 -1
- package/dist/composition/own-equation-magnitude.d.ts +95 -0
- package/dist/composition/own-equation-magnitude.d.ts.map +1 -0
- package/dist/composition/own-equation-magnitude.js +270 -0
- package/dist/composition/own-equation-magnitude.js.map +1 -0
- package/dist/composition/probe/backend-protocol.d.ts +3 -0
- package/dist/composition/probe/backend-protocol.d.ts.map +1 -1
- package/dist/composition/probe/backend-protocol.js.map +1 -1
- package/dist/composition/probe/candidate-store.d.ts +1 -0
- package/dist/composition/probe/candidate-store.d.ts.map +1 -1
- package/dist/composition/probe/candidate-store.js +1 -0
- package/dist/composition/probe/candidate-store.js.map +1 -1
- package/dist/composition/probe/corpus.d.ts +8 -4
- package/dist/composition/probe/corpus.d.ts.map +1 -1
- package/dist/composition/probe/corpus.js +23 -12
- package/dist/composition/probe/corpus.js.map +1 -1
- package/dist/composition/probe/dataset.d.ts +18 -0
- package/dist/composition/probe/dataset.d.ts.map +1 -1
- package/dist/composition/probe/dataset.js +95 -50
- package/dist/composition/probe/dataset.js.map +1 -1
- package/dist/composition/probe/experiment-design.d.ts +7 -1
- package/dist/composition/probe/experiment-design.d.ts.map +1 -1
- package/dist/composition/probe/experiment-design.js +44 -24
- package/dist/composition/probe/experiment-design.js.map +1 -1
- package/dist/composition/probe/falsify.d.ts +2 -0
- package/dist/composition/probe/falsify.d.ts.map +1 -1
- package/dist/composition/probe/falsify.js +2 -0
- package/dist/composition/probe/falsify.js.map +1 -1
- package/dist/composition/probe/fit.d.ts +7 -0
- package/dist/composition/probe/fit.d.ts.map +1 -1
- package/dist/composition/probe/fit.js +46 -22
- package/dist/composition/probe/fit.js.map +1 -1
- package/dist/composition/probe/frontier.d.ts.map +1 -1
- package/dist/composition/probe/frontier.js +33 -15
- package/dist/composition/probe/frontier.js.map +1 -1
- package/dist/composition/probe/generator.d.ts +30 -1
- package/dist/composition/probe/generator.d.ts.map +1 -1
- package/dist/composition/probe/generator.js +58 -36
- package/dist/composition/probe/generator.js.map +1 -1
- package/dist/composition/probe/index.d.ts +14 -0
- package/dist/composition/probe/index.d.ts.map +1 -1
- package/dist/composition/probe/index.js +6 -0
- package/dist/composition/probe/index.js.map +1 -1
- package/dist/composition/probe/limits.d.ts +25 -1
- package/dist/composition/probe/limits.d.ts.map +1 -1
- package/dist/composition/probe/limits.js +53 -11
- package/dist/composition/probe/limits.js.map +1 -1
- package/dist/composition/probe/pipeline.d.ts +5 -0
- package/dist/composition/probe/pipeline.d.ts.map +1 -1
- package/dist/composition/probe/pipeline.js +73 -24
- package/dist/composition/probe/pipeline.js.map +1 -1
- package/dist/composition/probe/power-law.d.ts +121 -0
- package/dist/composition/probe/power-law.d.ts.map +1 -0
- package/dist/composition/probe/power-law.js +251 -0
- package/dist/composition/probe/power-law.js.map +1 -0
- package/dist/composition/probe/problem.d.ts +8 -4
- package/dist/composition/probe/problem.d.ts.map +1 -1
- package/dist/composition/probe/problem.js +177 -49
- package/dist/composition/probe/problem.js.map +1 -1
- package/dist/composition/probe/report.js +1 -1
- package/dist/composition/probe/report.js.map +1 -1
- package/dist/composition/probe/residual.d.ts +7 -1
- package/dist/composition/probe/residual.d.ts.map +1 -1
- package/dist/composition/probe/residual.js +10 -7
- package/dist/composition/probe/residual.js.map +1 -1
- package/dist/composition/probe/run-manifest.d.ts +1 -0
- package/dist/composition/probe/run-manifest.d.ts.map +1 -1
- package/dist/composition/probe/run-manifest.js.map +1 -1
- package/dist/composition/probe/scalar-search.d.ts +50 -0
- package/dist/composition/probe/scalar-search.d.ts.map +1 -0
- package/dist/composition/probe/scalar-search.js +169 -0
- package/dist/composition/probe/scalar-search.js.map +1 -0
- package/dist/composition/probe/scoring.d.ts +1 -0
- package/dist/composition/probe/scoring.d.ts.map +1 -1
- package/dist/composition/probe/scoring.js.map +1 -1
- package/dist/composition/probe/structure.d.ts +82 -17
- package/dist/composition/probe/structure.d.ts.map +1 -1
- package/dist/composition/probe/structure.js +129 -55
- package/dist/composition/probe/structure.js.map +1 -1
- package/dist/composition/probe/study.d.ts +31 -9
- package/dist/composition/probe/study.d.ts.map +1 -1
- package/dist/composition/probe/study.js +235 -184
- package/dist/composition/probe/study.js.map +1 -1
- package/dist/composition/probe/t-tail.d.ts +16 -0
- package/dist/composition/probe/t-tail.d.ts.map +1 -0
- package/dist/composition/probe/t-tail.js +29 -0
- package/dist/composition/probe/t-tail.js.map +1 -0
- package/dist/composition/probe/types.d.ts +3 -0
- package/dist/composition/probe/types.d.ts.map +1 -1
- package/dist/composition/probe/types.js.map +1 -1
- package/dist/composition/proposed-bridges.d.ts +52 -12
- package/dist/composition/proposed-bridges.d.ts.map +1 -1
- package/dist/composition/proposed-bridges.js +107 -60
- package/dist/composition/proposed-bridges.js.map +1 -1
- package/dist/composition/quantity-clusters.d.ts +48 -0
- package/dist/composition/quantity-clusters.d.ts.map +1 -0
- package/dist/composition/quantity-clusters.js +98 -0
- package/dist/composition/quantity-clusters.js.map +1 -0
- package/dist/composition/rational-exponent.d.ts +40 -0
- package/dist/composition/rational-exponent.d.ts.map +1 -0
- package/dist/composition/rational-exponent.js +65 -0
- package/dist/composition/rational-exponent.js.map +1 -0
- package/dist/composition/representative-values.d.ts +22 -0
- package/dist/composition/representative-values.d.ts.map +1 -1
- package/dist/composition/representative-values.js +29 -0
- package/dist/composition/representative-values.js.map +1 -1
- package/dist/composition/retrodiction.d.ts +15 -0
- package/dist/composition/retrodiction.d.ts.map +1 -1
- package/dist/composition/retrodiction.js +12 -4
- package/dist/composition/retrodiction.js.map +1 -1
- package/dist/composition/user-equation.d.ts +1 -0
- package/dist/composition/user-equation.d.ts.map +1 -1
- package/dist/composition/user-equation.js +3 -2
- package/dist/composition/user-equation.js.map +1 -1
- package/dist/core/assignment.d.ts +19 -0
- package/dist/core/assignment.d.ts.map +1 -0
- package/dist/core/assignment.js +19 -0
- package/dist/core/assignment.js.map +1 -0
- package/dist/core/compare.d.ts +32 -0
- package/dist/core/compare.d.ts.map +1 -0
- package/dist/core/compare.js +46 -0
- package/dist/core/compare.js.map +1 -0
- package/dist/core/constants.d.ts +42 -41
- package/dist/core/constants.d.ts.map +1 -1
- package/dist/core/constants.js +71 -51
- package/dist/core/constants.js.map +1 -1
- package/dist/core/data-file.d.ts +7 -0
- package/dist/core/data-file.d.ts.map +1 -1
- package/dist/core/data-file.js +17 -0
- package/dist/core/data-file.js.map +1 -1
- package/dist/core/format.d.ts +36 -0
- package/dist/core/format.d.ts.map +1 -0
- package/dist/core/format.js +39 -0
- package/dist/core/format.js.map +1 -0
- package/dist/core/hash.d.ts +14 -0
- package/dist/core/hash.d.ts.map +1 -0
- package/dist/core/hash.js +17 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/json-schema.d.ts +2 -0
- package/dist/core/json-schema.d.ts.map +1 -1
- package/dist/core/json-schema.js +14 -13
- package/dist/core/json-schema.js.map +1 -1
- package/dist/core/labeled-tensor.d.ts.map +1 -1
- package/dist/core/labeled-tensor.js +0 -8
- package/dist/core/labeled-tensor.js.map +1 -1
- package/dist/core/mathts-read.d.ts +25 -0
- package/dist/core/mathts-read.d.ts.map +1 -0
- package/dist/core/mathts-read.js +51 -0
- package/dist/core/mathts-read.js.map +1 -0
- package/dist/core/tensor.d.ts.map +1 -1
- package/dist/core/tensor.js +24 -0
- package/dist/core/tensor.js.map +1 -1
- package/dist/core/types.d.ts +5 -5
- package/dist/diff/bridge-ast-gradient.d.ts +27 -23
- package/dist/diff/bridge-ast-gradient.d.ts.map +1 -1
- package/dist/diff/bridge-ast-gradient.js +75 -173
- package/dist/diff/bridge-ast-gradient.js.map +1 -1
- package/dist/diff/bridge-gradient.d.ts +19 -6
- package/dist/diff/bridge-gradient.d.ts.map +1 -1
- package/dist/diff/bridge-gradient.js +19 -11
- package/dist/diff/bridge-gradient.js.map +1 -1
- package/dist/diff/bridge-specs.d.ts.map +1 -1
- package/dist/diff/bridge-specs.js +3 -0
- package/dist/diff/bridge-specs.js.map +1 -1
- package/dist/dimensional/algebra.d.ts +18 -0
- package/dist/dimensional/algebra.d.ts.map +1 -1
- package/dist/dimensional/algebra.js +41 -1
- package/dist/dimensional/algebra.js.map +1 -1
- package/dist/dimensional/ast-builders.d.ts +7 -0
- package/dist/dimensional/ast-builders.d.ts.map +1 -1
- package/dist/dimensional/ast-builders.js +11 -0
- package/dist/dimensional/ast-builders.js.map +1 -1
- package/dist/dimensional/ast-leaves.d.ts +81 -0
- package/dist/dimensional/ast-leaves.d.ts.map +1 -0
- package/dist/dimensional/ast-leaves.js +146 -0
- package/dist/dimensional/ast-leaves.js.map +1 -0
- package/dist/dimensional/ast-types.d.ts +15 -0
- package/dist/dimensional/ast-types.d.ts.map +1 -1
- package/dist/dimensional/ast-types.js.map +1 -1
- package/dist/dimensional/buckingham.d.ts.map +1 -1
- package/dist/dimensional/buckingham.js +15 -27
- package/dist/dimensional/buckingham.js.map +1 -1
- package/dist/dimensional/constant-rows.js +9 -9
- package/dist/dimensional/constant-rows.js.map +1 -1
- package/dist/dimensional/curvature-composite.d.ts +1 -1
- package/dist/dimensional/curvature-composite.js.map +1 -1
- package/dist/dimensional/dimension-inference.d.ts.map +1 -1
- package/dist/dimensional/dimension-inference.js +1 -2
- package/dist/dimensional/dimension-inference.js.map +1 -1
- package/dist/dimensional/errors.d.ts +1 -1
- package/dist/dimensional/errors.d.ts.map +1 -1
- package/dist/dimensional/errors.js +1 -15
- package/dist/dimensional/errors.js.map +1 -1
- package/dist/dimensional/exact-scale.d.ts +24 -11
- package/dist/dimensional/exact-scale.d.ts.map +1 -1
- package/dist/dimensional/exact-scale.js +122 -130
- package/dist/dimensional/exact-scale.js.map +1 -1
- package/dist/dimensional/gauge-field.d.ts.map +1 -1
- package/dist/dimensional/gauge-field.js +2 -2
- package/dist/dimensional/gauge-field.js.map +1 -1
- package/dist/dimensional/hyphen-names.d.ts +12 -2
- package/dist/dimensional/hyphen-names.d.ts.map +1 -1
- package/dist/dimensional/hyphen-names.js +44 -19
- package/dist/dimensional/hyphen-names.js.map +1 -1
- package/dist/dimensional/mathts-unit-delegation.d.ts +29 -0
- package/dist/dimensional/mathts-unit-delegation.d.ts.map +1 -0
- package/dist/dimensional/mathts-unit-delegation.js +187 -0
- package/dist/dimensional/mathts-unit-delegation.js.map +1 -0
- package/dist/dimensional/mathts-unit-wrapper.d.ts +33 -0
- package/dist/dimensional/mathts-unit-wrapper.d.ts.map +1 -0
- package/dist/dimensional/mathts-unit-wrapper.js +190 -0
- package/dist/dimensional/mathts-unit-wrapper.js.map +1 -0
- package/dist/dimensional/metric.d.ts.map +1 -1
- package/dist/dimensional/metric.js +0 -1
- package/dist/dimensional/metric.js.map +1 -1
- package/dist/dimensional/scalar-lowering.d.ts +21 -0
- package/dist/dimensional/scalar-lowering.d.ts.map +1 -0
- package/dist/dimensional/scalar-lowering.js +45 -0
- package/dist/dimensional/scalar-lowering.js.map +1 -0
- package/dist/dimensional/symbolic-constants.d.ts +9 -0
- package/dist/dimensional/symbolic-constants.d.ts.map +1 -1
- package/dist/dimensional/symbolic-constants.js +13 -1
- package/dist/dimensional/symbolic-constants.js.map +1 -1
- package/dist/dimensional/types.d.ts +36 -0
- package/dist/dimensional/types.d.ts.map +1 -1
- package/dist/dimensional/types.js +45 -7
- package/dist/dimensional/types.js.map +1 -1
- package/dist/dimensional/unit-data.d.ts +5 -1
- package/dist/dimensional/unit-data.d.ts.map +1 -1
- package/dist/dimensional/unit-data.js +30 -6
- package/dist/dimensional/unit-data.js.map +1 -1
- package/dist/dimensional/units.d.ts +2 -0
- package/dist/dimensional/units.d.ts.map +1 -1
- package/dist/dimensional/units.js +59 -3
- package/dist/dimensional/units.js.map +1 -1
- package/dist/dimensional/validator.d.ts +2 -0
- package/dist/dimensional/validator.d.ts.map +1 -1
- package/dist/dimensional/validator.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/numerical/christoffel-flat.d.ts.map +1 -1
- package/dist/numerical/christoffel-flat.js +3 -2
- package/dist/numerical/christoffel-flat.js.map +1 -1
- package/dist/numerical/connection-lowering-helpers.d.ts +3 -1
- package/dist/numerical/connection-lowering-helpers.d.ts.map +1 -1
- package/dist/numerical/connection-lowering-helpers.js +11 -15
- package/dist/numerical/connection-lowering-helpers.js.map +1 -1
- package/dist/numerical/covariant-eikonal.d.ts.map +1 -1
- package/dist/numerical/covariant-eikonal.js +34 -11
- package/dist/numerical/covariant-eikonal.js.map +1 -1
- package/dist/numerical/curvature-lowering-helpers.js +3 -2
- package/dist/numerical/curvature-lowering-helpers.js.map +1 -1
- package/dist/numerical/errors.d.ts.map +1 -1
- package/dist/numerical/errors.js +0 -3
- package/dist/numerical/errors.js.map +1 -1
- package/dist/numerical/finite-difference.d.ts +22 -0
- package/dist/numerical/finite-difference.d.ts.map +1 -0
- package/dist/numerical/finite-difference.js +27 -0
- package/dist/numerical/finite-difference.js.map +1 -0
- package/dist/numerical/geodesic-integrator.d.ts.map +1 -1
- package/dist/numerical/geodesic-integrator.js +22 -14
- package/dist/numerical/geodesic-integrator.js.map +1 -1
- package/dist/numerical/geometrized.d.ts.map +1 -1
- package/dist/numerical/geometrized.js +0 -1
- package/dist/numerical/geometrized.js.map +1 -1
- package/dist/numerical/mathts-engine.d.ts.map +1 -1
- package/dist/numerical/mathts-engine.js +10 -24
- package/dist/numerical/mathts-engine.js.map +1 -1
- package/dist/numerical/metric-inverse.d.ts.map +1 -1
- package/dist/numerical/metric-inverse.js +83 -46
- package/dist/numerical/metric-inverse.js.map +1 -1
- package/dist/numerical/null-ray-integrator.d.ts +2 -1
- package/dist/numerical/null-ray-integrator.d.ts.map +1 -1
- package/dist/numerical/null-ray-integrator.js +12 -12
- package/dist/numerical/null-ray-integrator.js.map +1 -1
- package/dist/numerical/painleve-gullstrand-metric.js +2 -2
- package/dist/numerical/painleve-gullstrand-metric.js.map +1 -1
- package/dist/numerical/pderiv.d.ts.map +1 -1
- package/dist/numerical/pderiv.js +2 -6
- package/dist/numerical/pderiv.js.map +1 -1
- package/dist/numerical/perihelion-finder.d.ts +0 -36
- package/dist/numerical/perihelion-finder.d.ts.map +1 -1
- package/dist/numerical/perihelion-finder.js +41 -87
- package/dist/numerical/perihelion-finder.js.map +1 -1
- package/dist/numerical/quadrature.d.ts.map +1 -1
- package/dist/numerical/quadrature.js +11 -13
- package/dist/numerical/quadrature.js.map +1 -1
- package/dist/numerical/rk4-trajectory.d.ts +10 -0
- package/dist/numerical/rk4-trajectory.d.ts.map +1 -0
- package/dist/numerical/rk4-trajectory.js +37 -0
- package/dist/numerical/rk4-trajectory.js.map +1 -0
- package/dist/numerical/schwarzschild.d.ts +14 -0
- package/dist/numerical/schwarzschild.d.ts.map +1 -0
- package/dist/numerical/schwarzschild.js +17 -0
- package/dist/numerical/schwarzschild.js.map +1 -0
- package/dist/numerical/spacetime-metrics.d.ts +12 -0
- package/dist/numerical/spacetime-metrics.d.ts.map +1 -1
- package/dist/numerical/spacetime-metrics.js +72 -56
- package/dist/numerical/spacetime-metrics.js.map +1 -1
- package/dist/numerical/statistics.d.ts +24 -0
- package/dist/numerical/statistics.d.ts.map +1 -0
- package/dist/numerical/statistics.js +52 -0
- package/dist/numerical/statistics.js.map +1 -0
- package/dist/numerical/strides.d.ts +3 -2
- package/dist/numerical/strides.d.ts.map +1 -1
- package/dist/numerical/strides.js +3 -10
- package/dist/numerical/strides.js.map +1 -1
- package/dist/numerical/tensor-engine.d.ts +21 -0
- package/dist/numerical/tensor-engine.d.ts.map +1 -1
- package/dist/numerical/tensor-engine.js +12 -0
- package/dist/numerical/tensor-engine.js.map +1 -1
- package/dist/relations/regime.d.ts +10 -0
- package/dist/relations/regime.d.ts.map +1 -1
- package/dist/relations/regime.js +18 -1
- package/dist/relations/regime.js.map +1 -1
- package/package.json +9 -12
- package/dist/cases/brownian-sphere.d.ts +0 -68
- package/dist/cases/brownian-sphere.d.ts.map +0 -1
- package/dist/cases/brownian-sphere.js +0 -354
- package/dist/cases/brownian-sphere.js.map +0 -1
- package/dist/cases/damped-resonator.d.ts +0 -23
- package/dist/cases/damped-resonator.d.ts.map +0 -1
- package/dist/cases/damped-resonator.js +0 -224
- package/dist/cases/damped-resonator.js.map +0 -1
- package/dist/cases/kepler-rv.d.ts +0 -13
- package/dist/cases/kepler-rv.d.ts.map +0 -1
- package/dist/cases/kepler-rv.js +0 -172
- package/dist/cases/kepler-rv.js.map +0 -1
- package/dist/cases/lumped-cooling.d.ts +0 -46
- package/dist/cases/lumped-cooling.d.ts.map +0 -1
- package/dist/cases/lumped-cooling.js +0 -261
- package/dist/cases/lumped-cooling.js.map +0 -1
- package/dist/cases/resistor-noise.d.ts +0 -14
- package/dist/cases/resistor-noise.d.ts.map +0 -1
- package/dist/cases/resistor-noise.js +0 -215
- package/dist/cases/resistor-noise.js.map +0 -1
- package/dist/cases/skin-depth.d.ts +0 -21
- package/dist/cases/skin-depth.d.ts.map +0 -1
- package/dist/cases/skin-depth.js +0 -174
- package/dist/cases/skin-depth.js.map +0 -1
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UPT unit wrapper policy on top of MathTS (Part A steps A8, A11, A12 partial).
|
|
3
|
+
*
|
|
4
|
+
* Admission, refusal policy, and cycle counting stay here even when parsing and
|
|
5
|
+
* scales delegate to MathTS. Four deliberate overrides of MathTS defaults are
|
|
6
|
+
* layered here, each pinned by a test that reads both sides:
|
|
7
|
+
*
|
|
8
|
+
* 1. `ton` and `tons` — MathTS names them ambiguous; UPT refuses them with its own
|
|
9
|
+
* message (`data/units.json`, `tests/dimensional/unit-wrapper-refusal.test.ts`).
|
|
10
|
+
* 2. An affine temperature inside a compound — MathTS refuses `degC/s` but parses the
|
|
11
|
+
* spaced `deg C/s`; UPT refuses both (`localUnitReadings`,
|
|
12
|
+
* `tests/dimensional/mathts-unit-gaps.test.ts`).
|
|
13
|
+
* 3. `pc` prefixes — MathTS admits only k and up (`SHORT_UP_ONLY`); UPT's
|
|
14
|
+
* prefix table applies to every prefixable row, so `mpc` stays on the local
|
|
15
|
+
* grammar (`isSubKiloParsec`, `tests/dimensional/unit-override-parsec.test.ts`).
|
|
16
|
+
* 4. `bit` — MathTS reports scale 1 on its bit axis; UPT keeps ln 2 nat
|
|
17
|
+
* (`applyBitScaleOverride`, `tests/dimensional/unit-wrapper-bit.test.ts`).
|
|
18
|
+
*
|
|
19
|
+
* The refusal *definitions* for `dB`, `dBm`, `dBW`, `Np`, `Mach` and `mach` are
|
|
20
|
+
* MathTS's `REFUSED_UNIT_SPELLINGS` (0.21.0); `data/units.json` no longer
|
|
21
|
+
* repeats them. The wrapper turns a MathTS refusal into `UnitRefusedError`
|
|
22
|
+
* before any parse, compounds included.
|
|
23
|
+
*
|
|
24
|
+
* @module dimensional/mathts-unit-wrapper
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
import { REFUSED_UNIT_SPELLINGS, Unit, exactScaleToNumber } from '@danielsimonjr/mathts-core';
|
|
28
|
+
import { scaleToNumber, solidusSides, uptExactScaleFromCore } from './exact-scale.js';
|
|
29
|
+
import { isSubKiloParsec, mathtsParsedDimension } from './mathts-unit-delegation.js';
|
|
30
|
+
import { UNIT_DATA } from './unit-data.js';
|
|
31
|
+
const DIMENSIONLESS = { L: 0, M: 0, T: 0, I: 0, Theta: 0, N: 0, J: 0 };
|
|
32
|
+
const REFUSED = UNIT_DATA.refused;
|
|
33
|
+
const UNITS = UNIT_DATA.units;
|
|
34
|
+
/** Agreed spellings that fully parse through MathTS (Part A step A5). The 0.21.0
|
|
35
|
+
* core adds the day symbol, the angstrom spellings, and SI prefixes on `psi` and
|
|
36
|
+
* `torr`; the k-and-up parsec spellings agree with the table double for double.
|
|
37
|
+
* The 0.22.0 core adds the glued products `m2K`, `Vs`, `cm^2/Vs` and `W/m2K`. */
|
|
38
|
+
export const A5_DELEGATED_TEXTS = [
|
|
39
|
+
'km',
|
|
40
|
+
'degC',
|
|
41
|
+
'g/cm^3',
|
|
42
|
+
'mN/m',
|
|
43
|
+
'kohm',
|
|
44
|
+
'GeV',
|
|
45
|
+
'km/s/Mpc',
|
|
46
|
+
'd',
|
|
47
|
+
'day',
|
|
48
|
+
'Angstrom',
|
|
49
|
+
'angstrom',
|
|
50
|
+
'Å',
|
|
51
|
+
'psi',
|
|
52
|
+
'torr',
|
|
53
|
+
'kpsi',
|
|
54
|
+
'Mpsi',
|
|
55
|
+
'mtorr',
|
|
56
|
+
'utorr',
|
|
57
|
+
'kpc',
|
|
58
|
+
'Mpc',
|
|
59
|
+
'Gpc',
|
|
60
|
+
'm2K',
|
|
61
|
+
'Vs',
|
|
62
|
+
'cm^2/Vs',
|
|
63
|
+
'W/m2K',
|
|
64
|
+
];
|
|
65
|
+
const A5_DELEGATED = new Set(A5_DELEGATED_TEXTS);
|
|
66
|
+
const SUPERSCRIPT = { '¹': 1, '²': 2, '³': 3, '⁻¹': -1, '⁻²': -2, '⁻³': -3 };
|
|
67
|
+
function sideTokens(text) {
|
|
68
|
+
return text.split(/[*·\s]+|(?<=[A-Za-zµμΩ])\.(?=[A-Za-zµμΩ])/).filter((part) => part.length > 0);
|
|
69
|
+
}
|
|
70
|
+
function trySymbolBase(token) {
|
|
71
|
+
if (UNITS.has(token))
|
|
72
|
+
return token;
|
|
73
|
+
for (const [prefix] of UNIT_DATA.prefixes) {
|
|
74
|
+
if (!token.startsWith(prefix) || token.length === prefix.length)
|
|
75
|
+
continue;
|
|
76
|
+
const base = token.slice(prefix.length);
|
|
77
|
+
const row = UNITS.get(base);
|
|
78
|
+
if (row !== undefined && row.prefixable)
|
|
79
|
+
return base;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
function factorBase(token) {
|
|
84
|
+
let base = token;
|
|
85
|
+
const caret = /^(.+)\^([+-]?\d+)$/.exec(token);
|
|
86
|
+
if (caret !== null)
|
|
87
|
+
base = caret[1];
|
|
88
|
+
else {
|
|
89
|
+
const uni = /^(.*?)(⁻?[¹²³])$/.exec(token);
|
|
90
|
+
if (uni !== null && SUPERSCRIPT[uni[2]] !== undefined && uni[1].length > 0)
|
|
91
|
+
base = uni[1];
|
|
92
|
+
else {
|
|
93
|
+
const glued = /^(.*?)([1-9]\d*)$/.exec(token);
|
|
94
|
+
if (glued !== null && glued[1].length > 0 && trySymbolBase(glued[1]) !== null)
|
|
95
|
+
base = glued[1];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return trySymbolBase(base);
|
|
99
|
+
}
|
|
100
|
+
/** A token MathTS refuses by name: UPT policy rows first, then the MathTS registry. */
|
|
101
|
+
function refusalReasonFor(token) {
|
|
102
|
+
return REFUSED.get(token) ?? REFUSED_UNIT_SPELLINGS[token];
|
|
103
|
+
}
|
|
104
|
+
/** Tokens whose spelling carries a refusal reason: UPT policy rows first, then MathTS's registry. */
|
|
105
|
+
export function refusedTokensIn(text) {
|
|
106
|
+
const t = text.trim();
|
|
107
|
+
if (t === '' || t === '1')
|
|
108
|
+
return [];
|
|
109
|
+
const whole = refusalReasonFor(t);
|
|
110
|
+
if (whole !== undefined)
|
|
111
|
+
return [t];
|
|
112
|
+
const { numerator, denominator } = solidusSides(t);
|
|
113
|
+
const tokens = [...sideTokens(numerator), ...sideTokens(denominator)];
|
|
114
|
+
const hits = [];
|
|
115
|
+
for (const token of tokens) {
|
|
116
|
+
if (token === '1')
|
|
117
|
+
continue;
|
|
118
|
+
if (refusalReasonFor(token) !== undefined)
|
|
119
|
+
hits.push(token);
|
|
120
|
+
else {
|
|
121
|
+
const base = factorBase(token);
|
|
122
|
+
if (base !== null && refusalReasonFor(base) !== undefined)
|
|
123
|
+
hits.push(base);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return hits;
|
|
127
|
+
}
|
|
128
|
+
/** Refusal message: UPT policy (`ton`) first, then the MathTS registry (`dB` and friends). Null when the text is not denied. */
|
|
129
|
+
export function uptRefusalReason(text) {
|
|
130
|
+
const hits = refusedTokensIn(text);
|
|
131
|
+
if (hits.length === 0)
|
|
132
|
+
return null;
|
|
133
|
+
const token = hits[0];
|
|
134
|
+
return refusalReasonFor(token) ?? null;
|
|
135
|
+
}
|
|
136
|
+
/** Whether `text` is on the Part A step A5 delegated spelling list. */
|
|
137
|
+
export function isA5DelegatedText(text) {
|
|
138
|
+
return A5_DELEGATED.has(text.trim());
|
|
139
|
+
}
|
|
140
|
+
/** Whether MathTS `Unit.parse` accepts `text`. */
|
|
141
|
+
export function mathtsWouldParse(text) {
|
|
142
|
+
try {
|
|
143
|
+
Unit.parse(text.trim());
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** Keep `bit` at ln 2 nat on the 7-vector (A11a). */
|
|
151
|
+
export function applyBitScaleOverride(text, exact, scale) {
|
|
152
|
+
if (text.trim() !== 'bit')
|
|
153
|
+
return { exact, scale };
|
|
154
|
+
const row = UNITS.get('bit');
|
|
155
|
+
if (row === undefined)
|
|
156
|
+
return { exact, scale };
|
|
157
|
+
const localScale = scaleToNumber(row.scale);
|
|
158
|
+
return { exact: row.scale, scale: localScale };
|
|
159
|
+
}
|
|
160
|
+
function affineDim(text) {
|
|
161
|
+
const row = UNIT_DATA.affine.find((candidate) => candidate.symbols.includes(text));
|
|
162
|
+
return row === undefined ? null : { ...DIMENSIONLESS, Theta: 1 };
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Scale and dimension for an A5 in-set text through MathTS only (A12 partial).
|
|
166
|
+
* Returns null when the text is not on the A5 list or MathTS rejects it.
|
|
167
|
+
*/
|
|
168
|
+
export function tryMathtsA5Reading(text) {
|
|
169
|
+
const t = text.trim();
|
|
170
|
+
if (isSubKiloParsec(t))
|
|
171
|
+
return null;
|
|
172
|
+
if (!isA5DelegatedText(t))
|
|
173
|
+
return null;
|
|
174
|
+
const affineDimHint = affineDim(t);
|
|
175
|
+
try {
|
|
176
|
+
Unit.parse(t);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const core = Unit.exactScale(t);
|
|
182
|
+
if (core === null)
|
|
183
|
+
return null;
|
|
184
|
+
const scale = exactScaleToNumber(core);
|
|
185
|
+
const dim = mathtsParsedDimension(t, affineDimHint ?? DIMENSIONLESS);
|
|
186
|
+
const exact = UNITS.get(t)?.scale ?? uptExactScaleFromCore(core);
|
|
187
|
+
const overridden = applyBitScaleOverride(t, exact, scale);
|
|
188
|
+
return { exact: overridden.exact, scale: overridden.scale, dim, cycles: 0 };
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=mathts-unit-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mathts-unit-wrapper.js","sourceRoot":"","sources":["../../src/dimensional/mathts-unit-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,sBAAsB,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,qBAAqB,EAAmB,MAAM,kBAAkB,CAAC;AACvG,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,MAAM,aAAa,GAAc,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,C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,EAAE,CAAC,EAAE,CAAC;AACnE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACtB,IAAI,eAAe,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,MAAM,aAAa,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACnC,IAAI,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,qBAAqB,CAAC,CAAC,EAAE,aAAa,IAAI,aAAa,CAAC,CAAC;IACrE,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC1D,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AAC9E,CAAC","sourcesContent":["/**\n * UPT unit wrapper policy on top of MathTS (Part A steps A8, A11, A12 partial).\n *\n * Admission, refusal policy, and cycle counting stay here even when parsing and\n * scales delegate to MathTS. Four deliberate overrides of MathTS defaults are\n * layered here, each pinned by a test that reads both sides:\n *\n * 1. `ton` and `tons` — MathTS names them ambiguous; UPT refuses them with its own\n * message (`data/units.json`, `tests/dimensional/unit-wrapper-refusal.test.ts`).\n * 2. An affine temperature inside a compound — MathTS refuses `degC/s` but parses the\n * spaced `deg C/s`; UPT refuses both (`localUnitReadings`,\n * `tests/dimensional/mathts-unit-gaps.test.ts`).\n * 3. `pc` prefixes — MathTS admits only k and up (`SHORT_UP_ONLY`); UPT's\n * prefix table applies to every prefixable row, so `mpc` stays on the local\n * grammar (`isSubKiloParsec`, `tests/dimensional/unit-override-parsec.test.ts`).\n * 4. `bit` — MathTS reports scale 1 on its bit axis; UPT keeps ln 2 nat\n * (`applyBitScaleOverride`, `tests/dimensional/unit-wrapper-bit.test.ts`).\n *\n * The refusal *definitions* for `dB`, `dBm`, `dBW`, `Np`, `Mach` and `mach` are\n * MathTS's `REFUSED_UNIT_SPELLINGS` (0.21.0); `data/units.json` no longer\n * repeats them. The wrapper turns a MathTS refusal into `UnitRefusedError`\n * before any parse, compounds included.\n *\n * @module dimensional/mathts-unit-wrapper\n * @internal\n */\nimport { REFUSED_UNIT_SPELLINGS, Unit, exactScaleToNumber } from '@danielsimonjr/mathts-core';\nimport { scaleToNumber, solidusSides, uptExactScaleFromCore, type ExactScale } from './exact-scale.js';\nimport { isSubKiloParsec, mathtsParsedDimension } from './mathts-unit-delegation.js';\nimport { UNIT_DATA } from './unit-data.js';\nimport type { Dimension } from './types.js';\n\nconst DIMENSIONLESS: Dimension = { L: 0, M: 0, T: 0, I: 0, Theta: 0, N: 0, J: 0 };\n\nconst REFUSED = UNIT_DATA.refused;\nconst UNITS = UNIT_DATA.units;\n\n/** Agreed spellings that fully parse through MathTS (Part A step A5). The 0.21.0\n * core adds the day symbol, the angstrom spellings, and SI prefixes on `psi` and\n * `torr`; the k-and-up parsec spellings agree with the table double for double.\n * The 0.22.0 core adds the glued products `m2K`, `Vs`, `cm^2/Vs` and `W/m2K`. */\nexport const A5_DELEGATED_TEXTS = [\n 'km',\n 'degC',\n 'g/cm^3',\n 'mN/m',\n 'kohm',\n 'GeV',\n 'km/s/Mpc',\n 'd',\n 'day',\n 'Angstrom',\n 'angstrom',\n 'Å',\n 'psi',\n 'torr',\n 'kpsi',\n 'Mpsi',\n 'mtorr',\n 'utorr',\n 'kpc',\n 'Mpc',\n 'Gpc',\n 'm2K',\n 'Vs',\n 'cm^2/Vs',\n 'W/m2K',\n] as const;\n\nconst A5_DELEGATED = new Set<string>(A5_DELEGATED_TEXTS);\n\nconst SUPERSCRIPT: Readonly<Record<string, number>> = { '¹': 1, '²': 2, '³': 3, '⁻¹': -1, '⁻²': -2, '⁻³': -3 };\n\nfunction sideTokens(text: string): string[] {\n return text.split(/[*·\\s]+|(?<=[A-Za-zµμΩ])\\.(?=[A-Za-zµμΩ])/).filter((part) => part.length > 0);\n}\n\nfunction trySymbolBase(token: string): string | null {\n if (UNITS.has(token)) return token;\n for (const [prefix] of UNIT_DATA.prefixes) {\n if (!token.startsWith(prefix) || token.length === prefix.length) continue;\n const base = token.slice(prefix.length);\n const row = UNITS.get(base);\n if (row !== undefined && row.prefixable) return base;\n }\n return null;\n}\n\nfunction factorBase(token: string): string | null {\n let base = token;\n const caret = /^(.+)\\^([+-]?\\d+)$/.exec(token);\n if (caret !== null) base = caret[1]!;\n else {\n const uni = /^(.*?)(⁻?[¹²³])$/.exec(token);\n if (uni !== null && SUPERSCRIPT[uni[2]!] !== undefined && uni[1]!.length > 0) base = uni[1]!;\n else {\n const glued = /^(.*?)([1-9]\\d*)$/.exec(token);\n if (glued !== null && glued[1]!.length > 0 && trySymbolBase(glued[1]!) !== null) base = glued[1]!;\n }\n }\n return trySymbolBase(base);\n}\n\n/** A token MathTS refuses by name: UPT policy rows first, then the MathTS registry. */\nfunction refusalReasonFor(token: string): string | undefined {\n return REFUSED.get(token) ?? REFUSED_UNIT_SPELLINGS[token];\n}\n\n/** Tokens whose spelling carries a refusal reason: UPT policy rows first, then MathTS's registry. */\nexport function refusedTokensIn(text: string): readonly string[] {\n const t = text.trim();\n if (t === '' || t === '1') return [];\n const whole = refusalReasonFor(t);\n if (whole !== undefined) return [t];\n const { numerator, denominator } = solidusSides(t);\n const tokens = [...sideTokens(numerator), ...sideTokens(denominator)];\n const hits: string[] = [];\n for (const token of tokens) {\n if (token === '1') continue;\n if (refusalReasonFor(token) !== undefined) hits.push(token);\n else {\n const base = factorBase(token);\n if (base !== null && refusalReasonFor(base) !== undefined) hits.push(base);\n }\n }\n return hits;\n}\n\n/** Refusal message: UPT policy (`ton`) first, then the MathTS registry (`dB` and friends). Null when the text is not denied. */\nexport function uptRefusalReason(text: string): string | null {\n const hits = refusedTokensIn(text);\n if (hits.length === 0) return null;\n const token = hits[0]!;\n return refusalReasonFor(token) ?? null;\n}\n\n/** Whether `text` is on the Part A step A5 delegated spelling list. */\nexport function isA5DelegatedText(text: string): boolean {\n return A5_DELEGATED.has(text.trim());\n}\n\n/** Whether MathTS `Unit.parse` accepts `text`. */\nexport function mathtsWouldParse(text: string): boolean {\n try {\n Unit.parse(text.trim());\n return true;\n } catch {\n return false;\n }\n}\n\n/** Keep `bit` at ln 2 nat on the 7-vector (A11a). */\nexport function applyBitScaleOverride(text: string, exact: ExactScale, scale: number): { readonly exact: ExactScale; readonly scale: number } {\n if (text.trim() !== 'bit') return { exact, scale };\n const row = UNITS.get('bit');\n if (row === undefined) return { exact, scale };\n const localScale = scaleToNumber(row.scale);\n return { exact: row.scale, scale: localScale };\n}\n\n/** Scale, dimension, and cycles for one A5 in-set text read through MathTS. */\nexport interface MathtsDelegatedReading {\n readonly exact: ExactScale;\n readonly scale: number;\n readonly dim: Dimension;\n readonly cycles: number;\n}\n\nfunction affineDim(text: string): Dimension | null {\n const row = UNIT_DATA.affine.find((candidate) => candidate.symbols.includes(text));\n return row === undefined ? null : { ...DIMENSIONLESS, Theta: 1 };\n}\n\n/**\n * Scale and dimension for an A5 in-set text through MathTS only (A12 partial).\n * Returns null when the text is not on the A5 list or MathTS rejects it.\n */\nexport function tryMathtsA5Reading(text: string): MathtsDelegatedReading | null {\n const t = text.trim();\n if (isSubKiloParsec(t)) return null;\n if (!isA5DelegatedText(t)) return null;\n const affineDimHint = affineDim(t);\n try {\n Unit.parse(t);\n } catch {\n return null;\n }\n const core = Unit.exactScale(t);\n if (core === null) return null;\n const scale = exactScaleToNumber(core);\n const dim = mathtsParsedDimension(t, affineDimHint ?? DIMENSIONLESS);\n const exact = UNITS.get(t)?.scale ?? uptExactScaleFromCore(core);\n const overridden = applyBitScaleOverride(t, exact, scale);\n return { exact: overridden.exact, scale: overridden.scale, dim, cycles: 0 };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metric.d.ts","sourceRoot":"","sources":["../../src/dimensional/metric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EACV,gBAAgB,EAChB,kBAAkB,EAClB,2BAA2B,EAC3B,cAAc,EACf,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,EACnC,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,EACjB,kBAAkB,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU,GACpD,gBAAgB,CAWlB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CACvB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,GAAG,GAAE,SAAyB,GAC7B,kBAAkB,CASpB;AAED;;;GAGG;AACH,wBAAgB,MAAM,CACpB,EAAE,EAAE,QAAQ,EAC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GAAG;KACX,CAAC;IACF,IAAI,CAAC,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;QACtC,QAAgE,CAAC,kBAAkB;YAClF,CAAC,CAAC,kBAAkB,CAAC;IACzB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;AAC/D,CAAC","sourcesContent":["/**\n * User-facing constructors and ergonomic helpers for v0.3.0 metric-layer\n * AST nodes. The substantive logic (alpha-conversion) lives in raise() /\n * lower() (added in Task 8 — this file's initial revision contains only\n * the trivial constructors).\n *\n * Per docs/specification/Part-VIII-Metric-Layer.md §VIII.5 (raise/lower\n * contract) and §VIII.1 (grammar).\n *\n * @module dimensional/metric\n */\n\nimport type { Dimension } from './types.js';\nimport { DIMENSIONLESS } from './types.js';\nimport { freshLabel } from './fresh-label.js';\nimport type { TensorIndex } from './tensor.js';\nimport type { TensorProductNode } from './tensor.js';\nimport type {\n MetricTensorNode,\n KroneckerDeltaNode,\n TensorPartialDerivativeNode,\n CovariantIndex,\n} from './metric-validators.js';\nimport type { ExprNode } from './validator.js';\nimport { validate } from './validator.js';\nimport { MetricSignatureError, UPTError } from './errors.js';\n\n/**\n * Construct a metric-tensor node.\n *\n * @param name Symbolic name of the metric (e.g. `'g'`).\n * @param indices Exactly two TensorIndex entries (rank-2 requirement).\n * @param dim Physical dimension of the metric components.\n * @param signature Comma-separated `'+'`/`'-'` signs (e.g. `'+,-,-,-'`).\n * @param derivativeStrategy Optional hint for the numerical engine:\n * how to compute ∂g for Christoffel / ∇_μ. `'zero'` = constant metric\n * (∂g=0, Γ=0, ∇_μ=∂_μ); `'supplied'` = caller provides ∂g components;\n * `'computed'` (the default) = the lowering treats a raw-tensor metric\n * input as constant (∂g=0) — nothing is auto-differentiated. Metric\n * closures in `inputs.fields` take the curvature paths, which\n * finite-difference the closures.\n * Omit to leave the field absent (engine defaults to `'computed'`).\n */\nexport function metric(\n name: string,\n indices: ReadonlyArray<TensorIndex>,\n dim: Dimension,\n signature: string,\n derivativeStrategy?: 'computed' | 'zero' | 'supplied',\n): MetricTensorNode {\n const node: {\n kind: 'metric-tensor';\n name: string;\n indices: ReadonlyArray<TensorIndex>;\n signature: string;\n dim: Dimension;\n derivativeStrategy?: 'computed' | 'zero' | 'supplied';\n } = { kind: 'metric-tensor', name, indices, signature, dim };\n if (derivativeStrategy !== undefined) node.derivativeStrategy = derivativeStrategy;\n return node;\n}\n\n/**\n * Construct a Kronecker delta δ^upperLabel_lowerLabel.\n * Parameter order: upper first, lower second (canonical δ^μ_ν).\n * dim defaults to DIMENSIONLESS (Design §13 Q3 locked).\n */\nexport function kronecker(\n upperLabel: string,\n lowerLabel: string,\n dim: Dimension = DIMENSIONLESS,\n): KroneckerDeltaNode {\n return {\n kind: 'kronecker-delta',\n indices: [\n { label: upperLabel, variance: 'upper' },\n { label: lowerLabel, variance: 'lower' },\n ],\n dim,\n };\n}\n\n/**\n * Construct a tensor-partial-derivative. wrtIndex.variance MUST be 'lower'\n * — TypeScript enforces this via the CovariantIndex type.\n */\nexport function pderiv(\n of: ExprNode,\n wrt: ExprNode,\n wrtIndex: CovariantIndex,\n): TensorPartialDerivativeNode {\n return { kind: 'tensor-partial-derivative', of, wrt, wrtIndex };\n}\n\n/** Thrown by raise() / lower() when the operand's label is absent or has\n * the wrong variance for the requested operation. Private to this module\n * (not part of the public error surface per Design §6). */\nclass RaiseLowerInvalidLabelError extends UPTError {\n constructor(message: string) {\n super(message);\n this.name = 'RaiseLowerInvalidLabelError';\n Object.setPrototypeOf(this, RaiseLowerInvalidLabelError.prototype);\n }\n}\n\n/**\n * Collect free-index labels from an ExprNode by calling validate(). Returns\n * a map from label → variance (whichever side has count > 0). Note: this\n * performs a full subtree validation on `operand`; cost is acceptable for\n * typical raise/lower call sites (operand is a small subtree).\n */\nfunction collectFreeIndexLabels(node: ExprNode): Map<string, 'upper' | 'lower'> {\n const result = validate(node);\n const labels = new Map<string, 'upper' | 'lower'>();\n for (const [label, counts] of result.freeIndices) {\n if (counts.upper > 0) labels.set(label, 'upper');\n else if (counts.lower > 0) labels.set(label, 'lower');\n }\n return labels;\n}\n\n/**\n * Raise an index of `operand` via the inverse metric `gInverse`.\n *\n * Internal alpha-conversion: one of `gInverse`'s labels is renamed to\n * match `label` (so the Einstein-summation contraction picks it up);\n * the other is renamed to a fresh label that doesn't collide with any\n * free index in `operand`. The fresh label becomes the resulting\n * tensor-product's only new free index.\n *\n * Per Part-VIII §VIII.5 (raise/lower contract).\n *\n * Throws:\n * - MetricSignatureError if gInverse isn't both-upper\n * - RaiseLowerInvalidLabelError if label is absent or already upper in operand\n */\nexport function raise(\n operand: ExprNode,\n gInverse: MetricTensorNode,\n label: string,\n): TensorProductNode {\n if (\n gInverse.indices[0].variance !== 'upper' ||\n gInverse.indices[1].variance !== 'upper'\n ) {\n throw new MetricSignatureError(\n gInverse.name,\n `raise() requires both indices of the inverse metric to have variance 'upper'`,\n );\n }\n const operandLabels = collectFreeIndexLabels(operand);\n const operandVariance = operandLabels.get(label);\n if (operandVariance === undefined) {\n throw new RaiseLowerInvalidLabelError(\n `raise(): label '${label}' is not a free index of the operand. ` +\n `Operand free indices: ${Array.from(operandLabels.keys()).join(', ') || '(none)'}.`,\n );\n }\n if (operandVariance === 'upper') {\n throw new RaiseLowerInvalidLabelError(\n `raise(): label '${label}' is already 'upper' in the operand. ` +\n `Use lower() to lower it, or pick a different label.`,\n );\n }\n\n // Alpha-conversion: rename gInverse[0] → label (the dummy that contracts);\n // gInverse[1] → freshLabel(gInverse[1].label, operand-free-labels).\n const taken = new Set(operandLabels.keys());\n taken.add(label);\n const renamed = freshLabel(gInverse.indices[1].label, taken);\n\n const renamedGInverse: MetricTensorNode = {\n kind: 'metric-tensor',\n name: gInverse.name,\n indices: [\n { label, variance: 'upper' },\n { label: renamed, variance: 'upper' },\n ],\n signature: gInverse.signature,\n dim: gInverse.dim,\n };\n if (gInverse.derivativeStrategy !== undefined) {\n (renamedGInverse as { derivativeStrategy: typeof gInverse.derivativeStrategy }).derivativeStrategy =\n gInverse.derivativeStrategy;\n }\n\n return { kind: 'tensor-product', args: [renamedGInverse, operand] };\n}\n\n/**\n * Lower an index of `operand` via the covariant metric `g`.\n * Symmetric to raise(). Per Part-VIII §VIII.5.\n *\n * Throws:\n * - MetricSignatureError if g isn't both-lower\n * - RaiseLowerInvalidLabelError if label is absent or already lower in operand\n */\nexport function lower(\n operand: ExprNode,\n g: MetricTensorNode,\n label: string,\n): TensorProductNode {\n if (\n g.indices[0].variance !== 'lower' ||\n g.indices[1].variance !== 'lower'\n ) {\n throw new MetricSignatureError(\n g.name,\n `lower() requires both indices of the metric to have variance 'lower'`,\n );\n }\n const operandLabels = collectFreeIndexLabels(operand);\n const operandVariance = operandLabels.get(label);\n if (operandVariance === undefined) {\n throw new RaiseLowerInvalidLabelError(\n `lower(): label '${label}' is not a free index of the operand. ` +\n `Operand free indices: ${Array.from(operandLabels.keys()).join(', ') || '(none)'}.`,\n );\n }\n if (operandVariance === 'lower') {\n throw new RaiseLowerInvalidLabelError(\n `lower(): label '${label}' is already 'lower' in the operand. ` +\n `Use raise() to raise it, or pick a different label.`,\n );\n }\n\n const taken = new Set(operandLabels.keys());\n taken.add(label);\n const renamed = freshLabel(g.indices[1].label, taken);\n\n const renamedG: MetricTensorNode = {\n kind: 'metric-tensor',\n name: g.name,\n indices: [\n { label, variance: 'lower' },\n { label: renamed, variance: 'lower' },\n ],\n signature: g.signature,\n dim: g.dim,\n };\n if (g.derivativeStrategy !== undefined) {\n (renamedG as { derivativeStrategy: typeof g.derivativeStrategy }).derivativeStrategy =\n g.derivativeStrategy;\n }\n\n return { kind: 'tensor-product', args: [renamedG, operand] };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"metric.js","sourceRoot":"","sources":["../../src/dimensional/metric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC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3.0 metric-layer\n * AST nodes. The substantive logic (alpha-conversion) lives in raise() /\n * lower() (added in Task 8 — this file's initial revision contains only\n * the trivial constructors).\n *\n * Per docs/specification/Part-VIII-Metric-Layer.md §VIII.5 (raise/lower\n * contract) and §VIII.1 (grammar).\n *\n * @module dimensional/metric\n */\n\nimport type { Dimension } from './types.js';\nimport { DIMENSIONLESS } from './types.js';\nimport { freshLabel } from './fresh-label.js';\nimport type { TensorIndex } from './tensor.js';\nimport type { TensorProductNode } from './tensor.js';\nimport type {\n MetricTensorNode,\n KroneckerDeltaNode,\n TensorPartialDerivativeNode,\n CovariantIndex,\n} from './metric-validators.js';\nimport type { ExprNode } from './validator.js';\nimport { validate } from './validator.js';\nimport { MetricSignatureError, UPTError } from './errors.js';\n\n/**\n * Construct a metric-tensor node.\n *\n * @param name Symbolic name of the metric (e.g. `'g'`).\n * @param indices Exactly two TensorIndex entries (rank-2 requirement).\n * @param dim Physical dimension of the metric components.\n * @param signature Comma-separated `'+'`/`'-'` signs (e.g. `'+,-,-,-'`).\n * @param derivativeStrategy Optional hint for the numerical engine:\n * how to compute ∂g for Christoffel / ∇_μ. `'zero'` = constant metric\n * (∂g=0, Γ=0, ∇_μ=∂_μ); `'supplied'` = caller provides ∂g components;\n * `'computed'` (the default) = the lowering treats a raw-tensor metric\n * input as constant (∂g=0) — nothing is auto-differentiated. Metric\n * closures in `inputs.fields` take the curvature paths, which\n * finite-difference the closures.\n * Omit to leave the field absent (engine defaults to `'computed'`).\n */\nexport function metric(\n name: string,\n indices: ReadonlyArray<TensorIndex>,\n dim: Dimension,\n signature: string,\n derivativeStrategy?: 'computed' | 'zero' | 'supplied',\n): MetricTensorNode {\n const node: {\n kind: 'metric-tensor';\n name: string;\n indices: ReadonlyArray<TensorIndex>;\n signature: string;\n dim: Dimension;\n derivativeStrategy?: 'computed' | 'zero' | 'supplied';\n } = { kind: 'metric-tensor', name, indices, signature, dim };\n if (derivativeStrategy !== undefined) node.derivativeStrategy = derivativeStrategy;\n return node;\n}\n\n/**\n * Construct a Kronecker delta δ^upperLabel_lowerLabel.\n * Parameter order: upper first, lower second (canonical δ^μ_ν).\n * dim defaults to DIMENSIONLESS (Design §13 Q3 locked).\n */\nexport function kronecker(\n upperLabel: string,\n lowerLabel: string,\n dim: Dimension = DIMENSIONLESS,\n): KroneckerDeltaNode {\n return {\n kind: 'kronecker-delta',\n indices: [\n { label: upperLabel, variance: 'upper' },\n { label: lowerLabel, variance: 'lower' },\n ],\n dim,\n };\n}\n\n/**\n * Construct a tensor-partial-derivative. wrtIndex.variance MUST be 'lower'\n * — TypeScript enforces this via the CovariantIndex type.\n */\nexport function pderiv(\n of: ExprNode,\n wrt: ExprNode,\n wrtIndex: CovariantIndex,\n): TensorPartialDerivativeNode {\n return { kind: 'tensor-partial-derivative', of, wrt, wrtIndex };\n}\n\n/** Thrown by raise() / lower() when the operand's label is absent or has\n * the wrong variance for the requested operation. Private to this module\n * (not part of the public error surface per Design §6). */\nclass RaiseLowerInvalidLabelError extends UPTError {\n constructor(message: string) {\n super(message);\n this.name = 'RaiseLowerInvalidLabelError';\n }\n}\n\n/**\n * Collect free-index labels from an ExprNode by calling validate(). Returns\n * a map from label → variance (whichever side has count > 0). Note: this\n * performs a full subtree validation on `operand`; cost is acceptable for\n * typical raise/lower call sites (operand is a small subtree).\n */\nfunction collectFreeIndexLabels(node: ExprNode): Map<string, 'upper' | 'lower'> {\n const result = validate(node);\n const labels = new Map<string, 'upper' | 'lower'>();\n for (const [label, counts] of result.freeIndices) {\n if (counts.upper > 0) labels.set(label, 'upper');\n else if (counts.lower > 0) labels.set(label, 'lower');\n }\n return labels;\n}\n\n/**\n * Raise an index of `operand` via the inverse metric `gInverse`.\n *\n * Internal alpha-conversion: one of `gInverse`'s labels is renamed to\n * match `label` (so the Einstein-summation contraction picks it up);\n * the other is renamed to a fresh label that doesn't collide with any\n * free index in `operand`. The fresh label becomes the resulting\n * tensor-product's only new free index.\n *\n * Per Part-VIII §VIII.5 (raise/lower contract).\n *\n * Throws:\n * - MetricSignatureError if gInverse isn't both-upper\n * - RaiseLowerInvalidLabelError if label is absent or already upper in operand\n */\nexport function raise(\n operand: ExprNode,\n gInverse: MetricTensorNode,\n label: string,\n): TensorProductNode {\n if (\n gInverse.indices[0].variance !== 'upper' ||\n gInverse.indices[1].variance !== 'upper'\n ) {\n throw new MetricSignatureError(\n gInverse.name,\n `raise() requires both indices of the inverse metric to have variance 'upper'`,\n );\n }\n const operandLabels = collectFreeIndexLabels(operand);\n const operandVariance = operandLabels.get(label);\n if (operandVariance === undefined) {\n throw new RaiseLowerInvalidLabelError(\n `raise(): label '${label}' is not a free index of the operand. ` +\n `Operand free indices: ${Array.from(operandLabels.keys()).join(', ') || '(none)'}.`,\n );\n }\n if (operandVariance === 'upper') {\n throw new RaiseLowerInvalidLabelError(\n `raise(): label '${label}' is already 'upper' in the operand. ` +\n `Use lower() to lower it, or pick a different label.`,\n );\n }\n\n // Alpha-conversion: rename gInverse[0] → label (the dummy that contracts);\n // gInverse[1] → freshLabel(gInverse[1].label, operand-free-labels).\n const taken = new Set(operandLabels.keys());\n taken.add(label);\n const renamed = freshLabel(gInverse.indices[1].label, taken);\n\n const renamedGInverse: MetricTensorNode = {\n kind: 'metric-tensor',\n name: gInverse.name,\n indices: [\n { label, variance: 'upper' },\n { label: renamed, variance: 'upper' },\n ],\n signature: gInverse.signature,\n dim: gInverse.dim,\n };\n if (gInverse.derivativeStrategy !== undefined) {\n (renamedGInverse as { derivativeStrategy: typeof gInverse.derivativeStrategy }).derivativeStrategy =\n gInverse.derivativeStrategy;\n }\n\n return { kind: 'tensor-product', args: [renamedGInverse, operand] };\n}\n\n/**\n * Lower an index of `operand` via the covariant metric `g`.\n * Symmetric to raise(). Per Part-VIII §VIII.5.\n *\n * Throws:\n * - MetricSignatureError if g isn't both-lower\n * - RaiseLowerInvalidLabelError if label is absent or already lower in operand\n */\nexport function lower(\n operand: ExprNode,\n g: MetricTensorNode,\n label: string,\n): TensorProductNode {\n if (\n g.indices[0].variance !== 'lower' ||\n g.indices[1].variance !== 'lower'\n ) {\n throw new MetricSignatureError(\n g.name,\n `lower() requires both indices of the metric to have variance 'lower'`,\n );\n }\n const operandLabels = collectFreeIndexLabels(operand);\n const operandVariance = operandLabels.get(label);\n if (operandVariance === undefined) {\n throw new RaiseLowerInvalidLabelError(\n `lower(): label '${label}' is not a free index of the operand. ` +\n `Operand free indices: ${Array.from(operandLabels.keys()).join(', ') || '(none)'}.`,\n );\n }\n if (operandVariance === 'lower') {\n throw new RaiseLowerInvalidLabelError(\n `lower(): label '${label}' is already 'lower' in the operand. ` +\n `Use raise() to raise it, or pick a different label.`,\n );\n }\n\n const taken = new Set(operandLabels.keys());\n taken.add(label);\n const renamed = freshLabel(g.indices[1].label, taken);\n\n const renamedG: MetricTensorNode = {\n kind: 'metric-tensor',\n name: g.name,\n indices: [\n { label, variance: 'lower' },\n { label: renamed, variance: 'lower' },\n ],\n signature: g.signature,\n dim: g.dim,\n };\n if (g.derivativeStrategy !== undefined) {\n (renamedG as { derivativeStrategy: typeof g.derivativeStrategy }).derivativeStrategy =\n g.derivativeStrategy;\n }\n\n return { kind: 'tensor-product', args: [renamedG, operand] };\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one lowering of a UPT scalar `ExprNode` to a MathTS `ScalarNode`.
|
|
3
|
+
*
|
|
4
|
+
* MathTS `evaluateScalar` and `compileScalarGradient` read a one-argument `-`
|
|
5
|
+
* as the identity: `op('-', [x])` at x = 3 evaluates to 3. This module writes
|
|
6
|
+
* `−x` as `(−1)·x` and `+x` as `x` before the MathTS scalar builder reads the
|
|
7
|
+
* tree. Every other node goes to the builder unchanged. `composition/expr-eval`
|
|
8
|
+
* and `diff/bridge-ast-gradient` both call this function.
|
|
9
|
+
*
|
|
10
|
+
* @module dimensional/scalar-lowering
|
|
11
|
+
*/
|
|
12
|
+
import { type ScalarNode } from '@danielsimonjr/mathts-expression';
|
|
13
|
+
import type { ExprNode } from './validator.js';
|
|
14
|
+
/**
|
|
15
|
+
* A scalar `ExprNode` as a MathTS `ScalarNode`, with each one-argument sign
|
|
16
|
+
* rewritten first.
|
|
17
|
+
* @throws ScalarBuildError (MathTS) on a node kind outside symbol, op, transcendental and abs.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare function toScalarNode(node: ExprNode): ScalarNode;
|
|
21
|
+
//# sourceMappingURL=scalar-lowering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalar-lowering.d.ts","sourceRoot":"","sources":["../../src/dimensional/scalar-lowering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,kCAAkC,CAAC;AACxF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA0B/C;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,UAAU,CAEvD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one lowering of a UPT scalar `ExprNode` to a MathTS `ScalarNode`.
|
|
3
|
+
*
|
|
4
|
+
* MathTS `evaluateScalar` and `compileScalarGradient` read a one-argument `-`
|
|
5
|
+
* as the identity: `op('-', [x])` at x = 3 evaluates to 3. This module writes
|
|
6
|
+
* `−x` as `(−1)·x` and `+x` as `x` before the MathTS scalar builder reads the
|
|
7
|
+
* tree. Every other node goes to the builder unchanged. `composition/expr-eval`
|
|
8
|
+
* and `diff/bridge-ast-gradient` both call this function.
|
|
9
|
+
*
|
|
10
|
+
* @module dimensional/scalar-lowering
|
|
11
|
+
*/
|
|
12
|
+
import { createScalarBuilder } from '@danielsimonjr/mathts-expression';
|
|
13
|
+
import { DIMENSIONLESS } from './types.js';
|
|
14
|
+
const builder = createScalarBuilder();
|
|
15
|
+
const MINUS_ONE = { kind: 'symbol', name: '-1', dim: DIMENSIONLESS };
|
|
16
|
+
/** Rewrite every one-argument sign on the scalar arms. Return every other node unchanged. */
|
|
17
|
+
function rewriteSigns(node) {
|
|
18
|
+
switch (node.kind) {
|
|
19
|
+
case 'op': {
|
|
20
|
+
const args = node.args.map(rewriteSigns);
|
|
21
|
+
if (args.length === 1) {
|
|
22
|
+
if (node.op === '-')
|
|
23
|
+
return { kind: 'op', op: '*', args: [MINUS_ONE, args[0]] };
|
|
24
|
+
if (node.op === '+')
|
|
25
|
+
return args[0];
|
|
26
|
+
}
|
|
27
|
+
return { ...node, args };
|
|
28
|
+
}
|
|
29
|
+
case 'transcendental':
|
|
30
|
+
case 'abs':
|
|
31
|
+
return { ...node, arg: rewriteSigns(node.arg) };
|
|
32
|
+
default:
|
|
33
|
+
return node;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A scalar `ExprNode` as a MathTS `ScalarNode`, with each one-argument sign
|
|
38
|
+
* rewritten first.
|
|
39
|
+
* @throws ScalarBuildError (MathTS) on a node kind outside symbol, op, transcendental and abs.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export function toScalarNode(node) {
|
|
43
|
+
return builder.from(rewriteSigns(node));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=scalar-lowering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalar-lowering.js","sourceRoot":"","sources":["../../src/dimensional/scalar-lowering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,mBAAmB,EAAmB,MAAM,kCAAkC,CAAC;AAExF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;AAEtC,MAAM,SAAS,GAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC;AAE/E,6FAA6F;AAC7F,SAAS,YAAY,CAAC,IAAc;IAClC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;YACzC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACtB,IAAI,IAAI,CAAC,EAAE,KAAK,GAAG;oBAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAE,CAAC,EAAE,CAAC;gBACjF,IAAI,IAAI,CAAC,EAAE,KAAK,GAAG;oBAAE,OAAO,IAAI,CAAC,CAAC,CAAE,CAAC;YACvC,CAAC;YACD,OAAO,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;QACD,KAAK,gBAAgB,CAAC;QACtB,KAAK,KAAK;YACR,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAClD;YACE,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,IAAc;IACzC,OAAO,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["/**\n * The one lowering of a UPT scalar `ExprNode` to a MathTS `ScalarNode`.\n *\n * MathTS `evaluateScalar` and `compileScalarGradient` read a one-argument `-`\n * as the identity: `op('-', [x])` at x = 3 evaluates to 3. This module writes\n * `−x` as `(−1)·x` and `+x` as `x` before the MathTS scalar builder reads the\n * tree. Every other node goes to the builder unchanged. `composition/expr-eval`\n * and `diff/bridge-ast-gradient` both call this function.\n *\n * @module dimensional/scalar-lowering\n */\n\nimport { createScalarBuilder, type ScalarNode } from '@danielsimonjr/mathts-expression';\nimport type { ExprNode } from './validator.js';\nimport { DIMENSIONLESS } from './types.js';\n\nconst builder = createScalarBuilder();\n\nconst MINUS_ONE: ExprNode = { kind: 'symbol', name: '-1', dim: DIMENSIONLESS };\n\n/** Rewrite every one-argument sign on the scalar arms. Return every other node unchanged. */\nfunction rewriteSigns(node: ExprNode): ExprNode {\n switch (node.kind) {\n case 'op': {\n const args = node.args.map(rewriteSigns);\n if (args.length === 1) {\n if (node.op === '-') return { kind: 'op', op: '*', args: [MINUS_ONE, args[0]!] };\n if (node.op === '+') return args[0]!;\n }\n return { ...node, args };\n }\n case 'transcendental':\n case 'abs':\n return { ...node, arg: rewriteSigns(node.arg) };\n default:\n return node;\n }\n}\n\n/**\n * A scalar `ExprNode` as a MathTS `ScalarNode`, with each one-argument sign\n * rewritten first.\n * @throws ScalarBuildError (MathTS) on a node kind outside symbol, op, transcendental and abs.\n * @internal\n */\nexport function toScalarNode(node: ExprNode): ScalarNode {\n return builder.from(rewriteSigns(node));\n}\n"]}
|
|
@@ -75,6 +75,15 @@ export interface NamedConstantValue {
|
|
|
75
75
|
* (same IEEE-754 primitives).
|
|
76
76
|
*/
|
|
77
77
|
export declare const CONSTANTS: Readonly<Record<string, NamedConstantValue>>;
|
|
78
|
+
/**
|
|
79
|
+
* True when `name` is a key of {@link CONSTANTS} itself. `in` on that plain
|
|
80
|
+
* object is true for `constructor` and every other `Object.prototype` name,
|
|
81
|
+
* which once read a leaf spelled that way as a constant; this reads the own
|
|
82
|
+
* properties only, and is the one rule for "a registered constant".
|
|
83
|
+
*
|
|
84
|
+
* @internal
|
|
85
|
+
*/
|
|
86
|
+
export declare function isRegisteredConstant(name: string): boolean;
|
|
78
87
|
/** What a registered constant is, its SI unit, and where its value comes from (audit I10). @internal */
|
|
79
88
|
export interface ConstantProvenance {
|
|
80
89
|
readonly meaning: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbolic-constants.d.ts","sourceRoot":"","sources":["../../src/dimensional/symbolic-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;
|
|
1
|
+
{"version":3,"file":"symbolic-constants.d.ts","sourceRoot":"","sources":["../../src/dimensional/symbolic-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,OAAO,EAA8B,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAElF,4FAA4F;AAC5F,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,cAAc,EAGpD,CAAC;AAkBJ,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAG3E;AASD,8HAA8H;AAC9H,qBAAa,yBAA0B,SAAQ,KAAK;IAEhD,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM;IAJxB,YACW,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EAOvB;CACF;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO3E;AAED,mGAAmG;AACnG,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAO/D;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAItD;AAED,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CACzB;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAKlE,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wGAAwG;AACxG,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,iGAAiG;IACjG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAK5E,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMhE"}
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
*
|
|
30
30
|
* @module dimensional/symbolic-constants
|
|
31
31
|
*/
|
|
32
|
+
import { withinRel } from '../core/compare.js';
|
|
32
33
|
import { parseUnit } from './units.js';
|
|
33
34
|
import { CONSTANT_ROWS, constantRow } from './constant-rows.js';
|
|
34
35
|
/**
|
|
@@ -86,7 +87,7 @@ export function constantAgreement(key, value) {
|
|
|
86
87
|
const record = BY_SPELLING.get(key);
|
|
87
88
|
if (record === undefined)
|
|
88
89
|
return null;
|
|
89
|
-
if (
|
|
90
|
+
if (!withinRel(value, record.value, CONSTANT_AGREEMENT, 0)) {
|
|
90
91
|
throw new ConstantDisagreementError(key, record.name, record.value, value);
|
|
91
92
|
}
|
|
92
93
|
return record.name;
|
|
@@ -118,6 +119,17 @@ export const CONSTANTS = Object.fromEntries(CONSTANT_REGISTRY.filter((record) =>
|
|
|
118
119
|
record.name,
|
|
119
120
|
{ value: record.value, dim: record.dim },
|
|
120
121
|
]));
|
|
122
|
+
/**
|
|
123
|
+
* True when `name` is a key of {@link CONSTANTS} itself. `in` on that plain
|
|
124
|
+
* object is true for `constructor` and every other `Object.prototype` name,
|
|
125
|
+
* which once read a leaf spelled that way as a constant; this reads the own
|
|
126
|
+
* properties only, and is the one rule for "a registered constant".
|
|
127
|
+
*
|
|
128
|
+
* @internal
|
|
129
|
+
*/
|
|
130
|
+
export function isRegisteredConstant(name) {
|
|
131
|
+
return Object.prototype.hasOwnProperty.call(CONSTANTS, name);
|
|
132
|
+
}
|
|
121
133
|
/** One row per {@link CONSTANT_REGISTRY} name. @internal */
|
|
122
134
|
export const CONSTANT_PROVENANCE = Object.fromEntries(CONSTANT_REGISTRY.map((record) => [
|
|
123
135
|
record.name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbolic-constants.js","sourceRoot":"","sources":["../../src/dimensional/symbolic-constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAoB,MAAM,oBAAoB,CAAC;AAOlF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA8B,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC3F,GAAG,QAAQ;IACX,GAAG,EAAE,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG;CAClC,CAAC,CAAC,CAAC;AAEJ,MAAM,aAAa,GAAG,IAAI,GAAG,CAA8B,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,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M,SAAS,GAAiD,MAAM,CAAC,WAAW,CACvF,iBAAiB,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IACrE,MAAM,CAAC,IAAI;IACX,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE;CACzC,CAAC,CACH,CAAC;AAUF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAiD,MAAM,CAAC,WAAW,CACjG,iBAAiB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IAChC,MAAM,CAAC,IAAI;IACX,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;CACtE,CAAC,CACH,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACjC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACpD,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * The constant registry: one row per physical constant a formula may name.\n *\n * A row (written in `constant-rows.ts`) holds the formula name, its other\n * exact-case spellings, the SI value (imported from `core/constants.js`, the\n * one owner of every value), the SI unit in `parseUnit` syntax, the meaning\n * and the source. The dimension is derived from the unit once, here; no second\n * table states it. The rows sit in their own module because the unit table\n * names constants by these spellings, and this module imports the unit parser. Every other\n * constant table in the library ({@link CONSTANTS}, `FORMULA_NAMED`,\n * `CONSTANT_SPELLINGS`, {@link CONSTANT_PROVENANCE}, `CANONICAL_CONSTANTS`,\n * the `upt eval` scope, the binding scope, the gradient constants) is a\n * projection of this array, so a spelling, a value and a dimension cannot\n * disagree between two files. A constant that is also a quantity names its\n * `data/quantities.json` row in `quantity`; the quantity registry derives that\n * row's aliases from here, so the file states no constant spelling.\n *\n * `canonical` marks a universal constant a canonical equation's `governing`\n * list may bake as a leaf. A row that is an overlay for `upt eval` and the\n * dimensional assignment only (`m_p`, `N_A`, the GRW parameters) is not\n * canonical, so the canonical graph does not bake it.\n *\n * Numeric-literal leaves (`'2'`, `'3'`) are NOT registered — `evalExpr`\n * resolves them via `Number(name)` and they are implicitly dimensionless.\n * Non-base-10 tokens (`'8pi'`, `'4pi'`, `'ln2'`) MUST be here (`Number('8pi')`\n * is `NaN`).\n *\n * INTERNAL — not on the public surface.\n *\n * @module dimensional/symbolic-constants\n */\n\nimport type { Dimension } from './types.js';\nimport { parseUnit } from './units.js';\nimport { CONSTANT_ROWS, constantRow, type ConstantRow } from './constant-rows.js';\n\n/** One registered constant: its row, with the dimension derived from its unit. @internal */\nexport interface ConstantRecord extends ConstantRow {\n readonly dim: Dimension;\n}\n\n/**\n * Every registered constant, the rows of `constant-rows.ts` with each\n * dimension derived once from its unit. Order is the order the tables print.\n * @internal\n */\nexport const CONSTANT_REGISTRY: readonly ConstantRecord[] = CONSTANT_ROWS.map((constant) => ({\n ...constant,\n dim: parseUnit(constant.unit).dim,\n}));\n\nconst RECORD_OF_ROW = new Map<ConstantRow, ConstantRecord>(CONSTANT_ROWS.map((constant, i) => [constant, CONSTANT_REGISTRY[i]!]));\n\n/**\n * Every spelling → its record; `constant-rows.ts` refuses a spelling written twice. A constant\n * that is also a quantity (`quantity`, e.g. `k_B` → `boltzmann-constant`) is reachable by that\n * quantity id too, so a user who writes the quantity's name states the constant, and the value\n * is checked against the registry rather than bound.\n */\nconst BY_SPELLING = new Map<string, ConstantRecord>(\n CONSTANT_REGISTRY.flatMap((record) =>\n [record.name, ...record.spellings, ...(record.quantity === undefined ? [] : [record.quantity])].map(\n (spelling) => [spelling, record] as const,\n ),\n ),\n);\n\n/** The registered constant `spelling` names, or undefined. @internal */\nexport function constantRecord(spelling: string): ConstantRecord | undefined {\n const constant = constantRow(spelling);\n return constant === undefined ? undefined : RECORD_OF_ROW.get(constant);\n}\n\n/**\n * Relative tolerance within which a stated constant agrees with the registered\n * value. Textbook roundings such as `b = 2.9e-3` pass.\n * @internal\n */\nconst CONSTANT_AGREEMENT = 5e-3;\n\n/** A stated value for a registered constant disagrees with the registry. The equations use the registered value. @internal */\nexport class ConstantDisagreementError extends Error {\n constructor(\n readonly key: string,\n readonly constant: string,\n readonly registered: number,\n readonly given: number,\n ) {\n super(\n `'${key}' is the registered constant ${constant} = ${registered}; ` +\n `${given} disagrees, and the equations use the registered value, so it cannot be rebound.`,\n );\n this.name = 'ConstantDisagreementError';\n }\n}\n\n/**\n * The registered constant `key` names when `value` agrees with it within\n * {@link CONSTANT_AGREEMENT}, or null when `key` names no constant. A value\n * that disagrees throws {@link ConstantDisagreementError}: a constant is not\n * a graph quantity, so a stated value is checked, never bound.\n * @internal\n */\nexport function constantAgreement(key: string, value: number): string | null {\n const record = BY_SPELLING.get(key);\n if (record === undefined) return null;\n if (Math.abs(value - record.value) > CONSTANT_AGREEMENT * Math.abs(record.value)) {\n throw new ConstantDisagreementError(key, record.name, record.value, value);\n }\n return record.name;\n}\n\n/** The notes of the registered constants among `names`, each once, in registry order. @internal */\nexport function constantNotes(names: Iterable<string>): string[] {\n const seen = new Set<ConstantRecord>();\n for (const name of names) {\n const record = BY_SPELLING.get(name);\n if (record?.note !== undefined) seen.add(record);\n }\n return CONSTANT_REGISTRY.filter((record) => seen.has(record)).map((record) => record.note!);\n}\n\n/** Every spelling → SI value, for a numeric scope. `pi` and `tau` are added. @internal */\nexport function constantScope(): Record<string, number> {\n const scope: Record<string, number> = { pi: Math.PI, tau: 2 * Math.PI };\n for (const [spelling, record] of BY_SPELLING) scope[spelling] = record.value;\n return scope;\n}\n\n/** A registered constant leaf: SI value + SI dimension. @internal */\nexport interface NamedConstantValue {\n readonly value: number;\n readonly dim: Dimension;\n}\n\n/**\n * Constant leaves a `symbolic` ExprNode may reference, keyed by formula name:\n * the canonical rows of {@link CONSTANT_REGISTRY}. `ln2`/`8pi`/`4pi`\n * reproduce the evaluators' `Math.LN2` / `8*Math.PI` / `4*Math.PI` exactly\n * (same IEEE-754 primitives).\n */\nexport const CONSTANTS: Readonly<Record<string, NamedConstantValue>> = Object.fromEntries(\n CONSTANT_REGISTRY.filter((record) => record.canonical).map((record) => [\n record.name,\n { value: record.value, dim: record.dim },\n ]),\n);\n\n/** What a registered constant is, its SI unit, and where its value comes from (audit I10). @internal */\nexport interface ConstantProvenance {\n readonly meaning: string;\n /** The SI unit, in the syntax `parseUnit` reads; the registered dimension is derived from it. */\n readonly unit: string;\n readonly source: string;\n}\n\n/** One row per {@link CONSTANT_REGISTRY} name. @internal */\nexport const CONSTANT_PROVENANCE: Readonly<Record<string, ConstantProvenance>> = Object.fromEntries(\n CONSTANT_REGISTRY.map((record) => [\n record.name,\n { meaning: record.meaning, unit: record.unit, source: record.source },\n ]),\n);\n\n/**\n * A spelled-out multiple of π written as one symbol (`pi`, `6pi`). `2pi`,\n * `4pi` and `8pi` are also registered in {@link CONSTANTS}; this covers the\n * multiples an encoder spelled out and did not register (`6pi` in\n * CE-perihelion-precession). The structural normal form already drops these.\n * The numeric evaluator has to resolve them too, or a comparison treats `6pi`\n * as a free symbol and never aligns the formula.\n * @internal\n */\nexport function piMultipleValue(name: string): number | undefined {\n const m = /^(\\d*)pi$/.exec(name);\n if (m === null) return undefined;\n const n = m[1] === '' ? 1 : Number(m[1]);\n if (!Number.isInteger(n) || n <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BAAiB,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;IAChC,MAAM,CAAC,IAAI;IACX,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;CACtE,CAAC,CACH,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACjC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IACpD,OAAO,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AACrB,CAAC","sourcesContent":["/**\n * The constant registry: one row per physical constant a formula may name.\n *\n * A row (written in `constant-rows.ts`) holds the formula name, its other\n * exact-case spellings, the SI value (imported from `core/constants.js`, the\n * one owner of every value), the SI unit in `parseUnit` syntax, the meaning\n * and the source. The dimension is derived from the unit once, here; no second\n * table states it. The rows sit in their own module because the unit table\n * names constants by these spellings, and this module imports the unit parser. Every other\n * constant table in the library ({@link CONSTANTS}, `FORMULA_NAMED`,\n * `CONSTANT_SPELLINGS`, {@link CONSTANT_PROVENANCE}, `CANONICAL_CONSTANTS`,\n * the `upt eval` scope, the binding scope, the gradient constants) is a\n * projection of this array, so a spelling, a value and a dimension cannot\n * disagree between two files. A constant that is also a quantity names its\n * `data/quantities.json` row in `quantity`; the quantity registry derives that\n * row's aliases from here, so the file states no constant spelling.\n *\n * `canonical` marks a universal constant a canonical equation's `governing`\n * list may bake as a leaf. A row that is an overlay for `upt eval` and the\n * dimensional assignment only (`m_p`, `N_A`, the GRW parameters) is not\n * canonical, so the canonical graph does not bake it.\n *\n * Numeric-literal leaves (`'2'`, `'3'`) are NOT registered — `evalExpr`\n * resolves them via `Number(name)` and they are implicitly dimensionless.\n * Non-base-10 tokens (`'8pi'`, `'4pi'`, `'ln2'`) MUST be here (`Number('8pi')`\n * is `NaN`).\n *\n * INTERNAL — not on the public surface.\n *\n * @module dimensional/symbolic-constants\n */\n\nimport { withinRel } from '../core/compare.js';\nimport type { Dimension } from './types.js';\nimport { parseUnit } from './units.js';\nimport { CONSTANT_ROWS, constantRow, type ConstantRow } from './constant-rows.js';\n\n/** One registered constant: its row, with the dimension derived from its unit. @internal */\nexport interface ConstantRecord extends ConstantRow {\n readonly dim: Dimension;\n}\n\n/**\n * Every registered constant, the rows of `constant-rows.ts` with each\n * dimension derived once from its unit. Order is the order the tables print.\n * @internal\n */\nexport const CONSTANT_REGISTRY: readonly ConstantRecord[] = CONSTANT_ROWS.map((constant) => ({\n ...constant,\n dim: parseUnit(constant.unit).dim,\n}));\n\nconst RECORD_OF_ROW = new Map<ConstantRow, ConstantRecord>(CONSTANT_ROWS.map((constant, i) => [constant, CONSTANT_REGISTRY[i]!]));\n\n/**\n * Every spelling → its record; `constant-rows.ts` refuses a spelling written twice. A constant\n * that is also a quantity (`quantity`, e.g. `k_B` → `boltzmann-constant`) is reachable by that\n * quantity id too, so a user who writes the quantity's name states the constant, and the value\n * is checked against the registry rather than bound.\n */\nconst BY_SPELLING = new Map<string, ConstantRecord>(\n CONSTANT_REGISTRY.flatMap((record) =>\n [record.name, ...record.spellings, ...(record.quantity === undefined ? [] : [record.quantity])].map(\n (spelling) => [spelling, record] as const,\n ),\n ),\n);\n\n/** The registered constant `spelling` names, or undefined. @internal */\nexport function constantRecord(spelling: string): ConstantRecord | undefined {\n const constant = constantRow(spelling);\n return constant === undefined ? undefined : RECORD_OF_ROW.get(constant);\n}\n\n/**\n * Relative tolerance within which a stated constant agrees with the registered\n * value. Textbook roundings such as `b = 2.9e-3` pass.\n * @internal\n */\nconst CONSTANT_AGREEMENT = 5e-3;\n\n/** A stated value for a registered constant disagrees with the registry. The equations use the registered value. @internal */\nexport class ConstantDisagreementError extends Error {\n constructor(\n readonly key: string,\n readonly constant: string,\n readonly registered: number,\n readonly given: number,\n ) {\n super(\n `'${key}' is the registered constant ${constant} = ${registered}; ` +\n `${given} disagrees, and the equations use the registered value, so it cannot be rebound.`,\n );\n this.name = 'ConstantDisagreementError';\n }\n}\n\n/**\n * The registered constant `key` names when `value` agrees with it within\n * {@link CONSTANT_AGREEMENT}, or null when `key` names no constant. A value\n * that disagrees throws {@link ConstantDisagreementError}: a constant is not\n * a graph quantity, so a stated value is checked, never bound.\n * @internal\n */\nexport function constantAgreement(key: string, value: number): string | null {\n const record = BY_SPELLING.get(key);\n if (record === undefined) return null;\n if (!withinRel(value, record.value, CONSTANT_AGREEMENT, 0)) {\n throw new ConstantDisagreementError(key, record.name, record.value, value);\n }\n return record.name;\n}\n\n/** The notes of the registered constants among `names`, each once, in registry order. @internal */\nexport function constantNotes(names: Iterable<string>): string[] {\n const seen = new Set<ConstantRecord>();\n for (const name of names) {\n const record = BY_SPELLING.get(name);\n if (record?.note !== undefined) seen.add(record);\n }\n return CONSTANT_REGISTRY.filter((record) => seen.has(record)).map((record) => record.note!);\n}\n\n/** Every spelling → SI value, for a numeric scope. `pi` and `tau` are added. @internal */\nexport function constantScope(): Record<string, number> {\n const scope: Record<string, number> = { pi: Math.PI, tau: 2 * Math.PI };\n for (const [spelling, record] of BY_SPELLING) scope[spelling] = record.value;\n return scope;\n}\n\n/** A registered constant leaf: SI value + SI dimension. @internal */\nexport interface NamedConstantValue {\n readonly value: number;\n readonly dim: Dimension;\n}\n\n/**\n * Constant leaves a `symbolic` ExprNode may reference, keyed by formula name:\n * the canonical rows of {@link CONSTANT_REGISTRY}. `ln2`/`8pi`/`4pi`\n * reproduce the evaluators' `Math.LN2` / `8*Math.PI` / `4*Math.PI` exactly\n * (same IEEE-754 primitives).\n */\nexport const CONSTANTS: Readonly<Record<string, NamedConstantValue>> = Object.fromEntries(\n CONSTANT_REGISTRY.filter((record) => record.canonical).map((record) => [\n record.name,\n { value: record.value, dim: record.dim },\n ]),\n);\n\n/**\n * True when `name` is a key of {@link CONSTANTS} itself. `in` on that plain\n * object is true for `constructor` and every other `Object.prototype` name,\n * which once read a leaf spelled that way as a constant; this reads the own\n * properties only, and is the one rule for \"a registered constant\".\n *\n * @internal\n */\nexport function isRegisteredConstant(name: string): boolean {\n return Object.prototype.hasOwnProperty.call(CONSTANTS, name);\n}\n\n/** What a registered constant is, its SI unit, and where its value comes from (audit I10). @internal */\nexport interface ConstantProvenance {\n readonly meaning: string;\n /** The SI unit, in the syntax `parseUnit` reads; the registered dimension is derived from it. */\n readonly unit: string;\n readonly source: string;\n}\n\n/** One row per {@link CONSTANT_REGISTRY} name. @internal */\nexport const CONSTANT_PROVENANCE: Readonly<Record<string, ConstantProvenance>> = Object.fromEntries(\n CONSTANT_REGISTRY.map((record) => [\n record.name,\n { meaning: record.meaning, unit: record.unit, source: record.source },\n ]),\n);\n\n/**\n * A spelled-out multiple of π written as one symbol (`pi`, `6pi`). `2pi`,\n * `4pi` and `8pi` are also registered in {@link CONSTANTS}; this covers the\n * multiples an encoder spelled out and did not register (`6pi` in\n * CE-perihelion-precession). The structural normal form already drops these.\n * The numeric evaluator has to resolve them too, or a comparison treats `6pi`\n * as a free symbol and never aligns the formula.\n * @internal\n */\nexport function piMultipleValue(name: string): number | undefined {\n const m = /^(\\d*)pi$/.exec(name);\n if (m === null) return undefined;\n const n = m[1] === '' ? 1 : Number(m[1]);\n if (!Number.isInteger(n) || n < 0) return undefined;\n return n * Math.PI;\n}\n"]}
|
|
@@ -45,8 +45,44 @@ export declare const FORCE: Dimension;
|
|
|
45
45
|
export declare const ENERGY: Dimension;
|
|
46
46
|
export declare const POWER: Dimension;
|
|
47
47
|
export declare const ACTION: Dimension;
|
|
48
|
+
/** Volume, cubic metre. */
|
|
49
|
+
export declare const VOLUME: Dimension;
|
|
50
|
+
/** Momentum, kilogram metre per second. */
|
|
51
|
+
export declare const MOMENTUM: Dimension;
|
|
52
|
+
/** Pressure, pascal. */
|
|
53
|
+
export declare const PRESSURE: Dimension;
|
|
54
|
+
/** Spring constant, newton per metre. */
|
|
55
|
+
export declare const SPRING_CONSTANT: Dimension;
|
|
56
|
+
/** Dynamic viscosity, pascal second. */
|
|
57
|
+
export declare const VISCOSITY: Dimension;
|
|
58
|
+
/** Linear mass density, kilogram per metre. */
|
|
59
|
+
export declare const LINEAR_DENSITY: Dimension;
|
|
60
|
+
/** Wavenumber (any inverse length: a spatial frequency, a turn density), per metre. */
|
|
61
|
+
export declare const WAVENUMBER: Dimension;
|
|
62
|
+
/** Diffusivity (mass, thermal or momentum), square metre per second. */
|
|
63
|
+
export declare const DIFFUSIVITY: Dimension;
|
|
64
|
+
/** Energy flux density (power per area: intensity, a Poynting or radiative flux), watt per square metre. */
|
|
65
|
+
export declare const ENERGY_FLUX: Dimension;
|
|
66
|
+
/** The dimension of Newton's constant G, cubic metre per kilogram second squared. */
|
|
67
|
+
export declare const GRAVITATIONAL_CONSTANT: Dimension;
|
|
48
68
|
export declare const TEMPERATURE: Dimension;
|
|
49
69
|
export declare const ENTROPY: Dimension;
|
|
70
|
+
/** Thermal conductivity, watt per metre kelvin. */
|
|
71
|
+
export declare const THERMAL_CONDUCTIVITY: Dimension;
|
|
72
|
+
/** Specific heat capacity, joule per kilogram kelvin. */
|
|
73
|
+
export declare const SPECIFIC_HEAT: Dimension;
|
|
50
74
|
export declare const CHARGE: Dimension;
|
|
75
|
+
/** Capacitance, farad. */
|
|
76
|
+
export declare const CAPACITANCE: Dimension;
|
|
77
|
+
/** Inductance, henry. */
|
|
78
|
+
export declare const INDUCTANCE: Dimension;
|
|
79
|
+
/** Resistance, ohm. */
|
|
80
|
+
export declare const RESISTANCE: Dimension;
|
|
81
|
+
/** Permittivity, farad per metre. */
|
|
82
|
+
export declare const PERMITTIVITY: Dimension;
|
|
83
|
+
/** Electric field, volt per metre. */
|
|
84
|
+
export declare const ELECTRIC_FIELD: Dimension;
|
|
85
|
+
/** Electrical resistivity, ohm metre. */
|
|
86
|
+
export declare const RESISTIVITY: Dimension;
|
|
51
87
|
export declare const NAMED_DIMENSIONS: ReadonlyArray<readonly [string, Dimension]>;
|
|
52
88
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dimensional/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,SAAS;IACxB,yBAAyB;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,2BAA2B;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,wBAAwB;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,oCAAoC;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,CAAC,EAAE,MAAM,CAAC;IACV,wCAAwC;IACxC,CAAC,EAAE,MAAM,CAAC;CACX;AAED,eAAO,MAAM,aAAa,EAAE,SAA4D,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dimensional/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,SAAS;IACxB,yBAAyB;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,2BAA2B;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,wBAAwB;IACxB,CAAC,EAAE,MAAM,CAAC;IACV,oCAAoC;IACpC,CAAC,EAAE,MAAM,CAAC;IACV,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,CAAC,EAAE,MAAM,CAAC;IACV,wCAAwC;IACxC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