diff options
Diffstat (limited to 'lib/Numeric/Vector.hs')
-rw-r--r-- | lib/Numeric/Vector.hs | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/lib/Numeric/Vector.hs b/lib/Numeric/Vector.hs index 9acd6f0..3fcd880 100644 --- a/lib/Numeric/Vector.hs +++ b/lib/Numeric/Vector.hs | |||
@@ -13,30 +13,16 @@ | |||
13 | -- Stability : provisional | 13 | -- Stability : provisional |
14 | -- Portability : portable | 14 | -- Portability : portable |
15 | -- | 15 | -- |
16 | -- Numeric instances and functions for 'Vector'. | ||
17 | -- | ||
18 | -- Provides instances of standard classes 'Show', 'Read', 'Eq', | 16 | -- Provides instances of standard classes 'Show', 'Read', 'Eq', |
19 | -- 'Num', 'Fractional', and 'Floating' for 'Vector'. | 17 | -- 'Num', 'Fractional', and 'Floating' for 'Vector'. |
20 | -- | 18 | -- |
21 | ----------------------------------------------------------------------------- | 19 | ----------------------------------------------------------------------------- |
22 | 20 | ||
23 | module Numeric.Vector ( | 21 | module Numeric.Vector ( |
24 | -- * Basic vector functions | ||
25 | module Data.Packed.Vector, | ||
26 | module Numeric.Container, | ||
27 | -- * Vector creation | ||
28 | constant, linspace, | ||
29 | -- * Operators | ||
30 | (<.>), | ||
31 | -- * IO | ||
32 | fscanfVector, fprintfVector, freadVector, fwriteVector | ||
33 | ) where | 22 | ) where |
34 | 23 | ||
35 | import Data.Packed.Vector | ||
36 | import Data.Packed.Internal.Matrix | ||
37 | import Numeric.GSL.Vector | 24 | import Numeric.GSL.Vector |
38 | import Numeric.Container | 25 | import Numeric.Container |
39 | import Numeric.IO | ||
40 | 26 | ||
41 | ------------------------------------------------------------------- | 27 | ------------------------------------------------------------------- |
42 | 28 | ||
@@ -73,34 +59,6 @@ instance (Element a, Read a) => Read (Vector a) where | |||
73 | breakAt c l = (a++[c],tail b) where | 59 | breakAt c l = (a++[c],tail b) where |
74 | (a,b) = break (==c) l | 60 | (a,b) = break (==c) l |
75 | 61 | ||
76 | ------------------------------------------------------------------ | ||
77 | |||
78 | {- | creates a vector with a given number of equal components: | ||
79 | |||
80 | @> constant 2 7 | ||
81 | 7 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]@ | ||
82 | -} | ||
83 | constant :: Element a => a -> Int -> Vector a | ||
84 | -- constant x n = runSTVector (newVector x n) | ||
85 | constant = constantD -- about 2x faster | ||
86 | |||
87 | {- | Creates a real vector containing a range of values: | ||
88 | |||
89 | @\> linspace 5 (-3,7) | ||
90 | 5 |> [-3.0,-0.5,2.0,4.5,7.0]@ | ||
91 | |||
92 | Logarithmic spacing can be defined as follows: | ||
93 | |||
94 | @logspace n (a,b) = 10 ** linspace n (a,b)@ | ||
95 | -} | ||
96 | linspace :: (Enum e, Container Vector e) => Int -> (e, e) -> Vector e | ||
97 | linspace n (a,b) = addConstant a $ scale s $ fromList [0 .. fromIntegral n-1] | ||
98 | where s = (b-a)/fromIntegral (n-1) | ||
99 | |||
100 | -- | Dot product: @u \<.\> v = dot u v@ | ||
101 | (<.>) :: Product t => Vector t -> Vector t -> t | ||
102 | infixl 7 <.> | ||
103 | (<.>) = dot | ||
104 | 62 | ||
105 | ------------------------------------------------------------------ | 63 | ------------------------------------------------------------------ |
106 | 64 | ||