X-Git-Url: http://gitweb.michael.orlitzky.com/?p=numerical-analysis.git;a=blobdiff_plain;f=src%2FLinear%2FMatrix.hs;h=82665578cf037def7c04ef223a8b6e350ad9232f;hp=2422eefcb7e269de1e5104ddb1c559b4c5c73e34;hb=ca021dad591f47dbe1581c19c4ae4bf1fee821b9;hpb=7638f1a379035c045185e25cacf0ea2d9d257265 diff --git a/src/Linear/Matrix.hs b/src/Linear/Matrix.hs index 2422eef..8266557 100644 --- a/src/Linear/Matrix.hs +++ b/src/Linear/Matrix.hs @@ -579,11 +579,12 @@ instance (Ring.C a, Arity m, Arity n) => Module.C a (Mat m n a) where x *> (Mat rows) = Mat $ V.map (V.map (NP.* x)) rows -instance (Algebraic.C a, +instance (Absolute.C a, + Algebraic.C a, ToRational.C a, Arity m) - => Normed (Mat (S m) N1 a) where - -- | Generic p-norms for vectors in R^n that are represented as nx1 + => Normed (Col (S m) a) where + -- | Generic p-norms for vectors in R^n that are represented as n-by-1 -- matrices. -- -- Examples: @@ -594,8 +595,12 @@ instance (Algebraic.C a, -- >>> norm_p 2 v1 -- 5.0 -- + -- >>> let v1 = vec2d (-1,1) :: Col2 Double + -- >>> norm_p 1 v1 :: Double + -- 2.0 + -- norm_p p (Mat rows) = - (root p') $ sum [fromRational' (toRational x)^p' | x <- xs] + (root p') $ sum [fromRational' (toRational $ abs x)^p' | x <- xs] where p' = toInteger p xs = concat $ V.toList $ V.map V.toList rows @@ -851,7 +856,7 @@ trace matrix = -- >>> zip2 m1 m2 -- (((1,1),(2,1)),((3,1),(4,1))) -- -zip2 :: (Arity m, Arity n) => Mat m n a -> Mat m n a -> Mat m n (a,a) +zip2 :: (Arity m, Arity n) => Mat m n a -> Mat m n b -> Mat m n (a,b) zip2 m1 m2 = construct lambda where