From d5c50453a7565c30c76826647eb26e8eb96ce7e5 Mon Sep 17 00:00:00 2001 From: Francis Russell Date: Mon, 26 Nov 2012 14:15:37 +0000 Subject: [PATCH] Generate band-limiting variants of second-level expressions. --- OFC/SecondLevel.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/OFC/SecondLevel.hs b/OFC/SecondLevel.hs index 0fc69e5..250c15b 100644 --- a/OFC/SecondLevel.hs +++ b/OFC/SecondLevel.hs @@ -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 -- 2.47.3