]> git.unchartedbackwaters.co.uk Git - francis/ofc.git/commitdiff
Generate band-limiting variants of second-level expressions.
authorFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 26 Nov 2012 14:15:37 +0000 (14:15 +0000)
committerFrancis Russell <francis@unchartedbackwaters.co.uk>
Mon, 26 Nov 2012 14:15:37 +0000 (14:15 +0000)
OFC/SecondLevel.hs

index 0fc69e5073d8570e33b4ca32dc2763d83cfe1ff4..250c15b45af44f530bcd455212822d55f3ab99f5 100644 (file)
@@ -185,12 +185,15 @@ instance Resamplable (Expression PsincReciprocalE) where
   resampled _ e = [e]
 
 instance Resamplable (Expression PsincE) where
-  resampled ofl2 e = case getImplementationType ofl2 e of
-    Right (PositionT (Psinc i)) -> e : upsampled ++ downsampled where
-      upsampled = take (fromInteger $ maxPsincDensity - i) (tail $ iterate Upsample e)
-      downsampled = take (fromInteger $ i - minPsincDensity) (tail $ iterate Downsample e)
-    Right _ -> error $ "Expected expression " ++ prettyPrint e ++ " to be in a non-analytic basis."
-    Left _ -> error $ "Cannot resample expression with invalid implementation type: " ++ prettyPrint e
+  resampled ofl2 e = e : upsampled e ++ downsampled e ++ bandlimited e where
+      upsampled x = take (fromInteger $ maxPsincDensity - density x) (tail $ iterate Upsample x)
+      downsampled x = take (fromInteger $ density x - minPsincDensity) (tail $ iterate Downsample x)
+      bandlimited x = concatMap upsampled $ downsampled x
+      density x = case getImplementationType ofl2 x of
+        Right (PositionT (Psinc i)) -> i
+        Right _ -> error $ "Expected xession " ++ prettyPrint x ++ " to be in a non-analytic basis."
+        Left _ -> error $ "Cannot resample xession with invalid implementation type: " ++ prettyPrint x
+
 
 getImplementationType :: OFL2 -> Expression e -> Either String ValueType
 getImplementationType ofl2 expr = case expr of