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 @@
|
|
|
1
|
+
{"version":3,"file":"finite-difference.d.ts","sourceRoot":"","sources":["../../src/numerical/finite-difference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,EAC5C,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACvC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,MAAM,CAKR"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One central-difference rule.
|
|
3
|
+
*
|
|
4
|
+
* Three readers differentiated a closed form by central differences, each
|
|
5
|
+
* with its own step rule and its own denominator (`2h` at one, the
|
|
6
|
+
* representable step at another). The derivative is here, once: the caller
|
|
7
|
+
* passes the step its rule chose, and the denominator is the step the
|
|
8
|
+
* floating-point point actually took, `dx = (x + h) − (x − h)`, so a
|
|
9
|
+
* perturbation that rounds at an astrophysical `x` is divided by what was
|
|
10
|
+
* applied, not by what was asked.
|
|
11
|
+
*
|
|
12
|
+
* @module numerical/finite-difference
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* `∂f/∂x_key` at `point` by the central difference with half-step `step`:
|
|
16
|
+
* `(f(x + h) − f(x − h)) / ((x + h) − (x − h))`. The other keys of `point` are
|
|
17
|
+
* held. The step rule is the caller's; a zero or non-finite `step` makes the
|
|
18
|
+
* denominator 0 or NaN, which the caller refuses before calling.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export function centralPartial(f, point, key, step) {
|
|
22
|
+
const x = point[key];
|
|
23
|
+
const up = x + step;
|
|
24
|
+
const down = x - step;
|
|
25
|
+
return (f({ ...point, [key]: up }) - f({ ...point, [key]: down })) / (up - down);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=finite-difference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finite-difference.js","sourceRoot":"","sources":["../../src/numerical/finite-difference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,CAA4C,EAC5C,KAAuC,EACvC,GAAW,EACX,IAAY;IAEZ,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAE,CAAC;IACtB,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACpB,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC;AACnF,CAAC","sourcesContent":["/**\n * One central-difference rule.\n *\n * Three readers differentiated a closed form by central differences, each\n * with its own step rule and its own denominator (`2h` at one, the\n * representable step at another). The derivative is here, once: the caller\n * passes the step its rule chose, and the denominator is the step the\n * floating-point point actually took, `dx = (x + h) − (x − h)`, so a\n * perturbation that rounds at an astrophysical `x` is divided by what was\n * applied, not by what was asked.\n *\n * @module numerical/finite-difference\n */\n\n/**\n * `∂f/∂x_key` at `point` by the central difference with half-step `step`:\n * `(f(x + h) − f(x − h)) / ((x + h) − (x − h))`. The other keys of `point` are\n * held. The step rule is the caller's; a zero or non-finite `step` makes the\n * denominator 0 or NaN, which the caller refuses before calling.\n * @internal\n */\nexport function centralPartial(\n f: (point: Record<string, number>) => number,\n point: Readonly<Record<string, number>>,\n key: string,\n step: number,\n): number {\n const x = point[key]!;\n const up = x + step;\n const down = x - step;\n return (f({ ...point, [key]: up }) - f({ ...point, [key]: down })) / (up - down);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geodesic-integrator.d.ts","sourceRoot":"","sources":["../../src/numerical/geodesic-integrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"geodesic-integrator.d.ts","sourceRoot":"","sources":["../../src/numerical/geodesic-integrator.ts"],"names":[],"mappings":"AA4BA;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;;;;;;;;OAYG;IACH,aAAa,EAAE,CAAC,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,EAAE,YAAY,KAAK,YAAY,CAAC;IAE9E,iDAAiD;IACjD,EAAE,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9C;;;;;;;;OAQG;IACH,EAAE,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE9C,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IAEjB,uDAAuD;IACvD,MAAM,EAAE,MAAM,CAAC;IAEf,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,kCAAkC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3D,kCAAkC;IAClC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAE3D;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAC/E;AAuFD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,wBAAwB,GAC/B,wBAAwB,CA8D1B"}
|
|
@@ -14,16 +14,17 @@
|
|
|
14
14
|
* The Christoffel symbol Γ^μ_{νρ} is supplied as a plain-JS closure that
|
|
15
15
|
* maps a 4-coordinate array to a [4][4][4] tensor. No TensorEngine
|
|
16
16
|
* dependency — the integrator is self-contained. The fixed steps are
|
|
17
|
-
* MathTS `solveODESystem` with `dt` set,
|
|
18
|
-
* RK4. Adaptive `solveODE` is
|
|
17
|
+
* `rk4Trajectory` (MathTS `solveODESystem` with `dt` set, that library's
|
|
18
|
+
* classical RK4), which takes exactly `steps` steps. Adaptive `solveODE` is
|
|
19
|
+
* not this step.
|
|
19
20
|
*
|
|
20
21
|
* Validated against the cycloid parametric form for radial Schwarzschild
|
|
21
22
|
* infall to ±1e-6 (Task 14 test, η = 0.5).
|
|
22
23
|
*
|
|
23
24
|
* @module numerical/geodesic-integrator
|
|
24
25
|
*/
|
|
25
|
-
import { solveODESystem } from '@danielsimonjr/mathts-functions';
|
|
26
26
|
import { NumericalBackendError } from './errors.js';
|
|
27
|
+
import { rk4Trajectory } from './rk4-trajectory.js';
|
|
27
28
|
/**
|
|
28
29
|
* Evaluate the Christoffel acceleration −Γ^μ_{νρ} v^ν v^ρ at position x
|
|
29
30
|
* with 4-velocity v. Returns (dx/dτ, dv/dτ) = (v, accel).
|
|
@@ -149,28 +150,35 @@ export function integrateGeodesic(inputs) {
|
|
|
149
150
|
if (!Number.isInteger(steps) || steps <= 0) {
|
|
150
151
|
throw new NumericalBackendError(`integrateGeodesic: steps must be a positive integer, got ${steps}`);
|
|
151
152
|
}
|
|
152
|
-
|
|
153
|
+
// A NaN or infinite end made every step NaN and the result the start state; an
|
|
154
|
+
// end equal to the start is a zero step, which is not an integration either.
|
|
155
|
+
if (!Number.isFinite(tauStart)) {
|
|
156
|
+
throw new NumericalBackendError(`integrateGeodesic: tauStart must be finite, got ${tauStart}`);
|
|
157
|
+
}
|
|
158
|
+
if (!Number.isFinite(tauEnd)) {
|
|
159
|
+
throw new NumericalBackendError(`integrateGeodesic: tauEnd must be finite, got ${tauEnd}`);
|
|
160
|
+
}
|
|
161
|
+
if (tauEnd === tauStart) {
|
|
162
|
+
throw new NumericalBackendError(`integrateGeodesic: tauEnd must differ from tauStart, both are ${tauStart}`);
|
|
163
|
+
}
|
|
153
164
|
const y0 = [x0[0], x0[1], x0[2], x0[3], v0[0], v0[1], v0[2], v0[3]];
|
|
154
165
|
// One scratch buffer reused across all Christoffel evaluations (4 per step).
|
|
155
166
|
// Each geodesicRHS consumes its Γ before the next call, so reuse is safe and
|
|
156
167
|
// avoids ~4·steps Float64Array(64) allocations per integration.
|
|
157
168
|
const scratch = new Float64Array(64);
|
|
158
|
-
const
|
|
169
|
+
const states = rk4Trajectory((_tau, y) => {
|
|
159
170
|
const x = [y[0], y[1], y[2], y[3]];
|
|
160
171
|
const v = [y[4], y[5], y[6], y[7]];
|
|
161
172
|
const s = geodesicRHS(christoffelFn, x, v, scratch);
|
|
162
173
|
return [s.dx[0], s.dx[1], s.dx[2], s.dx[3], s.dv[0], s.dv[1], s.dv[2], s.dv[3]];
|
|
163
|
-
}, y0,
|
|
174
|
+
}, y0, tauStart, tauEnd, steps);
|
|
164
175
|
const asVec4 = (row) => [row[0], row[1], row[2], row[3]];
|
|
165
176
|
const sampleEvery = Math.max(1, Math.floor(steps / 100));
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
const last = sol.y[sol.y.length - 1] ?? y0;
|
|
177
|
+
// `rk4Trajectory` returns exactly steps + 1 states, so state i is the one after i steps.
|
|
178
|
+
const trajectory = [asVec4(states[0] ?? y0)];
|
|
179
|
+
for (let i = sampleEvery; i <= steps; i += sampleEvery)
|
|
180
|
+
trajectory.push(asVec4(states[i] ?? y0));
|
|
181
|
+
const last = states[steps] ?? y0;
|
|
174
182
|
return {
|
|
175
183
|
xFinal: asVec4(last),
|
|
176
184
|
vFinal: [last[4], last[5], last[6], last[7]],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geodesic-integrator.js","sourceRoot":"","sources":["../../src/numerical/geodesic-integrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AA+EpD;;;;;;GAMG;AACH,SAAS,WAAW,CACl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,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;IACzD,MAAM,UAAU,GAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/B,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,KAAK,CAAC,EAAE,CAAC;YAChC,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;YAC1D,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAE3C,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;QACpB,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5C,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Fixed-step RK4 integrator for the geodesic equation in an arbitrary\n * Lorentzian manifold (v0.4.0, Task 14 [U]).\n *\n * Solves the second-order ODE system\n *\n * d²x^μ/dτ² + Γ^μ_{νρ}(x) (dx^ν/dτ)(dx^ρ/dτ) = 0\n *\n * by casting it as a first-order system on the (x, v) phase space:\n *\n * dx^μ/dτ = v^μ\n * dv^μ/dτ = −Γ^μ_{νρ}(x) v^ν v^ρ (Einstein summation over ν, ρ)\n *\n * The Christoffel symbol Γ^μ_{νρ} is supplied as a plain-JS closure that\n * maps a 4-coordinate array to a [4][4][4] tensor. No TensorEngine\n * dependency — the integrator is self-contained. The fixed steps are\n * MathTS `solveODESystem` with `dt` set, which is that library's classical\n * RK4. Adaptive `solveODE` is not this step.\n *\n * Validated against the cycloid parametric form for radial Schwarzschild\n * infall to ±1e-6 (Task 14 test, η = 0.5).\n *\n * @module numerical/geodesic-integrator\n */\nimport { solveODESystem } from '@danielsimonjr/mathts-functions';\nimport { NumericalBackendError } from './errors.js';\n\n/**\n * Input bundle for `integrateGeodesic`.\n * @public\n */\nexport interface GeodesicIntegratorInputs {\n /**\n * Christoffel-symbol closure. Maps a 4-coordinate array x^μ to a\n * Float64Array(64) containing Γ^μ_{νρ}(x) in λ-major layout:\n * index (λ, μ, ν) → 16·λ + 4·μ + ν.\n *\n * BR-2 (v0.6.0 Task 2.9): migrated from nested number[][][] to flat\n * Float64Array(64). Consumers call `arr[16*mu + 4*nu + rho]`.\n *\n * The optional `out` buffer lets the integrator pass a reused scratch\n * Float64Array(64) so the hot loop avoids per-call allocation. A function\n * that ignores `out` (e.g. allocates fresh each call) still satisfies this\n * type — the optimization is opt-in.\n */\n christoffelFn: (x: ReadonlyArray<number>, out?: Float64Array) => Float64Array;\n\n /** Initial 4-position x^μ(τ₀) = [t, r, θ, φ]. */\n x0: readonly [number, number, number, number];\n\n /**\n * Initial 4-velocity dx^μ/dτ at τ₀.\n *\n * I2 fix: for a Schwarzschild radial timelike geodesic starting at\n * coordinate radius r₀, use\n * v0 = [1/√(1 − r_s/r₀), 0, 0, 0]\n * so that g_{μν} u^μ u^ν = −c² holds. At r₀ = 100·r_s this gives\n * dt/dτ ≈ 1.005, not 1.\n */\n v0: readonly [number, number, number, number];\n\n /** Proper-time parameter at the start of integration. */\n tauStart: number;\n\n /** Proper-time parameter at the end of integration. */\n tauEnd: number;\n\n /** Number of fixed RK4 steps. Must be a positive integer. */\n steps: number;\n\n /**\n * E11 fix: explicit domain-validity option in place of the\n * `(christoffelFn as any).r_s` monkey-patch. If supplied, the\n * integrator throws `NumericalBackendError` when `x0[1] < domainMinRadius`\n * (e.g. for Schwarzschild: caller passes `3 * r_s` to enforce the\n * v0.4.0 domain restriction r ≥ 3·r_Schwarz).\n */\n domainMinRadius?: number;\n}\n\n/**\n * Result of `integrateGeodesic`.\n * @public\n */\nexport interface GeodesicIntegratorResult {\n /** Final 4-position x^μ(τEnd). */\n readonly xFinal: readonly [number, number, number, number];\n\n /** Final 4-velocity v^μ(τEnd). */\n readonly vFinal: readonly [number, number, number, number];\n\n /**\n * Sampled trajectory positions (approximately 100 evenly-spaced snapshots\n * plus the initial point). Useful for visualisation and diagnostics.\n */\n readonly trajectory: ReadonlyArray<readonly [number, number, number, number]>;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\ntype Vec4 = [number, number, number, number];\n\n/**\n * Evaluate the Christoffel acceleration −Γ^μ_{νρ} v^ν v^ρ at position x\n * with 4-velocity v. Returns (dx/dτ, dv/dτ) = (v, accel).\n *\n * BR-2 (v0.6.0 Task 2.9): christoffelFn now returns Float64Array(64).\n * Index access: G[16*mu + 4*nu + rho] (λ-major layout).\n */\nfunction geodesicRHS(\n christoffelFn: (x: ReadonlyArray<number>, out?: Float64Array) => Float64Array,\n x: Vec4,\n v: Vec4,\n // Reused scratch buffer for the Christoffel evaluation. Safe: G is fully\n // consumed into `dv` below before geodesicRHS returns, so the next call may\n // overwrite it. `dx`/`dv` are fresh arrays and never alias G.\n scratch?: Float64Array,\n): { dx: Vec4; dv: Vec4 } {\n const G = christoffelFn(x, scratch);\n const v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];\n let dv0 = 0, dv1 = 0, dv2 = 0, dv3 = 0;\n\n for (let mu = 0; mu < 4; mu++) {\n // Bolt: Hoist the invariant 16 * mu multiplication outside the nu, rho loops\n const mu16 = mu * 16;\n let acc = 0;\n let accTerm = 0;\n let g = 0;\n\n // Bolt: Fully unroll the inner `nu` and `rho` loops for a fixed 4D spacetime\n // to eliminate loop overhead and index arithmetic, caching `v` into scalar variables.\n\n // nu = 0\n let offset = mu16;\n accTerm = 0;\n g = G[offset]; if (g !== 0) accTerm += g * v0;\n g = G[offset+1]; if (g !== 0) accTerm += g * v1;\n g = G[offset+2]; if (g !== 0) accTerm += g * v2;\n g = G[offset+3]; if (g !== 0) accTerm += g * v3;\n if (accTerm !== 0) acc += accTerm * v0;\n\n // nu = 1\n offset += 4;\n accTerm = 0;\n g = G[offset]; if (g !== 0) accTerm += g * v0;\n g = G[offset+1]; if (g !== 0) accTerm += g * v1;\n g = G[offset+2]; if (g !== 0) accTerm += g * v2;\n g = G[offset+3]; if (g !== 0) accTerm += g * v3;\n if (accTerm !== 0) acc += accTerm * v1;\n\n // nu = 2\n offset += 4;\n accTerm = 0;\n g = G[offset]; if (g !== 0) accTerm += g * v0;\n g = G[offset+1]; if (g !== 0) accTerm += g * v1;\n g = G[offset+2]; if (g !== 0) accTerm += g * v2;\n g = G[offset+3]; if (g !== 0) accTerm += g * v3;\n if (accTerm !== 0) acc += accTerm * v2;\n\n // nu = 3\n offset += 4;\n accTerm = 0;\n g = G[offset]; if (g !== 0) accTerm += g * v0;\n g = G[offset+1]; if (g !== 0) accTerm += g * v1;\n g = G[offset+2]; if (g !== 0) accTerm += g * v2;\n g = G[offset+3]; if (g !== 0) accTerm += g * v3;\n if (accTerm !== 0) acc += accTerm * v3;\n\n if (mu === 0) dv0 = -acc;\n else if (mu === 1) dv1 = -acc;\n else if (mu === 2) dv2 = -acc;\n else dv3 = -acc;\n }\n\n return { dx: [v0, v1, v2, v3], dv: [dv0, dv1, dv2, dv3] };\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Numerically integrate the geodesic equation for a timelike (or null)\n * worldline in an arbitrary curved spacetime using a fixed-step classical\n * fourth-order Runge-Kutta scheme.\n *\n * @public\n */\nexport function integrateGeodesic(\n inputs: GeodesicIntegratorInputs,\n): GeodesicIntegratorResult {\n const { christoffelFn, x0, v0, tauStart, tauEnd, steps, domainMinRadius } = inputs;\n // BR-2: christoffelFn now returns Float64Array(64); geodesicRHS reads flat layout.\n\n // E11 fix: explicit option in place of monkey-patched .r_s on the closure.\n // Callers (e.g. the Schwarzschild test fixture) pass `3 * r_s` directly.\n if (typeof domainMinRadius === 'number' && x0[1] < domainMinRadius) {\n throw new NumericalBackendError(\n `integrateGeodesic: initial radius r0=${x0[1]} < domainMinRadius=${domainMinRadius}. ` +\n `Position is outside the valid integration domain. ` +\n `For Schwarzschild geodesics this restriction is r ≥ 3·r_Schwarz (v0.4.0).`,\n );\n }\n\n if (!Number.isInteger(steps) || steps <= 0) {\n throw new NumericalBackendError(\n `integrateGeodesic: steps must be a positive integer, got ${steps}`,\n );\n }\n\n const h = (tauEnd - tauStart) / steps;\n const y0 = [x0[0], x0[1], x0[2], x0[3], v0[0], v0[1], v0[2], v0[3]];\n\n // One scratch buffer reused across all Christoffel evaluations (4 per step).\n // Each geodesicRHS consumes its Γ before the next call, so reuse is safe and\n // avoids ~4·steps Float64Array(64) allocations per integration.\n const scratch = new Float64Array(64);\n const sol = solveODESystem(\n (_tau, y) => {\n const x: Vec4 = [y[0], y[1], y[2], y[3]];\n const v: Vec4 = [y[4], y[5], y[6], y[7]];\n const s = geodesicRHS(christoffelFn, x, v, scratch);\n return [s.dx[0], s.dx[1], s.dx[2], s.dx[3], s.dv[0], s.dv[1], s.dv[2], s.dv[3]];\n },\n y0,\n [tauStart, tauEnd],\n { dt: h },\n );\n\n const asVec4 = (row: readonly number[]): Vec4 => [row[0], row[1], row[2], row[3]];\n const sampleEvery = Math.max(1, Math.floor(steps / 100));\n const trajectory: Vec4[] = [asVec4(sol.y[0] ?? y0)];\n for (let i = 0; i < steps; i++) {\n if ((i + 1) % sampleEvery === 0) {\n const row = sol.y[i + 1] ?? sol.y[sol.y.length - 1] ?? y0;\n trajectory.push(asVec4(row));\n }\n }\n const last = sol.y[sol.y.length - 1] ?? y0;\n\n return {\n xFinal: asVec4(last),\n vFinal: [last[4], last[5], last[6], last[7]],\n trajectory,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"geodesic-integrator.js","sourceRoot":"","sources":["../../src/numerical/geodesic-integrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA+EpD;;;;;;GAMG;AACH,SAAS,WAAW,CAClB,aAA6E,EAC7E,CAAO,EACP,CAAO;AACP,yEAAyE;AACzE,4EAA4E;AAC5E,8DAA8D;AAC9D,OAAsB;IAEtB,MAAM,CAAC,GAAG,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACpC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;IAEvC,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;QAC9B,6EAA6E;QAC7E,MAAM,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;QACrB,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,GAAG,CAAC,CAAC;QAEV,6EAA6E;QAC7E,sFAAsF;QAEtF,SAAS;QACT,IAAI,MAAM,GAAG,IAAI,CAAC;QAClB,OAAO,GAAG,CAAC,CAAC;QACZ,CAAC,GAAG,CAAC,CAAC,MAAM,CA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C,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5C,UAAU;KACX,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Fixed-step RK4 integrator for the geodesic equation in an arbitrary\n * Lorentzian manifold (v0.4.0, Task 14 [U]).\n *\n * Solves the second-order ODE system\n *\n * d²x^μ/dτ² + Γ^μ_{νρ}(x) (dx^ν/dτ)(dx^ρ/dτ) = 0\n *\n * by casting it as a first-order system on the (x, v) phase space:\n *\n * dx^μ/dτ = v^μ\n * dv^μ/dτ = −Γ^μ_{νρ}(x) v^ν v^ρ (Einstein summation over ν, ρ)\n *\n * The Christoffel symbol Γ^μ_{νρ} is supplied as a plain-JS closure that\n * maps a 4-coordinate array to a [4][4][4] tensor. No TensorEngine\n * dependency — the integrator is self-contained. The fixed steps are\n * `rk4Trajectory` (MathTS `solveODESystem` with `dt` set, that library's\n * classical RK4), which takes exactly `steps` steps. Adaptive `solveODE` is\n * not this step.\n *\n * Validated against the cycloid parametric form for radial Schwarzschild\n * infall to ±1e-6 (Task 14 test, η = 0.5).\n *\n * @module numerical/geodesic-integrator\n */\nimport { NumericalBackendError } from './errors.js';\nimport { rk4Trajectory } from './rk4-trajectory.js';\n\n/**\n * Input bundle for `integrateGeodesic`.\n * @public\n */\nexport interface GeodesicIntegratorInputs {\n /**\n * Christoffel-symbol closure. Maps a 4-coordinate array x^μ to a\n * Float64Array(64) containing Γ^μ_{νρ}(x) in λ-major layout:\n * index (λ, μ, ν) → 16·λ + 4·μ + ν.\n *\n * BR-2 (v0.6.0 Task 2.9): migrated from nested number[][][] to flat\n * Float64Array(64). Consumers call `arr[16*mu + 4*nu + rho]`.\n *\n * The optional `out` buffer lets the integrator pass a reused scratch\n * Float64Array(64) so the hot loop avoids per-call allocation. A function\n * that ignores `out` (e.g. allocates fresh each call) still satisfies this\n * type — the optimization is opt-in.\n */\n christoffelFn: (x: ReadonlyArray<number>, out?: Float64Array) => Float64Array;\n\n /** Initial 4-position x^μ(τ₀) = [t, r, θ, φ]. */\n x0: readonly [number, number, number, number];\n\n /**\n * Initial 4-velocity dx^μ/dτ at τ₀.\n *\n * I2 fix: for a Schwarzschild radial timelike geodesic starting at\n * coordinate radius r₀, use\n * v0 = [1/√(1 − r_s/r₀), 0, 0, 0]\n * so that g_{μν} u^μ u^ν = −c² holds. At r₀ = 100·r_s this gives\n * dt/dτ ≈ 1.005, not 1.\n */\n v0: readonly [number, number, number, number];\n\n /** Proper-time parameter at the start of integration. */\n tauStart: number;\n\n /** Proper-time parameter at the end of integration. */\n tauEnd: number;\n\n /** Number of fixed RK4 steps. Must be a positive integer. */\n steps: number;\n\n /**\n * E11 fix: explicit domain-validity option in place of the\n * `(christoffelFn as any).r_s` monkey-patch. If supplied, the\n * integrator throws `NumericalBackendError` when `x0[1] < domainMinRadius`\n * (e.g. for Schwarzschild: caller passes `3 * r_s` to enforce the\n * v0.4.0 domain restriction r ≥ 3·r_Schwarz).\n */\n domainMinRadius?: number;\n}\n\n/**\n * Result of `integrateGeodesic`.\n * @public\n */\nexport interface GeodesicIntegratorResult {\n /** Final 4-position x^μ(τEnd). */\n readonly xFinal: readonly [number, number, number, number];\n\n /** Final 4-velocity v^μ(τEnd). */\n readonly vFinal: readonly [number, number, number, number];\n\n /**\n * Sampled trajectory positions (approximately 100 evenly-spaced snapshots\n * plus the initial point). Useful for visualisation and diagnostics.\n */\n readonly trajectory: ReadonlyArray<readonly [number, number, number, number]>;\n}\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\ntype Vec4 = [number, number, number, number];\n\n/**\n * Evaluate the Christoffel acceleration −Γ^μ_{νρ} v^ν v^ρ at position x\n * with 4-velocity v. Returns (dx/dτ, dv/dτ) = (v, accel).\n *\n * BR-2 (v0.6.0 Task 2.9): christoffelFn now returns Float64Array(64).\n * Index access: G[16*mu + 4*nu + rho] (λ-major layout).\n */\nfunction geodesicRHS(\n christoffelFn: (x: ReadonlyArray<number>, out?: Float64Array) => Float64Array,\n x: Vec4,\n v: Vec4,\n // Reused scratch buffer for the Christoffel evaluation. Safe: G is fully\n // consumed into `dv` below before geodesicRHS returns, so the next call may\n // overwrite it. `dx`/`dv` are fresh arrays and never alias G.\n scratch?: Float64Array,\n): { dx: Vec4; dv: Vec4 } {\n const G = christoffelFn(x, scratch);\n const v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];\n let dv0 = 0, dv1 = 0, dv2 = 0, dv3 = 0;\n\n for (let mu = 0; mu < 4; mu++) {\n // Bolt: Hoist the invariant 16 * mu multiplication outside the nu, rho loops\n const mu16 = mu * 16;\n let acc = 0;\n let accTerm = 0;\n let g = 0;\n\n // Bolt: Fully unroll the inner `nu` and `rho` loops for a fixed 4D spacetime\n // to eliminate loop overhead and index arithmetic, caching `v` into scalar variables.\n\n // nu = 0\n let offset = mu16;\n accTerm = 0;\n g = G[offset]; if (g !== 0) accTerm += g * v0;\n g = G[offset+1]; if (g !== 0) accTerm += g * v1;\n g = G[offset+2]; if (g !== 0) accTerm += g * v2;\n g = G[offset+3]; if (g !== 0) accTerm += g * v3;\n if (accTerm !== 0) acc += accTerm * v0;\n\n // nu = 1\n offset += 4;\n accTerm = 0;\n g = G[offset]; if (g !== 0) accTerm += g * v0;\n g = G[offset+1]; if (g !== 0) accTerm += g * v1;\n g = G[offset+2]; if (g !== 0) accTerm += g * v2;\n g = G[offset+3]; if (g !== 0) accTerm += g * v3;\n if (accTerm !== 0) acc += accTerm * v1;\n\n // nu = 2\n offset += 4;\n accTerm = 0;\n g = G[offset]; if (g !== 0) accTerm += g * v0;\n g = G[offset+1]; if (g !== 0) accTerm += g * v1;\n g = G[offset+2]; if (g !== 0) accTerm += g * v2;\n g = G[offset+3]; if (g !== 0) accTerm += g * v3;\n if (accTerm !== 0) acc += accTerm * v2;\n\n // nu = 3\n offset += 4;\n accTerm = 0;\n g = G[offset]; if (g !== 0) accTerm += g * v0;\n g = G[offset+1]; if (g !== 0) accTerm += g * v1;\n g = G[offset+2]; if (g !== 0) accTerm += g * v2;\n g = G[offset+3]; if (g !== 0) accTerm += g * v3;\n if (accTerm !== 0) acc += accTerm * v3;\n\n if (mu === 0) dv0 = -acc;\n else if (mu === 1) dv1 = -acc;\n else if (mu === 2) dv2 = -acc;\n else dv3 = -acc;\n }\n\n return { dx: [v0, v1, v2, v3], dv: [dv0, dv1, dv2, dv3] };\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/**\n * Numerically integrate the geodesic equation for a timelike (or null)\n * worldline in an arbitrary curved spacetime using a fixed-step classical\n * fourth-order Runge-Kutta scheme.\n *\n * @public\n */\nexport function integrateGeodesic(\n inputs: GeodesicIntegratorInputs,\n): GeodesicIntegratorResult {\n const { christoffelFn, x0, v0, tauStart, tauEnd, steps, domainMinRadius } = inputs;\n // BR-2: christoffelFn now returns Float64Array(64); geodesicRHS reads flat layout.\n\n // E11 fix: explicit option in place of monkey-patched .r_s on the closure.\n // Callers (e.g. the Schwarzschild test fixture) pass `3 * r_s` directly.\n if (typeof domainMinRadius === 'number' && x0[1] < domainMinRadius) {\n throw new NumericalBackendError(\n `integrateGeodesic: initial radius r0=${x0[1]} < domainMinRadius=${domainMinRadius}. ` +\n `Position is outside the valid integration domain. ` +\n `For Schwarzschild geodesics this restriction is r ≥ 3·r_Schwarz (v0.4.0).`,\n );\n }\n\n if (!Number.isInteger(steps) || steps <= 0) {\n throw new NumericalBackendError(\n `integrateGeodesic: steps must be a positive integer, got ${steps}`,\n );\n }\n // A NaN or infinite end made every step NaN and the result the start state; an\n // end equal to the start is a zero step, which is not an integration either.\n if (!Number.isFinite(tauStart)) {\n throw new NumericalBackendError(`integrateGeodesic: tauStart must be finite, got ${tauStart}`);\n }\n if (!Number.isFinite(tauEnd)) {\n throw new NumericalBackendError(`integrateGeodesic: tauEnd must be finite, got ${tauEnd}`);\n }\n if (tauEnd === tauStart) {\n throw new NumericalBackendError(`integrateGeodesic: tauEnd must differ from tauStart, both are ${tauStart}`);\n }\n\n const y0 = [x0[0], x0[1], x0[2], x0[3], v0[0], v0[1], v0[2], v0[3]];\n\n // One scratch buffer reused across all Christoffel evaluations (4 per step).\n // Each geodesicRHS consumes its Γ before the next call, so reuse is safe and\n // avoids ~4·steps Float64Array(64) allocations per integration.\n const scratch = new Float64Array(64);\n const states = rk4Trajectory(\n (_tau, y) => {\n const x: Vec4 = [y[0], y[1], y[2], y[3]];\n const v: Vec4 = [y[4], y[5], y[6], y[7]];\n const s = geodesicRHS(christoffelFn, x, v, scratch);\n return [s.dx[0], s.dx[1], s.dx[2], s.dx[3], s.dv[0], s.dv[1], s.dv[2], s.dv[3]];\n },\n y0,\n tauStart,\n tauEnd,\n steps,\n );\n\n const asVec4 = (row: readonly number[]): Vec4 => [row[0], row[1], row[2], row[3]];\n const sampleEvery = Math.max(1, Math.floor(steps / 100));\n // `rk4Trajectory` returns exactly steps + 1 states, so state i is the one after i steps.\n const trajectory: Vec4[] = [asVec4(states[0] ?? y0)];\n for (let i = sampleEvery; i <= steps; i += sampleEvery) trajectory.push(asVec4(states[i] ?? y0));\n const last = states[steps] ?? y0;\n\n return {\n xFinal: asVec4(last),\n vFinal: [last[4], last[5], last[6], last[7]],\n trajectory,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometrized.d.ts","sourceRoot":"","sources":["../../src/numerical/geometrized.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD;;;;;GAKG;AACH,qBAAa,8BAA+B,SAAQ,QAAQ;IAC1D,YAAY,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"geometrized.d.ts","sourceRoot":"","sources":["../../src/numerical/geometrized.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD;;;;;GAKG;AACH,qBAAa,8BAA+B,SAAQ,QAAQ;IAC1D,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,SAAS,GAAG,MAAM,CASxD;AAED,4CAA4C;AAC5C,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,MAAM,CAErE;AAED,4CAA4C;AAC5C,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,MAAM,CAEzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometrized.js","sourceRoot":"","sources":["../../src/numerical/geometrized.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,OAAO,8BAA+B,SAAQ,QAAQ;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"geometrized.js","sourceRoot":"","sources":["../../src/numerical/geometrized.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,OAAO,8BAA+B,SAAQ,QAAQ;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAc;IAC9C,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,8BAA8B,CACtC,qEAAqE;YACnE,wCAAwC,GAAG,CAAC,CAAC,OAAO,GAAG,CAAC,KAAK,IAAI;YACjE,KAAK,GAAG,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,iDAAiD,CAC1E,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,aAAa,CAAC,OAAe,EAAE,GAAc;IAC3D,OAAO,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,eAAe,CAAC,SAAiB,EAAE,GAAc;IAC/D,OAAO,SAAS,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["/**\n * Geometrized-units boundary adapters (G-9 increment 1).\n *\n * Converts a scalar between SI and geometrized (G = c = 1) units, driven\n * MECHANICALLY by the `Dimension` exponent vector — the dimension functor\n * earning its keep. For an SI quantity of dimension L^l M^m T^t the single\n * conversion factor is `G^m · c^(t − 2m)` (each kg → G/c² metres, each second\n * → c metres); the geometrized quantity is a pure length L^(l+m+t).\n *\n * This is the self-contained FOUNDATION of the units-normalization layer\n * (design: docs/planning/v0.10.0-Units-Normalization-Design-Note.md, Adam-\n * vetted r2; plan: docs/planning/v0.13-G9-Adapters-Plan.md, Eve-vetted). Only c\n * and G are in scope: a nonzero electromagnetic / thermal / molar / luminous\n * exponent (I/Θ/N/J) throws.\n *\n * PUBLIC boundary API (G-9 increment 2): a consumer running the GR pipeline in\n * geometrized (G = c = 1) units converts scalars at the boundary with these\n * adapters. The consumer-wide DEFAULT-pipeline migration (increment 3) was\n * DECLINED after adversarial review — it is measured to give no precision win\n * (and far worse far-field; see docs/planning/v0.14-G9-Increment3-Disposition.md).\n * The SI pipeline stays the default; this geometrized layer is the optional\n * boundary API.\n *\n * @module numerical/geometrized\n */\n\nimport type { Dimension } from '../dimensional/types.js';\nimport { UPTError } from '../dimensional/errors.js';\nimport { C_SI, G_SI } from '../core/constants.js';\n\n/**\n * A dimension carries a non-c/G base (I/Θ/N/J ≠ 0) and cannot be geometrized\n * by c and G alone (k_B / ε₀ extensions are out of scope for this increment).\n *\n * @public\n */\nexport class NonGeometrizableDimensionError extends UPTError {\n constructor(message: string) {\n super(message);\n this.name = 'NonGeometrizableDimensionError';\n }\n}\n\n/**\n * The single SI→geometrized conversion factor for `dim`: `G^M · c^(T − 2M)`\n * (only the mass and time exponents enter). Shared by `toGeometrized` /\n * `fromGeometrized` so the round-trip is a clean inverse. A nonzero I/Θ/N/J\n * exponent throws `NonGeometrizableDimensionError` BEFORE any factor is\n * computed.\n *\n * @public\n */\nexport function geometrizedFactor(dim: Dimension): number {\n if (dim.I !== 0 || dim.Theta !== 0 || dim.N !== 0 || dim.J !== 0) {\n throw new NonGeometrizableDimensionError(\n `geometrizedFactor: only c and G are in scope; this dimension has a ` +\n `nonzero non-mechanizable exponent (I=${dim.I}, Θ=${dim.Theta}, ` +\n `N=${dim.N}, J=${dim.J}). Geometrization handles length / mass / time.`,\n );\n }\n return Math.pow(G_SI, dim.M) * Math.pow(C_SI, dim.T - 2 * dim.M);\n}\n\n/** SI → geometrized (G = c = 1). @public */\nexport function toGeometrized(valueSI: number, dim: Dimension): number {\n return valueSI * geometrizedFactor(dim);\n}\n\n/** Geometrized (G = c = 1) → SI. @public */\nexport function fromGeometrized(valueGeom: number, dim: Dimension): number {\n return valueGeom / geometrizedFactor(dim);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathts-engine.d.ts","sourceRoot":"","sources":["../../src/numerical/mathts-engine.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAmC9C;;;;;;;GAOG;AACH,qBAAa,YAAa,YAAW,YAAY;IAC/C,QAAQ,CAAC,IAAI,kBAAkB;IAE/B,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,YAAY,CAGxE;IACD,QAAQ,CAAC,CAAC,EAAE,YAAY,GAAG,WAAW,CAErC;IAED,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY,CAGlE;IACD,MAAM,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,YAAY,CAErD;IACD,SAAS,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,YAAY,CAErE;IACD,OAAO,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,YAAY,CAEnE;IASD,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"mathts-engine.d.ts","sourceRoot":"","sources":["../../src/numerical/mathts-engine.ts"],"names":[],"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Ac;IAItB,2EAA2E;IAC3E,OAAO,CAAC,gBAAgB;IAQxB;;;;;;;;;;;OAWG;IACG,WAAW,CACf,EAAE,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,YAAY,EACrC,CAAC,EAAE,YAAY,GACd,OAAO,CAAC,iBAAiB,CAAC,CAkB5B;IAMD;;;;;;;;;OASG;IACG,WAAW,CACf,EAAE,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,YAAY,EACrC,CAAC,EAAE,YAAY,EACf,SAAS,CAAC,EAAE,YAAY,GACvB,OAAO,CAAC,iBAAiB,CAAC,CAiB5B;CACF"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { Tensor } from '@danielsimonjr/mathts-tensor';
|
|
13
13
|
import { NumericalBackendError } from './errors.js';
|
|
14
|
-
import { EngineCapabilityError } from './tensor-engine.js';
|
|
14
|
+
import { EngineCapabilityError, isTracedTensor, tracedMode } from './tensor-engine.js';
|
|
15
15
|
/** EngineTensor handle wrapping a MathTS Tensor. */
|
|
16
16
|
class MathTSEngineTensor {
|
|
17
17
|
inner;
|
|
@@ -58,43 +58,29 @@ export class MathTSEngine {
|
|
|
58
58
|
}
|
|
59
59
|
// AD dispatch. `@danielsimonjr/mathts-autograd` wraps the traced input as a
|
|
60
60
|
// DualTensor (forward mode, carries `tangent`) or a TapedTensor (reverse
|
|
61
|
-
// mode, carries `tape`) and calls these methods with it. The
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
// the
|
|
65
|
-
//
|
|
61
|
+
// mode, carries `tape`) and calls these methods with it. The operations a
|
|
62
|
+
// wrapped tensor implements are declared on `TracedEngineTensor`; the guard
|
|
63
|
+
// `isTracedTensor` is the dispatch. Two operands trace together only when
|
|
64
|
+
// both are wrapped in the same mode; a mixed or half-wrapped pair falls
|
|
65
|
+
// through to the plain path, whose `unwrap` refuses it.
|
|
66
66
|
add(a, b) {
|
|
67
|
-
if (
|
|
67
|
+
if (isTracedTensor(a) && isTracedTensor(b) && tracedMode(a) === tracedMode(b))
|
|
68
68
|
return a.add(b);
|
|
69
|
-
}
|
|
70
|
-
// AD dispatch: TapedTensor (reverse-mode)
|
|
71
|
-
if ('tape' in a && 'tape' in b) {
|
|
72
|
-
return a.add(b);
|
|
73
|
-
}
|
|
74
69
|
return new MathTSEngineTensor(unwrap(a, 'add').add(unwrap(b, 'add')));
|
|
75
70
|
}
|
|
76
71
|
sub(a, b) {
|
|
77
|
-
if (
|
|
78
|
-
return a.sub(b);
|
|
79
|
-
}
|
|
80
|
-
if ('tape' in a && 'tape' in b) {
|
|
72
|
+
if (isTracedTensor(a) && isTracedTensor(b) && tracedMode(a) === tracedMode(b))
|
|
81
73
|
return a.sub(b);
|
|
82
|
-
}
|
|
83
74
|
return new MathTSEngineTensor(unwrap(a, 'sub').sub(unwrap(b, 'sub')));
|
|
84
75
|
}
|
|
85
76
|
mul(a, b) {
|
|
86
|
-
if (
|
|
87
|
-
return a.mul(b);
|
|
88
|
-
}
|
|
89
|
-
if ('tape' in a && 'tape' in b) {
|
|
77
|
+
if (isTracedTensor(a) && isTracedTensor(b) && tracedMode(a) === tracedMode(b))
|
|
90
78
|
return a.mul(b);
|
|
91
|
-
}
|
|
92
79
|
return new MathTSEngineTensor(unwrap(a, 'mul').mul(unwrap(b, 'mul')));
|
|
93
80
|
}
|
|
94
81
|
scale(t, k) {
|
|
95
|
-
if (
|
|
82
|
+
if (isTracedTensor(t))
|
|
96
83
|
return t.scale(k);
|
|
97
|
-
}
|
|
98
84
|
return new MathTSEngineTensor(unwrap(t, 'scale').scale(k));
|
|
99
85
|
}
|
|
100
86
|
identity(n) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mathts-engine.js","sourceRoot":"","sources":["../../src/numerical/mathts-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAAE,qBAAqB,EA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ACzF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAAC,MAAM,IAAI,qBAAqB,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAAC,CAAC;QAE9F,+EAA+E;QAC/E,sEAAsE;QACtE,+EAA+E;QAC/E,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACxE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAC9E,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC;YACnC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SAC1C,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * MathTSEngine — a TensorEngine implementation backed by\n * @danielsimonjr/mathts-tensor's rank-N Tensor. It is the only engine.\n * The MathTS packages are required dependencies; see engine-registry.ts.\n *\n * Thin adapter: it translates the TensorEngine contract onto the MathTS\n * Tensor's methods. The engine-conformance suite is what checks that\n * translation.\n *\n * @module numerical/mathts-engine\n */\nimport { Tensor } from '@danielsimonjr/mathts-tensor';\nimport type { EngineTensor, TensorEngine, EinsumSpec, ForwardGradResult, ReverseGradResult } from './tensor-engine.js';\nimport type { NestedArray } from './types.js';\nimport { NumericalBackendError } from './errors.js';\nimport { EngineCapabilityError } from './tensor-engine.js';\n\n/** EngineTensor handle wrapping a MathTS Tensor. */\nclass MathTSEngineTensor implements EngineTensor {\n constructor(readonly inner: Tensor) {}\n get shape(): ReadonlyArray<number> { return this.inner.shape; }\n}\n\nfunction unwrap(t: EngineTensor, op: string): Tensor {\n if (!(t instanceof MathTSEngineTensor)) {\n throw new NumericalBackendError(`MathTSEngine.${op}: operand is not a MathTSEngineTensor`);\n }\n return t.inner;\n}\n\n/**\n * Call-site shape for `@danielsimonjr/mathts-autograd`. The package is a\n * required dependency and is loaded at the call, so this interface covers\n * the dynamic-import result only.\n * @internal\n */\ninterface MathTSAutograd {\n forwardGrad(\n fn: (x: EngineTensor) => EngineTensor,\n x: Tensor,\n ): Promise<{ value: Tensor; jacobian: Tensor }>;\n reverseGrad(\n fn: (x: EngineTensor) => EngineTensor,\n x: Tensor,\n cotangent?: Tensor,\n ): Promise<{ value: Tensor; gradient: Tensor }>;\n}\n\n/**\n * `TensorEngine` backed by `@danielsimonjr/mathts-tensor`'s rank-N Tensor.\n * The MathTS packages are required dependencies.\n *\n * @public — reachable only via the\n * `universal-physics-tensor/numerical/mathts-engine` exports subpath.\n * Intentionally NOT re-exported from the root barrel.\n */\nexport class MathTSEngine implements TensorEngine {\n readonly name = 'MathTSEngine';\n\n fromNested(data: NestedArray, shape: ReadonlyArray<number>): EngineTensor {\n // UPT's NestedArray and MathTS's are the same shape; the type parameters differ.\n return new MathTSEngineTensor(Tensor.fromNested(data as never, shape));\n }\n toNested(t: EngineTensor): NestedArray {\n return unwrap(t, 'toNested').toNested();\n }\n\n einsum(spec: EinsumSpec, ...operands: EngineTensor[]): EngineTensor {\n const inner = operands.map((o, i) => unwrap(o, `einsum (operand ${i})`));\n return new MathTSEngineTensor(Tensor.einsum(spec, ...inner));\n }\n matMul(a: EngineTensor, b: EngineTensor): EngineTensor {\n return new MathTSEngineTensor(unwrap(a, 'matMul').matMul(unwrap(b, 'matMul')));\n }\n transpose(t: EngineTensor, perm?: ReadonlyArray<number>): EngineTensor {\n return new MathTSEngineTensor(unwrap(t, 'transpose').transpose(perm));\n }\n reshape(t: EngineTensor, shape: ReadonlyArray<number>): EngineTensor {\n return new MathTSEngineTensor(unwrap(t, 'reshape').reshape(shape));\n }\n\n // AD dispatch. `@danielsimonjr/mathts-autograd` wraps the traced input as a\n // DualTensor (forward mode, carries `tangent`) or a TapedTensor (reverse\n // mode, carries `tape`) and calls these methods with it. The autograd\n // package is loaded at the AD call, not at module load, so its classes\n // cannot be named here; the structural casts below state the invariant\n // the package keeps: a wrapped tensor implements add/sub/mul/scale over\n // another wrapped tensor and returns a wrapped tensor.\n add(a: EngineTensor, b: EngineTensor): EngineTensor {\n if ('tangent' in a && 'tangent' in b) {\n return (a as unknown as { add(o: unknown): EngineTensor }).add(b);\n }\n // AD dispatch: TapedTensor (reverse-mode)\n if ('tape' in a && 'tape' in b) {\n return (a as unknown as { add(o: unknown): EngineTensor }).add(b);\n }\n return new MathTSEngineTensor(unwrap(a, 'add').add(unwrap(b, 'add')));\n }\n sub(a: EngineTensor, b: EngineTensor): EngineTensor {\n if ('tangent' in a && 'tangent' in b) {\n return (a as unknown as { sub(o: unknown): EngineTensor }).sub(b);\n }\n if ('tape' in a && 'tape' in b) {\n return (a as unknown as { sub(o: unknown): EngineTensor }).sub(b);\n }\n return new MathTSEngineTensor(unwrap(a, 'sub').sub(unwrap(b, 'sub')));\n }\n mul(a: EngineTensor, b: EngineTensor): EngineTensor {\n if ('tangent' in a && 'tangent' in b) {\n return (a as unknown as { mul(o: unknown): EngineTensor }).mul(b);\n }\n if ('tape' in a && 'tape' in b) {\n return (a as unknown as { mul(o: unknown): EngineTensor }).mul(b);\n }\n return new MathTSEngineTensor(unwrap(a, 'mul').mul(unwrap(b, 'mul')));\n }\n scale(t: EngineTensor, k: number): EngineTensor {\n if ('tangent' in t || 'tape' in t) {\n return (t as unknown as { scale(k: number): EngineTensor }).scale(k);\n }\n return new MathTSEngineTensor(unwrap(t, 'scale').scale(k));\n }\n\n identity(n: number): EngineTensor {\n return new MathTSEngineTensor(Tensor.identity(n));\n }\n normInf(t: EngineTensor): number {\n return unwrap(t, 'normInf').normInf();\n }\n\n // ---------------------------------------------------------------------------\n // Internal helpers for AD boundary conversions\n // ---------------------------------------------------------------------------\n\n /** Unwrap an EngineTensor to its underlying MathTS Tensor (for the AD boundary). */\n private toMathTSTensor(t: EngineTensor): Tensor {\n return unwrap(t, 'toMathTSTensor');\n }\n\n /** Wrap a MathTS Tensor (returned by autograd) back as an EngineTensor. */\n private fromMathTSTensor(t: Tensor): EngineTensor {\n return new MathTSEngineTensor(t);\n }\n\n // ---------------------------------------------------------------------------\n // Forward-mode AD (Jacobian-vector product)\n // ---------------------------------------------------------------------------\n\n /**\n * Forward-mode automatic differentiation via a lazy-imported\n * `@danielsimonjr/mathts-autograd`. Throws `EngineCapabilityError` if that\n * import fails.\n *\n * S1 fix: `fn` is passed UNCHANGED to `autograd.forwardGrad`. The autograd\n * package wraps `x` as a DualTensor internally; MathTSEngine's arithmetic\n * methods (mul/add/sub/scale) must dispatch DualTensor inputs through to\n * mathts-autograd's dual arithmetic — there must be no fn-wrapping at the\n * boundary, which would strip DualTensor instrumentation and silence the\n * AD trace.\n */\n async forwardGrad(\n fn: (x: EngineTensor) => EngineTensor,\n x: EngineTensor,\n ): Promise<ForwardGradResult> {\n let autograd: MathTSAutograd;\n try {\n // Narrow the dynamic import to the local call-site shape.\n autograd = await import('@danielsimonjr/mathts-autograd') as unknown as MathTSAutograd;\n } catch (cause) { throw new EngineCapabilityError('MathTSEngine', 'forwardGrad', { cause }); }\n\n // S1 fix: pass fn UNCHANGED. autograd.forwardGrad wraps x as a DualTensor;\n // MathTSEngine's arithmetic methods (mul/add/sub/scale) MUST dispatch\n // DualTensor inputs to mathts-autograd's dual arithmetic via\n // `'tangent' in arg`. Wrapping fn at the boundary strips the\n // instrumentation — the v0 sketch's bug.\n const xMathts = this.toMathTSTensor(x);\n const { value, jacobian } = await autograd.forwardGrad(fn, xMathts);\n return {\n value: this.fromMathTSTensor(value),\n jacobian: this.fromMathTSTensor(jacobian),\n };\n }\n\n // ---------------------------------------------------------------------------\n // Reverse-mode AD (vector-Jacobian product)\n // ---------------------------------------------------------------------------\n\n /**\n * Reverse-mode automatic differentiation via a lazy-imported\n * `@danielsimonjr/mathts-autograd`. Throws `EngineCapabilityError` if that\n * import fails.\n *\n * S1 fix: `fn` is passed UNCHANGED (see forwardGrad note above). The\n * autograd package wraps `x` as a TapedTensor; MathTSEngine's op methods\n * must dispatch TapedTensor inputs to mathts-autograd's tape arithmetic via\n * `'tape' in arg` branching.\n */\n async reverseGrad(\n fn: (x: EngineTensor) => EngineTensor,\n x: EngineTensor,\n cotangent?: EngineTensor,\n ): Promise<ReverseGradResult> {\n let autograd: MathTSAutograd;\n try {\n // Narrow the dynamic import to the local call-site shape.\n autograd = await import('@danielsimonjr/mathts-autograd') as unknown as MathTSAutograd;\n } catch (cause) { throw new EngineCapabilityError('MathTSEngine', 'reverseGrad', { cause }); }\n\n // S1 fix: pass fn UNCHANGED (see forwardGrad note above). autograd.reverseGrad\n // wraps x as a TapedTensor; MathTSEngine's mul/add/sub/scale dispatch\n // TapedTensor inputs to mathts-autograd's tape arithmetic via `'tape' in arg`.\n const xMathts = this.toMathTSTensor(x);\n const ctMathts = cotangent ? this.toMathTSTensor(cotangent) : undefined;\n const { value, gradient } = await autograd.reverseGrad(fn, xMathts, ctMathts);\n return {\n value: this.fromMathTSTensor(value),\n gradient: this.fromMathTSTensor(gradient),\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mathts-engine.js","sourceRoot":"","sources":["../../src/numerical/mathts-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEvF,oDAAoD;AACpD,MAAM,kBAAkB;IACD,KAAK;IAA1B,YAAqB,KAAa;qBAAb,KAAK;IAAW,CAAC;IACtC,IAAI,KAAK,KAA4B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;CAChE;AAED,SAAS,MAAM,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,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SAC1C,CAAC;IACJ,CAAC;CACF","sourcesContent":["/**\n * MathTSEngine — a TensorEngine implementation backed by\n * @danielsimonjr/mathts-tensor's rank-N Tensor. It is the only engine.\n * The MathTS packages are required dependencies; see engine-registry.ts.\n *\n * Thin adapter: it translates the TensorEngine contract onto the MathTS\n * Tensor's methods. The engine-conformance suite is what checks that\n * translation.\n *\n * @module numerical/mathts-engine\n */\nimport { Tensor } from '@danielsimonjr/mathts-tensor';\nimport type { EngineTensor, TensorEngine, EinsumSpec, ForwardGradResult, ReverseGradResult } from './tensor-engine.js';\nimport type { NestedArray } from './types.js';\nimport { NumericalBackendError } from './errors.js';\nimport { EngineCapabilityError, isTracedTensor, tracedMode } from './tensor-engine.js';\n\n/** EngineTensor handle wrapping a MathTS Tensor. */\nclass MathTSEngineTensor implements EngineTensor {\n constructor(readonly inner: Tensor) {}\n get shape(): ReadonlyArray<number> { return this.inner.shape; }\n}\n\nfunction unwrap(t: EngineTensor, op: string): Tensor {\n if (!(t instanceof MathTSEngineTensor)) {\n throw new NumericalBackendError(`MathTSEngine.${op}: operand is not a MathTSEngineTensor`);\n }\n return t.inner;\n}\n\n/**\n * Call-site shape for `@danielsimonjr/mathts-autograd`. The package is a\n * required dependency and is loaded at the call, so this interface covers\n * the dynamic-import result only.\n * @internal\n */\ninterface MathTSAutograd {\n forwardGrad(\n fn: (x: EngineTensor) => EngineTensor,\n x: Tensor,\n ): Promise<{ value: Tensor; jacobian: Tensor }>;\n reverseGrad(\n fn: (x: EngineTensor) => EngineTensor,\n x: Tensor,\n cotangent?: Tensor,\n ): Promise<{ value: Tensor; gradient: Tensor }>;\n}\n\n/**\n * `TensorEngine` backed by `@danielsimonjr/mathts-tensor`'s rank-N Tensor.\n * The MathTS packages are required dependencies.\n *\n * @public — reachable only via the\n * `universal-physics-tensor/numerical/mathts-engine` exports subpath.\n * Intentionally NOT re-exported from the root barrel.\n */\nexport class MathTSEngine implements TensorEngine {\n readonly name = 'MathTSEngine';\n\n fromNested(data: NestedArray, shape: ReadonlyArray<number>): EngineTensor {\n // UPT's NestedArray and MathTS's are the same shape; the type parameters differ.\n return new MathTSEngineTensor(Tensor.fromNested(data as never, shape));\n }\n toNested(t: EngineTensor): NestedArray {\n return unwrap(t, 'toNested').toNested();\n }\n\n einsum(spec: EinsumSpec, ...operands: EngineTensor[]): EngineTensor {\n const inner = operands.map((o, i) => unwrap(o, `einsum (operand ${i})`));\n return new MathTSEngineTensor(Tensor.einsum(spec, ...inner));\n }\n matMul(a: EngineTensor, b: EngineTensor): EngineTensor {\n return new MathTSEngineTensor(unwrap(a, 'matMul').matMul(unwrap(b, 'matMul')));\n }\n transpose(t: EngineTensor, perm?: ReadonlyArray<number>): EngineTensor {\n return new MathTSEngineTensor(unwrap(t, 'transpose').transpose(perm));\n }\n reshape(t: EngineTensor, shape: ReadonlyArray<number>): EngineTensor {\n return new MathTSEngineTensor(unwrap(t, 'reshape').reshape(shape));\n }\n\n // AD dispatch. `@danielsimonjr/mathts-autograd` wraps the traced input as a\n // DualTensor (forward mode, carries `tangent`) or a TapedTensor (reverse\n // mode, carries `tape`) and calls these methods with it. The operations a\n // wrapped tensor implements are declared on `TracedEngineTensor`; the guard\n // `isTracedTensor` is the dispatch. Two operands trace together only when\n // both are wrapped in the same mode; a mixed or half-wrapped pair falls\n // through to the plain path, whose `unwrap` refuses it.\n add(a: EngineTensor, b: EngineTensor): EngineTensor {\n if (isTracedTensor(a) && isTracedTensor(b) && tracedMode(a) === tracedMode(b)) return a.add(b);\n return new MathTSEngineTensor(unwrap(a, 'add').add(unwrap(b, 'add')));\n }\n sub(a: EngineTensor, b: EngineTensor): EngineTensor {\n if (isTracedTensor(a) && isTracedTensor(b) && tracedMode(a) === tracedMode(b)) return a.sub(b);\n return new MathTSEngineTensor(unwrap(a, 'sub').sub(unwrap(b, 'sub')));\n }\n mul(a: EngineTensor, b: EngineTensor): EngineTensor {\n if (isTracedTensor(a) && isTracedTensor(b) && tracedMode(a) === tracedMode(b)) return a.mul(b);\n return new MathTSEngineTensor(unwrap(a, 'mul').mul(unwrap(b, 'mul')));\n }\n scale(t: EngineTensor, k: number): EngineTensor {\n if (isTracedTensor(t)) return t.scale(k);\n return new MathTSEngineTensor(unwrap(t, 'scale').scale(k));\n }\n\n identity(n: number): EngineTensor {\n return new MathTSEngineTensor(Tensor.identity(n));\n }\n normInf(t: EngineTensor): number {\n return unwrap(t, 'normInf').normInf();\n }\n\n // ---------------------------------------------------------------------------\n // Internal helpers for AD boundary conversions\n // ---------------------------------------------------------------------------\n\n /** Unwrap an EngineTensor to its underlying MathTS Tensor (for the AD boundary). */\n private toMathTSTensor(t: EngineTensor): Tensor {\n return unwrap(t, 'toMathTSTensor');\n }\n\n /** Wrap a MathTS Tensor (returned by autograd) back as an EngineTensor. */\n private fromMathTSTensor(t: Tensor): EngineTensor {\n return new MathTSEngineTensor(t);\n }\n\n // ---------------------------------------------------------------------------\n // Forward-mode AD (Jacobian-vector product)\n // ---------------------------------------------------------------------------\n\n /**\n * Forward-mode automatic differentiation via a lazy-imported\n * `@danielsimonjr/mathts-autograd`. Throws `EngineCapabilityError` if that\n * import fails.\n *\n * S1 fix: `fn` is passed UNCHANGED to `autograd.forwardGrad`. The autograd\n * package wraps `x` as a DualTensor internally; MathTSEngine's arithmetic\n * methods (mul/add/sub/scale) must dispatch DualTensor inputs through to\n * mathts-autograd's dual arithmetic — there must be no fn-wrapping at the\n * boundary, which would strip DualTensor instrumentation and silence the\n * AD trace.\n */\n async forwardGrad(\n fn: (x: EngineTensor) => EngineTensor,\n x: EngineTensor,\n ): Promise<ForwardGradResult> {\n let autograd: MathTSAutograd;\n try {\n // Narrow the dynamic import to the local call-site shape.\n autograd = await import('@danielsimonjr/mathts-autograd') as unknown as MathTSAutograd;\n } catch (cause) { throw new EngineCapabilityError('MathTSEngine', 'forwardGrad', { cause }); }\n\n // S1 fix: pass fn UNCHANGED. autograd.forwardGrad wraps x as a DualTensor;\n // MathTSEngine's arithmetic methods (mul/add/sub/scale) MUST dispatch\n // DualTensor inputs to mathts-autograd's dual arithmetic via\n // `'tangent' in arg`. Wrapping fn at the boundary strips the\n // instrumentation — the v0 sketch's bug.\n const xMathts = this.toMathTSTensor(x);\n const { value, jacobian } = await autograd.forwardGrad(fn, xMathts);\n return {\n value: this.fromMathTSTensor(value),\n jacobian: this.fromMathTSTensor(jacobian),\n };\n }\n\n // ---------------------------------------------------------------------------\n // Reverse-mode AD (vector-Jacobian product)\n // ---------------------------------------------------------------------------\n\n /**\n * Reverse-mode automatic differentiation via a lazy-imported\n * `@danielsimonjr/mathts-autograd`. Throws `EngineCapabilityError` if that\n * import fails.\n *\n * S1 fix: `fn` is passed UNCHANGED (see forwardGrad note above). The\n * autograd package wraps `x` as a TapedTensor; MathTSEngine's op methods\n * must dispatch TapedTensor inputs to mathts-autograd's tape arithmetic via\n * `'tape' in arg` branching.\n */\n async reverseGrad(\n fn: (x: EngineTensor) => EngineTensor,\n x: EngineTensor,\n cotangent?: EngineTensor,\n ): Promise<ReverseGradResult> {\n let autograd: MathTSAutograd;\n try {\n // Narrow the dynamic import to the local call-site shape.\n autograd = await import('@danielsimonjr/mathts-autograd') as unknown as MathTSAutograd;\n } catch (cause) { throw new EngineCapabilityError('MathTSEngine', 'reverseGrad', { cause }); }\n\n // S1 fix: pass fn UNCHANGED (see forwardGrad note above). autograd.reverseGrad\n // wraps x as a TapedTensor; MathTSEngine's mul/add/sub/scale dispatch\n // TapedTensor inputs to mathts-autograd's tape arithmetic via `'tape' in arg`.\n const xMathts = this.toMathTSTensor(x);\n const ctMathts = cotangent ? this.toMathTSTensor(cotangent) : undefined;\n const { value, gradient } = await autograd.reverseGrad(fn, xMathts, ctMathts);\n return {\n value: this.fromMathTSTensor(value),\n gradient: this.fromMathTSTensor(gradient),\n };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metric-inverse.d.ts","sourceRoot":"","sources":["../../src/numerical/metric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A0B,EACrC,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,YAAY,CAAA;CAAE,GAClC,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC,CAkCxD;AAED;;;2EAG2E;AAC3E,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,QAAQ,GACb;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GAAG,IAAI,CA0F/D"}
|
|
@@ -39,54 +39,91 @@ export async function evaluateMetricInverse(gInverse, g, inputs, tolerance = DEF
|
|
|
39
39
|
* @internal — cross-module use only; not part of the consumer surface. */
|
|
40
40
|
export function scanForMetricPair(node) {
|
|
41
41
|
const metrics = [];
|
|
42
|
+
// An exhaustive switch: a node kind added to `ExprNode` without an arm here
|
|
43
|
+
// fails to compile at the `never` arm, instead of becoming a silent leaf (the
|
|
44
|
+
// way `kretschmann-scalar` and `einstein-equation` were, so the warning never
|
|
45
|
+
// fired on them). A kind with no metric inside is listed as a leaf on purpose.
|
|
42
46
|
const walk = (n) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
switch (n.kind) {
|
|
48
|
+
case 'metric-tensor':
|
|
49
|
+
metrics.push(n);
|
|
50
|
+
break;
|
|
51
|
+
case 'op':
|
|
52
|
+
case 'tensor-product':
|
|
53
|
+
n.args.forEach(walk);
|
|
54
|
+
break;
|
|
55
|
+
case 'integral':
|
|
56
|
+
walk(n.over);
|
|
57
|
+
walk(n.integrand);
|
|
58
|
+
if (n.lower !== undefined)
|
|
59
|
+
walk(n.lower);
|
|
60
|
+
if (n.upper !== undefined)
|
|
61
|
+
walk(n.upper);
|
|
62
|
+
break;
|
|
63
|
+
case 'derivative':
|
|
64
|
+
walk(n.of);
|
|
65
|
+
walk(n.wrt);
|
|
66
|
+
break;
|
|
67
|
+
case 'variational-derivative':
|
|
68
|
+
walk(n.functional);
|
|
69
|
+
walk(n.field);
|
|
70
|
+
walk(n.over);
|
|
71
|
+
break;
|
|
72
|
+
case 'dirac-delta':
|
|
73
|
+
case 'transcendental':
|
|
74
|
+
case 'abs':
|
|
75
|
+
walk(n.arg);
|
|
76
|
+
break;
|
|
77
|
+
case 'tensor-partial-derivative':
|
|
78
|
+
walk(n.of);
|
|
79
|
+
walk(n.wrt);
|
|
80
|
+
break;
|
|
81
|
+
case 'covariant-derivative':
|
|
82
|
+
walk(n.of);
|
|
83
|
+
walk(n.gLower);
|
|
84
|
+
walk(n.gInverse);
|
|
85
|
+
break;
|
|
86
|
+
case 'riemann-tensor':
|
|
87
|
+
walk(n.gLower);
|
|
88
|
+
walk(n.gInverse);
|
|
89
|
+
break;
|
|
90
|
+
case 'ricci-tensor':
|
|
91
|
+
case 'bianchi-residual':
|
|
92
|
+
walk(n.riemann); // the inner Riemann holds the pair
|
|
93
|
+
break;
|
|
94
|
+
case 'einstein-tensor':
|
|
95
|
+
walk(n.riemann);
|
|
96
|
+
walk(n.gLower);
|
|
97
|
+
walk(n.gInverse);
|
|
98
|
+
break;
|
|
99
|
+
case 'weyl-tensor':
|
|
100
|
+
walk(n.metric);
|
|
101
|
+
break;
|
|
102
|
+
case 'kretschmann-scalar':
|
|
103
|
+
walk(n.riemann);
|
|
104
|
+
walk(n.metric);
|
|
105
|
+
break;
|
|
106
|
+
case 'killing-vector':
|
|
107
|
+
walk(n.metric);
|
|
108
|
+
break;
|
|
109
|
+
case 'conserved-charge':
|
|
110
|
+
walk(n.killing);
|
|
111
|
+
break;
|
|
112
|
+
case 'einstein-equation':
|
|
113
|
+
walk(n.lhs);
|
|
114
|
+
walk(n.metric);
|
|
115
|
+
break;
|
|
116
|
+
case 'symbol':
|
|
117
|
+
case 'tensor-symbol':
|
|
118
|
+
case 'kronecker-delta':
|
|
119
|
+
case 'stress-energy':
|
|
120
|
+
case 'cosmological-constant':
|
|
121
|
+
break; // leaves: no metric inside
|
|
122
|
+
default: {
|
|
123
|
+
const unreachable = n;
|
|
124
|
+
throw new NumericalBackendError(`scanForMetricPair: unhandled node kind ${String(unreachable.kind)}`);
|
|
125
|
+
}
|
|
52
126
|
}
|
|
53
|
-
else if (n.kind === 'derivative') {
|
|
54
|
-
walk(n.of);
|
|
55
|
-
walk(n.wrt);
|
|
56
|
-
}
|
|
57
|
-
else if (n.kind === 'tensor-partial-derivative') {
|
|
58
|
-
walk(n.of);
|
|
59
|
-
walk(n.wrt);
|
|
60
|
-
}
|
|
61
|
-
// v0.5.1 PC-3: walk the v0.4.0+v0.5.0 curvature node kinds so that
|
|
62
|
-
// InverseMetricInconsistencyWarning fires on the GR pipeline. Prior to
|
|
63
|
-
// this, scan stopped at riemann/ricci/einstein/bianchi/covariant-derivative
|
|
64
|
-
// and the warning was silently never emitted on the whole curvature stack
|
|
65
|
-
// — "a validation mechanism that doesn't run is worse than no validation
|
|
66
|
-
// at all" (Adam, v0.5.1 audit).
|
|
67
|
-
//
|
|
68
|
-
// FUTURE: when a new curvature kind is added, this scan needs an arm.
|
|
69
|
-
else if (n.kind === 'covariant-derivative') {
|
|
70
|
-
walk(n.of);
|
|
71
|
-
walk(n.gLower);
|
|
72
|
-
walk(n.gInverse);
|
|
73
|
-
}
|
|
74
|
-
else if (n.kind === 'riemann-tensor') {
|
|
75
|
-
walk(n.gLower);
|
|
76
|
-
walk(n.gInverse);
|
|
77
|
-
}
|
|
78
|
-
else if (n.kind === 'ricci-tensor') {
|
|
79
|
-
walk(n.riemann); // inner Riemann walks its own gLower/gInverse
|
|
80
|
-
}
|
|
81
|
-
else if (n.kind === 'einstein-tensor') {
|
|
82
|
-
walk(n.riemann);
|
|
83
|
-
walk(n.gLower);
|
|
84
|
-
walk(n.gInverse);
|
|
85
|
-
}
|
|
86
|
-
else if (n.kind === 'bianchi-residual') {
|
|
87
|
-
walk(n.riemann); // recurse via inner Riemann
|
|
88
|
-
}
|
|
89
|
-
// tensor-symbol / kronecker-delta / symbol: leaves, no metric inside
|
|
90
127
|
};
|
|
91
128
|
walk(node);
|
|
92
129
|
const lower = metrics.find((m) => m.indices.every((i) => i.variance === 'lower'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metric-inverse.js","sourceRoot":"","sources":["../../src/numerical/metric-inverse.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC;cACc;AACd,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,QAA0B,EAC1B,CAAmB,EACnB,MAAuB,EACvB,SAAS,GAAW,iBAAiB,EACrC,OAAmC;IAEnC,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,MAAM,eAAe,EAAE,CAAC;IAC1D,MAAM,CAAC,GAAG,MAAM,CAAC,SAAS,IAAI,CAAC,CAAC;IAEhC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,IAAI,qBAAqB,CAC7B,yDAAyD,QAAQ,CAAC,IAAI,qBAAqB,CAC5F,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,qBAAqB,CAC7B,yDAAyD,CAAC,CAAC,IAAI,qBAAqB,CACrF,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,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I,CAAC,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YACtC,IAAI,CAAC,CAAC,CAAC,OAA8B,CAAC,CAAC;YACvC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;YACf,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QACnB,CAAC;aACI,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;YACvC,IAAI,CAAC,CAAC,CAAC,OAA8B,CAAC,CAAC,CAAE,4BAA4B;QACvE,CAAC;QACD,qEAAqE;IACvE,CAAC,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,CAAC;IACX,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC;IAClF,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC;IAClF,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC","sourcesContent":["/**\n * InverseMetricInconsistencyWarning — numerical path. Builds g⁻¹ and g as\n * EngineTensors, computes ‖matMul(g⁻¹, g) − I‖_∞, and emits a\n * 'warning'-severity Violation when it exceeds tolerance. v0.3.5-Design.md\n * §7. Resolves the v0.3.0 §13 Q2 deferral. `scanForMetricPair` finds an\n * identifiable lower/upper metric pair in an AST so evaluateNumerical can\n * run the check automatically.\n *\n * @module numerical/metric-inverse\n */\nimport type { ExprNode, Violation } from '../dimensional/validator.js';\nimport type { MetricTensorNode } from '../dimensional/metric-validators.js';\nimport { DIMENSIONLESS } from '../dimensional/types.js';\nimport type { TensorEngine } from './tensor-engine.js';\nimport type { NumericalInputs } from './types.js';\nimport { getActiveEngine } from './engine-registry.js';\nimport { NumericalBackendError } from './errors.js';\n\nconst DEFAULT_TOLERANCE = 1e-10;\n\n/** Compute ‖g⁻¹g − I‖_∞ and, if it exceeds tolerance, return a warning.\n * @public */\nexport async function evaluateMetricInverse(\n gInverse: MetricTensorNode,\n g: MetricTensorNode,\n inputs: NumericalInputs,\n tolerance: number = DEFAULT_TOLERANCE,\n options?: { engine?: TensorEngine },\n): Promise<{ residualNorm: number; warning?: Violation }> {\n const engine = options?.engine ?? await getActiveEngine();\n const N = inputs.dimension ?? 4;\n\n const gInvData = inputs.tensors.get(gInverse.name);\n const gData = inputs.tensors.get(g.name);\n if (gInvData === undefined) {\n throw new NumericalBackendError(\n `evaluateMetricInverse: missing tensor components for \"${gInverse.name}\" in inputs.tensors`,\n );\n }\n if (gData === undefined) {\n throw new NumericalBackendError(\n `evaluateMetricInverse: missing tensor components for \"${g.name}\" in inputs.tensors`,\n );\n }\n const gInvT = engine.fromNested(gInvData, [N, N]);\n const gT = engine.fromNested(gData, [N, N]);\n const residual = engine.sub(engine.matMul(gInvT, gT), engine.identity(N));\n const residualNorm = engine.normInf(residual);\n\n if (residualNorm > tolerance) {\n const warning: Violation = {\n location: `${gInverse.name}·${g.name}`,\n expected: DIMENSIONLESS,\n actual: DIMENSIONLESS,\n note: `InverseMetricInconsistencyWarning: ‖${gInverse.name}·${g.name} − I‖_∞ = `\n + `${residualNorm.toExponential(3)} exceeds tolerance ${tolerance.toExponential(1)} — `\n + `the supplied metrics are not numerical inverses`,\n severity: 'warning',\n };\n return { residualNorm, warning };\n }\n return { residualNorm };\n}\n\n/** Walk an ExprNode tree; return the first all-lower / all-upper\n * metric-tensor pair found, or null. Cheap — evaluateNumerical already\n * walks the tree to lower it.\n * @internal — cross-module use only; not part of the consumer surface. */\nexport function scanForMetricPair(\n node: ExprNode,\n): { gLower: MetricTensorNode; gUpper: MetricTensorNode } | null {\n const metrics: MetricTensorNode[] = [];\n const walk = (n: ExprNode): void => {\n if (n.kind === 'metric-tensor') metrics.push(n);\n else if (n.kind === 'op') n.args.forEach(walk);\n else if (n.kind === 'tensor-product') n.args.forEach(walk);\n else if (n.kind === 'integral') { walk(n.over); walk(n.integrand); }\n else if (n.kind === 'derivative') { walk(n.of); walk(n.wrt); }\n else if (n.kind === 'tensor-partial-derivative') {\n walk(n.of as ExprNode); walk(n.wrt as ExprNode);\n }\n // v0.5.1 PC-3: walk the v0.4.0+v0.5.0 curvature node kinds so that\n // InverseMetricInconsistencyWarning fires on the GR pipeline. Prior to\n // this, scan stopped at riemann/ricci/einstein/bianchi/covariant-derivative\n // and the warning was silently never emitted on the whole curvature stack\n // — \"a validation mechanism that doesn't run is worse than no validation\n // at all\" (Adam, v0.5.1 audit).\n //\n // FUTURE: when a new curvature kind is added, this scan needs an arm.\n else if (n.kind === 'covariant-derivative') {\n walk(n.of as ExprNode);\n walk(n.gLower);\n walk(n.gInverse);\n }\n else if (n.kind === 'riemann-tensor') {\n walk(n.gLower);\n walk(n.gInverse);\n }\n else if (n.kind === 'ricci-tensor') {\n walk(n.riemann as unknown as ExprNode); // inner Riemann walks its own gLower/gInverse\n }\n else if (n.kind === 'einstein-tensor') {\n walk(n.riemann as unknown as ExprNode);\n walk(n.gLower);\n walk(n.gInverse);\n }\n else if (n.kind === 'bianchi-residual') {\n walk(n.riemann as unknown as ExprNode); // recurse via inner Riemann\n }\n // tensor-symbol / kronecker-delta / symbol: leaves, no metric inside\n };\n walk(node);\n const lower = metrics.find((m) => m.indices.every((i) => i.variance === 'lower'));\n const upper = metrics.find((m) => m.indices.every((i) => i.variance === 'upper'));\n return lower && upper ? { gLower: lower, gUpper: upper } : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"metric-inverse.js","sourceRoot":"","sources":["../../src/numerical/metric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AAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC;IAClF,OAAO,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAClE,CAAC","sourcesContent":["/**\n * InverseMetricInconsistencyWarning — numerical path. Builds g⁻¹ and g as\n * EngineTensors, computes ‖matMul(g⁻¹, g) − I‖_∞, and emits a\n * 'warning'-severity Violation when it exceeds tolerance. v0.3.5-Design.md\n * §7. Resolves the v0.3.0 §13 Q2 deferral. `scanForMetricPair` finds an\n * identifiable lower/upper metric pair in an AST so evaluateNumerical can\n * run the check automatically.\n *\n * @module numerical/metric-inverse\n */\nimport type { ExprNode, Violation } from '../dimensional/validator.js';\nimport type { MetricTensorNode } from '../dimensional/metric-validators.js';\nimport { DIMENSIONLESS } from '../dimensional/types.js';\nimport type { TensorEngine } from './tensor-engine.js';\nimport type { NumericalInputs } from './types.js';\nimport { getActiveEngine } from './engine-registry.js';\nimport { NumericalBackendError } from './errors.js';\n\nconst DEFAULT_TOLERANCE = 1e-10;\n\n/** Compute ‖g⁻¹g − I‖_∞ and, if it exceeds tolerance, return a warning.\n * @public */\nexport async function evaluateMetricInverse(\n gInverse: MetricTensorNode,\n g: MetricTensorNode,\n inputs: NumericalInputs,\n tolerance: number = DEFAULT_TOLERANCE,\n options?: { engine?: TensorEngine },\n): Promise<{ residualNorm: number; warning?: Violation }> {\n const engine = options?.engine ?? await getActiveEngine();\n const N = inputs.dimension ?? 4;\n\n const gInvData = inputs.tensors.get(gInverse.name);\n const gData = inputs.tensors.get(g.name);\n if (gInvData === undefined) {\n throw new NumericalBackendError(\n `evaluateMetricInverse: missing tensor components for \"${gInverse.name}\" in inputs.tensors`,\n );\n }\n if (gData === undefined) {\n throw new NumericalBackendError(\n `evaluateMetricInverse: missing tensor components for \"${g.name}\" in inputs.tensors`,\n );\n }\n const gInvT = engine.fromNested(gInvData, [N, N]);\n const gT = engine.fromNested(gData, [N, N]);\n const residual = engine.sub(engine.matMul(gInvT, gT), engine.identity(N));\n const residualNorm = engine.normInf(residual);\n\n if (residualNorm > tolerance) {\n const warning: Violation = {\n location: `${gInverse.name}·${g.name}`,\n expected: DIMENSIONLESS,\n actual: DIMENSIONLESS,\n note: `InverseMetricInconsistencyWarning: ‖${gInverse.name}·${g.name} − I‖_∞ = `\n + `${residualNorm.toExponential(3)} exceeds tolerance ${tolerance.toExponential(1)} — `\n + `the supplied metrics are not numerical inverses`,\n severity: 'warning',\n };\n return { residualNorm, warning };\n }\n return { residualNorm };\n}\n\n/** Walk an ExprNode tree; return the first all-lower / all-upper\n * metric-tensor pair found, or null. Cheap — evaluateNumerical already\n * walks the tree to lower it.\n * @internal — cross-module use only; not part of the consumer surface. */\nexport function scanForMetricPair(\n node: ExprNode,\n): { gLower: MetricTensorNode; gUpper: MetricTensorNode } | null {\n const metrics: MetricTensorNode[] = [];\n // An exhaustive switch: a node kind added to `ExprNode` without an arm here\n // fails to compile at the `never` arm, instead of becoming a silent leaf (the\n // way `kretschmann-scalar` and `einstein-equation` were, so the warning never\n // fired on them). A kind with no metric inside is listed as a leaf on purpose.\n const walk = (n: ExprNode): void => {\n switch (n.kind) {\n case 'metric-tensor':\n metrics.push(n);\n break;\n case 'op':\n case 'tensor-product':\n n.args.forEach(walk);\n break;\n case 'integral':\n walk(n.over);\n walk(n.integrand);\n if (n.lower !== undefined) walk(n.lower);\n if (n.upper !== undefined) walk(n.upper);\n break;\n case 'derivative':\n walk(n.of);\n walk(n.wrt);\n break;\n case 'variational-derivative':\n walk(n.functional);\n walk(n.field);\n walk(n.over);\n break;\n case 'dirac-delta':\n case 'transcendental':\n case 'abs':\n walk(n.arg);\n break;\n case 'tensor-partial-derivative':\n walk(n.of);\n walk(n.wrt);\n break;\n case 'covariant-derivative':\n walk(n.of);\n walk(n.gLower);\n walk(n.gInverse);\n break;\n case 'riemann-tensor':\n walk(n.gLower);\n walk(n.gInverse);\n break;\n case 'ricci-tensor':\n case 'bianchi-residual':\n walk(n.riemann); // the inner Riemann holds the pair\n break;\n case 'einstein-tensor':\n walk(n.riemann);\n walk(n.gLower);\n walk(n.gInverse);\n break;\n case 'weyl-tensor':\n walk(n.metric);\n break;\n case 'kretschmann-scalar':\n walk(n.riemann);\n walk(n.metric);\n break;\n case 'killing-vector':\n walk(n.metric);\n break;\n case 'conserved-charge':\n walk(n.killing);\n break;\n case 'einstein-equation':\n walk(n.lhs);\n walk(n.metric);\n break;\n case 'symbol':\n case 'tensor-symbol':\n case 'kronecker-delta':\n case 'stress-energy':\n case 'cosmological-constant':\n break; // leaves: no metric inside\n default: {\n const unreachable: never = n;\n throw new NumericalBackendError(`scanForMetricPair: unhandled node kind ${String((unreachable as { kind: unknown }).kind)}`);\n }\n }\n };\n walk(node);\n const lower = metrics.find((m) => m.indices.every((i) => i.variance === 'lower'));\n const upper = metrics.find((m) => m.indices.every((i) => i.variance === 'upper'));\n return lower && upper ? { gLower: lower, gUpper: upper } : null;\n}\n"]}
|
|
@@ -5,7 +5,8 @@ type ODESystem = (lambda: number, y: ReadonlyArray<number>) => number[];
|
|
|
5
5
|
/**
|
|
6
6
|
* Integrate `system` from affine parameter `lambda0` to `lambda1` in
|
|
7
7
|
* `steps` fixed RK4 steps, starting from state `y0`. Returns the final
|
|
8
|
-
* state vector. Classical 4th-order Runge-Kutta — global error O(h⁴).
|
|
8
|
+
* state vector. Classical 4th-order Runge-Kutta — global error O(h⁴). It takes
|
|
9
|
+
* exactly `steps` steps of (lambda1 − lambda0)/steps (`rk4Trajectory`).
|
|
9
10
|
*
|
|
10
11
|
* @internal — cross-module/test use only; not part of the consumer surface.
|
|
11
12
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"null-ray-integrator.d.ts","sourceRoot":"","sources":["../../src/numerical/null-ray-integrator.ts"],"names":[],"mappings":"AAcA;;+EAE+E;AAC/E,KAAK,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,MAAM,EAAE,CAAC;AAUxE
|
|
1
|
+
{"version":3,"file":"null-ray-integrator.d.ts","sourceRoot":"","sources":["../../src/numerical/null-ray-integrator.ts"],"names":[],"mappings":"AAcA;;+EAE+E;AAC/E,KAAK,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,MAAM,EAAE,CAAC;AAUxE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,SAAS,EACjB,EAAE,EAAE,aAAa,CAAC,MAAM,CAAC,EACzB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,MAAM,EAAE,CAiBV"}
|