summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/base/hmatrix-base.cabal8
-rw-r--r--packages/base/src/Numeric/Container.hs (renamed from packages/base/src/Data/Packed/Numeric.hs)4
-rw-r--r--packages/base/src/Numeric/LinearAlgebra.hs (renamed from packages/base/src/Numeric/LinearAlgebra/Base.hs)4
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Data.hs2
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Devel.hs2
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Random.hs2
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util.hs2
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs2
-rw-r--r--packages/hmatrix/hmatrix.cabal15
-rw-r--r--packages/hmatrix/src/Numeric/Container.hs23
-rw-r--r--packages/hmatrix/src/Numeric/GSL/Fitting.hs2
-rw-r--r--packages/hmatrix/src/Numeric/GSL/IO.hs (renamed from packages/hmatrix/src/Numeric/LinearAlgebra/IO.hs)6
-rw-r--r--packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs38
-rw-r--r--packages/hmatrix/src/Numeric/GSL/Random.hs (renamed from packages/hmatrix/src/Numeric/LinearAlgebra/Random.hs)10
-rw-r--r--packages/hmatrix/src/Numeric/GSL/Vector.hs (renamed from packages/hmatrix/src/Numeric/LinearAlgebra/GSL.hs)43
-rw-r--r--packages/hmatrix/src/Numeric/LinearAlgebra.hs20
16 files changed, 69 insertions, 114 deletions
diff --git a/packages/base/hmatrix-base.cabal b/packages/base/hmatrix-base.cabal
index b884518..91dc0db 100644
--- a/packages/base/hmatrix-base.cabal
+++ b/packages/base/hmatrix-base.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix-base 1Name: hmatrix
2Version: 0.16.0.0 2Version: 0.16.0.2
3License: BSD3 3License: BSD3
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -38,10 +38,10 @@ library
38 38
39 Numeric.LinearAlgebra.LAPACK 39 Numeric.LinearAlgebra.LAPACK
40 Numeric.LinearAlgebra.Algorithms 40 Numeric.LinearAlgebra.Algorithms
41 Data.Packed.Numeric 41 Numeric.Container
42 Numeric.LinearAlgebra.Util 42 Numeric.LinearAlgebra.Util
43 43
44 Numeric.LinearAlgebra.Base 44 Numeric.LinearAlgebra
45 Numeric.LinearAlgebra.Devel 45 Numeric.LinearAlgebra.Devel
46 Numeric.LinearAlgebra.Data 46 Numeric.LinearAlgebra.Data
47 47
diff --git a/packages/base/src/Data/Packed/Numeric.hs b/packages/base/src/Numeric/Container.hs
index d130ecd..c715dac 100644
--- a/packages/base/src/Data/Packed/Numeric.hs
+++ b/packages/base/src/Numeric/Container.hs
@@ -7,7 +7,7 @@
7 7
8----------------------------------------------------------------------------- 8-----------------------------------------------------------------------------
9-- | 9-- |
10-- Module : Data.Packed.Numeric 10-- Module : Numeric.Container
11-- Copyright : (c) Alberto Ruiz 2010-14 11-- Copyright : (c) Alberto Ruiz 2010-14
12-- License : BSD3 12-- License : BSD3
13-- Maintainer : Alberto Ruiz 13-- Maintainer : Alberto Ruiz
@@ -24,7 +24,7 @@
24----------------------------------------------------------------------------- 24-----------------------------------------------------------------------------
25{-# OPTIONS_HADDOCK hide #-} 25{-# OPTIONS_HADDOCK hide #-}
26 26
27module Data.Packed.Numeric ( 27module Numeric.Container (
28 -- * Basic functions 28 -- * Basic functions
29 module Data.Packed, 29 module Data.Packed,
30 konst, build, 30 konst, build,
diff --git a/packages/base/src/Numeric/LinearAlgebra/Base.hs b/packages/base/src/Numeric/LinearAlgebra.hs
index 8d44d26..96bf29f 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Base.hs
+++ b/packages/base/src/Numeric/LinearAlgebra.hs
@@ -8,7 +8,7 @@ Stability : provisional
8 8
9-} 9-}
10----------------------------------------------------------------------------- 10-----------------------------------------------------------------------------
11module Numeric.LinearAlgebra.Base ( 11module Numeric.LinearAlgebra (
12 12
13 -- * Basic types and data processing 13 -- * Basic types and data processing
14 module Numeric.LinearAlgebra.Data, 14 module Numeric.LinearAlgebra.Data,
@@ -132,7 +132,7 @@ import Numeric.LinearAlgebra.Data
132 132
133import Numeric.Matrix() 133import Numeric.Matrix()
134import Numeric.Vector() 134import Numeric.Vector()
135import Data.Packed.Numeric 135import Numeric.Container
136import Numeric.LinearAlgebra.Algorithms 136import Numeric.LinearAlgebra.Algorithms
137import Numeric.LinearAlgebra.Util 137import Numeric.LinearAlgebra.Util
138import Numeric.LinearAlgebra.Random 138import Numeric.LinearAlgebra.Random
diff --git a/packages/base/src/Numeric/LinearAlgebra/Data.hs b/packages/base/src/Numeric/LinearAlgebra/Data.hs
index 45fc00c..7e8af03 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Data.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Data.hs
@@ -62,7 +62,7 @@ module Numeric.LinearAlgebra.Data(
62 62
63import Data.Packed.Vector 63import Data.Packed.Vector
64import Data.Packed.Matrix 64import Data.Packed.Matrix
65import Data.Packed.Numeric 65import Numeric.Container
66import Numeric.LinearAlgebra.Util 66import Numeric.LinearAlgebra.Util
67import Data.Complex 67import Data.Complex
68 68
diff --git a/packages/base/src/Numeric/LinearAlgebra/Devel.hs b/packages/base/src/Numeric/LinearAlgebra/Devel.hs
index b5ef60d..c41db2d 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Devel.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Devel.hs
@@ -60,7 +60,7 @@ module Numeric.LinearAlgebra.Devel(
60import Data.Packed.Foreign 60import Data.Packed.Foreign
61import Data.Packed.Development 61import Data.Packed.Development
62import Data.Packed.ST 62import Data.Packed.ST
63import Data.Packed.Numeric(Container,Contraction,LSDiv,Product, 63import Numeric.Container(Container,Contraction,LSDiv,Product,
64 Complexable(),RealElement(), 64 Complexable(),RealElement(),
65 RealOf, ComplexOf, SingleOf, DoubleOf, IndexOf) 65 RealOf, ComplexOf, SingleOf, DoubleOf, IndexOf)
66import Data.Packed 66import Data.Packed
diff --git a/packages/base/src/Numeric/LinearAlgebra/Random.hs b/packages/base/src/Numeric/LinearAlgebra/Random.hs
index b36c7a3..7afd658 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Random.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Random.hs
@@ -20,7 +20,7 @@ module Numeric.LinearAlgebra.Random (
20) where 20) where
21 21
22import Numeric.Vectorized 22import Numeric.Vectorized
23import Data.Packed.Numeric 23import Numeric.Container
24import Numeric.LinearAlgebra.Algorithms 24import Numeric.LinearAlgebra.Algorithms
25import System.Random(randomIO) 25import System.Random(randomIO)
26 26
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util.hs b/packages/base/src/Numeric/LinearAlgebra/Util.hs
index 440f6d1..2f91e18 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util.hs
@@ -48,7 +48,7 @@ module Numeric.LinearAlgebra.Util(
48 vtrans 48 vtrans
49) where 49) where
50 50
51import Data.Packed.Numeric 51import Numeric.Container
52import Numeric.LinearAlgebra.Algorithms hiding (i) 52import Numeric.LinearAlgebra.Algorithms hiding (i)
53import Numeric.Matrix() 53import Numeric.Matrix()
54import Numeric.Vector() 54import Numeric.Vector()
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs b/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs
index 1d4e089..e4cba8f 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs
@@ -16,7 +16,7 @@ module Numeric.LinearAlgebra.Util.Convolution(
16 corr2, conv2, separable 16 corr2, conv2, separable
17) where 17) where
18 18
19import Data.Packed.Numeric 19import Numeric.Container
20 20
21 21
22vectSS :: Element t => Int -> Vector t -> Matrix t 22vectSS :: Element t => Int -> Vector t -> Matrix t
diff --git a/packages/hmatrix/hmatrix.cabal b/packages/hmatrix/hmatrix.cabal
index a61c64f..83a2188 100644
--- a/packages/hmatrix/hmatrix.cabal
+++ b/packages/hmatrix/hmatrix.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix 1Name: hmatrix-gsl
2Version: 0.16.0.1 2Version: 0.16.0.0
3License: GPL 3License: GPL
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -73,7 +73,7 @@ flag debugnan
73 73
74library 74library
75 75
76 Build-Depends: base, hmatrix-base, array, vector, 76 Build-Depends: base, hmatrix, array, vector,
77 process, random 77 process, random
78 78
79 79
@@ -90,13 +90,12 @@ library
90 Numeric.GSL.Fitting, 90 Numeric.GSL.Fitting,
91 Numeric.GSL.ODE, 91 Numeric.GSL.ODE,
92 Numeric.GSL, 92 Numeric.GSL,
93 Numeric.LinearAlgebra, 93 Numeric.GSL.LinearAlgebra,
94 Numeric.Container,
95 Graphics.Plot 94 Graphics.Plot
96 other-modules: Numeric.GSL.Internal, 95 other-modules: Numeric.GSL.Internal,
97 Numeric.GSL.LinearAlgebra, 96 Numeric.GSL.Vector,
98 Numeric.LinearAlgebra.IO, 97 Numeric.GSL.IO,
99 Numeric.LinearAlgebra.Random 98 Numeric.GSL.Random
100 99
101 100
102 C-sources: src/Numeric/GSL/gsl-aux.c 101 C-sources: src/Numeric/GSL/gsl-aux.c
diff --git a/packages/hmatrix/src/Numeric/Container.hs b/packages/hmatrix/src/Numeric/Container.hs
deleted file mode 100644
index 2b61d90..0000000
--- a/packages/hmatrix/src/Numeric/Container.hs
+++ /dev/null
@@ -1,23 +0,0 @@
1-----------------------------------------------------------------------------
2{- |
3Module : Numeric.Container
4Copyright : (c) Alberto Ruiz 2006-14
5License : GPL
6Maintainer : Alberto Ruiz
7Stability : provisional
8
9-}
10-----------------------------------------------------------------------------
11
12module Numeric.Container (
13 module Data.Packed.Numeric,
14 module Numeric.LinearAlgebra.IO,
15 module Numeric.LinearAlgebra.Random,
16 meanCov
17) where
18
19import Data.Packed.Numeric hiding (saveMatrix, loadMatrix)
20import Numeric.LinearAlgebra.IO
21import Numeric.LinearAlgebra.Random hiding (Seed)
22import Numeric.LinearAlgebra.Util(meanCov)
23
diff --git a/packages/hmatrix/src/Numeric/GSL/Fitting.hs b/packages/hmatrix/src/Numeric/GSL/Fitting.hs
index 0a92373..93fb281 100644
--- a/packages/hmatrix/src/Numeric/GSL/Fitting.hs
+++ b/packages/hmatrix/src/Numeric/GSL/Fitting.hs
@@ -116,7 +116,7 @@ err (model,deriv) dat vsol = zip sol errs where
116 dof = length dat - (rows cov) 116 dof = length dat - (rows cov)
117 chi = norm2 (fromList $ cost (resMs model) dat sol) 117 chi = norm2 (fromList $ cost (resMs model) dat sol)
118 js = fromLists $ jacobian (resDs deriv) dat sol 118 js = fromLists $ jacobian (resDs deriv) dat sol
119 cov = inv $ trans js <> js 119 cov = inv $ trans js <.> js
120 errs = toList $ scalar c * sqrt (takeDiag cov) 120 errs = toList $ scalar c * sqrt (takeDiag cov)
121 121
122 122
diff --git a/packages/hmatrix/src/Numeric/LinearAlgebra/IO.hs b/packages/hmatrix/src/Numeric/GSL/IO.hs
index d2278ee..0d6031a 100644
--- a/packages/hmatrix/src/Numeric/LinearAlgebra/IO.hs
+++ b/packages/hmatrix/src/Numeric/GSL/IO.hs
@@ -1,6 +1,6 @@
1----------------------------------------------------------------------------- 1-----------------------------------------------------------------------------
2-- | 2-- |
3-- Module : Numeric.LinearAlgebra.IO 3-- Module : Numeric.GSL.IO
4-- Copyright : (c) Alberto Ruiz 2007-14 4-- Copyright : (c) Alberto Ruiz 2007-14
5-- License : GPL 5-- License : GPL
6-- Maintainer : Alberto Ruiz 6-- Maintainer : Alberto Ruiz
@@ -8,14 +8,14 @@
8-- 8--
9----------------------------------------------------------------------------- 9-----------------------------------------------------------------------------
10 10
11module Numeric.LinearAlgebra.IO ( 11module Numeric.GSL.IO (
12 saveMatrix, 12 saveMatrix,
13 fwriteVector, freadVector, fprintfVector, fscanfVector, 13 fwriteVector, freadVector, fprintfVector, fscanfVector,
14 fileDimensions, loadMatrix, fromFile 14 fileDimensions, loadMatrix, fromFile
15) where 15) where
16 16
17import Data.Packed 17import Data.Packed
18import Numeric.GSL.LinearAlgebra 18import Numeric.GSL.Vector
19import System.Process(readProcess) 19import System.Process(readProcess)
20 20
21 21
diff --git a/packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs b/packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs
index 8bd0cc2..17e2258 100644
--- a/packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs
+++ b/packages/hmatrix/src/Numeric/GSL/LinearAlgebra.hs
@@ -9,13 +9,13 @@
9----------------------------------------------------------------------------- 9-----------------------------------------------------------------------------
10 10
11module Numeric.GSL.LinearAlgebra ( 11module Numeric.GSL.LinearAlgebra (
12 randomVector, 12 RandDist(..), randomVector,
13 saveMatrix, 13 saveMatrix,
14 fwriteVector, freadVector, fprintfVector, fscanfVector 14 fwriteVector, freadVector, fprintfVector, fscanfVector,
15 fileDimensions, loadMatrix, fromFile
15) where 16) where
16 17
17import Data.Packed 18import Data.Packed
18import Numeric.LinearAlgebra.Base(RandDist(..))
19import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) 19import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM)
20 20
21import Foreign.Marshal.Alloc(free) 21import Foreign.Marshal.Alloc(free)
@@ -23,11 +23,16 @@ import Foreign.Ptr(Ptr)
23import Foreign.C.Types 23import Foreign.C.Types
24import Foreign.C.String(newCString) 24import Foreign.C.String(newCString)
25import System.IO.Unsafe(unsafePerformIO) 25import System.IO.Unsafe(unsafePerformIO)
26import System.Process(readProcess)
26 27
27fromei x = fromIntegral (fromEnum x) :: CInt 28fromei x = fromIntegral (fromEnum x) :: CInt
28 29
29----------------------------------------------------------------------- 30-----------------------------------------------------------------------
30 31
32data RandDist = Uniform -- ^ uniform distribution in [0,1)
33 | Gaussian -- ^ normal distribution with mean zero and standard deviation one
34 deriving Enum
35
31-- | Obtains a vector of pseudorandom elements from the the mt19937 generator in GSL, with a given seed. Use randomIO to get a random seed. 36-- | Obtains a vector of pseudorandom elements from the the mt19937 generator in GSL, with a given seed. Use randomIO to get a random seed.
32randomVector :: Int -- ^ seed 37randomVector :: Int -- ^ seed
33 -> RandDist -- ^ distribution 38 -> RandDist -- ^ distribution
@@ -35,10 +40,10 @@ randomVector :: Int -- ^ seed
35 -> Vector Double 40 -> Vector Double
36randomVector seed dist n = unsafePerformIO $ do 41randomVector seed dist n = unsafePerformIO $ do
37 r <- createVector n 42 r <- createVector n
38 app1 (c_random_vector_GSL (fi seed) ((fi.fromEnum) dist)) vec r "randomVectorGSL" 43 app1 (c_random_vector (fi seed) ((fi.fromEnum) dist)) vec r "randomVector"
39 return r 44 return r
40 45
41foreign import ccall unsafe "random_vector_GSL" c_random_vector_GSL :: CInt -> CInt -> TV 46foreign import ccall unsafe "random_vector" c_random_vector :: CInt -> CInt -> TV
42 47
43-------------------------------------------------------------------------------- 48--------------------------------------------------------------------------------
44 49
@@ -105,3 +110,26 @@ type PD = Ptr Double --
105type TV = CInt -> PD -> IO CInt -- 110type TV = CInt -> PD -> IO CInt --
106type TM = CInt -> CInt -> PD -> IO CInt -- 111type TM = CInt -> CInt -> PD -> IO CInt --
107 112
113--------------------------------------------------------------------------------
114
115{- | obtains the number of rows and columns in an ASCII data file
116 (provisionally using unix's wc).
117-}
118fileDimensions :: FilePath -> IO (Int,Int)
119fileDimensions fname = do
120 wcres <- readProcess "wc" ["-w",fname] ""
121 contents <- readFile fname
122 let tot = read . head . words $ wcres
123 c = length . head . dropWhile null . map words . lines $ contents
124 if tot > 0
125 then return (tot `div` c, c)
126 else return (0,0)
127
128-- | Loads a matrix from an ASCII file formatted as a 2D table.
129loadMatrix :: FilePath -> IO (Matrix Double)
130loadMatrix file = fromFile file =<< fileDimensions file
131
132-- | Loads a matrix from an ASCII file (the number of rows and columns must be known in advance).
133fromFile :: FilePath -> (Int,Int) -> IO (Matrix Double)
134fromFile filename (r,c) = reshape c `fmap` fscanfVector filename (r*c)
135
diff --git a/packages/hmatrix/src/Numeric/LinearAlgebra/Random.hs b/packages/hmatrix/src/Numeric/GSL/Random.hs
index fa125a0..2872b17 100644
--- a/packages/hmatrix/src/Numeric/LinearAlgebra/Random.hs
+++ b/packages/hmatrix/src/Numeric/GSL/Random.hs
@@ -1,6 +1,6 @@
1----------------------------------------------------------------------------- 1-----------------------------------------------------------------------------
2-- | 2-- |
3-- Module : Numeric.LinearAlgebra.Random 3-- Module : Numeric.GSL.Random
4-- Copyright : (c) Alberto Ruiz 2009-14 4-- Copyright : (c) Alberto Ruiz 2009-14
5-- License : GPL 5-- License : GPL
6-- 6--
@@ -11,7 +11,7 @@
11-- 11--
12----------------------------------------------------------------------------- 12-----------------------------------------------------------------------------
13 13
14module Numeric.LinearAlgebra.Random ( 14module Numeric.GSL.Random (
15 Seed, 15 Seed,
16 RandDist(..), 16 RandDist(..),
17 randomVector, 17 randomVector,
@@ -20,9 +20,9 @@ module Numeric.LinearAlgebra.Random (
20 rand, randn 20 rand, randn
21) where 21) where
22 22
23import Numeric.GSL.LinearAlgebra 23import Numeric.GSL.Vector
24import Data.Packed.Numeric 24import Numeric.Container
25import Numeric.LinearAlgebra.Base(Seed,RandDist(..),cholSH) 25import Numeric.LinearAlgebra(Seed,RandDist(..),cholSH)
26import System.Random(randomIO) 26import System.Random(randomIO)
27 27
28 28
diff --git a/packages/hmatrix/src/Numeric/LinearAlgebra/GSL.hs b/packages/hmatrix/src/Numeric/GSL/Vector.hs
index 1fde621..af79f32 100644
--- a/packages/hmatrix/src/Numeric/LinearAlgebra/GSL.hs
+++ b/packages/hmatrix/src/Numeric/GSL/Vector.hs
@@ -1,6 +1,6 @@
1----------------------------------------------------------------------------- 1-----------------------------------------------------------------------------
2-- | 2-- |
3-- Module : Numeric.LinearAlgebra.GSL 3-- Module : Numeric.GSL.Vector
4-- Copyright : (c) Alberto Ruiz 2007-14 4-- Copyright : (c) Alberto Ruiz 2007-14
5-- License : GPL 5-- License : GPL
6-- Maintainer : Alberto Ruiz 6-- Maintainer : Alberto Ruiz
@@ -8,32 +8,26 @@
8-- 8--
9----------------------------------------------------------------------------- 9-----------------------------------------------------------------------------
10 10
11module Numeric.LinearAlgebra.GSL ( 11module Numeric.GSL.Vector (
12 RandDist(..), randomVector, 12 randomVector,
13 saveMatrix, 13 saveMatrix,
14 fwriteVector, freadVector, fprintfVector, fscanfVector, 14 fwriteVector, freadVector, fprintfVector, fscanfVector
15 fileDimensions, loadMatrix, fromFile
16) where 15) where
17 16
18import Data.Packed 17import Data.Packed
18import Numeric.LinearAlgebra(RandDist(..))
19import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) 19import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM)
20 20
21import Data.Complex
22import Foreign.Marshal.Alloc(free) 21import Foreign.Marshal.Alloc(free)
23import Foreign.Ptr(Ptr) 22import Foreign.Ptr(Ptr)
24import Foreign.C.Types 23import Foreign.C.Types
25import Foreign.C.String(newCString) 24import Foreign.C.String(newCString)
26import System.IO.Unsafe(unsafePerformIO) 25import System.IO.Unsafe(unsafePerformIO)
27import System.Process(readProcess)
28 26
29fromei x = fromIntegral (fromEnum x) :: CInt 27fromei x = fromIntegral (fromEnum x) :: CInt
30 28
31----------------------------------------------------------------------- 29-----------------------------------------------------------------------
32 30
33data RandDist = Uniform -- ^ uniform distribution in [0,1)
34 | Gaussian -- ^ normal distribution with mean zero and standard deviation one
35 deriving Enum
36
37-- | Obtains a vector of pseudorandom elements from the the mt19937 generator in GSL, with a given seed. Use randomIO to get a random seed. 31-- | Obtains a vector of pseudorandom elements from the the mt19937 generator in GSL, with a given seed. Use randomIO to get a random seed.
38randomVector :: Int -- ^ seed 32randomVector :: Int -- ^ seed
39 -> RandDist -- ^ distribution 33 -> RandDist -- ^ distribution
@@ -41,10 +35,10 @@ randomVector :: Int -- ^ seed
41 -> Vector Double 35 -> Vector Double
42randomVector seed dist n = unsafePerformIO $ do 36randomVector seed dist n = unsafePerformIO $ do
43 r <- createVector n 37 r <- createVector n
44 app1 (c_random_vector (fi seed) ((fi.fromEnum) dist)) vec r "randomVector" 38 app1 (c_random_vector_GSL (fi seed) ((fi.fromEnum) dist)) vec r "randomVectorGSL"
45 return r 39 return r
46 40
47foreign import ccall unsafe "random_vector" c_random_vector :: CInt -> CInt -> TV 41foreign import ccall unsafe "random_vector_GSL" c_random_vector_GSL :: CInt -> CInt -> TV
48 42
49-------------------------------------------------------------------------------- 43--------------------------------------------------------------------------------
50 44
@@ -111,26 +105,3 @@ type PD = Ptr Double --
111type TV = CInt -> PD -> IO CInt -- 105type TV = CInt -> PD -> IO CInt --
112type TM = CInt -> CInt -> PD -> IO CInt -- 106type TM = CInt -> CInt -> PD -> IO CInt --
113 107
114--------------------------------------------------------------------------------
115
116{- | obtains the number of rows and columns in an ASCII data file
117 (provisionally using unix's wc).
118-}
119fileDimensions :: FilePath -> IO (Int,Int)
120fileDimensions fname = do
121 wcres <- readProcess "wc" ["-w",fname] ""
122 contents <- readFile fname
123 let tot = read . head . words $ wcres
124 c = length . head . dropWhile null . map words . lines $ contents
125 if tot > 0
126 then return (tot `div` c, c)
127 else return (0,0)
128
129-- | Loads a matrix from an ASCII file formatted as a 2D table.
130loadMatrix :: FilePath -> IO (Matrix Double)
131loadMatrix file = fromFile file =<< fileDimensions file
132
133-- | Loads a matrix from an ASCII file (the number of rows and columns must be known in advance).
134fromFile :: FilePath -> (Int,Int) -> IO (Matrix Double)
135fromFile filename (r,c) = reshape c `fmap` fscanfVector filename (r*c)
136
diff --git a/packages/hmatrix/src/Numeric/LinearAlgebra.hs b/packages/hmatrix/src/Numeric/LinearAlgebra.hs
deleted file mode 100644
index 71ed808..0000000
--- a/packages/hmatrix/src/Numeric/LinearAlgebra.hs
+++ /dev/null
@@ -1,20 +0,0 @@
1-----------------------------------------------------------------------------
2{- |
3Module : Numeric.LinearAlgebra
4Copyright : (c) Alberto Ruiz 2006-14
5License : GPL
6Maintainer : Alberto Ruiz
7Stability : provisional
8
9-}
10-----------------------------------------------------------------------------
11
12module Numeric.LinearAlgebra (
13 module Numeric.Container,
14 module Numeric.LinearAlgebra.Algorithms,
15) where
16
17import Numeric.Container
18import Numeric.LinearAlgebra.Algorithms
19import Numeric.LinearAlgebra.Util()
20