X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FTwoTuple.hs;h=3950fee9afeabd5bfb8d884ca6543c4689873c24;hb=1832912058bfe274e1f049dae80ea05daa94a1a1;hp=1b5e93e151f1f7d8b5f3774e454b4a4589c20b3b;hpb=c5da1efa77844ae6159dfc781ed886fdffbbf4d1;p=numerical-analysis.git diff --git a/src/TwoTuple.hs b/src/TwoTuple.hs index 1b5e93e..3950fee 100644 --- a/src/TwoTuple.hs +++ b/src/TwoTuple.hs @@ -21,7 +21,14 @@ instance Functor TwoTuple where instance (RealFloat a) => Vector (TwoTuple a) where -- The standard Euclidean 2-norm. We need RealFloat for the square -- root. - norm (TwoTuple x1 y1) = fromRational $ toRational (sqrt(x1^2 + y1^2)) + norm_2 (TwoTuple x y) = fromRational $ toRational (sqrt(x^2 + y^2)) + + -- The infinity norm, i.e. the maximum entry. + norm_infty (TwoTuple x y) = + fromRational $ max absx absy + where + absx = abs (toRational x) + absy = abs (toRational y) -- | It's not correct to use Num here, but I really don't want to have -- to define my own addition and subtraction.