diff options
author | Alberto Ruiz <aruiz@um.es> | 2010-05-11 09:07:52 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2010-05-11 09:07:52 +0000 |
commit | aa8debb5ab389de7bc5b47c5ae5f038349b6efc1 (patch) | |
tree | ceb1ae6932ef0769616089fd05a7ba099b9a5b30 /lib | |
parent | 0c1b8611b9cc55cc646c708b63442f3aaac1249d (diff) |
simplify modules
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Data/Packed/Random.hs | 5 | ||||
-rw-r--r-- | lib/Graphics/Plot.hs | 18 | ||||
-rw-r--r-- | lib/Numeric/GSL.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/GSL/ODE.hs | 1 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra.hs | 6 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Algorithms.hs | 1 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Interface.hs | 29 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Linear.hs | 2 |
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 | ||
22 | import Numeric.GSL.Vector | 22 | import Numeric.GSL.Vector |
23 | import Data.Packed | 23 | import Data.Packed.Matrix |
24 | import Numeric.LinearAlgebra.Linear | 24 | import Data.Packed.Vector |
25 | import Numeric.LinearAlgebra.Algorithms | 25 | import Numeric.LinearAlgebra.Algorithms |
26 | import Numeric.LinearAlgebra.Instances() | ||
27 | import Numeric.LinearAlgebra.Interface | 26 | import 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 | |||
208 | gnuplotWin :: String -> String -> [([[Double]], String)] -> IO () | ||
209 | gnuplotWin 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) | |||
8 | Stability : provisional | 8 | Stability : provisional |
9 | Portability : uses -fffi and -fglasgow-exts | 9 | Portability : uses -fffi and -fglasgow-exts |
10 | 10 | ||
11 | This module reexports all the available GSL functions (except those in "Numeric.LinearAlgebra"). | 11 | This module reexports all available GSL functions. |
12 | |||
13 | The 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 | ||
35 | import Data.Packed.Internal | 35 | import Data.Packed.Internal |
36 | import Data.Packed.Matrix | ||
37 | import Foreign | 36 | import Foreign |
38 | import Foreign.C.Types(CInt) | 37 | import Foreign.C.Types(CInt) |
39 | import Numeric.GSL.Internal | 38 | import 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) | |||
8 | Stability : provisional | 8 | Stability : provisional |
9 | Portability : uses ffi | 9 | Portability : uses ffi |
10 | 10 | ||
11 | Basic matrix computations implemented by BLAS, LAPACK and GSL. | 11 | This module reexports all normally required functions for Linear Algebra applications. |
12 | |||
13 | This module reexports the most comon functions (including "Numeric.LinearAlgebra.Instances"). | ||
14 | 12 | ||
15 | -} | 13 | -} |
16 | ----------------------------------------------------------------------------- | 14 | ----------------------------------------------------------------------------- |
17 | module Numeric.LinearAlgebra ( | 15 | module 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 | ||
25 | import Data.Packed | 22 | import Data.Packed |
26 | import Data.Packed.Random | 23 | import Data.Packed.Random |
27 | import Numeric.LinearAlgebra.Linear | ||
28 | import Numeric.LinearAlgebra.Algorithms | 24 | import Numeric.LinearAlgebra.Algorithms |
29 | import Numeric.LinearAlgebra.Instances() | 25 | import Numeric.LinearAlgebra.Instances() |
30 | import Numeric.LinearAlgebra.Interface | 26 | import 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) | |||
9 | Stability : provisional | 9 | Stability : provisional |
10 | Portability : portable | 10 | Portability : portable |
11 | 11 | ||
12 | (Very provisional) operators for frequent operations. | 12 | Operators for frequent operations. |
13 | |||
14 | This module exports Show, Read, Eq, Num, Fractional, and Floating instances for Vector and Matrix. | ||
15 | |||
16 | In 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 | ||
24 | import Numeric.LinearAlgebra.Linear | 29 | import Numeric.LinearAlgebra.Instances() |
25 | import Data.Packed.Vector | 30 | import Data.Packed.Vector |
26 | import Data.Packed.Matrix | 31 | import Data.Packed.Matrix |
27 | import Numeric.LinearAlgebra.Algorithms | 32 | import Numeric.LinearAlgebra.Algorithms |
28 | 33 | ||
29 | class Mul a b c | a b -> c where | 34 | class 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 | ||
34 | instance Mul Matrix Matrix Matrix where | 39 | instance 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 |
47 | infixl 7 <.> | 52 | infixl 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 |
56 | infixl 7 .* | 61 | infixl 7 .* |
57 | a .* x = scale a x | 62 | a .* 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 |
65 | infixl 7 */ | 70 | infixl 7 */ |
66 | v */ x = scale (recip x) v | 71 | v */ x = scale (recip x) v |
67 | 72 | ||
@@ -94,7 +99,7 @@ instance Joinable Vector Matrix where | |||
94 | infixl 4 <|> | 99 | infixl 4 <|> |
95 | infixl 3 <-> | 100 | infixl 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 |
109 | a <|> b = joinH a b | 114 | a <|> 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 |
113 | a <-> b = joinV a b | 118 | a <-> 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 ( | |||
21 | import Data.Packed | 21 | import Data.Packed |
22 | import Numeric.GSL.Vector | 22 | import 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. |
25 | class (Container c e) => Linear c e where | 25 | class (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 |