universal-physics-tensor 0.4.5
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/LICENSE +21 -0
- package/README.md +377 -0
- package/dist/bridges/equations/be-11-decoherence-master.d.ts +83 -0
- package/dist/bridges/equations/be-11-decoherence-master.d.ts.map +1 -0
- package/dist/bridges/equations/be-11-decoherence-master.js +116 -0
- package/dist/bridges/equations/be-11-decoherence-master.js.map +1 -0
- package/dist/bridges/equations/be-12-coherence-length.d.ts +80 -0
- package/dist/bridges/equations/be-12-coherence-length.d.ts.map +1 -0
- package/dist/bridges/equations/be-12-coherence-length.js +128 -0
- package/dist/bridges/equations/be-12-coherence-length.js.map +1 -0
- package/dist/bridges/equations/be-13-einstein-trace.d.ts +89 -0
- package/dist/bridges/equations/be-13-einstein-trace.d.ts.map +1 -0
- package/dist/bridges/equations/be-13-einstein-trace.js +143 -0
- package/dist/bridges/equations/be-13-einstein-trace.js.map +1 -0
- package/dist/bridges/equations/be-14-ryu-takayanagi.d.ts +67 -0
- package/dist/bridges/equations/be-14-ryu-takayanagi.d.ts.map +1 -0
- package/dist/bridges/equations/be-14-ryu-takayanagi.js +112 -0
- package/dist/bridges/equations/be-14-ryu-takayanagi.js.map +1 -0
- package/dist/bridges/equations/be-15-emergence.d.ts +164 -0
- package/dist/bridges/equations/be-15-emergence.d.ts.map +1 -0
- package/dist/bridges/equations/be-15-emergence.js +204 -0
- package/dist/bridges/equations/be-15-emergence.js.map +1 -0
- package/dist/bridges/equations/be-16-landauer.d.ts +180 -0
- package/dist/bridges/equations/be-16-landauer.d.ts.map +1 -0
- package/dist/bridges/equations/be-16-landauer.js +206 -0
- package/dist/bridges/equations/be-16-landauer.js.map +1 -0
- package/dist/bridges/equations/be-17-einstein-cartan.d.ts +245 -0
- package/dist/bridges/equations/be-17-einstein-cartan.d.ts.map +1 -0
- package/dist/bridges/equations/be-17-einstein-cartan.js +304 -0
- package/dist/bridges/equations/be-17-einstein-cartan.js.map +1 -0
- package/dist/bridges/equations/be-18-higgs-mass.d.ts +65 -0
- package/dist/bridges/equations/be-18-higgs-mass.d.ts.map +1 -0
- package/dist/bridges/equations/be-18-higgs-mass.js +86 -0
- package/dist/bridges/equations/be-18-higgs-mass.js.map +1 -0
- package/dist/bridges/equations/be-19-quantum-bounce.d.ts +72 -0
- package/dist/bridges/equations/be-19-quantum-bounce.d.ts.map +1 -0
- package/dist/bridges/equations/be-19-quantum-bounce.js +151 -0
- package/dist/bridges/equations/be-19-quantum-bounce.js.map +1 -0
- package/dist/bridges/equations/be-20-vacuum-energy.d.ts +72 -0
- package/dist/bridges/equations/be-20-vacuum-energy.d.ts.map +1 -0
- package/dist/bridges/equations/be-20-vacuum-energy.js +115 -0
- package/dist/bridges/equations/be-20-vacuum-energy.js.map +1 -0
- package/dist/bridges/equations/be-21-kss-bound.d.ts +72 -0
- package/dist/bridges/equations/be-21-kss-bound.d.ts.map +1 -0
- package/dist/bridges/equations/be-21-kss-bound.js +103 -0
- package/dist/bridges/equations/be-21-kss-bound.js.map +1 -0
- package/dist/bridges/equations/be-22-topological-entanglement.d.ts +90 -0
- package/dist/bridges/equations/be-22-topological-entanglement.d.ts.map +1 -0
- package/dist/bridges/equations/be-22-topological-entanglement.js +123 -0
- package/dist/bridges/equations/be-22-topological-entanglement.js.map +1 -0
- package/dist/bridges/equations/be-23-syk-planckian.d.ts +89 -0
- package/dist/bridges/equations/be-23-syk-planckian.d.ts.map +1 -0
- package/dist/bridges/equations/be-23-syk-planckian.js +155 -0
- package/dist/bridges/equations/be-23-syk-planckian.js.map +1 -0
- package/dist/bridges/equations/be-24-foerster-fret.d.ts +81 -0
- package/dist/bridges/equations/be-24-foerster-fret.d.ts.map +1 -0
- package/dist/bridges/equations/be-24-foerster-fret.js +121 -0
- package/dist/bridges/equations/be-24-foerster-fret.js.map +1 -0
- package/dist/bridges/equations/be-25-iit-phi.d.ts +220 -0
- package/dist/bridges/equations/be-25-iit-phi.d.ts.map +1 -0
- package/dist/bridges/equations/be-25-iit-phi.js +259 -0
- package/dist/bridges/equations/be-25-iit-phi.js.map +1 -0
- package/dist/bridges/equations/be-25-orch-or.d.ts +78 -0
- package/dist/bridges/equations/be-25-orch-or.d.ts.map +1 -0
- package/dist/bridges/equations/be-25-orch-or.js +121 -0
- package/dist/bridges/equations/be-25-orch-or.js.map +1 -0
- package/dist/bridges/equations/be-26-dna-tunneling.d.ts +75 -0
- package/dist/bridges/equations/be-26-dna-tunneling.d.ts.map +1 -0
- package/dist/bridges/equations/be-26-dna-tunneling.js +138 -0
- package/dist/bridges/equations/be-26-dna-tunneling.js.map +1 -0
- package/dist/bridges/equations/be-27-effective-temperature.d.ts +81 -0
- package/dist/bridges/equations/be-27-effective-temperature.d.ts.map +1 -0
- package/dist/bridges/equations/be-27-effective-temperature.js +120 -0
- package/dist/bridges/equations/be-27-effective-temperature.js.map +1 -0
- package/dist/bridges/equations/be-28-onsager-entropy-production.d.ts +175 -0
- package/dist/bridges/equations/be-28-onsager-entropy-production.d.ts.map +1 -0
- package/dist/bridges/equations/be-28-onsager-entropy-production.js +203 -0
- package/dist/bridges/equations/be-28-onsager-entropy-production.js.map +1 -0
- package/dist/bridges/equations/be-29-jarzynski.d.ts +86 -0
- package/dist/bridges/equations/be-29-jarzynski.d.ts.map +1 -0
- package/dist/bridges/equations/be-29-jarzynski.js +132 -0
- package/dist/bridges/equations/be-29-jarzynski.js.map +1 -0
- package/dist/bridges/equations/be-30-flm-first-law.d.ts +93 -0
- package/dist/bridges/equations/be-30-flm-first-law.d.ts.map +1 -0
- package/dist/bridges/equations/be-30-flm-first-law.js +109 -0
- package/dist/bridges/equations/be-30-flm-first-law.js.map +1 -0
- package/dist/bridges/equations/be-31-causal-set-bd.d.ts +96 -0
- package/dist/bridges/equations/be-31-causal-set-bd.d.ts.map +1 -0
- package/dist/bridges/equations/be-31-causal-set-bd.js +133 -0
- package/dist/bridges/equations/be-31-causal-set-bd.js.map +1 -0
- package/dist/bridges/equations/be-32-quantum-reference-frame.d.ts +113 -0
- package/dist/bridges/equations/be-32-quantum-reference-frame.d.ts.map +1 -0
- package/dist/bridges/equations/be-32-quantum-reference-frame.js +155 -0
- package/dist/bridges/equations/be-32-quantum-reference-frame.js.map +1 -0
- package/dist/bridges/equations/be-33-hertz-millis.d.ts +77 -0
- package/dist/bridges/equations/be-33-hertz-millis.d.ts.map +1 -0
- package/dist/bridges/equations/be-33-hertz-millis.js +113 -0
- package/dist/bridges/equations/be-33-hertz-millis.js.map +1 -0
- package/dist/bridges/equations/be-34-kibble-zurek.d.ts +76 -0
- package/dist/bridges/equations/be-34-kibble-zurek.d.ts.map +1 -0
- package/dist/bridges/equations/be-34-kibble-zurek.js +139 -0
- package/dist/bridges/equations/be-34-kibble-zurek.js.map +1 -0
- package/dist/bridges/equations/be-35-conformal-bootstrap.d.ts +117 -0
- package/dist/bridges/equations/be-35-conformal-bootstrap.d.ts.map +1 -0
- package/dist/bridges/equations/be-35-conformal-bootstrap.js +167 -0
- package/dist/bridges/equations/be-35-conformal-bootstrap.js.map +1 -0
- package/dist/bridges/equations/be-36-gw-speed-bound.d.ts +77 -0
- package/dist/bridges/equations/be-36-gw-speed-bound.d.ts.map +1 -0
- package/dist/bridges/equations/be-36-gw-speed-bound.js +107 -0
- package/dist/bridges/equations/be-36-gw-speed-bound.js.map +1 -0
- package/dist/bridges/equations/be-37-shapiro-delay.d.ts +260 -0
- package/dist/bridges/equations/be-37-shapiro-delay.d.ts.map +1 -0
- package/dist/bridges/equations/be-37-shapiro-delay.js +429 -0
- package/dist/bridges/equations/be-37-shapiro-delay.js.map +1 -0
- package/dist/bridges/equations/be-38-mond.d.ts +86 -0
- package/dist/bridges/equations/be-38-mond.d.ts.map +1 -0
- package/dist/bridges/equations/be-38-mond.js +122 -0
- package/dist/bridges/equations/be-38-mond.js.map +1 -0
- package/dist/bridges/equations/be-39-asymptotic-safety.d.ts +106 -0
- package/dist/bridges/equations/be-39-asymptotic-safety.d.ts.map +1 -0
- package/dist/bridges/equations/be-39-asymptotic-safety.js +155 -0
- package/dist/bridges/equations/be-39-asymptotic-safety.js.map +1 -0
- package/dist/bridges/equations/be-40-composite-higgs.d.ts +81 -0
- package/dist/bridges/equations/be-40-composite-higgs.d.ts.map +1 -0
- package/dist/bridges/equations/be-40-composite-higgs.js +149 -0
- package/dist/bridges/equations/be-40-composite-higgs.js.map +1 -0
- package/dist/bridges/equations/be-41-swampland.d.ts +67 -0
- package/dist/bridges/equations/be-41-swampland.d.ts.map +1 -0
- package/dist/bridges/equations/be-41-swampland.js +109 -0
- package/dist/bridges/equations/be-41-swampland.js.map +1 -0
- package/dist/bridges/equations/be-42-hawking-temperature.d.ts +67 -0
- package/dist/bridges/equations/be-42-hawking-temperature.d.ts.map +1 -0
- package/dist/bridges/equations/be-42-hawking-temperature.js +109 -0
- package/dist/bridges/equations/be-42-hawking-temperature.js.map +1 -0
- package/dist/bridges/equations/be-43-er-epr.d.ts +73 -0
- package/dist/bridges/equations/be-43-er-epr.d.ts.map +1 -0
- package/dist/bridges/equations/be-43-er-epr.js +114 -0
- package/dist/bridges/equations/be-43-er-epr.js.map +1 -0
- package/dist/bridges/equations/be-44-soft-hair.d.ts +151 -0
- package/dist/bridges/equations/be-44-soft-hair.d.ts.map +1 -0
- package/dist/bridges/equations/be-44-soft-hair.js +185 -0
- package/dist/bridges/equations/be-44-soft-hair.js.map +1 -0
- package/dist/bridges/equations/be-45-tcc.d.ts +116 -0
- package/dist/bridges/equations/be-45-tcc.d.ts.map +1 -0
- package/dist/bridges/equations/be-45-tcc.js +157 -0
- package/dist/bridges/equations/be-45-tcc.js.map +1 -0
- package/dist/bridges/equations/be-46-multiverse-measure.d.ts +163 -0
- package/dist/bridges/equations/be-46-multiverse-measure.d.ts.map +1 -0
- package/dist/bridges/equations/be-46-multiverse-measure.js +198 -0
- package/dist/bridges/equations/be-46-multiverse-measure.js.map +1 -0
- package/dist/bridges/equations/be-47-bbn-dark-sector.d.ts +72 -0
- package/dist/bridges/equations/be-47-bbn-dark-sector.d.ts.map +1 -0
- package/dist/bridges/equations/be-47-bbn-dark-sector.js +121 -0
- package/dist/bridges/equations/be-47-bbn-dark-sector.js.map +1 -0
- package/dist/bridges/equations/be-48-grw-localization.d.ts +84 -0
- package/dist/bridges/equations/be-48-grw-localization.d.ts.map +1 -0
- package/dist/bridges/equations/be-48-grw-localization.js +107 -0
- package/dist/bridges/equations/be-48-grw-localization.js.map +1 -0
- package/dist/bridges/equations/be-49-quantum-darwinism.d.ts +97 -0
- package/dist/bridges/equations/be-49-quantum-darwinism.d.ts.map +1 -0
- package/dist/bridges/equations/be-49-quantum-darwinism.js +129 -0
- package/dist/bridges/equations/be-49-quantum-darwinism.js.map +1 -0
- package/dist/bridges/equations/be-50-wheeler-feynman.d.ts +120 -0
- package/dist/bridges/equations/be-50-wheeler-feynman.d.ts.map +1 -0
- package/dist/bridges/equations/be-50-wheeler-feynman.js +151 -0
- package/dist/bridges/equations/be-50-wheeler-feynman.js.map +1 -0
- package/dist/bridges/gravitational-lensing.d.ts +52 -0
- package/dist/bridges/gravitational-lensing.d.ts.map +1 -0
- package/dist/bridges/gravitational-lensing.js +48 -0
- package/dist/bridges/gravitational-lensing.js.map +1 -0
- package/dist/bridges/index.d.ts +104 -0
- package/dist/bridges/index.d.ts.map +1 -0
- package/dist/bridges/index.js +1663 -0
- package/dist/bridges/index.js.map +1 -0
- package/dist/bridges/perihelion-precession.d.ts +62 -0
- package/dist/bridges/perihelion-precession.d.ts.map +1 -0
- package/dist/bridges/perihelion-precession.js +68 -0
- package/dist/bridges/perihelion-precession.js.map +1 -0
- package/dist/core/tensor.d.ts +135 -0
- package/dist/core/tensor.d.ts.map +1 -0
- package/dist/core/tensor.js +376 -0
- package/dist/core/tensor.js.map +1 -0
- package/dist/core/types.d.ts +131 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +25 -0
- package/dist/core/types.js.map +1 -0
- package/dist/dimensional/algebra.d.ts +34 -0
- package/dist/dimensional/algebra.d.ts.map +1 -0
- package/dist/dimensional/algebra.js +90 -0
- package/dist/dimensional/algebra.js.map +1 -0
- package/dist/dimensional/bridge-check.d.ts +48 -0
- package/dist/dimensional/bridge-check.d.ts.map +1 -0
- package/dist/dimensional/bridge-check.js +137 -0
- package/dist/dimensional/bridge-check.js.map +1 -0
- package/dist/dimensional/connection-validators.d.ts +53 -0
- package/dist/dimensional/connection-validators.d.ts.map +1 -0
- package/dist/dimensional/connection-validators.js +84 -0
- package/dist/dimensional/connection-validators.js.map +1 -0
- package/dist/dimensional/connection.d.ts +40 -0
- package/dist/dimensional/connection.d.ts.map +1 -0
- package/dist/dimensional/connection.js +81 -0
- package/dist/dimensional/connection.js.map +1 -0
- package/dist/dimensional/constants.d.ts +30 -0
- package/dist/dimensional/constants.d.ts.map +1 -0
- package/dist/dimensional/constants.js +31 -0
- package/dist/dimensional/constants.js.map +1 -0
- package/dist/dimensional/errors.d.ts +161 -0
- package/dist/dimensional/errors.d.ts.map +1 -0
- package/dist/dimensional/errors.js +254 -0
- package/dist/dimensional/errors.js.map +1 -0
- package/dist/dimensional/fresh-label.d.ts +26 -0
- package/dist/dimensional/fresh-label.d.ts.map +1 -0
- package/dist/dimensional/fresh-label.js +31 -0
- package/dist/dimensional/fresh-label.js.map +1 -0
- package/dist/dimensional/metric-validators.d.ts +124 -0
- package/dist/dimensional/metric-validators.d.ts.map +1 -0
- package/dist/dimensional/metric-validators.js +141 -0
- package/dist/dimensional/metric-validators.js.map +1 -0
- package/dist/dimensional/metric.d.ts +67 -0
- package/dist/dimensional/metric.d.ts.map +1 -0
- package/dist/dimensional/metric.js +177 -0
- package/dist/dimensional/metric.js.map +1 -0
- package/dist/dimensional/tensor.d.ts +153 -0
- package/dist/dimensional/tensor.d.ts.map +1 -0
- package/dist/dimensional/tensor.js +138 -0
- package/dist/dimensional/tensor.js.map +1 -0
- package/dist/dimensional/types.d.ts +50 -0
- package/dist/dimensional/types.d.ts.map +1 -0
- package/dist/dimensional/types.js +66 -0
- package/dist/dimensional/types.js.map +1 -0
- package/dist/dimensional/validator.d.ts +84 -0
- package/dist/dimensional/validator.d.ts.map +1 -0
- package/dist/dimensional/validator.js +505 -0
- package/dist/dimensional/validator.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/numerical/be37-covariant-eikonal.d.ts +90 -0
- package/dist/numerical/be37-covariant-eikonal.d.ts.map +1 -0
- package/dist/numerical/be37-covariant-eikonal.js +79 -0
- package/dist/numerical/be37-covariant-eikonal.js.map +1 -0
- package/dist/numerical/connection-lowering-helpers.d.ts +107 -0
- package/dist/numerical/connection-lowering-helpers.d.ts.map +1 -0
- package/dist/numerical/connection-lowering-helpers.js +315 -0
- package/dist/numerical/connection-lowering-helpers.js.map +1 -0
- package/dist/numerical/engine-registry.d.ts +50 -0
- package/dist/numerical/engine-registry.d.ts.map +1 -0
- package/dist/numerical/engine-registry.js +82 -0
- package/dist/numerical/engine-registry.js.map +1 -0
- package/dist/numerical/errors.d.ts +28 -0
- package/dist/numerical/errors.d.ts.map +1 -0
- package/dist/numerical/errors.js +39 -0
- package/dist/numerical/errors.js.map +1 -0
- package/dist/numerical/float64-engine.d.ts +53 -0
- package/dist/numerical/float64-engine.d.ts.map +1 -0
- package/dist/numerical/float64-engine.js +638 -0
- package/dist/numerical/float64-engine.js.map +1 -0
- package/dist/numerical/geodesic-integrator.d.ts +62 -0
- package/dist/numerical/geodesic-integrator.d.ts.map +1 -0
- package/dist/numerical/geodesic-integrator.js +103 -0
- package/dist/numerical/geodesic-integrator.js.map +1 -0
- package/dist/numerical/grid-field.d.ts +24 -0
- package/dist/numerical/grid-field.d.ts.map +1 -0
- package/dist/numerical/grid-field.js +2 -0
- package/dist/numerical/grid-field.js.map +1 -0
- package/dist/numerical/index.d.ts +80 -0
- package/dist/numerical/index.d.ts.map +1 -0
- package/dist/numerical/index.js +75 -0
- package/dist/numerical/index.js.map +1 -0
- package/dist/numerical/lowering.d.ts +48 -0
- package/dist/numerical/lowering.d.ts.map +1 -0
- package/dist/numerical/lowering.js +443 -0
- package/dist/numerical/lowering.js.map +1 -0
- package/dist/numerical/mathts-engine.d.ts +55 -0
- package/dist/numerical/mathts-engine.d.ts.map +1 -0
- package/dist/numerical/mathts-engine.js +164 -0
- package/dist/numerical/mathts-engine.js.map +1 -0
- package/dist/numerical/metric-inverse.d.ts +31 -0
- package/dist/numerical/metric-inverse.d.ts.map +1 -0
- package/dist/numerical/metric-inverse.js +68 -0
- package/dist/numerical/metric-inverse.js.map +1 -0
- package/dist/numerical/null-ray-integrator.d.ts +13 -0
- package/dist/numerical/null-ray-integrator.d.ts.map +1 -0
- package/dist/numerical/null-ray-integrator.js +53 -0
- package/dist/numerical/null-ray-integrator.js.map +1 -0
- package/dist/numerical/pderiv.d.ts +43 -0
- package/dist/numerical/pderiv.d.ts.map +1 -0
- package/dist/numerical/pderiv.js +121 -0
- package/dist/numerical/pderiv.js.map +1 -0
- package/dist/numerical/tensor-engine.d.ts +114 -0
- package/dist/numerical/tensor-engine.d.ts.map +1 -0
- package/dist/numerical/tensor-engine.js +64 -0
- package/dist/numerical/tensor-engine.js.map +1 -0
- package/dist/numerical/types.d.ts +37 -0
- package/dist/numerical/types.d.ts.map +1 -0
- package/dist/numerical/types.js +8 -0
- package/dist/numerical/types.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine registry — selects the active TensorEngine. v0.4.0: when both
|
|
3
|
+
* @danielsimonjr/mathts-tensor AND @danielsimonjr/mathts-autograd are
|
|
4
|
+
* installed, getActiveEngine() returns MathTSEngine. Falls back to
|
|
5
|
+
* Float64ReferenceEngine (the zero-dep default) with a one-time
|
|
6
|
+
* console.warn (suppressible via UPT_QUIET_FALLBACK=1) when either dep
|
|
7
|
+
* is absent.
|
|
8
|
+
*
|
|
9
|
+
* HONEST FRAMING: both engines run the same naive O(n) algorithms in
|
|
10
|
+
* v0.4.0. This default flip is a dep-shape + code-path-signal change,
|
|
11
|
+
* NOT a performance win. MathTSEngine becomes the default because that
|
|
12
|
+
* is where the autograd capability (AD) lives.
|
|
13
|
+
*
|
|
14
|
+
* I4 fix (Promise-cache): the Promise itself is cached, not the resolved
|
|
15
|
+
* instance. Two concurrent first-time callers therefore observe the same
|
|
16
|
+
* in-flight Promise and never race to create separate engine instances.
|
|
17
|
+
*
|
|
18
|
+
* I5 fix (browser guard): `process` is undefined in browser bundlers.
|
|
19
|
+
* All access is guarded by `typeof process !== 'undefined'`.
|
|
20
|
+
*
|
|
21
|
+
* @module numerical/engine-registry
|
|
22
|
+
*/
|
|
23
|
+
import type { TensorEngine } from './tensor-engine.js';
|
|
24
|
+
/**
|
|
25
|
+
* The TensorEngine currently used by the `evaluateNumerical*` entry points
|
|
26
|
+
* when no per-call `EvaluateOptions.engine` is supplied.
|
|
27
|
+
*
|
|
28
|
+
* v0.4.0: returns MathTSEngine when both @danielsimonjr/mathts-tensor AND
|
|
29
|
+
* @danielsimonjr/mathts-autograd are installed; otherwise Float64ReferenceEngine.
|
|
30
|
+
*
|
|
31
|
+
* I4: returns a cached Promise — concurrent first-time callers share the
|
|
32
|
+
* same in-flight resolution, so at most one MathTSEngine is ever constructed.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare function getActiveEngine(): Promise<TensorEngine>;
|
|
37
|
+
/**
|
|
38
|
+
* Set the process-wide active TensorEngine (e.g. to `MathTSEngine`).
|
|
39
|
+
* Wraps the engine in a resolved Promise to match the async getActiveEngine
|
|
40
|
+
* contract and invalidate any prior in-flight detection.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export declare function setActiveEngine(engine: TensorEngine): void;
|
|
44
|
+
/**
|
|
45
|
+
* Reset the Promise-cache and detection state for testing purposes only.
|
|
46
|
+
* Not part of the public API surface; NOT exported from the root barrel.
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare function resetEngineForTesting(): void;
|
|
50
|
+
//# sourceMappingURL=engine-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-registry.d.ts","sourceRoot":"","sources":["../../src/numerical/engine-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA+CvD;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,CAU7D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAE1D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAG5C"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Float64ReferenceEngine } from './float64-engine.js';
|
|
2
|
+
// Module-level cache. Stores a Promise so that concurrent first-time calls
|
|
3
|
+
// to getActiveEngine() both await the same in-flight detection, never racing
|
|
4
|
+
// to construct two separate engine instances (I4 fix).
|
|
5
|
+
let _activeEngineP;
|
|
6
|
+
// Cache the detection result so we don't re-import on every getActiveEngine()
|
|
7
|
+
// call after the first. Reset by resetEngineForTesting() in tests.
|
|
8
|
+
let _resolvedDefault;
|
|
9
|
+
/**
|
|
10
|
+
* Attempt to import both optional peer deps. Returns 'mathts' when both are
|
|
11
|
+
* present; 'float64' otherwise. Emits a one-time console.warn on fallback
|
|
12
|
+
* (suppressible via UPT_QUIET_FALLBACK=1).
|
|
13
|
+
*/
|
|
14
|
+
async function detectDefault() {
|
|
15
|
+
if (_resolvedDefault !== undefined)
|
|
16
|
+
return _resolvedDefault;
|
|
17
|
+
try {
|
|
18
|
+
await import('@danielsimonjr/mathts-tensor');
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
20
|
+
// @ts-ignore — @danielsimonjr/mathts-autograd is an optional peer dep with
|
|
21
|
+
// no bundled type declarations; the try-catch handles the absent case.
|
|
22
|
+
await import('@danielsimonjr/mathts-autograd');
|
|
23
|
+
_resolvedDefault = 'mathts';
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// I5 fix: `process` is undefined in browser bundlers; guard before reading.
|
|
27
|
+
const quiet = typeof process !== 'undefined' && process.env?.UPT_QUIET_FALLBACK === '1';
|
|
28
|
+
if (!quiet) {
|
|
29
|
+
console.warn('[universal-physics-tensor v0.4.0] @danielsimonjr/mathts-tensor and/or '
|
|
30
|
+
+ '@danielsimonjr/mathts-autograd not installed. '
|
|
31
|
+
+ 'Falling back to Float64ReferenceEngine. '
|
|
32
|
+
+ 'Install both peers for MathTS-default + autograd (AD) support. '
|
|
33
|
+
+ '(Suppress this warning with UPT_QUIET_FALLBACK=1.)');
|
|
34
|
+
}
|
|
35
|
+
_resolvedDefault = 'float64';
|
|
36
|
+
}
|
|
37
|
+
return _resolvedDefault;
|
|
38
|
+
}
|
|
39
|
+
// @public: getActiveEngine/setActiveEngine are part of the consumer-facing
|
|
40
|
+
// engine-switching contract (re-exported from the root barrel).
|
|
41
|
+
/**
|
|
42
|
+
* The TensorEngine currently used by the `evaluateNumerical*` entry points
|
|
43
|
+
* when no per-call `EvaluateOptions.engine` is supplied.
|
|
44
|
+
*
|
|
45
|
+
* v0.4.0: returns MathTSEngine when both @danielsimonjr/mathts-tensor AND
|
|
46
|
+
* @danielsimonjr/mathts-autograd are installed; otherwise Float64ReferenceEngine.
|
|
47
|
+
*
|
|
48
|
+
* I4: returns a cached Promise — concurrent first-time callers share the
|
|
49
|
+
* same in-flight resolution, so at most one MathTSEngine is ever constructed.
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
export async function getActiveEngine() {
|
|
54
|
+
_activeEngineP ??= (async () => {
|
|
55
|
+
const choice = await detectDefault();
|
|
56
|
+
if (choice === 'mathts') {
|
|
57
|
+
const { MathTSEngine } = await import('./mathts-engine.js');
|
|
58
|
+
return new MathTSEngine();
|
|
59
|
+
}
|
|
60
|
+
return new Float64ReferenceEngine();
|
|
61
|
+
})();
|
|
62
|
+
return _activeEngineP;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Set the process-wide active TensorEngine (e.g. to `MathTSEngine`).
|
|
66
|
+
* Wraps the engine in a resolved Promise to match the async getActiveEngine
|
|
67
|
+
* contract and invalidate any prior in-flight detection.
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export function setActiveEngine(engine) {
|
|
71
|
+
_activeEngineP = Promise.resolve(engine);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Reset the Promise-cache and detection state for testing purposes only.
|
|
75
|
+
* Not part of the public API surface; NOT exported from the root barrel.
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
78
|
+
export function resetEngineForTesting() {
|
|
79
|
+
_activeEngineP = undefined;
|
|
80
|
+
_resolvedDefault = undefined;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=engine-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-registry.js","sourceRoot":"","sources":["../../src/numerical/engine-registry.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,2EAA2E;AAC3E,6EAA6E;AAC7E,uDAAuD;AACvD,IAAI,cAAiD,CAAC;AAEtD,8EAA8E;AAC9E,mEAAmE;AACnE,IAAI,gBAAkD,CAAC;AAEvD;;;;GAIG;AACH,KAAK,UAAU,aAAa;IAC1B,IAAI,gBAAgB,KAAK,SAAS;QAAE,OAAO,gBAAgB,CAAC;IAC5D,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,8BAA8B,CAAC,CAAC;QAC7C,6DAA6D;QAC7D,2EAA2E;QAC3E,uEAAuE;QACvE,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAC;QAC/C,gBAAgB,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,4EAA4E;QAC5E,MAAM,KAAK,GACT,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,kBAAkB,KAAK,GAAG,CAAC;QAC5E,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CACV,wEAAwE;kBACtE,gDAAgD;kBAChD,0CAA0C;kBAC1C,iEAAiE;kBACjE,oDAAoD,CACvD,CAAC;QACJ,CAAC;QACD,gBAAgB,GAAG,SAAS,CAAC;IAC/B,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,2EAA2E;AAC3E,gEAAgE;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,cAAc,KAAK,CAAC,KAAK,IAAI,EAAE;QAC7B,MAAM,MAAM,GAAG,MAAM,aAAa,EAAE,CAAC;QACrC,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;YACxB,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC,CAAC;YAC5D,OAAO,IAAI,YAAY,EAAE,CAAC;QAC5B,CAAC;QACD,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACtC,CAAC,CAAC,EAAE,CAAC;IACL,OAAO,cAAc,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAoB;IAClD,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IACnC,cAAc,GAAG,SAAS,CAAC;IAC3B,gBAAgB,GAAG,SAAS,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numerical-backend error type. Subclass of UPTError so downstream
|
|
3
|
+
* consumers discriminate UPT-source errors uniformly with `instanceof`.
|
|
4
|
+
*
|
|
5
|
+
* @module numerical/errors
|
|
6
|
+
*/
|
|
7
|
+
import { UPTError } from '../dimensional/errors.js';
|
|
8
|
+
/**
|
|
9
|
+
* Error type thrown by the numerical-contraction backend. Subclass of
|
|
10
|
+
* `UPTError` so consumers can discriminate UPT-source errors with `instanceof`.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare class NumericalBackendError extends UPTError {
|
|
14
|
+
constructor(message: string);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Thrown when a TensorEngine method required for an operation is not
|
|
18
|
+
* implemented by the active engine (e.g. forwardGrad/reverseGrad on
|
|
19
|
+
* Float64ReferenceEngine). Call `hasAutogradSupport(engine)` before
|
|
20
|
+
* invoking AD methods to avoid this error.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare class EngineCapabilityError extends NumericalBackendError {
|
|
24
|
+
readonly engineName: string;
|
|
25
|
+
readonly missingMethod: string;
|
|
26
|
+
constructor(engineName: string, missingMethod: string);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/numerical/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,QAAQ;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAED;;;;;;GAMG;AACH,qBAAa,qBAAsB,SAAQ,qBAAqB;aAE5C,UAAU,EAAE,MAAM;aAClB,aAAa,EAAE,MAAM;gBADrB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM;CASxC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numerical-backend error type. Subclass of UPTError so downstream
|
|
3
|
+
* consumers discriminate UPT-source errors uniformly with `instanceof`.
|
|
4
|
+
*
|
|
5
|
+
* @module numerical/errors
|
|
6
|
+
*/
|
|
7
|
+
import { UPTError } from '../dimensional/errors.js';
|
|
8
|
+
/**
|
|
9
|
+
* Error type thrown by the numerical-contraction backend. Subclass of
|
|
10
|
+
* `UPTError` so consumers can discriminate UPT-source errors with `instanceof`.
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export class NumericalBackendError extends UPTError {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'NumericalBackendError';
|
|
17
|
+
Object.setPrototypeOf(this, NumericalBackendError.prototype);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Thrown when a TensorEngine method required for an operation is not
|
|
22
|
+
* implemented by the active engine (e.g. forwardGrad/reverseGrad on
|
|
23
|
+
* Float64ReferenceEngine). Call `hasAutogradSupport(engine)` before
|
|
24
|
+
* invoking AD methods to avoid this error.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export class EngineCapabilityError extends NumericalBackendError {
|
|
28
|
+
engineName;
|
|
29
|
+
missingMethod;
|
|
30
|
+
constructor(engineName, missingMethod) {
|
|
31
|
+
super(`Engine "${engineName}" does not implement "${missingMethod}". ` +
|
|
32
|
+
`Call \`hasAutogradSupport(engine)\` to detect support before invoking.`);
|
|
33
|
+
this.engineName = engineName;
|
|
34
|
+
this.missingMethod = missingMethod;
|
|
35
|
+
this.name = 'EngineCapabilityError';
|
|
36
|
+
Object.setPrototypeOf(this, EngineCapabilityError.prototype);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/numerical/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,QAAQ;IACjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,qBAAsB,SAAQ,qBAAqB;IAE5C;IACA;IAFlB,YACkB,UAAkB,EAClB,aAAqB;QAErC,KAAK,CACH,WAAW,UAAU,yBAAyB,aAAa,KAAK;YAChE,wEAAwE,CACzE,CAAC;QANc,eAAU,GAAV,UAAU,CAAQ;QAClB,kBAAa,GAAb,aAAa,CAAQ;QAMrC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,qBAAqB,CAAC,SAAS,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Float64ReferenceEngine — the pure-TypeScript, Float64Array-backed
|
|
3
|
+
* TensorEngine implementation. v0.3.5's default engine. Zero runtime
|
|
4
|
+
* dependencies. Naive O(n) algorithms: a correctness baseline, not a
|
|
5
|
+
* performance target (v0.3.5-Design.md §13). MathTSEngine (Task 11) is
|
|
6
|
+
* the performance answer.
|
|
7
|
+
*
|
|
8
|
+
* @module numerical/float64-engine
|
|
9
|
+
*/
|
|
10
|
+
import type { EngineTensor, TensorEngine, EinsumSpec, ForwardGradResult, ReverseGradResult } from './tensor-engine.js';
|
|
11
|
+
import type { NestedArray } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* The pure-TypeScript, zero-dependency `TensorEngine` — v0.3.5's default
|
|
14
|
+
* engine and the correctness baseline for the conformance suite.
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export declare class Float64ReferenceEngine implements TensorEngine {
|
|
18
|
+
readonly name = "Float64ReferenceEngine";
|
|
19
|
+
fromNested(data: NestedArray, shape: ReadonlyArray<number>): EngineTensor;
|
|
20
|
+
toNested(t: EngineTensor): NestedArray;
|
|
21
|
+
add(a: EngineTensor, b: EngineTensor): EngineTensor;
|
|
22
|
+
sub(a: EngineTensor, b: EngineTensor): EngineTensor;
|
|
23
|
+
mul(a: EngineTensor, b: EngineTensor): EngineTensor;
|
|
24
|
+
scale(t: EngineTensor, k: number): EngineTensor;
|
|
25
|
+
identity(n: number): EngineTensor;
|
|
26
|
+
normInf(t: EngineTensor): number;
|
|
27
|
+
reshape(t: EngineTensor, shape: ReadonlyArray<number>): EngineTensor;
|
|
28
|
+
transpose(t: EngineTensor, perm?: ReadonlyArray<number>): EngineTensor;
|
|
29
|
+
matMul(a: EngineTensor, b: EngineTensor): EngineTensor;
|
|
30
|
+
einsum(spec: EinsumSpec, ...operands: EngineTensor[]): EngineTensor;
|
|
31
|
+
/**
|
|
32
|
+
* Compute the value and full Jacobian of `fn` at point `x` using
|
|
33
|
+
* forward-mode automatic differentiation (dual numbers).
|
|
34
|
+
*
|
|
35
|
+
* Returns `{ value, jacobian }` where `jacobian.shape = [...value.shape, ...x.shape]`
|
|
36
|
+
* (row-major). `jacobian.data[kY * xSize + kX] = ∂y[kY] / ∂x[kX]`.
|
|
37
|
+
*
|
|
38
|
+
* Guard: if `fn` returns a non-EngineDualTensor, throws a clear error
|
|
39
|
+
* ("AD-traceable" guard, reconciliation fix S6/I2).
|
|
40
|
+
*/
|
|
41
|
+
forwardGrad(fn: (x: EngineTensor) => EngineTensor, x: EngineTensor): Promise<ForwardGradResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Compute the value and gradient (VJP) of `fn` at point `x` using
|
|
44
|
+
* reverse-mode automatic differentiation (tape).
|
|
45
|
+
*
|
|
46
|
+
* `cotangent` defaults to ones-like(value). For non-scalar outputs,
|
|
47
|
+
* cotangent.shape must match value.shape.
|
|
48
|
+
*
|
|
49
|
+
* Guard: if `fn` returns a non-EngineTapedTensor, throws a clear error.
|
|
50
|
+
*/
|
|
51
|
+
reverseGrad(fn: (x: EngineTensor) => EngineTensor, x: EngineTensor, cotangent?: EngineTensor): Promise<ReverseGradResult>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=float64-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"float64-engine.d.ts","sourceRoot":"","sources":["../../src/numerical/float64-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,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;AAyW9C;;;;GAIG;AACH,qBAAa,sBAAuB,YAAW,YAAY;IACzD,QAAQ,CAAC,IAAI,4BAA4B;IAEzC,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,YAAY;IAIzE,QAAQ,CAAC,CAAC,EAAE,YAAY,GAAG,WAAW;IAItC,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,YAAY;IAWnD,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,YAAY;IAWnD,GAAG,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,YAAY;IAWnD,KAAK,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY;IAe/C,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY;IAMjC,OAAO,CAAC,CAAC,EAAE,YAAY,GAAG,MAAM;IAUhC,OAAO,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,YAAY;IAWpE,SAAS,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,YAAY;IAoBtE,MAAM,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,YAAY;IAwBtD,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,QAAQ,EAAE,YAAY,EAAE,GAAG,YAAY;IAsFnE;;;;;;;;;OASG;IACG,WAAW,CACf,EAAE,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,YAAY,EACrC,CAAC,EAAE,YAAY,GACd,OAAO,CAAC,iBAAiB,CAAC;IAgD7B;;;;;;;;OAQG;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;CA2C9B"}
|