diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-01-22 13:06:13 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-01-22 13:06:13 +0000 |
commit | baeb3890896e424e57582b108f7419f4ae479c42 (patch) | |
tree | 09d805dc1460e0530f9e55c31707c65cecb54aa9 /lib/Numeric/GSL | |
parent | e92696514c8861e7bed7abb434ca24527861c05c (diff) |
CInt in all imports
Diffstat (limited to 'lib/Numeric/GSL')
-rw-r--r-- | lib/Numeric/GSL/Matrix.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/GSL/Minimization.hs | 11 |
2 files changed, 5 insertions, 10 deletions
diff --git a/lib/Numeric/GSL/Matrix.hs b/lib/Numeric/GSL/Matrix.hs index d51728e..acf4e77 100644 --- a/lib/Numeric/GSL/Matrix.hs +++ b/lib/Numeric/GSL/Matrix.hs | |||
@@ -179,10 +179,6 @@ unpackQR' (qrp,tau) = unsafePerformIO $ do | |||
179 | c = cols qrp | 179 | c = cols qrp |
180 | foreign import ccall "gsl-aux.h QRunpack" c_qrUnpack :: TMVMM | 180 | foreign import ccall "gsl-aux.h QRunpack" c_qrUnpack :: TMVMM |
181 | 181 | ||
182 | |||
183 | type TMMV = Int -> Int -> PD -> TMV | ||
184 | type TMVMM = Int -> Int -> PD -> Int -> PD -> TMM | ||
185 | |||
186 | {- | Cholesky decomposition of a symmetric positive definite real matrix using /gsl_linalg_cholesky_decomp/. | 182 | {- | Cholesky decomposition of a symmetric positive definite real matrix using /gsl_linalg_cholesky_decomp/. |
187 | 183 | ||
188 | @\> chol $ (2><2) [1,2, | 184 | @\> chol $ (2><2) [1,2, |
diff --git a/lib/Numeric/GSL/Minimization.hs b/lib/Numeric/GSL/Minimization.hs index 65705cc..b84da06 100644 --- a/lib/Numeric/GSL/Minimization.hs +++ b/lib/Numeric/GSL/Minimization.hs | |||
@@ -86,7 +86,7 @@ minimizeNMSimplex f xi sz tol maxit = unsafePerformIO $ do | |||
86 | fp <- mkVecfun (iv (f.toList)) | 86 | fp <- mkVecfun (iv (f.toList)) |
87 | rawpath <- ww2 withVector xiv withVector szv $ \xiv' szv' -> | 87 | rawpath <- ww2 withVector xiv withVector szv $ \xiv' szv' -> |
88 | createMIO maxit (n+3) | 88 | createMIO maxit (n+3) |
89 | (c_minimizeNMSimplex fp tol (fromIntegral maxit) // xiv' // szv') | 89 | (c_minimizeNMSimplex fp tol (fi maxit) // xiv' // szv') |
90 | "minimizeNMSimplex" | 90 | "minimizeNMSimplex" |
91 | let it = round (rawpath @@> (maxit-1,0)) | 91 | let it = round (rawpath @@> (maxit-1,0)) |
92 | path = takeRows it rawpath | 92 | path = takeRows it rawpath |
@@ -96,8 +96,7 @@ minimizeNMSimplex f xi sz tol maxit = unsafePerformIO $ do | |||
96 | 96 | ||
97 | 97 | ||
98 | foreign import ccall "gsl-aux.h minimize" | 98 | foreign import ccall "gsl-aux.h minimize" |
99 | c_minimizeNMSimplex:: FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt | 99 | c_minimizeNMSimplex:: FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TVVM |
100 | -> TVVM | ||
101 | 100 | ||
102 | ---------------------------------------------------------------------------------- | 101 | ---------------------------------------------------------------------------------- |
103 | 102 | ||
@@ -152,7 +151,7 @@ minimizeConjugateGradient istep minimpar tol maxit f df xi = unsafePerformIO $ d | |||
152 | dfp <- mkVecVecfun (aux_vTov df') | 151 | dfp <- mkVecVecfun (aux_vTov df') |
153 | rawpath <- withVector xiv $ \xiv' -> | 152 | rawpath <- withVector xiv $ \xiv' -> |
154 | createMIO maxit (n+2) | 153 | createMIO maxit (n+2) |
155 | (c_minimizeConjugateGradient fp dfp istep minimpar tol (fromIntegral maxit) // xiv') | 154 | (c_minimizeConjugateGradient fp dfp istep minimpar tol (fi maxit) // xiv') |
156 | "minimizeDerivV" | 155 | "minimizeDerivV" |
157 | let it = round (rawpath @@> (maxit-1,0)) | 156 | let it = round (rawpath @@> (maxit-1,0)) |
158 | path = takeRows it rawpath | 157 | path = takeRows it rawpath |
@@ -172,7 +171,7 @@ foreign import ccall "gsl-aux.h minimizeWithDeriv" | |||
172 | iv :: (Vector Double -> Double) -> (CInt -> Ptr Double -> Double) | 171 | iv :: (Vector Double -> Double) -> (CInt -> Ptr Double -> Double) |
173 | iv f n p = f (createV (fromIntegral n) copy "iv") where | 172 | iv f n p = f (createV (fromIntegral n) copy "iv") where |
174 | copy n' q = do | 173 | copy n' q = do |
175 | copyArray q p n' | 174 | copyArray q p (fromIntegral n') |
176 | return 0 | 175 | return 0 |
177 | 176 | ||
178 | -- | conversion of Haskell functions into function pointers that can be used in the C side | 177 | -- | conversion of Haskell functions into function pointers that can be used in the C side |
@@ -190,7 +189,7 @@ aux_vTov f n p r = g where | |||
190 | V {fptr = pr} = f x | 189 | V {fptr = pr} = f x |
191 | x = createV (fromIntegral n) copy "aux_vTov" | 190 | x = createV (fromIntegral n) copy "aux_vTov" |
192 | copy n' q = do | 191 | copy n' q = do |
193 | copyArray q p n' | 192 | copyArray q p (fromIntegral n') |
194 | return 0 | 193 | return 0 |
195 | g = withForeignPtr pr $ \p' -> copyArray r p' (fromIntegral n) | 194 | g = withForeignPtr pr $ \p' -> copyArray r p' (fromIntegral n) |
196 | 195 | ||