From 1e50b14bbdb48fbb63c487c66f5594fa20d58350 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 18 Feb 2014 19:51:18 -0500 Subject: [PATCH] Fix the column matrix 1-norm (it was missing the absolute value). --- src/Linear/Matrix.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Linear/Matrix.hs b/src/Linear/Matrix.hs index 2422eef..90a97b2 100644 --- a/src/Linear/Matrix.hs +++ b/src/Linear/Matrix.hs @@ -579,7 +579,8 @@ 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 @@ -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 -- 2.44.2