summaryrefslogtreecommitdiff
path: root/lib/LinearAlgebra/Linear.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-10-01 09:43:19 +0000
committerAlberto Ruiz <aruiz@um.es>2007-10-01 09:43:19 +0000
commit768f08d4134a066d773d56a9c03ae688e3850352 (patch)
tree99cbfc8c7a547d4e2c65c8ff22a525d05f5b1f49 /lib/LinearAlgebra/Linear.hs
parent13dfe14e171941b3ca82cd858973e3681d7b254e (diff)
check hermitian on chol and eigSH
Diffstat (limited to 'lib/LinearAlgebra/Linear.hs')
-rw-r--r--lib/LinearAlgebra/Linear.hs7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/LinearAlgebra/Linear.hs b/lib/LinearAlgebra/Linear.hs
index 3e6c55d..7cd1a52 100644
--- a/lib/LinearAlgebra/Linear.hs
+++ b/lib/LinearAlgebra/Linear.hs
@@ -37,6 +37,8 @@ class (Container c e) => Linear c e where
37 divide :: c e -> c e -> c e 37 divide :: c e -> c e -> c e
38 -- | scale the element by element reciprocal of the object: @scaleRecip 2 (fromList [5,i]) == 2 |> [0.4 :+ 0.0,0.0 :+ (-2.0)]@ 38 -- | scale the element by element reciprocal of the object: @scaleRecip 2 (fromList [5,i]) == 2 |> [0.4 :+ 0.0,0.0 :+ (-2.0)]@
39 scaleRecip :: e -> c e -> c e 39 scaleRecip :: e -> c e -> c e
40 equal :: c e -> c e -> Bool
41-- numequal :: Double -> c e -> c e -> Bool
40 42
41instance Linear Vector Double where 43instance Linear Vector Double where
42 scale = vectorMapValR Scale 44 scale = vectorMapValR Scale
@@ -46,6 +48,7 @@ instance Linear Vector Double where
46 sub = vectorZipR Sub 48 sub = vectorZipR Sub
47 mul = vectorZipR Mul 49 mul = vectorZipR Mul
48 divide = vectorZipR Div 50 divide = vectorZipR Div
51 equal u v = dim u == dim v && vectorMax (vectorMapR Abs (sub u v)) == 0.0
49 52
50instance Linear Vector (Complex Double) where 53instance Linear Vector (Complex Double) where
51 scale = vectorMapValC Scale 54 scale = vectorMapValC Scale
@@ -55,6 +58,7 @@ instance Linear Vector (Complex Double) where
55 sub = vectorZipC Sub 58 sub = vectorZipC Sub
56 mul = vectorZipC Mul 59 mul = vectorZipC Mul
57 divide = vectorZipC Div 60 divide = vectorZipC Div
61 equal u v = dim u == dim v && vectorMax (liftVector magnitude (sub u v)) == 0.0
58 62
59instance Linear Matrix Double where 63instance Linear Matrix Double where
60 scale x = liftMatrix (scale x) 64 scale x = liftMatrix (scale x)
@@ -64,6 +68,8 @@ instance Linear Matrix Double where
64 sub = liftMatrix2 sub 68 sub = liftMatrix2 sub
65 mul = liftMatrix2 mul 69 mul = liftMatrix2 mul
66 divide = liftMatrix2 divide 70 divide = liftMatrix2 divide
71 equal a b = cols a == cols b && cdat a `equal` cdat b
72
67 73
68instance Linear Matrix (Complex Double) where 74instance Linear Matrix (Complex Double) where
69 scale x = liftMatrix (scale x) 75 scale x = liftMatrix (scale x)
@@ -73,6 +79,7 @@ instance Linear Matrix (Complex Double) where
73 sub = liftMatrix2 sub 79 sub = liftMatrix2 sub
74 mul = liftMatrix2 mul 80 mul = liftMatrix2 mul
75 divide = liftMatrix2 divide 81 divide = liftMatrix2 divide
82 equal a b = cols a == cols b && cdat a `equal` cdat b
76 83
77-------------------------------------------------- 84--------------------------------------------------
78 85