summaryrefslogtreecommitdiff
path: root/lib/Numeric
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric')
-rw-r--r--lib/Numeric/LinearAlgebra/Instances.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Numeric/LinearAlgebra/Instances.hs b/lib/Numeric/LinearAlgebra/Instances.hs
index 3f295bf..c8bf126 100644
--- a/lib/Numeric/LinearAlgebra/Instances.hs
+++ b/lib/Numeric/LinearAlgebra/Instances.hs
@@ -26,6 +26,8 @@ import Data.Packed.Vector
26import Complex 26import Complex
27import Data.List(transpose,intersperse) 27import Data.List(transpose,intersperse)
28import Foreign(Storable) 28import Foreign(Storable)
29import Data.Monoid
30import Data.Packed.Internal.Vector
29 31
30------------------------------------------------------------------ 32------------------------------------------------------------------
31 33
@@ -159,3 +161,12 @@ instance (Linear Vector a, Floating (Vector a)) => Floating (Matrix a) where
159 (**) = liftMatrix2' (**) 161 (**) = liftMatrix2' (**)
160 sqrt = liftMatrix sqrt 162 sqrt = liftMatrix sqrt
161 pi = (1><1) [pi] 163 pi = (1><1) [pi]
164
165---------------------------------------------------------------
166
167instance (Storable a) => Monoid (Vector a) where
168 mempty = V { dim = 0, fptr = undefined }
169 mappend a b = mconcat [a,b]
170 mconcat = j . filter ((>0).dim)
171 where j [] = mempty
172 j l = join l