diff options
Diffstat (limited to 'lib/Numeric')
-rw-r--r-- | lib/Numeric/LinearAlgebra/Instances.hs | 11 |
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 | |||
26 | import Complex | 26 | import Complex |
27 | import Data.List(transpose,intersperse) | 27 | import Data.List(transpose,intersperse) |
28 | import Foreign(Storable) | 28 | import Foreign(Storable) |
29 | import Data.Monoid | ||
30 | import 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 | |||
167 | instance (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 | ||