summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Numeric/Container.hs24
-rw-r--r--lib/Numeric/LinearAlgebra/Algorithms.hs12
-rw-r--r--lib/Numeric/LinearAlgebra/Tests.hs2
3 files changed, 19 insertions, 19 deletions
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs
index fc4fb0d..a3a039a 100644
--- a/lib/Numeric/Container.hs
+++ b/lib/Numeric/Container.hs
@@ -216,13 +216,13 @@ class Num e => Vectors a e where
216 -- | dot (inner) product 216 -- | dot (inner) product
217 dot :: a e -> a e -> e 217 dot :: a e -> a e -> e
218 -- | sum of absolute value of elements (differs in complex case from @norm1@ 218 -- | sum of absolute value of elements (differs in complex case from @norm1@
219 absSum :: a e -> e 219 absSum :: a e -> RealOf e
220 -- | sum of absolute value of elements 220 -- | sum of absolute value of elements
221 norm1 :: a e -> e 221 norm1 :: a e -> RealOf e
222 -- | euclidean norm 222 -- | euclidean norm
223 norm2 :: a e -> e 223 norm2 :: a e -> RealOf e
224 -- | element of maximum magnitude 224 -- | element of maximum magnitude
225 normInf :: a e -> e 225 normInf :: a e -> RealOf e
226 226
227instance Vectors Vector Float where 227instance Vectors Vector Float where
228 norm2 = toScalarF Norm2 228 norm2 = toScalarF Norm2
@@ -239,18 +239,18 @@ instance Vectors Vector Double where
239 normInf = maxElement . vectorMapR Abs 239 normInf = maxElement . vectorMapR Abs
240 240
241instance Vectors Vector (Complex Float) where 241instance Vectors Vector (Complex Float) where
242 norm2 = (:+ 0) . toScalarQ Norm2 242 norm2 = toScalarQ Norm2
243 absSum = (:+ 0) . toScalarQ AbsSum 243 absSum = toScalarQ AbsSum
244 dot = dotQ 244 dot = dotQ
245 norm1 = (:+ 0) . sumElements . fst . fromComplex . vectorMapQ Abs 245 norm1 = sumElements . fst . fromComplex . vectorMapQ Abs
246 normInf = (:+ 0) . maxElement . fst . fromComplex . vectorMapQ Abs 246 normInf = maxElement . fst . fromComplex . vectorMapQ Abs
247 247
248instance Vectors Vector (Complex Double) where 248instance Vectors Vector (Complex Double) where
249 norm2 = (:+ 0) . toScalarC Norm2 249 norm2 = toScalarC Norm2
250 absSum = (:+ 0) . toScalarC AbsSum 250 absSum = toScalarC AbsSum
251 dot = dotC 251 dot = dotC
252 norm1 = (:+ 0) . sumElements . fst . fromComplex . vectorMapC Abs 252 norm1 = sumElements . fst . fromComplex . vectorMapC Abs
253 normInf = (:+ 0) . maxElement . fst . fromComplex . vectorMapC Abs 253 normInf = maxElement . fst . fromComplex . vectorMapC Abs
254 254
255---------------------------------------------------- 255----------------------------------------------------
256 256
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs
index fa6c475..cf86904 100644
--- a/lib/Numeric/LinearAlgebra/Algorithms.hs
+++ b/lib/Numeric/LinearAlgebra/Algorithms.hs
@@ -645,9 +645,9 @@ instance Normed (Vector Double) where
645 pnorm Frobenius = norm2 645 pnorm Frobenius = norm2
646 646
647instance Normed (Vector (Complex Double)) where 647instance Normed (Vector (Complex Double)) where
648 pnorm PNorm1 = realPart . norm1 648 pnorm PNorm1 = norm1
649 pnorm PNorm2 = realPart . norm2 649 pnorm PNorm2 = norm2
650 pnorm Infinity = realPart . normInf 650 pnorm Infinity = normInf
651 pnorm Frobenius = pnorm PNorm2 651 pnorm Frobenius = pnorm PNorm2
652 652
653instance Normed (Vector Float) where 653instance Normed (Vector Float) where
@@ -657,9 +657,9 @@ instance Normed (Vector Float) where
657 pnorm Frobenius = pnorm PNorm2 657 pnorm Frobenius = pnorm PNorm2
658 658
659instance Normed (Vector (Complex Float)) where 659instance Normed (Vector (Complex Float)) where
660 pnorm PNorm1 = realToFrac . realPart . norm1 660 pnorm PNorm1 = realToFrac . norm1
661 pnorm PNorm2 = realToFrac . realPart . norm2 661 pnorm PNorm2 = realToFrac . norm2
662 pnorm Infinity = realToFrac . realPart . normInf 662 pnorm Infinity = realToFrac . normInf
663 pnorm Frobenius = pnorm PNorm2 663 pnorm Frobenius = pnorm PNorm2
664 664
665 665
diff --git a/lib/Numeric/LinearAlgebra/Tests.hs b/lib/Numeric/LinearAlgebra/Tests.hs
index 5b42226..0b4e3bf 100644
--- a/lib/Numeric/LinearAlgebra/Tests.hs
+++ b/lib/Numeric/LinearAlgebra/Tests.hs
@@ -240,7 +240,7 @@ normsVTest = TestList [
240 ] where v = fromList [1,-2,3:+4] :: Vector (Complex Double) 240 ] where v = fromList [1,-2,3:+4] :: Vector (Complex Double)
241 x = fromList [1,2,-3] :: Vector Double 241 x = fromList [1,2,-3] :: Vector Double
242 norm2PropR a = norm2 a =~= sqrt (dot a a) 242 norm2PropR a = norm2 a =~= sqrt (dot a a)
243 norm2PropC a = norm2 a =~= sqrt (dot a (conj a)) 243 norm2PropC a = norm2 a =~= realPart (sqrt (dot a (conj a)))
244 a =~= b = fromList [a] |~| fromList [b] 244 a =~= b = fromList [a] |~| fromList [b]
245 245
246normsMTest = TestList [ 246normsMTest = TestList [