summaryrefslogtreecommitdiff
path: root/src/CHAD/Types
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2025-04-29 20:37:06 +0200
committerTom Smeding <tom@tomsmeding.com>2025-04-29 20:38:05 +0200
commitd0eb9a1edfb4233d557d954f46685f25382234d8 (patch)
tree04eb5a746258fcaa2a3b98228c6eadb2b0178ba3 /src/CHAD/Types
parent4ad7eaba73d5fda8ff5028d1e53966f728d704d3 (diff)
Reorder TLEither to after TEither
Diffstat (limited to 'src/CHAD/Types')
-rw-r--r--src/CHAD/Types/ToTan.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/CHAD/Types/ToTan.hs b/src/CHAD/Types/ToTan.hs
index 87c01cb..8476712 100644
--- a/src/CHAD/Types/ToTan.hs
+++ b/src/CHAD/Types/ToTan.hs
@@ -28,6 +28,11 @@ toTan typ primal der = case typ of
(Left p, Left d') -> Left (toTan t1 p d')
(Right p, Right d') -> Right (toTan t2 p d')
_ -> error "Primal and cotangent disagree on Either alternative"
+ STLEither t1 t2 -> case (primal, der) of
+ (_, Nothing) -> Nothing
+ (Just (Left p), Just (Left d)) -> Just (Left (toTan t1 p d))
+ (Just (Right p), Just (Right d)) -> Just (Right (toTan t2 p d))
+ _ -> error "Primal and cotangent disagree on LEither alternative"
STMaybe t -> liftA2 (toTan t) primal der
STArr _ t -> case der of
Nothing -> arrayMap (zeroTan t) primal
@@ -40,8 +45,3 @@ toTan typ primal der = case typ of
STScal sty -> case sty of
STI32 -> der ; STI64 -> der ; STF32 -> der ; STF64 -> der ; STBool -> der
STAccum{} -> error "Accumulators not allowed in input program"
- STLEither t1 t2 -> case (primal, der) of
- (_, Nothing) -> Nothing
- (Just (Left p), Just (Left d)) -> Just (Left (toTan t1 p d))
- (Just (Right p), Just (Right d)) -> Just (Right (toTan t2 p d))
- _ -> error "Primal and cotangent disagree on LEither alternative"