diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2026-01-26 23:37:55 +0100 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2026-01-26 23:37:55 +0100 |
| commit | b4f988cb1490ed31ab225323b33448667b8578c0 (patch) | |
| tree | d048e70e33f2e2787aae68a9b671b78094c05c43 /src/CHAD/AST/Env.hs | |
| parent | a9e6c72eff3bee8d45e0d906e8cd027066e04793 (diff) | |
Multihot cotangents WIP (doesn't work)multihot-cotangents
The idea is sound but for a smaller source language. Notes also in
Obsidian, but the theory so far is that dropping support for nested
arrays makes this possible, although making the result type-safe (i.e.
not have partial functions in a bunch of places) would require making
the lack of nested array support explicit in the embedded type system,
i.e. have Accelerate-like stratification.
The point is that multihots can be added heterogeneously using
plusSparseS but not homogeneously with EPlus or plusSparse, because the
indices might differ between the summands. Thus as long as we never need
to homogeneously sum multihot cotangents, we're golden.
Now the crucial observation is that we only need plus to be homogeneous
on array elements. So if array elements cannot themselves be arrays,
i.e. we drop support for nested arrays, no homogeneous plus of multihot
array cotangents is needed, and we can have static multihots.
Diffstat (limited to 'src/CHAD/AST/Env.hs')
| -rw-r--r-- | src/CHAD/AST/Env.hs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/CHAD/AST/Env.hs b/src/CHAD/AST/Env.hs index 8e6b745..40b6ca2 100644 --- a/src/CHAD/AST/Env.hs +++ b/src/CHAD/AST/Env.hs @@ -53,9 +53,9 @@ subenvOnehot (SCons _ env) IZ sp = SEYes sp (subenvNone env) subenvOnehot (SCons _ env) (IS i) sp = SENo (subenvOnehot env i sp) subenvOnehot SNil i _ = case i of {} -subenvCompose :: IsSubType s => Subenv' s env1 env2 -> Subenv' s env2 env3 -> Subenv' s env1 env3 +subenvCompose :: IsSubType s => Subenv' (:~:) env1 env2 -> Subenv' s env2 env3 -> Subenv' s env1 env3 subenvCompose SETop SETop = SETop -subenvCompose (SEYes s1 sub1) (SEYes s2 sub2) = SEYes (subtTrans s1 s2) (subenvCompose sub1 sub2) +subenvCompose (SEYes Refl sub1) (SEYes s2 sub2) = SEYes s2 (subenvCompose sub1 sub2) subenvCompose (SEYes _ sub1) (SENo sub2) = SENo (subenvCompose sub1 sub2) subenvCompose (SENo sub1) sub2 = SENo (subenvCompose sub1 sub2) |
