X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FLinear%2FMatrix.hs;h=69a74b50eeacf7ea944c790d3858dd0cba12c266;hb=d8dc884aa9b16c7bbd88c4c107ddd684a339a191;hp=66b22f9f9d964e843e596678c0f7ebe34e8e9a22;hpb=af25e6f32f6787a747be63093adc10915ad60068;p=numerical-analysis.git diff --git a/src/Linear/Matrix.hs b/src/Linear/Matrix.hs index 66b22f9..69a74b5 100644 --- a/src/Linear/Matrix.hs +++ b/src/Linear/Matrix.hs @@ -35,7 +35,6 @@ import Data.Vector.Fixed ( ) import qualified Data.Vector.Fixed as V ( and, - foldl, fromList, head, length, @@ -45,7 +44,6 @@ import qualified Data.Vector.Fixed as V ( toList, zipWith ) -import Data.Vector.Fixed.Boxed (Vec) import Data.Vector.Fixed.Cont (Arity, arity) import Linear.Vector import Normed @@ -430,8 +428,8 @@ instance (Algebraic.C a, ToRational.C a, Arity m) => Normed (Mat (S m) N1 a) where - -- | Generic p-norms. The usual norm in R^n is (norm_p 2). We treat - -- all matrices as big vectors. + -- | Generic p-norms for vectors in R^n that are represented as nx1 + -- matrices. -- -- Examples: -- @@ -475,15 +473,10 @@ instance (Algebraic.C a, -- frobenius_norm :: (Algebraic.C a, Ring.C a) => Mat m n a -> a frobenius_norm (Mat rows) = - sqrt $ vsum $ V.map row_sum rows + sqrt $ element_sum $ V.map row_sum rows where - -- | The \"sum\" function defined in fixed-vector requires a 'Num' - -- constraint whereas we want to use the classes from - -- numeric-prelude. - vsum = V.foldl (+) (fromInteger 0) - -- | Square and add up the entries of a row. - row_sum = vsum . V.map (^2) + row_sum = element_sum . V.map (^2) -- Vector helpers. We want it to be easy to create low-dimension