summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs2
-rw-r--r--lib/Data/Packed/Vector.hs15
-rw-r--r--lib/GSL.hs36
-rw-r--r--lib/GSLHaskell.hs (renamed from lib/GSL/Compat.hs)58
-rw-r--r--lib/Graphics/Plot.hs (renamed from lib/Data/Packed/Plot.hs)4
-rw-r--r--lib/LinearAlgebra/Linear.hs4
6 files changed, 66 insertions, 53 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index f9dd9a9..89a162a 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -171,7 +171,7 @@ compat m1 m2 = rows m1 == rows m2 && cols m1 == cols m2
171---------------------------------------------------------------- 171----------------------------------------------------------------
172 172
173-- | Optimized matrix computations are provided for elements in the Field class. 173-- | Optimized matrix computations are provided for elements in the Field class.
174class Storable a => Field a where 174class (Storable a, Num a) => Field a where
175 constantD :: a -> Int -> Vector a 175 constantD :: a -> Int -> Vector a
176 transdata :: Int -> Vector a -> Int -> Vector a 176 transdata :: Int -> Vector a -> Int -> Vector a
177 multiplyD :: Matrix a -> Matrix a -> Matrix a 177 multiplyD :: Matrix a -> Matrix a -> Matrix a
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs
index 9818d58..3fc625c 100644
--- a/lib/Data/Packed/Vector.hs
+++ b/lib/Data/Packed/Vector.hs
@@ -18,12 +18,13 @@ module Data.Packed.Vector (
18 dim, (@>), 18 dim, (@>),
19 subVector, join, 19 subVector, join,
20 constant, linspace, 20 constant, linspace,
21 21 vectorMax, vectorMin, vectorMaxIndex, vectorMinIndex,
22 liftVector, liftVector2 22 liftVector, liftVector2
23) where 23) where
24 24
25import Data.Packed.Internal 25import Data.Packed.Internal
26import Complex 26import Complex
27import GSL.Vector
27 28
28{- | Creates a real vector containing a range of values: 29{- | Creates a real vector containing a range of values:
29 30
@@ -33,3 +34,15 @@ import Complex
33linspace :: Int -> (Double, Double) -> Vector Double 34linspace :: Int -> (Double, Double) -> Vector Double
34linspace n (a,b) = fromList [a, a+delta .. b] 35linspace n (a,b) = fromList [a, a+delta .. b]
35 where delta = (b-a)/(fromIntegral n -1) 36 where delta = (b-a)/(fromIntegral n -1)
37
38vectorMax :: Vector Double -> Double
39vectorMax = toScalarR Max
40
41vectorMin :: Vector Double -> Double
42vectorMin = toScalarR Min
43
44vectorMaxIndex :: Vector Double -> Int
45vectorMaxIndex = round . toScalarR MaxIdx
46
47vectorMinIndex :: Vector Double -> Int
48vectorMinIndex = round . toScalarR MinIdx
diff --git a/lib/GSL.hs b/lib/GSL.hs
index 84df81b..8b6365b 100644
--- a/lib/GSL.hs
+++ b/lib/GSL.hs
@@ -8,43 +8,25 @@ 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 the basic functionality and a collection of utilities (old interface) 11This module reexports all the GSL functions (except those in "LinearAlgebra").
12 12
13-} 13-}
14 14
15module GSL ( 15module GSL (
16 16 module GSL.Integration
17module Data.Packed.Vector, 17, module GSL.Differentiation
18module Data.Packed.Matrix, 18, module GSL.Fourier
19--module Data.Packed.Tensor, 19, module GSL.Polynomials
20module LinearAlgebra.Algorithms, 20, module GSL.Minimization
21module LAPACK, 21, module GSL.Special
22module GSL.Integration, 22, module Complex
23module GSL.Differentiation,
24module GSL.Fourier,
25module GSL.Polynomials,
26module GSL.Minimization,
27module GSL.Matrix,
28module GSL.Compat,
29module Data.Packed.Plot,
30module Complex,
31
32setErrorHandlerOff
33
34) where 23) where
35 24
36import Data.Packed.Vector hiding (constant)
37import Data.Packed.Matrix hiding ((><))
38import LinearAlgebra.Algorithms hiding (pnorm)
39import LAPACK
40import GSL.Integration 25import GSL.Integration
41import GSL.Differentiation 26import GSL.Differentiation
42import GSL.Special 27import GSL.Special
43import GSL.Fourier 28import GSL.Fourier
44import GSL.Polynomials 29import GSL.Polynomials
45import GSL.Minimization 30import GSL.Minimization
46import GSL.Matrix
47import GSL.Compat
48import Data.Packed.Plot
49import Complex 31import Complex
50import GSL.Special(setErrorHandlerOff) 32import GSL.Special
diff --git a/lib/GSL/Compat.hs b/lib/GSLHaskell.hs
index 8a59915..e65ff28 100644
--- a/lib/GSL/Compat.hs
+++ b/lib/GSLHaskell.hs
@@ -1,7 +1,7 @@
1{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances #-} 1{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances #-}
2----------------------------------------------------------------------------- 2-----------------------------------------------------------------------------
3{- | 3{- |
4Module : GSL.Compat 4Module : GSLHaskell
5Copyright : (c) Alberto Ruiz 2006 5Copyright : (c) Alberto Ruiz 2006
6License : GPL-style 6License : GPL-style
7 7
@@ -9,23 +9,53 @@ Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional 9Stability : provisional
10Portability : uses -fffi and -fglasgow-exts 10Portability : uses -fffi and -fglasgow-exts
11 11
12Creates reasonable numeric instances for Vectors and Matrices. In the context of the standard numeric operators, one-component vectors and matrices automatically expand to match the dimensions of the other operand. 12GSLHaskell interface, with reasonable numeric instances for Vectors and Matrices. In the context of the standard numeric operators, one-component vectors and matrices automatically expand to match the dimensions of the other operand.
13 13
14-} 14-}
15----------------------------------------------------------------------------- 15-----------------------------------------------------------------------------
16 16
17module GSL.Compat( 17module GSLHaskell(
18 Mul,(<>), readMatrix, size, dispR, dispC, format, gmap, Joinable, (<|>),(<->), GSL.Compat.constant, 18 module Data.Packed.Vector,
19 vectorMax, vectorMin, vectorMaxIndex, vectorMinIndex, fromArray2D, fromComplex, GSL.Compat.pnorm, scale 19 module Data.Packed.Matrix,
20 module LinearAlgebra.Algorithms,
21 module LAPACK,
22 module GSL.Integration,
23 module GSL.Differentiation,
24 module GSL.Fourier,
25 module GSL.Polynomials,
26 module GSL.Minimization,
27 module GSL.Matrix,
28 module GSL.Special,
29 module Graphics.Plot,
30 module Complex,
31 Mul,(<>), readMatrix, size, dispR, dispC, format, gmap, Joinable, (<|>),(<->), GSLHaskell.constant,
32 fromArray2D, fromComplex, toComplex, GSLHaskell.pnorm, scale, outer
20) where 33) where
21 34
35
36import LAPACK
37import GSL.Integration
38import GSL.Differentiation
39import GSL.Fourier
40import GSL.Polynomials
41import GSL.Minimization
42import GSL.Matrix
43import Graphics.Plot
44import Complex
45import GSL.Special(setErrorHandlerOff,
46 erf,
47 erf_Z,
48 bessel_J0_e,
49 exp_e10_e,
50 gamma)
22import Data.Packed.Internal hiding (dsp) 51import Data.Packed.Internal hiding (dsp)
23import Data.Packed.Vector 52import Data.Packed.Vector hiding (constant)
24import Data.Packed.Matrix 53import Data.Packed.Matrix
54import Data.Packed.Matrix hiding ((><))
25import GSL.Vector 55import GSL.Vector
26import LinearAlgebra.Linear 56import LinearAlgebra.Linear
27import GSL.Matrix 57import qualified LinearAlgebra.Algorithms
28import LinearAlgebra.Algorithms 58import LinearAlgebra.Algorithms hiding (pnorm)
29import Complex 59import Complex
30import Numeric(showGFloat) 60import Numeric(showGFloat)
31import Data.List(transpose,intersperse) 61import Data.List(transpose,intersperse)
@@ -437,18 +467,6 @@ a <-> b = joinV a b
437 467
438---------------------------------------------------------- 468----------------------------------------------------------
439 469
440vectorMax :: Vector Double -> Double
441vectorMax = toScalarR Max
442
443vectorMin :: Vector Double -> Double
444vectorMin = toScalarR Min
445
446vectorMaxIndex :: Vector Double -> Int
447vectorMaxIndex = round . toScalarR MaxIdx
448
449vectorMinIndex :: Vector Double -> Int
450vectorMinIndex = round . toScalarR MinIdx
451
452fromArray2D :: (Field e) => Array (Int, Int) e -> Matrix e 470fromArray2D :: (Field e) => Array (Int, Int) e -> Matrix e
453fromArray2D m = (r><c) (elems m) 471fromArray2D m = (r><c) (elems m)
454 where ((r0,c0),(r1,c1)) = bounds m 472 where ((r0,c0),(r1,c1)) = bounds m
diff --git a/lib/Data/Packed/Plot.hs b/lib/Graphics/Plot.hs
index 7d63426..9f719ab 100644
--- a/lib/Data/Packed/Plot.hs
+++ b/lib/Graphics/Plot.hs
@@ -1,6 +1,6 @@
1----------------------------------------------------------------------------- 1-----------------------------------------------------------------------------
2-- | 2-- |
3-- Module : Data.Packed.Plot 3-- Module : Graphics.Plot
4-- Copyright : (c) Alberto Ruiz 2005 4-- Copyright : (c) Alberto Ruiz 2005
5-- License : GPL-style 5-- License : GPL-style
6-- 6--
@@ -12,7 +12,7 @@
12-- 12--
13----------------------------------------------------------------------------- 13-----------------------------------------------------------------------------
14 14
15module Data.Packed.Plot( 15module Graphics.Plot(
16 16
17 gnuplotX, mplot, 17 gnuplotX, mplot,
18 18
diff --git a/lib/LinearAlgebra/Linear.hs b/lib/LinearAlgebra/Linear.hs
index 51b32f5..53e011f 100644
--- a/lib/LinearAlgebra/Linear.hs
+++ b/lib/LinearAlgebra/Linear.hs
@@ -27,7 +27,7 @@ import GSL.Vector
27import Complex 27import Complex
28 28
29 29
30class (Num e, Field e) => Linear c e where 30class (Field e) => Linear c e where
31 scale :: e -> c e -> c e 31 scale :: e -> c e -> c e
32 addConstant :: e -> c e -> c e 32 addConstant :: e -> c e -> c e
33 add :: c e -> c e -> c e 33 add :: c e -> c e -> c e
@@ -68,5 +68,5 @@ dot u v = dat (multiply r c) `at` 0
68 , 10.0, 4.0, 6.0 68 , 10.0, 4.0, 6.0
69 , 15.0, 6.0, 9.0 ]@ 69 , 15.0, 6.0, 9.0 ]@
70-} 70-}
71outer :: (Num t, Field t) => Vector t -> Vector t -> Matrix t 71outer :: (Field t) => Vector t -> Vector t -> Matrix t
72outer u v = asColumn u `multiply` asRow v 72outer u v = asColumn u `multiply` asRow v