summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2011-09-02 12:35:22 +0000
committerAlberto Ruiz <aruiz@um.es>2011-09-02 12:35:22 +0000
commit3797b187d1747f1971c112084976fb2808fc87b0 (patch)
treededc7b8c9d8988e7a6da3144ab26b4e9812f58f8 /lib
parent05f4f9703162317f3d2610a9136a853eea7ab417 (diff)
require vector >= 0.8
Diffstat (limited to 'lib')
-rw-r--r--lib/Numeric/Vector.hs52
1 files changed, 6 insertions, 46 deletions
diff --git a/lib/Numeric/Vector.hs b/lib/Numeric/Vector.hs
index 5b72951..1717e7b 100644
--- a/lib/Numeric/Vector.hs
+++ b/lib/Numeric/Vector.hs
@@ -6,7 +6,7 @@
6----------------------------------------------------------------------------- 6-----------------------------------------------------------------------------
7-- | 7-- |
8-- Module : Numeric.Vector 8-- Module : Numeric.Vector
9-- Copyright : (c) Alberto Ruiz 2010 9-- Copyright : (c) Alberto Ruiz 2011
10-- License : GPL-style 10-- License : GPL-style
11-- 11--
12-- Maintainer : Alberto Ruiz <aruiz@um.es> 12-- Maintainer : Alberto Ruiz <aruiz@um.es>
@@ -18,8 +18,7 @@
18-- 18--
19----------------------------------------------------------------------------- 19-----------------------------------------------------------------------------
20 20
21module Numeric.Vector ( 21module Numeric.Vector () where
22 ) where
23 22
24import Numeric.GSL.Vector 23import Numeric.GSL.Vector
25import Numeric.Container 24import Numeric.Container
@@ -37,30 +36,19 @@ import Foreign(Storable)
37instance (Show a, Storable a) => (Show (Vector a)) where 36instance (Show a, Storable a) => (Show (Vector a)) where
38 show v = (show (dim v))++" |> " ++ show (toList v) 37 show v = (show (dim v))++" |> " ++ show (toList v)
39 38
40#endif 39instance Container Vector a => Eq (Vector a) where
41 40 (==) = equal
42#ifdef VECTOR
43
44#if !MIN_VERSION_vector(0,8,0)
45instance (Element a, Read a) => Read (Vector a) where
46 readsPrec _ s = [(fromList . read $ listnums, rest)]
47 where (thing,trest) = breakAt ']' s
48 (dims,listnums) = breakAt ' ' (dropWhile (==' ') thing)
49 rest = drop 31 trest
50#endif
51#else
52 41
53instance (Element a, Read a) => Read (Vector a) where 42instance (Element a, Read a) => Read (Vector a) where
54 readsPrec _ s = [((d |>) . read $ listnums, rest)] 43 readsPrec _ s = [((d |>) . read $ listnums, rest)]
55 where (thing,rest) = breakAt ']' s 44 where (thing,rest) = breakAt ']' s
56 (dims,listnums) = breakAt '>' thing 45 (dims,listnums) = breakAt '>' thing
57 d = read . init . fst . breakAt '|' $ dims 46 d = read . init . fst . breakAt '|' $ dims
47 breakAt c l = (a++[c],tail b) where
48 (a,b) = break (==c) l
58 49
59#endif 50#endif
60 51
61breakAt c l = (a++[c],tail b) where
62 (a,b) = break (==c) l
63
64 52
65------------------------------------------------------------------ 53------------------------------------------------------------------
66 54
@@ -71,13 +59,6 @@ adaptScalar f1 f2 f3 x y
71 59
72------------------------------------------------------------------ 60------------------------------------------------------------------
73 61
74#ifndef VECTOR
75
76instance Container Vector a => Eq (Vector a) where
77 (==) = equal
78
79#endif
80
81instance Num (Vector Float) where 62instance Num (Vector Float) where
82 (+) = adaptScalar addConstant add (flip addConstant) 63 (+) = adaptScalar addConstant add (flip addConstant)
83 negate = scale (-1) 64 negate = scale (-1)
@@ -202,24 +183,3 @@ instance Floating (Vector (Complex Float)) where
202 (**) = adaptScalar (vectorMapValQ PowSV) (vectorZipQ Pow) (flip (vectorMapValQ PowVS)) 183 (**) = adaptScalar (vectorMapValQ PowSV) (vectorZipQ Pow) (flip (vectorMapValQ PowVS))
203 pi = fromList [pi] 184 pi = fromList [pi]
204 185
205-----------------------------------------------------------
206
207
208-- instance (Storable a, Num (Vector a)) => Monoid (Vector a) where
209-- mempty = 0 { idim = 0 }
210-- mappend a b = mconcat [a,b]
211-- mconcat = j . filter ((>0).dim)
212-- where j [] = mempty
213-- j l = join l
214
215---------------------------------------------------------------
216
217-- instance (NFData a, Storable a) => NFData (Vector a) where
218-- rnf = rnf . (@>0)
219--
220-- instance (NFData a, Element a) => NFData (Matrix a) where
221-- rnf = rnf . flatten
222
223
224--------------------------------------------------------------------------
225