summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/base/hmatrix.cabal34
-rw-r--r--packages/base/src/Data/Packed/IO.hs1
-rw-r--r--packages/base/src/Data/Packed/Internal/Numeric.hs1
-rw-r--r--packages/base/src/Data/Packed/Internal/Vector.hs1
-rw-r--r--packages/base/src/Data/Packed/Numeric.hs1
-rw-r--r--packages/base/src/Numeric/Chain.hs2
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Algorithms.hs5
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Static.hs28
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util/CG.hs6
-rw-r--r--packages/base/src/Numeric/Vectorized.hs1
-rw-r--r--packages/glpk/hmatrix-glpk.cabal4
-rw-r--r--packages/glpk/src/Numeric/LinearProgramming.hs21
-rw-r--r--packages/glpk/src/Numeric/LinearProgramming/L1.hs2
-rw-r--r--packages/gsl/hmatrix-gsl.cabal4
-rw-r--r--packages/gsl/src/Graphics/Plot.hs4
-rw-r--r--packages/gsl/src/Numeric/GSL/Fitting.hs16
-rw-r--r--packages/gsl/src/Numeric/GSL/Fourier.hs5
-rw-r--r--packages/gsl/src/Numeric/GSL/IO.hs2
-rw-r--r--packages/gsl/src/Numeric/GSL/Internal.hs7
-rw-r--r--packages/gsl/src/Numeric/GSL/LinearAlgebra.hs2
-rw-r--r--packages/gsl/src/Numeric/GSL/Minimization.hs17
-rw-r--r--packages/gsl/src/Numeric/GSL/ODE.hs16
-rw-r--r--packages/gsl/src/Numeric/GSL/Polynomials.hs7
-rw-r--r--packages/gsl/src/Numeric/GSL/Random.hs16
-rw-r--r--packages/gsl/src/Numeric/GSL/Root.hs18
-rw-r--r--packages/gsl/src/Numeric/GSL/Vector.hs3
-rw-r--r--packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs7
-rw-r--r--packages/special/hmatrix-special.cabal4
-rw-r--r--packages/special/lib/Numeric/GSL/Special/Internal.hsc2
29 files changed, 110 insertions, 127 deletions
diff --git a/packages/base/hmatrix.cabal b/packages/base/hmatrix.cabal
index 3895dc1..350023f 100644
--- a/packages/base/hmatrix.cabal
+++ b/packages/base/hmatrix.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix 1Name: hmatrix
2Version: 0.16.1.5 2Version: 0.17.0.0
3License: BSD3 3License: BSD3
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -39,7 +39,7 @@ flag openblas
39 39
40library 40library
41 41
42 Build-Depends: base >= 4 && < 5, 42 Build-Depends: base >= 4.8 && < 5,
43 binary, 43 binary,
44 array, 44 array,
45 deepseq, 45 deepseq,
@@ -51,27 +51,19 @@ library
51 51
52 hs-source-dirs: src 52 hs-source-dirs: src
53 53
54 exposed-modules: Data.Packed, 54 exposed-modules: Numeric.LinearAlgebra.Devel
55 Data.Packed.Vector,
56 Data.Packed.Matrix,
57 Data.Packed.Foreign,
58 Data.Packed.ST,
59 Data.Packed.Development,
60
61 Numeric.LinearAlgebra
62 Numeric.LinearAlgebra.LAPACK
63 Numeric.LinearAlgebra.Algorithms
64 Numeric.Container
65 Numeric.LinearAlgebra.Util
66
67 Numeric.LinearAlgebra.Devel
68 Numeric.LinearAlgebra.Data 55 Numeric.LinearAlgebra.Data
69 Numeric.LinearAlgebra.HMatrix 56 Numeric.LinearAlgebra.HMatrix
70 Numeric.LinearAlgebra.Static 57 Numeric.LinearAlgebra.Static
71 58 Numeric.LinearAlgebra.Util
72
73 59
74 other-modules: Data.Packed.Internal, 60 other-modules: Data.Packed,
61 Data.Packed.Vector
62 Data.Packed.Matrix
63 Data.Packed.Foreign
64 Data.Packed.ST
65 Data.Packed.Development
66 Data.Packed.Internal
75 Data.Packed.Internal.Common 67 Data.Packed.Internal.Common
76 Data.Packed.Internal.Signatures 68 Data.Packed.Internal.Signatures
77 Data.Packed.Internal.Vector 69 Data.Packed.Internal.Vector
@@ -83,6 +75,10 @@ library
83 Numeric.Matrix 75 Numeric.Matrix
84 Data.Packed.Internal.Numeric 76 Data.Packed.Internal.Numeric
85 Data.Packed.Numeric 77 Data.Packed.Numeric
78 Numeric.LinearAlgebra
79 Numeric.LinearAlgebra.LAPACK
80 Numeric.LinearAlgebra.Algorithms
81 Numeric.Container
86 Numeric.LinearAlgebra.Util.Convolution 82 Numeric.LinearAlgebra.Util.Convolution
87 Numeric.LinearAlgebra.Util.CG 83 Numeric.LinearAlgebra.Util.CG
88 Numeric.LinearAlgebra.Random 84 Numeric.LinearAlgebra.Random
diff --git a/packages/base/src/Data/Packed/IO.hs b/packages/base/src/Data/Packed/IO.hs
index 85f1b37..b0999a8 100644
--- a/packages/base/src/Data/Packed/IO.hs
+++ b/packages/base/src/Data/Packed/IO.hs
@@ -22,7 +22,6 @@ import Text.Printf(printf)
22import Data.List(intersperse) 22import Data.List(intersperse)
23import Data.Complex 23import Data.Complex
24import Numeric.Vectorized(vectorScan,saveMatrix) 24import Numeric.Vectorized(vectorScan,saveMatrix)
25import Control.Applicative((<$>))
26import Data.Packed.Internal 25import Data.Packed.Internal
27 26
28{- | Creates a string from a matrix given a separator and a function to show each entry. Using 27{- | Creates a string from a matrix given a separator and a function to show each entry. Using
diff --git a/packages/base/src/Data/Packed/Internal/Numeric.hs b/packages/base/src/Data/Packed/Internal/Numeric.hs
index 257ad73..7a4dd29 100644
--- a/packages/base/src/Data/Packed/Internal/Numeric.hs
+++ b/packages/base/src/Data/Packed/Internal/Numeric.hs
@@ -48,7 +48,6 @@ import Numeric.Conversion
48import Data.Packed.Development 48import Data.Packed.Development
49import Numeric.Vectorized 49import Numeric.Vectorized
50import Data.Complex 50import Data.Complex
51import Control.Applicative((<*>))
52 51
53import Numeric.LinearAlgebra.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ) 52import Numeric.LinearAlgebra.LAPACK(multiplyR,multiplyC,multiplyF,multiplyQ)
54import Data.Packed.Internal 53import Data.Packed.Internal
diff --git a/packages/base/src/Data/Packed/Internal/Vector.hs b/packages/base/src/Data/Packed/Internal/Vector.hs
index d0bc143..b49f379 100644
--- a/packages/base/src/Data/Packed/Internal/Vector.hs
+++ b/packages/base/src/Data/Packed/Internal/Vector.hs
@@ -35,7 +35,6 @@ import Foreign.Ptr(Ptr)
35import Foreign.Storable(Storable, peekElemOff, pokeElemOff, sizeOf) 35import Foreign.Storable(Storable, peekElemOff, pokeElemOff, sizeOf)
36import Foreign.C.Types 36import Foreign.C.Types
37import Data.Complex 37import Data.Complex
38import Control.Monad(when)
39import System.IO.Unsafe(unsafePerformIO) 38import System.IO.Unsafe(unsafePerformIO)
40 39
41#if __GLASGOW_HASKELL__ >= 605 40#if __GLASGOW_HASKELL__ >= 605
diff --git a/packages/base/src/Data/Packed/Numeric.hs b/packages/base/src/Data/Packed/Numeric.hs
index 6027f43..b2395f2 100644
--- a/packages/base/src/Data/Packed/Numeric.hs
+++ b/packages/base/src/Data/Packed/Numeric.hs
@@ -71,7 +71,6 @@ import Data.Packed
71import Data.Packed.Internal.Numeric 71import Data.Packed.Internal.Numeric
72import Data.Complex 72import Data.Complex
73import Numeric.LinearAlgebra.Algorithms(Field,linearSolveSVD) 73import Numeric.LinearAlgebra.Algorithms(Field,linearSolveSVD)
74import Data.Monoid(Monoid(mconcat))
75import Data.Packed.IO 74import Data.Packed.IO
76import Numeric.LinearAlgebra.Random 75import Numeric.LinearAlgebra.Random
77 76
diff --git a/packages/base/src/Numeric/Chain.hs b/packages/base/src/Numeric/Chain.hs
index 443bd28..64c09c0 100644
--- a/packages/base/src/Numeric/Chain.hs
+++ b/packages/base/src/Numeric/Chain.hs
@@ -1,3 +1,5 @@
1{-# LANGUAGE FlexibleContexts #-}
2
1----------------------------------------------------------------------------- 3-----------------------------------------------------------------------------
2-- | 4-- |
3-- Module : Numeric.Chain 5-- Module : Numeric.Chain
diff --git a/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs b/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
index 02ac6a0..a113d48 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
@@ -935,10 +935,9 @@ relativeError' x y = dig (norm (x `sub` y) / norm x)
935 dig r = round $ -logBase 10 (realToFrac r :: Double) 935 dig r = round $ -logBase 10 (realToFrac r :: Double)
936 936
937 937
938relativeError :: (Normed c t, Num (c t)) => NormType -> c t -> c t -> Double 938relativeError :: Num a => (a -> Double) -> a -> a -> Double
939relativeError t a b = realToFrac r 939relativeError norm a b = r
940 where 940 where
941 norm = pnorm t
942 na = norm a 941 na = norm a
943 nb = norm b 942 nb = norm b
944 nab = norm (a-b) 943 nab = norm (a-b)
diff --git a/packages/base/src/Numeric/LinearAlgebra/Static.hs b/packages/base/src/Numeric/LinearAlgebra/Static.hs
index 3398e6a..4c3186f 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Static.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Static.hs
@@ -1,5 +1,3 @@
1#if __GLASGOW_HASKELL__ >= 708
2
3{-# LANGUAGE DataKinds #-} 1{-# LANGUAGE DataKinds #-}
4{-# LANGUAGE KindSignatures #-} 2{-# LANGUAGE KindSignatures #-}
5{-# LANGUAGE GeneralizedNewtypeDeriving #-} 3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -13,7 +11,6 @@
13{-# LANGUAGE TypeOperators #-} 11{-# LANGUAGE TypeOperators #-}
14{-# LANGUAGE ViewPatterns #-} 12{-# LANGUAGE ViewPatterns #-}
15{-# LANGUAGE GADTs #-} 13{-# LANGUAGE GADTs #-}
16{-# LANGUAGE OverlappingInstances #-}
17{-# LANGUAGE TypeFamilies #-} 14{-# LANGUAGE TypeFamilies #-}
18 15
19 16
@@ -184,8 +181,9 @@ a ¦ b = tr (tr a —— tr b)
184type Sq n = L n n 181type Sq n = L n n
185--type CSq n = CL n n 182--type CSq n = CL n n
186 183
187type GL = forall n m. (KnownNat n, KnownNat m) => L m n 184
188type GSq = forall n. KnownNat n => Sq n 185type GL = forall n m . (KnownNat n, KnownNat m) => L m n
186type GSq = forall n . KnownNat n => Sq n
189 187
190isKonst :: forall m n . (KnownNat m, KnownNat n) => L m n -> Maybe (ℝ,(Int,Int)) 188isKonst :: forall m n . (KnownNat m, KnownNat n) => L m n -> Maybe (ℝ,(Int,Int))
191isKonst s@(unwrap -> x) 189isKonst s@(unwrap -> x)
@@ -618,23 +616,3 @@ instance (KnownNat n', KnownNat m') => Testable (L n' m')
618 where 616 where
619 checkT _ = test 617 checkT _ = test
620 618
621#else
622
623{- |
624Module : Numeric.LinearAlgebra.Static
625Copyright : (c) Alberto Ruiz 2014
626License : BSD3
627Stability : experimental
628
629Experimental interface with statically checked dimensions.
630
631This module requires GHC >= 7.8
632
633-}
634
635module Numeric.LinearAlgebra.Static
636{-# WARNING "This module requires GHC >= 7.8" #-}
637where
638
639#endif
640
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs b/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs
index b82c74f..899a5bf 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util/CG.hs
@@ -9,7 +9,7 @@ module Numeric.LinearAlgebra.Util.CG(
9import Data.Packed.Numeric 9import Data.Packed.Numeric
10import Numeric.Sparse 10import Numeric.Sparse
11import Numeric.Vector() 11import Numeric.Vector()
12import Numeric.LinearAlgebra.Algorithms(linearSolveLS, relativeError, NormType(..)) 12import Numeric.LinearAlgebra.Algorithms(linearSolveLS, relativeError, pnorm, NormType(..))
13import Control.Arrow((***)) 13import Control.Arrow((***))
14 14
15{- 15{-
@@ -142,13 +142,13 @@ instance Testable GMatrix
142 print s3; print d3 142 print s3; print d3
143 print s4; print d4 143 print s4; print d4
144 print s5; print d5 144 print s5; print d5
145 print $ relativeError Infinity s5 d5 145 print $ relativeError (pnorm Infinity) s5 d5
146 146
147 ok = s1==d1 147 ok = s1==d1
148 && s2==d2 148 && s2==d2
149 && s3==d3 149 && s3==d3
150 && s4==d4 150 && s4==d4
151 && relativeError Infinity s5 d5 < 1E-10 151 && relativeError (pnorm Infinity) s5 d5 < 1E-10
152 152
153 disp = putStr . dispf 2 153 disp = putStr . dispf 2
154 154
diff --git a/packages/base/src/Numeric/Vectorized.hs b/packages/base/src/Numeric/Vectorized.hs
index 6f0d240..405ae01 100644
--- a/packages/base/src/Numeric/Vectorized.hs
+++ b/packages/base/src/Numeric/Vectorized.hs
@@ -37,7 +37,6 @@ import Foreign.C.String
37import System.IO.Unsafe(unsafePerformIO) 37import System.IO.Unsafe(unsafePerformIO)
38 38
39import Control.Monad(when) 39import Control.Monad(when)
40import Control.Applicative((<$>))
41 40
42 41
43 42
diff --git a/packages/glpk/hmatrix-glpk.cabal b/packages/glpk/hmatrix-glpk.cabal
index 5a1b59c..8593e0a 100644
--- a/packages/glpk/hmatrix-glpk.cabal
+++ b/packages/glpk/hmatrix-glpk.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix-glpk 1Name: hmatrix-glpk
2Version: 0.4.1.0 2Version: 0.5.0.0
3License: GPL 3License: GPL
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -23,7 +23,7 @@ extra-source-files: examples/simplex1.hs
23 examples/simplex5.hs 23 examples/simplex5.hs
24 24
25library 25library
26 Build-Depends: base <5, hmatrix >= 0.16, containers >= 0.5.4.0 26 Build-Depends: base <5, hmatrix >= 0.17, containers
27 27
28 hs-source-dirs: src 28 hs-source-dirs: src
29 29
diff --git a/packages/glpk/src/Numeric/LinearProgramming.hs b/packages/glpk/src/Numeric/LinearProgramming.hs
index 6a0c47d..7bf4279 100644
--- a/packages/glpk/src/Numeric/LinearProgramming.hs
+++ b/packages/glpk/src/Numeric/LinearProgramming.hs
@@ -85,8 +85,8 @@ module Numeric.LinearProgramming(
85 Solution(..) 85 Solution(..)
86) where 86) where
87 87
88import Data.Packed 88import Numeric.LinearAlgebra.HMatrix
89import Data.Packed.Development 89import Numeric.LinearAlgebra.Devel hiding (Dense)
90import Foreign(Ptr) 90import Foreign(Ptr)
91import System.IO.Unsafe(unsafePerformIO) 91import System.IO.Unsafe(unsafePerformIO)
92import Foreign.C.Types 92import Foreign.C.Types
@@ -180,16 +180,17 @@ exact opt constr@(General _) bnds = exact opt (sparseOfGeneral constr) bnds
180 180
181adapt :: Optimization -> (Int, Double, [Double]) 181adapt :: Optimization -> (Int, Double, [Double])
182adapt opt = case opt of 182adapt opt = case opt of
183 Maximize x -> (size x, 1 ,x) 183 Maximize x -> (sz x, 1 ,x)
184 Minimize x -> (size x, -1, (map negate x)) 184 Minimize x -> (sz x, -1, (map negate x))
185 where size x | null x = error "simplex: objective function with zero variables" 185 where
186 | otherwise = length x 186 sz x | null x = error "simplex: objective function with zero variables"
187 | otherwise = length x
187 188
188extract :: Double -> Vector Double -> Solution 189extract :: Double -> Vector Double -> Solution
189extract sg sol = r where 190extract sg sol = r where
190 z = sg * (sol@>1) 191 z = sg * (sol!1)
191 v = toList $ subVector 2 (dim sol -2) sol 192 v = toList $ subVector 2 (size sol -2) sol
192 r = case round(sol@>0)::Int of 193 r = case round(sol!0)::Int of
193 1 -> Undefined 194 1 -> Undefined
194 2 -> Feasible (z,v) 195 2 -> Feasible (z,v)
195 3 -> Infeasible (z,v) 196 3 -> Infeasible (z,v)
@@ -261,7 +262,7 @@ mkConstrD n f b1 | ok = fromLists (ob ++ co)
261 ok = all (==n) ls 262 ok = all (==n) ls
262 den = fromLists cs 263 den = fromLists cs
263 ob = map (([0,0]++).return) f 264 ob = map (([0,0]++).return) f
264 co = [[fromIntegral i, fromIntegral j,den@@>(i-1,j-1)]| i<-[1 ..rows den], j<-[1 .. cols den]] 265 co = [[fromIntegral i, fromIntegral j,den `atIndex` (i-1,j-1)]| i<-[1 ..rows den], j<-[1 .. cols den]]
265 266
266mkConstrS :: Int -> [Double] -> [Bound [(Double, Int)]] -> Matrix Double 267mkConstrS :: Int -> [Double] -> [Bound [(Double, Int)]] -> Matrix Double
267mkConstrS n objfun b1 = fromLists (ob ++ co) where 268mkConstrS n objfun b1 = fromLists (ob ++ co) where
diff --git a/packages/glpk/src/Numeric/LinearProgramming/L1.hs b/packages/glpk/src/Numeric/LinearProgramming/L1.hs
index f55c721..d7f1258 100644
--- a/packages/glpk/src/Numeric/LinearProgramming/L1.hs
+++ b/packages/glpk/src/Numeric/LinearProgramming/L1.hs
@@ -14,7 +14,7 @@ module Numeric.LinearProgramming.L1 (
14 l1SolveU, 14 l1SolveU,
15) where 15) where
16 16
17import Numeric.LinearAlgebra 17import Numeric.LinearAlgebra.HMatrix
18import Numeric.LinearProgramming 18import Numeric.LinearProgramming
19 19
20-- | L_inf solution of overconstrained system Ax=b. 20-- | L_inf solution of overconstrained system Ax=b.
diff --git a/packages/gsl/hmatrix-gsl.cabal b/packages/gsl/hmatrix-gsl.cabal
index 95fa3ed..70e4246 100644
--- a/packages/gsl/hmatrix-gsl.cabal
+++ b/packages/gsl/hmatrix-gsl.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix-gsl 1Name: hmatrix-gsl
2Version: 0.16.0.3 2Version: 0.17.0.0
3License: GPL 3License: GPL
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -25,7 +25,7 @@ flag onlygsl
25 25
26library 26library
27 27
28 Build-Depends: base<5, hmatrix>=0.16, array, vector, 28 Build-Depends: base<5, hmatrix>=0.17, array, vector,
29 process, random 29 process, random
30 30
31 31
diff --git a/packages/gsl/src/Graphics/Plot.hs b/packages/gsl/src/Graphics/Plot.hs
index 0ea41ac..d2ea192 100644
--- a/packages/gsl/src/Graphics/Plot.hs
+++ b/packages/gsl/src/Graphics/Plot.hs
@@ -27,13 +27,13 @@ module Graphics.Plot(
27 27
28) where 28) where
29 29
30import Numeric.Container 30import Numeric.LinearAlgebra.HMatrix
31import Data.List(intersperse) 31import Data.List(intersperse)
32import System.Process (system) 32import System.Process (system)
33 33
34-- | From vectors x and y, it generates a pair of matrices to be used as x and y arguments for matrix functions. 34-- | From vectors x and y, it generates a pair of matrices to be used as x and y arguments for matrix functions.
35meshdom :: Vector Double -> Vector Double -> (Matrix Double , Matrix Double) 35meshdom :: Vector Double -> Vector Double -> (Matrix Double , Matrix Double)
36meshdom r1 r2 = (outer r1 (constant 1 (dim r2)), outer (constant 1 (dim r1)) r2) 36meshdom r1 r2 = (outer r1 (konst 1 (size r2)), outer (konst 1 (size r1)) r2)
37 37
38 38
39{- | Draws a 3D surface representation of a real matrix. 39{- | Draws a 3D surface representation of a real matrix.
diff --git a/packages/gsl/src/Numeric/GSL/Fitting.hs b/packages/gsl/src/Numeric/GSL/Fitting.hs
index 0a92373..db9d82f 100644
--- a/packages/gsl/src/Numeric/GSL/Fitting.hs
+++ b/packages/gsl/src/Numeric/GSL/Fitting.hs
@@ -1,3 +1,5 @@
1{-# LANGUAGE FlexibleContexts #-}
2
1{- | 3{- |
2Module : Numeric.GSL.Fitting 4Module : Numeric.GSL.Fitting
3Copyright : (c) Alberto Ruiz 2010 5Copyright : (c) Alberto Ruiz 2010
@@ -50,7 +52,7 @@ module Numeric.GSL.Fitting (
50 fitModelScaled, fitModel 52 fitModelScaled, fitModel
51) where 53) where
52 54
53import Numeric.LinearAlgebra 55import Numeric.LinearAlgebra.HMatrix
54import Numeric.GSL.Internal 56import Numeric.GSL.Internal
55 57
56import Foreign.Ptr(FunPtr, freeHaskellFunPtr) 58import Foreign.Ptr(FunPtr, freeHaskellFunPtr)
@@ -80,13 +82,13 @@ nlFitting :: FittingMethod
80nlFitting method epsabs epsrel maxit fun jac xinit = nlFitGen (fi (fromEnum method)) fun jac xinit epsabs epsrel maxit 82nlFitting method epsabs epsrel maxit fun jac xinit = nlFitGen (fi (fromEnum method)) fun jac xinit epsabs epsrel maxit
81 83
82nlFitGen m f jac xiv epsabs epsrel maxit = unsafePerformIO $ do 84nlFitGen m f jac xiv epsabs epsrel maxit = unsafePerformIO $ do
83 let p = dim xiv 85 let p = size xiv
84 n = dim (f xiv) 86 n = size (f xiv)
85 fp <- mkVecVecfun (aux_vTov (checkdim1 n p . f)) 87 fp <- mkVecVecfun (aux_vTov (checkdim1 n p . f))
86 jp <- mkVecMatfun (aux_vTom (checkdim2 n p . jac)) 88 jp <- mkVecMatfun (aux_vTom (checkdim2 n p . jac))
87 rawpath <- createMatrix RowMajor maxit (2+p) 89 rawpath <- createMatrix RowMajor maxit (2+p)
88 app2 (c_nlfit m fp jp epsabs epsrel (fi maxit) (fi n)) vec xiv mat rawpath "c_nlfit" 90 app2 (c_nlfit m fp jp epsabs epsrel (fi maxit) (fi n)) vec xiv mat rawpath "c_nlfit"
89 let it = round (rawpath @@> (maxit-1,0)) 91 let it = round (rawpath `atIndex` (maxit-1,0))
90 path = takeRows it rawpath 92 path = takeRows it rawpath
91 [sol] = toRows $ dropRows (it-1) path 93 [sol] = toRows $ dropRows (it-1) path
92 freeHaskellFunPtr fp 94 freeHaskellFunPtr fp
@@ -99,7 +101,7 @@ foreign import ccall safe "nlfit"
99------------------------------------------------------- 101-------------------------------------------------------
100 102
101checkdim1 n _p v 103checkdim1 n _p v
102 | dim v == n = v 104 | size v == n = v
103 | otherwise = error $ "Error: "++ show n 105 | otherwise = error $ "Error: "++ show n
104 ++ " components expected in the result of the function supplied to nlFitting" 106 ++ " components expected in the result of the function supplied to nlFitting"
105 107
@@ -114,9 +116,9 @@ err (model,deriv) dat vsol = zip sol errs where
114 sol = toList vsol 116 sol = toList vsol
115 c = max 1 (chi/sqrt (fromIntegral dof)) 117 c = max 1 (chi/sqrt (fromIntegral dof))
116 dof = length dat - (rows cov) 118 dof = length dat - (rows cov)
117 chi = norm2 (fromList $ cost (resMs model) dat sol) 119 chi = norm_2 (fromList $ cost (resMs model) dat sol)
118 js = fromLists $ jacobian (resDs deriv) dat sol 120 js = fromLists $ jacobian (resDs deriv) dat sol
119 cov = inv $ trans js <> js 121 cov = inv $ tr js <> js
120 errs = toList $ scalar c * sqrt (takeDiag cov) 122 errs = toList $ scalar c * sqrt (takeDiag cov)
121 123
122 124
diff --git a/packages/gsl/src/Numeric/GSL/Fourier.hs b/packages/gsl/src/Numeric/GSL/Fourier.hs
index 734325b..d824b4f 100644
--- a/packages/gsl/src/Numeric/GSL/Fourier.hs
+++ b/packages/gsl/src/Numeric/GSL/Fourier.hs
@@ -16,14 +16,13 @@ module Numeric.GSL.Fourier (
16 ifft 16 ifft
17) where 17) where
18 18
19import Data.Packed 19import Numeric.LinearAlgebra.HMatrix
20import Numeric.GSL.Internal 20import Numeric.GSL.Internal
21import Data.Complex
22import Foreign.C.Types 21import Foreign.C.Types
23import System.IO.Unsafe (unsafePerformIO) 22import System.IO.Unsafe (unsafePerformIO)
24 23
25genfft code v = unsafePerformIO $ do 24genfft code v = unsafePerformIO $ do
26 r <- createVector (dim v) 25 r <- createVector (size v)
27 app2 (c_fft code) vec v vec r "fft" 26 app2 (c_fft code) vec v vec r "fft"
28 return r 27 return r
29 28
diff --git a/packages/gsl/src/Numeric/GSL/IO.hs b/packages/gsl/src/Numeric/GSL/IO.hs
index 0d6031a..936f6bf 100644
--- a/packages/gsl/src/Numeric/GSL/IO.hs
+++ b/packages/gsl/src/Numeric/GSL/IO.hs
@@ -14,7 +14,7 @@ module Numeric.GSL.IO (
14 fileDimensions, loadMatrix, fromFile 14 fileDimensions, loadMatrix, fromFile
15) where 15) where
16 16
17import Data.Packed 17import Numeric.LinearAlgebra.HMatrix hiding(saveMatrix, loadMatrix)
18import Numeric.GSL.Vector 18import Numeric.GSL.Vector
19import System.Process(readProcess) 19import System.Process(readProcess)
20 20
diff --git a/packages/gsl/src/Numeric/GSL/Internal.hs b/packages/gsl/src/Numeric/GSL/Internal.hs
index a1c4e0c..a269224 100644
--- a/packages/gsl/src/Numeric/GSL/Internal.hs
+++ b/packages/gsl/src/Numeric/GSL/Internal.hs
@@ -22,14 +22,13 @@ module Numeric.GSL.Internal(
22 aux_vTom, 22 aux_vTom,
23 createV, 23 createV,
24 createMIO, 24 createMIO,
25 module Data.Packed.Development, 25 module Numeric.LinearAlgebra.Devel,
26 check, 26 check,
27 Res,TV,TM,TCV,TCM 27 Res,TV,TM,TCV,TCM
28) where 28) where
29 29
30import Data.Packed 30import Numeric.LinearAlgebra.HMatrix
31import Data.Packed.Development hiding (check) 31import Numeric.LinearAlgebra.Devel hiding (check)
32import Data.Complex
33 32
34import Foreign.Marshal.Array(copyArray) 33import Foreign.Marshal.Array(copyArray)
35import Foreign.Ptr(Ptr, FunPtr) 34import Foreign.Ptr(Ptr, FunPtr)
diff --git a/packages/gsl/src/Numeric/GSL/LinearAlgebra.hs b/packages/gsl/src/Numeric/GSL/LinearAlgebra.hs
index 17e2258..cb78bf4 100644
--- a/packages/gsl/src/Numeric/GSL/LinearAlgebra.hs
+++ b/packages/gsl/src/Numeric/GSL/LinearAlgebra.hs
@@ -15,7 +15,7 @@ module Numeric.GSL.LinearAlgebra (
15 fileDimensions, loadMatrix, fromFile 15 fileDimensions, loadMatrix, fromFile
16) where 16) where
17 17
18import Data.Packed 18import Numeric.LinearAlgebra.HMatrix hiding (RandDist,randomVector,saveMatrix,loadMatrix)
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)
diff --git a/packages/gsl/src/Numeric/GSL/Minimization.hs b/packages/gsl/src/Numeric/GSL/Minimization.hs
index 056d463..00e0619 100644
--- a/packages/gsl/src/Numeric/GSL/Minimization.hs
+++ b/packages/gsl/src/Numeric/GSL/Minimization.hs
@@ -1,3 +1,6 @@
1{-# LANGUAGE FlexibleContexts #-}
2
3
1{- | 4{- |
2Module : Numeric.GSL.Minimization 5Module : Numeric.GSL.Minimization
3Copyright : (c) Alberto Ruiz 2006-9 6Copyright : (c) Alberto Ruiz 2006-9
@@ -56,7 +59,7 @@ module Numeric.GSL.Minimization (
56) where 59) where
57 60
58 61
59import Data.Packed 62import Numeric.LinearAlgebra.HMatrix hiding(step)
60import Numeric.GSL.Internal 63import Numeric.GSL.Internal
61 64
62import Foreign.Ptr(Ptr, FunPtr, freeHaskellFunPtr) 65import Foreign.Ptr(Ptr, FunPtr, freeHaskellFunPtr)
@@ -99,7 +102,7 @@ uniMinimizeGen m f xmin xl xu epsrel maxit = unsafePerformIO $ do
99 rawpath <- createMIO maxit 4 102 rawpath <- createMIO maxit 4
100 (c_uniMinize m fp epsrel (fi maxit) xmin xl xu) 103 (c_uniMinize m fp epsrel (fi maxit) xmin xl xu)
101 "uniMinimize" 104 "uniMinimize"
102 let it = round (rawpath @@> (maxit-1,0)) 105 let it = round (rawpath `atIndex` (maxit-1,0))
103 path = takeRows it rawpath 106 path = takeRows it rawpath
104 [sol] = toLists $ dropRows (it-1) path 107 [sol] = toLists $ dropRows (it-1) path
105 freeHaskellFunPtr fp 108 freeHaskellFunPtr fp
@@ -137,13 +140,13 @@ minimize method eps maxit sz f xi = v2l $ minimizeV method eps maxit (fromList s
137ww2 w1 o1 w2 o2 f = w1 o1 $ \a1 -> w2 o2 $ \a2 -> f a1 a2 140ww2 w1 o1 w2 o2 f = w1 o1 $ \a1 -> w2 o2 $ \a2 -> f a1 a2
138 141
139minimizeV method eps maxit szv f xiv = unsafePerformIO $ do 142minimizeV method eps maxit szv f xiv = unsafePerformIO $ do
140 let n = dim xiv 143 let n = size xiv
141 fp <- mkVecfun (iv f) 144 fp <- mkVecfun (iv f)
142 rawpath <- ww2 vec xiv vec szv $ \xiv' szv' -> 145 rawpath <- ww2 vec xiv vec szv $ \xiv' szv' ->
143 createMIO maxit (n+3) 146 createMIO maxit (n+3)
144 (c_minimize (fi (fromEnum method)) fp eps (fi maxit) // xiv' // szv') 147 (c_minimize (fi (fromEnum method)) fp eps (fi maxit) // xiv' // szv')
145 "minimize" 148 "minimize"
146 let it = round (rawpath @@> (maxit-1,0)) 149 let it = round (rawpath `atIndex` (maxit-1,0))
147 path = takeRows it rawpath 150 path = takeRows it rawpath
148 sol = flatten $ dropColumns 3 $ dropRows (it-1) path 151 sol = flatten $ dropColumns 3 $ dropRows (it-1) path
149 freeHaskellFunPtr fp 152 freeHaskellFunPtr fp
@@ -191,7 +194,7 @@ minimizeD method eps maxit istep tol f df xi = v2l $ minimizeVD
191 194
192 195
193minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do 196minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do
194 let n = dim xiv 197 let n = size xiv
195 f' = f 198 f' = f
196 df' = (checkdim1 n . df) 199 df' = (checkdim1 n . df)
197 fp <- mkVecfun (iv f') 200 fp <- mkVecfun (iv f')
@@ -200,7 +203,7 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do
200 createMIO maxit (n+2) 203 createMIO maxit (n+2)
201 (c_minimizeD (fi (fromEnum method)) fp dfp istep tol eps (fi maxit) // xiv') 204 (c_minimizeD (fi (fromEnum method)) fp dfp istep tol eps (fi maxit) // xiv')
202 "minimizeD" 205 "minimizeD"
203 let it = round (rawpath @@> (maxit-1,0)) 206 let it = round (rawpath `atIndex` (maxit-1,0))
204 path = takeRows it rawpath 207 path = takeRows it rawpath
205 sol = flatten $ dropColumns 2 $ dropRows (it-1) path 208 sol = flatten $ dropColumns 2 $ dropRows (it-1) path
206 freeHaskellFunPtr fp 209 freeHaskellFunPtr fp
@@ -217,6 +220,6 @@ foreign import ccall safe "gsl-aux.h minimizeD"
217--------------------------------------------------------------------- 220---------------------------------------------------------------------
218 221
219checkdim1 n v 222checkdim1 n v
220 | dim v == n = v 223 | size v == n = v
221 | otherwise = error $ "Error: "++ show n 224 | otherwise = error $ "Error: "++ show n
222 ++ " components expected in the result of the gradient supplied to minimizeD" 225 ++ " components expected in the result of the gradient supplied to minimizeD"
diff --git a/packages/gsl/src/Numeric/GSL/ODE.hs b/packages/gsl/src/Numeric/GSL/ODE.hs
index 7549a65..3258b83 100644
--- a/packages/gsl/src/Numeric/GSL/ODE.hs
+++ b/packages/gsl/src/Numeric/GSL/ODE.hs
@@ -1,3 +1,6 @@
1{-# LANGUAGE FlexibleContexts #-}
2
3
1{- | 4{- |
2Module : Numeric.GSL.ODE 5Module : Numeric.GSL.ODE
3Copyright : (c) Alberto Ruiz 2010 6Copyright : (c) Alberto Ruiz 2010
@@ -32,7 +35,7 @@ module Numeric.GSL.ODE (
32 odeSolve, odeSolveV, ODEMethod(..), Jacobian 35 odeSolve, odeSolveV, ODEMethod(..), Jacobian
33) where 36) where
34 37
35import Data.Packed 38import Numeric.LinearAlgebra.HMatrix
36import Numeric.GSL.Internal 39import Numeric.GSL.Internal
37 40
38import Foreign.Ptr(FunPtr, nullFunPtr, freeHaskellFunPtr) 41import Foreign.Ptr(FunPtr, nullFunPtr, freeHaskellFunPtr)
@@ -68,7 +71,7 @@ odeSolve
68 -> Vector Double -- ^ desired solution times 71 -> Vector Double -- ^ desired solution times
69 -> Matrix Double -- ^ solution 72 -> Matrix Double -- ^ solution
70odeSolve xdot xi ts = odeSolveV RKf45 hi epsAbs epsRel (l2v xdot) (fromList xi) ts 73odeSolve xdot xi ts = odeSolveV RKf45 hi epsAbs epsRel (l2v xdot) (fromList xi) ts
71 where hi = (ts@>1 - ts@>0)/100 74 where hi = (ts!1 - ts!0)/100
72 epsAbs = 1.49012e-08 75 epsAbs = 1.49012e-08
73 epsRel = 1.49012e-08 76 epsRel = 1.49012e-08
74 l2v f = \t -> fromList . f t . toList 77 l2v f = \t -> fromList . f t . toList
@@ -107,14 +110,14 @@ odeSolveV'
107 -> Vector Double -- ^ desired solution times 110 -> Vector Double -- ^ desired solution times
108 -> Matrix Double -- ^ solution 111 -> Matrix Double -- ^ solution
109odeSolveV' method mbjac h epsAbs epsRel f xiv ts = unsafePerformIO $ do 112odeSolveV' method mbjac h epsAbs epsRel f xiv ts = unsafePerformIO $ do
110 let n = dim xiv 113 let n = size xiv
111 fp <- mkDoubleVecVecfun (\t -> aux_vTov (checkdim1 n . f t)) 114 fp <- mkDoubleVecVecfun (\t -> aux_vTov (checkdim1 n . f t))
112 jp <- case mbjac of 115 jp <- case mbjac of
113 Just jac -> mkDoubleVecMatfun (\t -> aux_vTom (checkdim2 n . jac t)) 116 Just jac -> mkDoubleVecMatfun (\t -> aux_vTom (checkdim2 n . jac t))
114 Nothing -> return nullFunPtr 117 Nothing -> return nullFunPtr
115 sol <- vec xiv $ \xiv' -> 118 sol <- vec xiv $ \xiv' ->
116 vec (checkTimes ts) $ \ts' -> 119 vec (checkTimes ts) $ \ts' ->
117 createMIO (dim ts) n 120 createMIO (size ts) n
118 (ode_c (method) h epsAbs epsRel fp jp // xiv' // ts' ) 121 (ode_c (method) h epsAbs epsRel fp jp // xiv' // ts' )
119 "ode" 122 "ode"
120 freeHaskellFunPtr fp 123 freeHaskellFunPtr fp
@@ -126,7 +129,7 @@ foreign import ccall safe "ode"
126------------------------------------------------------- 129-------------------------------------------------------
127 130
128checkdim1 n v 131checkdim1 n v
129 | dim v == n = v 132 | size v == n = v
130 | otherwise = error $ "Error: "++ show n 133 | otherwise = error $ "Error: "++ show n
131 ++ " components expected in the result of the function supplied to odeSolve" 134 ++ " components expected in the result of the function supplied to odeSolve"
132 135
@@ -135,6 +138,7 @@ checkdim2 n m
135 | otherwise = error $ "Error: "++ show n ++ "x" ++ show n 138 | otherwise = error $ "Error: "++ show n ++ "x" ++ show n
136 ++ " Jacobian expected in odeSolve" 139 ++ " Jacobian expected in odeSolve"
137 140
138checkTimes ts | dim ts > 1 && all (>0) (zipWith subtract ts' (tail ts')) = ts 141checkTimes ts | size ts > 1 && all (>0) (zipWith subtract ts' (tail ts')) = ts
139 | otherwise = error "odeSolve requires increasing times" 142 | otherwise = error "odeSolve requires increasing times"
140 where ts' = toList ts 143 where ts' = toList ts
144
diff --git a/packages/gsl/src/Numeric/GSL/Polynomials.hs b/packages/gsl/src/Numeric/GSL/Polynomials.hs
index b1be85d..246e301 100644
--- a/packages/gsl/src/Numeric/GSL/Polynomials.hs
+++ b/packages/gsl/src/Numeric/GSL/Polynomials.hs
@@ -16,9 +16,8 @@ module Numeric.GSL.Polynomials (
16 polySolve 16 polySolve
17) where 17) where
18 18
19import Data.Packed 19import Numeric.LinearAlgebra.HMatrix
20import Numeric.GSL.Internal 20import Numeric.GSL.Internal
21import Data.Complex
22import System.IO.Unsafe (unsafePerformIO) 21import System.IO.Unsafe (unsafePerformIO)
23 22
24#if __GLASGOW_HASKELL__ >= 704 23#if __GLASGOW_HASKELL__ >= 704
@@ -47,8 +46,8 @@ polySolve :: [Double] -> [Complex Double]
47polySolve = toList . polySolve' . fromList 46polySolve = toList . polySolve' . fromList
48 47
49polySolve' :: Vector Double -> Vector (Complex Double) 48polySolve' :: Vector Double -> Vector (Complex Double)
50polySolve' v | dim v > 1 = unsafePerformIO $ do 49polySolve' v | size v > 1 = unsafePerformIO $ do
51 r <- createVector (dim v-1) 50 r <- createVector (size v-1)
52 app2 c_polySolve vec v vec r "polySolve" 51 app2 c_polySolve vec v vec r "polySolve"
53 return r 52 return r
54 | otherwise = error "polySolve on a polynomial of degree zero" 53 | otherwise = error "polySolve on a polynomial of degree zero"
diff --git a/packages/gsl/src/Numeric/GSL/Random.hs b/packages/gsl/src/Numeric/GSL/Random.hs
index f1f49e5..139c921 100644
--- a/packages/gsl/src/Numeric/GSL/Random.hs
+++ b/packages/gsl/src/Numeric/GSL/Random.hs
@@ -21,11 +21,13 @@ module Numeric.GSL.Random (
21) where 21) where
22 22
23import Numeric.GSL.Vector 23import Numeric.GSL.Vector
24import Numeric.LinearAlgebra(cholSH) 24import Numeric.LinearAlgebra.HMatrix hiding (
25import Numeric.Container hiding (
26 randomVector, 25 randomVector,
27 gaussianSample, 26 gaussianSample,
28 uniformSample 27 uniformSample,
28 Seed,
29 rand,
30 randn
29 ) 31 )
30import System.Random(randomIO) 32import System.Random(randomIO)
31 33
@@ -40,10 +42,10 @@ gaussianSample :: Seed
40 -> Matrix Double -- ^ covariance matrix 42 -> Matrix Double -- ^ covariance matrix
41 -> Matrix Double -- ^ result 43 -> Matrix Double -- ^ result
42gaussianSample seed n med cov = m where 44gaussianSample seed n med cov = m where
43 c = dim med 45 c = size med
44 meds = konst 1 n `outer` med 46 meds = konst 1 n `outer` med
45 rs = reshape c $ randomVector seed Gaussian (c * n) 47 rs = reshape c $ randomVector seed Gaussian (c * n)
46 m = rs `mXm` cholSH cov `add` meds 48 m = rs <> cholSH cov + meds
47 49
48-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate 50-- | Obtains a matrix whose rows are pseudorandom samples from a multivariate
49-- uniform distribution. 51-- uniform distribution.
@@ -55,10 +57,10 @@ uniformSample seed n rgs = m where
55 (as,bs) = unzip rgs 57 (as,bs) = unzip rgs
56 a = fromList as 58 a = fromList as
57 cs = zipWith subtract as bs 59 cs = zipWith subtract as bs
58 d = dim a 60 d = size a
59 dat = toRows $ reshape n $ randomVector seed Uniform (n*d) 61 dat = toRows $ reshape n $ randomVector seed Uniform (n*d)
60 am = konst 1 n `outer` a 62 am = konst 1 n `outer` a
61 m = fromColumns (zipWith scale cs dat) `add` am 63 m = fromColumns (zipWith scale cs dat) + am
62 64
63-- | pseudorandom matrix with uniform elements between 0 and 1 65-- | pseudorandom matrix with uniform elements between 0 and 1
64randm :: RandDist 66randm :: RandDist
diff --git a/packages/gsl/src/Numeric/GSL/Root.hs b/packages/gsl/src/Numeric/GSL/Root.hs
index b9f3b94..724f32f 100644
--- a/packages/gsl/src/Numeric/GSL/Root.hs
+++ b/packages/gsl/src/Numeric/GSL/Root.hs
@@ -1,3 +1,5 @@
1{-# LANGUAGE FlexibleContexts #-}
2
1{- | 3{- |
2Module : Numeric.GSL.Root 4Module : Numeric.GSL.Root
3Copyright : (c) Alberto Ruiz 2009 5Copyright : (c) Alberto Ruiz 2009
@@ -39,7 +41,7 @@ module Numeric.GSL.Root (
39 rootJ, RootMethodJ(..), 41 rootJ, RootMethodJ(..),
40) where 42) where
41 43
42import Data.Packed 44import Numeric.LinearAlgebra.HMatrix
43import Numeric.GSL.Internal 45import Numeric.GSL.Internal
44import Foreign.Ptr(FunPtr, freeHaskellFunPtr) 46import Foreign.Ptr(FunPtr, freeHaskellFunPtr)
45import Foreign.C.Types 47import Foreign.C.Types
@@ -69,7 +71,7 @@ uniRootGen m f xl xu epsrel maxit = unsafePerformIO $ do
69 rawpath <- createMIO maxit 4 71 rawpath <- createMIO maxit 4
70 (c_root m fp epsrel (fi maxit) xl xu) 72 (c_root m fp epsrel (fi maxit) xl xu)
71 "root" 73 "root"
72 let it = round (rawpath @@> (maxit-1,0)) 74 let it = round (rawpath `atIndex` (maxit-1,0))
73 path = takeRows it rawpath 75 path = takeRows it rawpath
74 [sol] = toLists $ dropRows (it-1) path 76 [sol] = toLists $ dropRows (it-1) path
75 freeHaskellFunPtr fp 77 freeHaskellFunPtr fp
@@ -100,7 +102,7 @@ uniRootJGen m f df x epsrel maxit = unsafePerformIO $ do
100 rawpath <- createMIO maxit 2 102 rawpath <- createMIO maxit 2
101 (c_rootj m fp dfp epsrel (fi maxit) x) 103 (c_rootj m fp dfp epsrel (fi maxit) x)
102 "rootj" 104 "rootj"
103 let it = round (rawpath @@> (maxit-1,0)) 105 let it = round (rawpath `atIndex` (maxit-1,0))
104 path = takeRows it rawpath 106 path = takeRows it rawpath
105 [sol] = toLists $ dropRows (it-1) path 107 [sol] = toLists $ dropRows (it-1) path
106 freeHaskellFunPtr fp 108 freeHaskellFunPtr fp
@@ -132,13 +134,13 @@ root method epsabs maxit fun xinit = rootGen (fi (fromEnum method)) fun xinit ep
132 134
133rootGen m f xi epsabs maxit = unsafePerformIO $ do 135rootGen m f xi epsabs maxit = unsafePerformIO $ do
134 let xiv = fromList xi 136 let xiv = fromList xi
135 n = dim xiv 137 n = size xiv
136 fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList)) 138 fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList))
137 rawpath <- vec xiv $ \xiv' -> 139 rawpath <- vec xiv $ \xiv' ->
138 createMIO maxit (2*n+1) 140 createMIO maxit (2*n+1)
139 (c_multiroot m fp epsabs (fi maxit) // xiv') 141 (c_multiroot m fp epsabs (fi maxit) // xiv')
140 "multiroot" 142 "multiroot"
141 let it = round (rawpath @@> (maxit-1,0)) 143 let it = round (rawpath `atIndex` (maxit-1,0))
142 path = takeRows it rawpath 144 path = takeRows it rawpath
143 [sol] = toLists $ dropRows (it-1) path 145 [sol] = toLists $ dropRows (it-1) path
144 freeHaskellFunPtr fp 146 freeHaskellFunPtr fp
@@ -169,14 +171,14 @@ rootJ method epsabs maxit fun jac xinit = rootJGen (fi (fromEnum method)) fun ja
169 171
170rootJGen m f jac xi epsabs maxit = unsafePerformIO $ do 172rootJGen m f jac xi epsabs maxit = unsafePerformIO $ do
171 let xiv = fromList xi 173 let xiv = fromList xi
172 n = dim xiv 174 n = size xiv
173 fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList)) 175 fp <- mkVecVecfun (aux_vTov (checkdim1 n . fromList . f . toList))
174 jp <- mkVecMatfun (aux_vTom (checkdim2 n . fromLists . jac . toList)) 176 jp <- mkVecMatfun (aux_vTom (checkdim2 n . fromLists . jac . toList))
175 rawpath <- vec xiv $ \xiv' -> 177 rawpath <- vec xiv $ \xiv' ->
176 createMIO maxit (2*n+1) 178 createMIO maxit (2*n+1)
177 (c_multirootj m fp jp epsabs (fi maxit) // xiv') 179 (c_multirootj m fp jp epsabs (fi maxit) // xiv')
178 "multiroot" 180 "multiroot"
179 let it = round (rawpath @@> (maxit-1,0)) 181 let it = round (rawpath `atIndex` (maxit-1,0))
180 path = takeRows it rawpath 182 path = takeRows it rawpath
181 [sol] = toLists $ dropRows (it-1) path 183 [sol] = toLists $ dropRows (it-1) path
182 freeHaskellFunPtr fp 184 freeHaskellFunPtr fp
@@ -189,7 +191,7 @@ foreign import ccall safe "multirootj"
189------------------------------------------------------- 191-------------------------------------------------------
190 192
191checkdim1 n v 193checkdim1 n v
192 | dim v == n = v 194 | size v == n = v
193 | otherwise = error $ "Error: "++ show n 195 | otherwise = error $ "Error: "++ show n
194 ++ " components expected in the result of the function supplied to root" 196 ++ " components expected in the result of the function supplied to root"
195 197
diff --git a/packages/gsl/src/Numeric/GSL/Vector.hs b/packages/gsl/src/Numeric/GSL/Vector.hs
index af79f32..0cd99eb 100644
--- a/packages/gsl/src/Numeric/GSL/Vector.hs
+++ b/packages/gsl/src/Numeric/GSL/Vector.hs
@@ -14,8 +14,7 @@ module Numeric.GSL.Vector (
14 fwriteVector, freadVector, fprintfVector, fscanfVector 14 fwriteVector, freadVector, fprintfVector, fscanfVector
15) where 15) where
16 16
17import Data.Packed 17import Numeric.LinearAlgebra.HMatrix hiding(randomVector, saveMatrix)
18import Numeric.LinearAlgebra(RandDist(..))
19import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM) 18import Numeric.GSL.Internal hiding (TV,TM,TCV,TCM)
20 19
21import Foreign.Marshal.Alloc(free) 20import Foreign.Marshal.Alloc(free)
diff --git a/packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs b/packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs
index 8608394..d75fec2 100644
--- a/packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs
+++ b/packages/sparse/src/Numeric/LinearAlgebra/Sparse.hs
@@ -13,8 +13,11 @@ import System.IO.Unsafe(unsafePerformIO)
13import Foreign(Ptr) 13import Foreign(Ptr)
14import Numeric.LinearAlgebra.HMatrix 14import Numeric.LinearAlgebra.HMatrix
15import Text.Printf 15import Text.Printf
16import Numeric.LinearAlgebra.Util((~!~)) 16import Control.Monad(when)
17 17
18(???) :: Bool -> String -> IO ()
19infixl 0 ???
20c ??? msg = when c (error msg)
18 21
19type IV t = CInt -> Ptr CInt -> t 22type IV t = CInt -> Ptr CInt -> t
20type V t = CInt -> Ptr Double -> t 23type V t = CInt -> Ptr Double -> t
@@ -22,7 +25,7 @@ type SMxV = V (IV (IV (V (V (IO CInt)))))
22 25
23dss :: CSR -> Vector Double -> Vector Double 26dss :: CSR -> Vector Double -> Vector Double
24dss CSR{..} b = unsafePerformIO $ do 27dss CSR{..} b = unsafePerformIO $ do
25 size b /= csrNRows ~!~ printf "dss: incorrect sizes: (%d,%d) x %d" csrNRows csrNCols (size b) 28 size b /= csrNRows ??? printf "dss: incorrect sizes: (%d,%d) x %d" csrNRows csrNCols (size b)
26 r <- createVector csrNCols 29 r <- createVector csrNCols
27 app5 c_dss vec csrVals vec csrCols vec csrRows vec b vec r "dss" 30 app5 c_dss vec csrVals vec csrCols vec csrRows vec b vec r "dss"
28 return r 31 return r
diff --git a/packages/special/hmatrix-special.cabal b/packages/special/hmatrix-special.cabal
index 28b294b..3b122c8 100644
--- a/packages/special/hmatrix-special.cabal
+++ b/packages/special/hmatrix-special.cabal
@@ -1,5 +1,5 @@
1Name: hmatrix-special 1Name: hmatrix-special
2Version: 0.3.0.1 2Version: 0.4.0.0
3License: GPL 3License: GPL
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -27,7 +27,7 @@ flag safe-cheap
27 default: False 27 default: False
28 28
29library 29library
30 Build-Depends: base <5, hmatrix, hmatrix-gsl 30 Build-Depends: base <5, hmatrix>=0.17, hmatrix-gsl
31 31
32 Extensions: ForeignFunctionInterface, 32 Extensions: ForeignFunctionInterface,
33 CPP 33 CPP
diff --git a/packages/special/lib/Numeric/GSL/Special/Internal.hsc b/packages/special/lib/Numeric/GSL/Special/Internal.hsc
index e7c38e8..a9aab9b 100644
--- a/packages/special/lib/Numeric/GSL/Special/Internal.hsc
+++ b/packages/special/lib/Numeric/GSL/Special/Internal.hsc
@@ -33,7 +33,7 @@ import Foreign.Storable
33import Foreign.Ptr 33import Foreign.Ptr
34import Foreign.Marshal 34import Foreign.Marshal
35import System.IO.Unsafe(unsafePerformIO) 35import System.IO.Unsafe(unsafePerformIO)
36import Data.Packed.Development(check,(//)) 36import Numeric.LinearAlgebra.Devel(check,(//))
37import Foreign.C.Types 37import Foreign.C.Types
38 38
39data Precision = PrecDouble | PrecSingle | PrecApprox 39data Precision = PrecDouble | PrecSingle | PrecApprox