summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2010-05-11 09:07:52 +0000
committerAlberto Ruiz <aruiz@um.es>2010-05-11 09:07:52 +0000
commitaa8debb5ab389de7bc5b47c5ae5f038349b6efc1 (patch)
treeceb1ae6932ef0769616089fd05a7ba099b9a5b30 /lib
parent0c1b8611b9cc55cc646c708b63442f3aaac1249d (diff)
simplify modules
Diffstat (limited to 'lib')
-rw-r--r--lib/Data/Packed/Random.hs5
-rw-r--r--lib/Graphics/Plot.hs18
-rw-r--r--lib/Numeric/GSL.hs4
-rw-r--r--lib/Numeric/GSL/ODE.hs1
-rw-r--r--lib/Numeric/LinearAlgebra.hs6
-rw-r--r--lib/Numeric/LinearAlgebra/Algorithms.hs1
-rw-r--r--lib/Numeric/LinearAlgebra/Interface.hs29
-rw-r--r--lib/Numeric/LinearAlgebra/Linear.hs2
8 files changed, 42 insertions, 24 deletions
diff --git a/lib/Data/Packed/Random.hs b/lib/Data/Packed/Random.hs
index 260e4dc..e57ba6e 100644
--- a/lib/Data/Packed/Random.hs
+++ b/lib/Data/Packed/Random.hs
@@ -20,10 +20,9 @@ module Data.Packed.Random (
20) where 20) where
21 21
22import Numeric.GSL.Vector 22import Numeric.GSL.Vector
23import Data.Packed 23import Data.Packed.Matrix
24import Numeric.LinearAlgebra.Linear 24import Data.Packed.Vector
25import Numeric.LinearAlgebra.Algorithms 25import Numeric.LinearAlgebra.Algorithms
26import Numeric.LinearAlgebra.Instances()
27import Numeric.LinearAlgebra.Interface 26import Numeric.LinearAlgebra.Interface
28 27
29-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate 28-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate
diff --git a/lib/Graphics/Plot.hs b/lib/Graphics/Plot.hs
index 3f66d98..b4e8a11 100644
--- a/lib/Graphics/Plot.hs
+++ b/lib/Graphics/Plot.hs
@@ -24,7 +24,7 @@ module Graphics.Plot(
24 24
25 matrixToPGM, imshow, 25 matrixToPGM, imshow,
26 26
27 gnuplotX, gnuplotpdf 27 gnuplotX, gnuplotpdf, gnuplotWin
28 28
29) where 29) where
30 30
@@ -204,3 +204,19 @@ gnuplotpdf title command ds = gnuplot (prelude ++ command ++" "++ draw) >> postp
204 _ <- system "gnuplot gnuplotcommand" 204 _ <- system "gnuplot gnuplotcommand"
205 _ <- system "rm gnuplotcommand" 205 _ <- system "rm gnuplotcommand"
206 return () 206 return ()
207
208gnuplotWin :: String -> String -> [([[Double]], String)] -> IO ()
209gnuplotWin title command ds = gnuplot (prelude ++ command ++" "++ draw) where
210 (dats,defs) = unzip ds
211 draw = concat (intersperse ", " (map ("\"-\" "++) defs)) ++ "\n" ++
212 concatMap pr dats
213
214 pr = (++"e\n") . unlines . map (unwords . (map show))
215
216 prelude = "set title \""++title++"\";"
217
218 gnuplot cmd = do
219 writeFile "gnuplotcommand" cmd
220 _ <- system "gnuplot -persist gnuplotcommand"
221 _ <- system "rm gnuplotcommand"
222 return ()
diff --git a/lib/Numeric/GSL.hs b/lib/Numeric/GSL.hs
index ae4c81e..e53022e 100644
--- a/lib/Numeric/GSL.hs
+++ b/lib/Numeric/GSL.hs
@@ -8,7 +8,9 @@ Maintainer : Alberto Ruiz (aruiz at um dot es)
8Stability : provisional 8Stability : provisional
9Portability : uses -fffi and -fglasgow-exts 9Portability : uses -fffi and -fglasgow-exts
10 10
11This module reexports all the available GSL functions (except those in "Numeric.LinearAlgebra"). 11This module reexports all available GSL functions.
12
13The GSL special functions are in the separate package hmatrix-special.
12 14
13-} 15-}
14 16
diff --git a/lib/Numeric/GSL/ODE.hs b/lib/Numeric/GSL/ODE.hs
index eca06f8..912e8a8 100644
--- a/lib/Numeric/GSL/ODE.hs
+++ b/lib/Numeric/GSL/ODE.hs
@@ -33,7 +33,6 @@ module Numeric.GSL.ODE (
33) where 33) where
34 34
35import Data.Packed.Internal 35import Data.Packed.Internal
36import Data.Packed.Matrix
37import Foreign 36import Foreign
38import Foreign.C.Types(CInt) 37import Foreign.C.Types(CInt)
39import Numeric.GSL.Internal 38import Numeric.GSL.Internal
diff --git a/lib/Numeric/LinearAlgebra.hs b/lib/Numeric/LinearAlgebra.hs
index 337c007..2652f2d 100644
--- a/lib/Numeric/LinearAlgebra.hs
+++ b/lib/Numeric/LinearAlgebra.hs
@@ -8,23 +8,19 @@ Maintainer : Alberto Ruiz (aruiz at um dot es)
8Stability : provisional 8Stability : provisional
9Portability : uses ffi 9Portability : uses ffi
10 10
11Basic matrix computations implemented by BLAS, LAPACK and GSL. 11This module reexports all normally required functions for Linear Algebra applications.
12
13This module reexports the most comon functions (including "Numeric.LinearAlgebra.Instances").
14 12
15-} 13-}
16----------------------------------------------------------------------------- 14-----------------------------------------------------------------------------
17module Numeric.LinearAlgebra ( 15module Numeric.LinearAlgebra (
18 module Data.Packed, 16 module Data.Packed,
19 module Data.Packed.Random, 17 module Data.Packed.Random,
20 module Numeric.LinearAlgebra.Linear,
21 module Numeric.LinearAlgebra.Algorithms, 18 module Numeric.LinearAlgebra.Algorithms,
22 module Numeric.LinearAlgebra.Interface 19 module Numeric.LinearAlgebra.Interface
23) where 20) where
24 21
25import Data.Packed 22import Data.Packed
26import Data.Packed.Random 23import Data.Packed.Random
27import Numeric.LinearAlgebra.Linear
28import Numeric.LinearAlgebra.Algorithms 24import Numeric.LinearAlgebra.Algorithms
29import Numeric.LinearAlgebra.Instances() 25import Numeric.LinearAlgebra.Instances()
30import Numeric.LinearAlgebra.Interface 26import Numeric.LinearAlgebra.Interface
diff --git a/lib/Numeric/LinearAlgebra/Algorithms.hs b/lib/Numeric/LinearAlgebra/Algorithms.hs
index fc2fcb2..7de9587 100644
--- a/lib/Numeric/LinearAlgebra/Algorithms.hs
+++ b/lib/Numeric/LinearAlgebra/Algorithms.hs
@@ -66,6 +66,7 @@ module Numeric.LinearAlgebra.Algorithms (
66-- * Misc 66-- * Misc
67 ctrans, 67 ctrans,
68 eps, i, 68 eps, i,
69 Linear(..),
69-- * Util 70-- * Util
70 haussholder, 71 haussholder,
71 unpackQR, unpackHess, 72 unpackQR, unpackHess,
diff --git a/lib/Numeric/LinearAlgebra/Interface.hs b/lib/Numeric/LinearAlgebra/Interface.hs
index b74180f..750670b 100644
--- a/lib/Numeric/LinearAlgebra/Interface.hs
+++ b/lib/Numeric/LinearAlgebra/Interface.hs
@@ -9,7 +9,12 @@ Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional 9Stability : provisional
10Portability : portable 10Portability : portable
11 11
12(Very provisional) operators for frequent operations. 12Operators for frequent operations.
13
14This module exports Show, Read, Eq, Num, Fractional, and Floating instances for Vector and Matrix.
15
16In the context of the standard numeric operators, one-component vectors and matrices automatically expand to match the dimensions of the other operand.
17
13 18
14-} 19-}
15----------------------------------------------------------------------------- 20-----------------------------------------------------------------------------
@@ -21,14 +26,14 @@ module Numeric.LinearAlgebra.Interface(
21 (<|>),(<->), 26 (<|>),(<->),
22) where 27) where
23 28
24import Numeric.LinearAlgebra.Linear 29import Numeric.LinearAlgebra.Instances()
25import Data.Packed.Vector 30import Data.Packed.Vector
26import Data.Packed.Matrix 31import Data.Packed.Matrix
27import Numeric.LinearAlgebra.Algorithms 32import Numeric.LinearAlgebra.Algorithms
28 33
29class Mul a b c | a b -> c where 34class Mul a b c | a b -> c where
30 infixl 7 <> 35 infixl 7 <>
31 -- | matrix product 36 -- | Matrix-matrix, matrix-vector, and vector-matrix products.
32 (<>) :: Field t => a t -> b t -> c t 37 (<>) :: Field t => a t -> b t -> c t
33 38
34instance Mul Matrix Matrix Matrix where 39instance Mul Matrix Matrix Matrix where
@@ -42,7 +47,7 @@ instance Mul Vector Matrix Vector where
42 47
43--------------------------------------------------- 48---------------------------------------------------
44 49
45-- | @u \<.\> v = dot u v@ 50-- | Dot product: @u \<.\> v = dot u v@
46(<.>) :: (Field t) => Vector t -> Vector t -> t 51(<.>) :: (Field t) => Vector t -> Vector t -> t
47infixl 7 <.> 52infixl 7 <.>
48(<.>) = dot 53(<.>) = dot
@@ -51,8 +56,8 @@ infixl 7 <.>
51 56
52{-# DEPRECATED (.*) "use scale a x or scalar a * x" #-} 57{-# DEPRECATED (.*) "use scale a x or scalar a * x" #-}
53 58
54-- | @x .* a = scale x a@ 59-- -- | @x .* a = scale x a@
55(.*) :: (Linear c a) => a -> c a -> c a 60-- (.*) :: (Linear c a) => a -> c a -> c a
56infixl 7 .* 61infixl 7 .*
57a .* x = scale a x 62a .* x = scale a x
58 63
@@ -60,8 +65,8 @@ a .* x = scale a x
60 65
61{-# DEPRECATED (*/) "use scale (recip a) x or x / scalar a" #-} 66{-# DEPRECATED (*/) "use scale (recip a) x or x / scalar a" #-}
62 67
63-- | @a *\/ x = scale (recip x) a@ 68-- -- | @a *\/ x = scale (recip x) a@
64(*/) :: (Linear c a) => c a -> a -> c a 69-- (*/) :: (Linear c a) => c a -> a -> c a
65infixl 7 */ 70infixl 7 */
66v */ x = scale (recip x) v 71v */ x = scale (recip x) v
67 72
@@ -94,7 +99,7 @@ instance Joinable Vector Matrix where
94infixl 4 <|> 99infixl 4 <|>
95infixl 3 <-> 100infixl 3 <->
96 101
97{- | Horizontal concatenation of matrices and vectors: 102{-- - | Horizontal concatenation of matrices and vectors:
98 103
99@> (ident 3 \<-\> 3 * ident 3) \<|\> fromList [1..6.0] 104@> (ident 3 \<-\> 3 * ident 3) \<|\> fromList [1..6.0]
100(6><4) 105(6><4)
@@ -105,10 +110,10 @@ infixl 3 <->
105 , 0.0, 3.0, 0.0, 5.0 110 , 0.0, 3.0, 0.0, 5.0
106 , 0.0, 0.0, 3.0, 6.0 ]@ 111 , 0.0, 0.0, 3.0, 6.0 ]@
107-} 112-}
108(<|>) :: (Element t, Joinable a b) => a t -> b t -> Matrix t 113-- (<|>) :: (Element t, Joinable a b) => a t -> b t -> Matrix t
109a <|> b = joinH a b 114a <|> b = joinH a b
110 115
111-- | Vertical concatenation of matrices and vectors. 116-- -- | Vertical concatenation of matrices and vectors.
112(<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t 117-- (<->) :: (Element t, Joinable a b) => a t -> b t -> Matrix t
113a <-> b = joinV a b 118a <-> b = joinV a b
114 119
diff --git a/lib/Numeric/LinearAlgebra/Linear.hs b/lib/Numeric/LinearAlgebra/Linear.hs
index 7e23745..2568410 100644
--- a/lib/Numeric/LinearAlgebra/Linear.hs
+++ b/lib/Numeric/LinearAlgebra/Linear.hs
@@ -21,7 +21,7 @@ module Numeric.LinearAlgebra.Linear (
21import Data.Packed 21import Data.Packed
22import Numeric.GSL.Vector 22import Numeric.GSL.Vector
23 23
24-- | A generic interface for vectors and matrices to a few element-by-element functions in Numeric.GSL.Vector. 24-- | Basic element-by-element functions.
25class (Container c e) => Linear c e where 25class (Container c e) => Linear c e where
26 -- | create a structure with a single element 26 -- | create a structure with a single element
27 scalar :: e -> c e 27 scalar :: e -> c e