X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FNormed.hs;h=3752edc04b9fef7fa04f3ec5fd9a074d5789a0bb;hb=bb7f6082639f8589a851487c02ab396f7f91b927;hp=8554bd97f2eba0bd66a4b458a05cdb334f2e4f87;hpb=29f7502f34bdd54dff446a3a886f0e24b7e44493;p=numerical-analysis.git diff --git a/src/Normed.hs b/src/Normed.hs index 8554bd9..3752edc 100644 --- a/src/Normed.hs +++ b/src/Normed.hs @@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE RebindableSyntax #-} + -- | The 'Normed' class represents elements of a normed vector -- space. We define instances for all common numeric types. module Normed @@ -8,27 +9,23 @@ where import BigFloat import NumericPrelude hiding (abs) -import Algebra.Absolute -import Algebra.Field -import Algebra.Ring -import Algebra.ToInteger +import Algebra.Absolute (abs) +import qualified Algebra.Absolute as Absolute +import qualified Algebra.Algebraic as Algebraic +import qualified Algebra.RealField as RealField +import qualified Algebra.RealRing as RealRing +import qualified Algebra.ToInteger as ToInteger -- Since the norm is defined on a vector space, we should be able to -- add and subtract anything on which a norm is defined. Of course -- 'Num' is a bad choice here, but we really prefer to use the normal -- addition and subtraction operators. -class (Algebra.Ring.C a, Algebra.Absolute.C a) => Normed a where - norm_p :: (Algebra.ToInteger.C c, - Algebra.Field.C b, - Algebra.Absolute.C b) - => c -> a -> b - - norm_infty :: (Algebra.Field.C b, - Algebra.Absolute.C b) - => a -> b +class Normed a where + norm_p :: (ToInteger.C c, Algebraic.C b, Absolute.C b) => c -> a -> b + norm_infty :: (RealField.C b) => a -> b -- | The "usual" norm. Defaults to the Euclidean norm. - norm :: (Algebra.Field.C b, Algebra.Absolute.C b) => a -> b + norm :: (Algebraic.C b, Absolute.C b) => a -> b norm = norm_p (2 :: Integer) -- Define instances for common numeric types.