From: Francis Russell Date: Tue, 20 Nov 2012 16:27:02 +0000 (+0000) Subject: Alter Bandwidth's Num semantics. X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=4e65bb6fc9147739fac766942366a456f30b890c;p=francis%2Fofc.git Alter Bandwidth's Num semantics. --- diff --git a/OFC/SecondLevel.hs b/OFC/SecondLevel.hs index cde2b8f..164f2e8 100644 --- a/OFC/SecondLevel.hs +++ b/OFC/SecondLevel.hs @@ -391,9 +391,11 @@ instance Ord Bandwidth where instance Num Bandwidth where (+) Infinite _ = Infinite (+) _ Infinite = Infinite - (+) (GMaxMultiple a) (GMaxMultiple b) = GMaxMultiple $ a + b - (-) _ _ = error "Unimplemented: Bandwidth subtraction" - (*) _ _ = error "Unimplemented: Bandwidth multiplication" + (+) (GMaxMultiple a) (GMaxMultiple b) = GMaxMultiple $ max a b + (-) = (+) + (*) Infinite _ = Infinite + (*) _ Infinite = Infinite + (*) (GMaxMultiple a) (GMaxMultiple b) = GMaxMultiple $ a + b abs _ = error "Unimplemnted: Bandwidth abs" signum _ = error "Unimplemnted: Bandwidth signum" fromInteger _ = error "Unimplemented: Bandwidth fromInteger" @@ -412,12 +414,12 @@ theoreticalFrequency _ (AnalyticPosition _) = Infinite theoreticalFrequency _ (AnalyticMomentum _) = Infinite theoreticalFrequency ofl2 (AnalyticToPsinc e _) = theoreticalFrequency ofl2 e theoreticalFrequency ofl2 (Sum e _) = theoreticalFrequency ofl2 e -theoreticalFrequency ofl2 (Add e1 e2) = max (theoreticalFrequency ofl2 e1) (theoreticalFrequency ofl2 e2) -theoreticalFrequency ofl2 (Sub e1 e2) = max (theoreticalFrequency ofl2 e1) (theoreticalFrequency ofl2 e2) +theoreticalFrequency ofl2 (Add e1 e2) = (theoreticalFrequency ofl2 e1) + (theoreticalFrequency ofl2 e2) +theoreticalFrequency ofl2 (Sub e1 e2) = (theoreticalFrequency ofl2 e1) - (theoreticalFrequency ofl2 e2) theoreticalFrequency ofl2 (Neg e) = theoreticalFrequency ofl2 e theoreticalFrequency ofl2 (MulScalar e _) = theoreticalFrequency ofl2 e theoreticalFrequency ofl2 (DivScalar e _) = theoreticalFrequency ofl2 e -theoreticalFrequency ofl2 (PsincProduct a b) = (theoreticalFrequency ofl2 a) + (theoreticalFrequency ofl2 b) +theoreticalFrequency ofl2 (PsincProduct a b) = (theoreticalFrequency ofl2 a) * (theoreticalFrequency ofl2 b) theoreticalFrequency ofl2 (PsincReciprocalProduct a b) = min (theoreticalFrequency ofl2 a) (theoreticalFrequency ofl2 b) theoreticalFrequency _ (ConstInteger _) = GMaxMultiple 0 theoreticalFrequency _ (ConstReal _) = GMaxMultiple 0