summaryrefslogtreecommitdiff
path: root/lib/Numeric/Vector.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2010-09-23 12:41:35 +0000
committerAlberto Ruiz <aruiz@um.es>2010-09-23 12:41:35 +0000
commitf50304b47f99ce0280d7ab7daf28ffe6b0d0b853 (patch)
tree020b9b66e4bc93e0928a7b3077a38db9fa7be189 /lib/Numeric/Vector.hs
parent3cfce69bf3cb7d7f7976abb454b64f6fa3a32c97 (diff)
ContainerBoot
Diffstat (limited to 'lib/Numeric/Vector.hs')
-rw-r--r--lib/Numeric/Vector.hs42
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
23module Numeric.Vector ( 21module 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
35import Data.Packed.Vector
36import Data.Packed.Internal.Matrix
37import Numeric.GSL.Vector 24import Numeric.GSL.Vector
38import Numeric.Container 25import Numeric.Container
39import Numeric.IO
40 26
41------------------------------------------------------------------- 27-------------------------------------------------------------------
42 28
@@ -73,34 +59,6 @@ instance (Element a, Read a) => Read (Vector a) where
73breakAt c l = (a++[c],tail b) where 59breakAt 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
817 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]@
82-}
83constant :: Element a => a -> Int -> Vector a
84-- constant x n = runSTVector (newVector x n)
85constant = constantD -- about 2x faster
86
87{- | Creates a real vector containing a range of values:
88
89@\> linspace 5 (-3,7)
905 |> [-3.0,-0.5,2.0,4.5,7.0]@
91
92Logarithmic spacing can be defined as follows:
93
94@logspace n (a,b) = 10 ** linspace n (a,b)@
95-}
96linspace :: (Enum e, Container Vector e) => Int -> (e, e) -> Vector e
97linspace 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
102infixl 7 <.>
103(<.>) = dot
104 62
105------------------------------------------------------------------ 63------------------------------------------------------------------
106 64