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
-- >>> 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