diff options
author | Clark Gaebel <cgaebel@csclub.uwaterloo.ca> | 2012-03-10 18:26:56 -0500 |
---|---|---|
committer | Clark Gaebel <cgaebel@csclub.uwaterloo.ca> | 2012-03-10 18:26:56 -0500 |
commit | f8b7b3734fa6bb8d63914719e09d17940add27d4 (patch) | |
tree | 233c1c41ea8d5a0cf43bf9430cc2b60cff38a3e9 /lib | |
parent | 13fe05779923baad386b0059ff6fbc7c6af405d9 (diff) |
Removed foreign import safety.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Data/Packed/Internal/Common.hs | 4 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 22 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/Vector.hs | 24 | ||||
-rw-r--r-- | lib/Numeric/GSL.hs | 2 | ||||
-rw-r--r-- | lib/Numeric/GSL/Differentiation.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/GSL/Fitting.hs | 2 | ||||
-rw-r--r-- | lib/Numeric/GSL/Fourier.hs | 2 | ||||
-rw-r--r-- | lib/Numeric/GSL/Integration.hs | 12 | ||||
-rw-r--r-- | lib/Numeric/GSL/Internal.hs | 10 | ||||
-rw-r--r-- | lib/Numeric/GSL/Minimization.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/GSL/ODE.hs | 2 | ||||
-rw-r--r-- | lib/Numeric/GSL/Polynomials.hs | 2 | ||||
-rw-r--r-- | lib/Numeric/GSL/Root.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/GSL/Vector.hs | 58 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/LAPACK.hs | 64 |
15 files changed, 108 insertions, 108 deletions
diff --git a/lib/Data/Packed/Internal/Common.hs b/lib/Data/Packed/Internal/Common.hs index a8c3c3e..49f17b0 100644 --- a/lib/Data/Packed/Internal/Common.hs +++ b/lib/Data/Packed/Internal/Common.hs | |||
@@ -140,7 +140,7 @@ errorCode n = "code "++show n | |||
140 | 140 | ||
141 | 141 | ||
142 | -- | clear the fpu | 142 | -- | clear the fpu |
143 | foreign import ccall "asm_finit" finit :: IO () | 143 | foreign import ccall unsafe "asm_finit" finit :: IO () |
144 | 144 | ||
145 | -- | check the error code | 145 | -- | check the error code |
146 | check :: String -> IO CInt -> IO () | 146 | check :: String -> IO CInt -> IO () |
@@ -158,7 +158,7 @@ check msg f = do | |||
158 | return () | 158 | return () |
159 | 159 | ||
160 | -- | description of GSL error codes | 160 | -- | description of GSL error codes |
161 | foreign import ccall "gsl_strerror" gsl_strerror :: CInt -> IO (Ptr CChar) | 161 | foreign import ccall unsafe "gsl_strerror" gsl_strerror :: CInt -> IO (Ptr CChar) |
162 | 162 | ||
163 | -- | Error capture and conversion to Maybe | 163 | -- | Error capture and conversion to Maybe |
164 | mbCatch :: IO x -> IO (Maybe x) | 164 | mbCatch :: IO x -> IO (Maybe x) |
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 257e4fc..b8ed18d 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -331,11 +331,11 @@ transdataP c1 d c2 = | |||
331 | sz = sizeOf (d @> 0) | 331 | sz = sizeOf (d @> 0) |
332 | noneed = r1 == 1 || c1 == 1 | 332 | noneed = r1 == 1 || c1 == 1 |
333 | 333 | ||
334 | foreign import ccall "transF" ctransF :: TFMFM | 334 | foreign import ccall unsafe "transF" ctransF :: TFMFM |
335 | foreign import ccall "transR" ctransR :: TMM | 335 | foreign import ccall unsafe "transR" ctransR :: TMM |
336 | foreign import ccall "transQ" ctransQ :: TQMQM | 336 | foreign import ccall unsafe "transQ" ctransQ :: TQMQM |
337 | foreign import ccall "transC" ctransC :: TCMCM | 337 | foreign import ccall unsafe "transC" ctransC :: TCMCM |
338 | foreign import ccall "transP" ctransP :: CInt -> CInt -> Ptr () -> CInt -> CInt -> CInt -> Ptr () -> CInt -> IO CInt | 338 | foreign import ccall unsafe "transP" ctransP :: CInt -> CInt -> Ptr () -> CInt -> CInt -> CInt -> Ptr () -> CInt -> IO CInt |
339 | 339 | ||
340 | ---------------------------------------------------------------------- | 340 | ---------------------------------------------------------------------- |
341 | 341 | ||
@@ -358,19 +358,19 @@ constantAux fun x n = unsafePerformIO $ do | |||
358 | 358 | ||
359 | constantF :: Float -> Int -> Vector Float | 359 | constantF :: Float -> Int -> Vector Float |
360 | constantF = constantAux cconstantF | 360 | constantF = constantAux cconstantF |
361 | foreign import ccall "constantF" cconstantF :: Ptr Float -> TF | 361 | foreign import ccall unsafe "constantF" cconstantF :: Ptr Float -> TF |
362 | 362 | ||
363 | constantR :: Double -> Int -> Vector Double | 363 | constantR :: Double -> Int -> Vector Double |
364 | constantR = constantAux cconstantR | 364 | constantR = constantAux cconstantR |
365 | foreign import ccall "constantR" cconstantR :: Ptr Double -> TV | 365 | foreign import ccall unsafe "constantR" cconstantR :: Ptr Double -> TV |
366 | 366 | ||
367 | constantQ :: Complex Float -> Int -> Vector (Complex Float) | 367 | constantQ :: Complex Float -> Int -> Vector (Complex Float) |
368 | constantQ = constantAux cconstantQ | 368 | constantQ = constantAux cconstantQ |
369 | foreign import ccall "constantQ" cconstantQ :: Ptr (Complex Float) -> TQV | 369 | foreign import ccall unsafe "constantQ" cconstantQ :: Ptr (Complex Float) -> TQV |
370 | 370 | ||
371 | constantC :: Complex Double -> Int -> Vector (Complex Double) | 371 | constantC :: Complex Double -> Int -> Vector (Complex Double) |
372 | constantC = constantAux cconstantC | 372 | constantC = constantAux cconstantC |
373 | foreign import ccall "constantC" cconstantC :: Ptr (Complex Double) -> TCV | 373 | foreign import ccall unsafe "constantC" cconstantC :: Ptr (Complex Double) -> TCV |
374 | 374 | ||
375 | constantP :: Storable a => a -> Int -> Vector a | 375 | constantP :: Storable a => a -> Int -> Vector a |
376 | constantP a n = unsafePerformIO $ do | 376 | constantP a n = unsafePerformIO $ do |
@@ -381,7 +381,7 @@ constantP a n = unsafePerformIO $ do | |||
381 | poke k a | 381 | poke k a |
382 | cconstantP (castPtr k) (fi n) (castPtr p) (fi sz) // check "constantP" | 382 | cconstantP (castPtr k) (fi n) (castPtr p) (fi sz) // check "constantP" |
383 | return v | 383 | return v |
384 | foreign import ccall "constantP" cconstantP :: Ptr () -> CInt -> Ptr () -> CInt -> IO CInt | 384 | foreign import ccall unsafe "constantP" cconstantP :: Ptr () -> CInt -> Ptr () -> CInt -> IO CInt |
385 | 385 | ||
386 | ---------------------------------------------------------------------- | 386 | ---------------------------------------------------------------------- |
387 | 387 | ||
@@ -427,7 +427,7 @@ saveMatrix filename fmt m = do | |||
427 | free charname | 427 | free charname |
428 | free charfmt | 428 | free charfmt |
429 | 429 | ||
430 | foreign import ccall "matrix_fprintf" matrix_fprintf :: Ptr CChar -> Ptr CChar -> CInt -> TM | 430 | foreign import ccall unsafe "matrix_fprintf" matrix_fprintf :: Ptr CChar -> Ptr CChar -> CInt -> TM |
431 | 431 | ||
432 | ---------------------------------------------------------------------- | 432 | ---------------------------------------------------------------------- |
433 | 433 | ||
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs index 936479d..d3b80ff 100644 --- a/lib/Data/Packed/Internal/Vector.hs +++ b/lib/Data/Packed/Internal/Vector.hs | |||
@@ -308,8 +308,8 @@ double2FloatV v = unsafePerformIO $ do | |||
308 | return r | 308 | return r |
309 | 309 | ||
310 | 310 | ||
311 | foreign import ccall "float2double" c_float2double:: TFV | 311 | foreign import ccall unsafe "float2double" c_float2double:: TFV |
312 | foreign import ccall "double2float" c_double2float:: TVF | 312 | foreign import ccall unsafe "double2float" c_double2float:: TVF |
313 | 313 | ||
314 | --------------------------------------------------------------- | 314 | --------------------------------------------------------------- |
315 | 315 | ||
@@ -325,8 +325,8 @@ stepD v = unsafePerformIO $ do | |||
325 | app2 c_stepD vec v vec r "stepD" | 325 | app2 c_stepD vec v vec r "stepD" |
326 | return r | 326 | return r |
327 | 327 | ||
328 | foreign import ccall "stepF" c_stepF :: TFF | 328 | foreign import ccall unsafe "stepF" c_stepF :: TFF |
329 | foreign import ccall "stepD" c_stepD :: TVV | 329 | foreign import ccall unsafe "stepD" c_stepD :: TVV |
330 | 330 | ||
331 | --------------------------------------------------------------- | 331 | --------------------------------------------------------------- |
332 | 332 | ||
@@ -342,8 +342,8 @@ condD x y l e g = unsafePerformIO $ do | |||
342 | app6 c_condD vec x vec y vec l vec e vec g vec r "condD" | 342 | app6 c_condD vec x vec y vec l vec e vec g vec r "condD" |
343 | return r | 343 | return r |
344 | 344 | ||
345 | foreign import ccall "condF" c_condF :: CInt -> PF -> CInt -> PF -> CInt -> PF -> TFFF | 345 | foreign import ccall unsafe "condF" c_condF :: CInt -> PF -> CInt -> PF -> CInt -> PF -> TFFF |
346 | foreign import ccall "condD" c_condD :: CInt -> PD -> CInt -> PD -> CInt -> PD -> TVVV | 346 | foreign import ccall unsafe "condD" c_condD :: CInt -> PD -> CInt -> PD -> CInt -> PD -> TVVV |
347 | 347 | ||
348 | -------------------------------------------------------------------------------- | 348 | -------------------------------------------------------------------------------- |
349 | 349 | ||
@@ -354,11 +354,11 @@ conjugateAux fun x = unsafePerformIO $ do | |||
354 | 354 | ||
355 | conjugateQ :: Vector (Complex Float) -> Vector (Complex Float) | 355 | conjugateQ :: Vector (Complex Float) -> Vector (Complex Float) |
356 | conjugateQ = conjugateAux c_conjugateQ | 356 | conjugateQ = conjugateAux c_conjugateQ |
357 | foreign import ccall "conjugateQ" c_conjugateQ :: TQVQV | 357 | foreign import ccall unsafe "conjugateQ" c_conjugateQ :: TQVQV |
358 | 358 | ||
359 | conjugateC :: Vector (Complex Double) -> Vector (Complex Double) | 359 | conjugateC :: Vector (Complex Double) -> Vector (Complex Double) |
360 | conjugateC = conjugateAux c_conjugateC | 360 | conjugateC = conjugateAux c_conjugateC |
361 | foreign import ccall "conjugateC" c_conjugateC :: TCVCV | 361 | foreign import ccall unsafe "conjugateC" c_conjugateC :: TCVCV |
362 | 362 | ||
363 | -------------------------------------------------------------------------------- | 363 | -------------------------------------------------------------------------------- |
364 | 364 | ||
@@ -547,7 +547,7 @@ fscanfVector filename n = do | |||
547 | free charname | 547 | free charname |
548 | return res | 548 | return res |
549 | 549 | ||
550 | foreign import ccall "vector_fscanf" gsl_vector_fscanf:: Ptr CChar -> TV | 550 | foreign import ccall unsafe "vector_fscanf" gsl_vector_fscanf:: Ptr CChar -> TV |
551 | 551 | ||
552 | -- | Saves the elements of a vector, with a given format (%f, %e, %g), to an ASCII file. | 552 | -- | Saves the elements of a vector, with a given format (%f, %e, %g), to an ASCII file. |
553 | fprintfVector :: FilePath -> String -> Vector Double -> IO () | 553 | fprintfVector :: FilePath -> String -> Vector Double -> IO () |
@@ -558,7 +558,7 @@ fprintfVector filename fmt v = do | |||
558 | free charname | 558 | free charname |
559 | free charfmt | 559 | free charfmt |
560 | 560 | ||
561 | foreign import ccall "vector_fprintf" gsl_vector_fprintf :: Ptr CChar -> Ptr CChar -> TV | 561 | foreign import ccall unsafe "vector_fprintf" gsl_vector_fprintf :: Ptr CChar -> Ptr CChar -> TV |
562 | 562 | ||
563 | -- | Loads a vector from a binary file (the number of elements must be known in advance). | 563 | -- | Loads a vector from a binary file (the number of elements must be known in advance). |
564 | freadVector :: FilePath -> Int -> IO (Vector Double) | 564 | freadVector :: FilePath -> Int -> IO (Vector Double) |
@@ -569,7 +569,7 @@ freadVector filename n = do | |||
569 | free charname | 569 | free charname |
570 | return res | 570 | return res |
571 | 571 | ||
572 | foreign import ccall "vector_fread" gsl_vector_fread:: Ptr CChar -> TV | 572 | foreign import ccall unsafe "vector_fread" gsl_vector_fread:: Ptr CChar -> TV |
573 | 573 | ||
574 | -- | Saves the elements of a vector to a binary file. | 574 | -- | Saves the elements of a vector to a binary file. |
575 | fwriteVector :: FilePath -> Vector Double -> IO () | 575 | fwriteVector :: FilePath -> Vector Double -> IO () |
@@ -578,5 +578,5 @@ fwriteVector filename v = do | |||
578 | app1 (gsl_vector_fwrite charname) vec v "gsl_vector_fwrite" | 578 | app1 (gsl_vector_fwrite charname) vec v "gsl_vector_fwrite" |
579 | free charname | 579 | free charname |
580 | 580 | ||
581 | foreign import ccall "vector_fwrite" gsl_vector_fwrite :: Ptr CChar -> TV | 581 | foreign import ccall unsafe "vector_fwrite" gsl_vector_fwrite :: Ptr CChar -> TV |
582 | 582 | ||
diff --git a/lib/Numeric/GSL.hs b/lib/Numeric/GSL.hs index e53022e..5f39a3e 100644 --- a/lib/Numeric/GSL.hs +++ b/lib/Numeric/GSL.hs | |||
@@ -40,4 +40,4 @@ import Data.Complex | |||
40 | 40 | ||
41 | -- | This action removes the GSL default error handler (which aborts the program), so that | 41 | -- | This action removes the GSL default error handler (which aborts the program), so that |
42 | -- GSL errors can be handled by Haskell (using Control.Exception) and ghci doesn't abort. | 42 | -- GSL errors can be handled by Haskell (using Control.Exception) and ghci doesn't abort. |
43 | foreign import ccall "GSL/gsl-aux.h no_abort_on_error" setErrorHandlerOff :: IO () | 43 | foreign import ccall unsafe "GSL/gsl-aux.h no_abort_on_error" setErrorHandlerOff :: IO () |
diff --git a/lib/Numeric/GSL/Differentiation.hs b/lib/Numeric/GSL/Differentiation.hs index ab5eb50..448ab63 100644 --- a/lib/Numeric/GSL/Differentiation.hs +++ b/lib/Numeric/GSL/Differentiation.hs | |||
@@ -48,7 +48,7 @@ derivGen c h f x = unsafePerformIO $ do | |||
48 | freeHaskellFunPtr fp | 48 | freeHaskellFunPtr fp |
49 | return result | 49 | return result |
50 | 50 | ||
51 | foreign import ccall "gsl-aux.h deriv" | 51 | foreign import ccall unsafe "gsl-aux.h deriv" |
52 | c_deriv :: CInt -> FunPtr (Double -> Ptr () -> Double) -> Double -> Double | 52 | c_deriv :: CInt -> FunPtr (Double -> Ptr () -> Double) -> Double -> Double |
53 | -> Ptr Double -> Ptr Double -> IO CInt | 53 | -> Ptr Double -> Ptr Double -> IO CInt |
54 | 54 | ||
@@ -84,4 +84,4 @@ derivBackward = derivGen 2 | |||
84 | 84 | ||
85 | {- | conversion of Haskell functions into function pointers that can be used in the C side | 85 | {- | conversion of Haskell functions into function pointers that can be used in the C side |
86 | -} | 86 | -} |
87 | foreign import ccall "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) | 87 | foreign import ccall unsafe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) |
diff --git a/lib/Numeric/GSL/Fitting.hs b/lib/Numeric/GSL/Fitting.hs index 79db23f..e5d0fd5 100644 --- a/lib/Numeric/GSL/Fitting.hs +++ b/lib/Numeric/GSL/Fitting.hs | |||
@@ -90,7 +90,7 @@ nlFitGen m f jac xiv epsabs epsrel maxit = unsafePerformIO $ do | |||
90 | freeHaskellFunPtr jp | 90 | freeHaskellFunPtr jp |
91 | return (subVector 2 p sol, path) | 91 | return (subVector 2 p sol, path) |
92 | 92 | ||
93 | foreign import ccall "nlfit" | 93 | foreign import ccall unsafe "nlfit" |
94 | c_nlfit:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> Double -> CInt -> CInt -> TVM | 94 | c_nlfit:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> Double -> CInt -> CInt -> TVM |
95 | 95 | ||
96 | ------------------------------------------------------- | 96 | ------------------------------------------------------- |
diff --git a/lib/Numeric/GSL/Fourier.hs b/lib/Numeric/GSL/Fourier.hs index 71bc8a1..4ef19b3 100644 --- a/lib/Numeric/GSL/Fourier.hs +++ b/lib/Numeric/GSL/Fourier.hs | |||
@@ -30,7 +30,7 @@ genfft code v = unsafePerformIO $ do | |||
30 | app2 (c_fft code) vec v vec r "fft" | 30 | app2 (c_fft code) vec v vec r "fft" |
31 | return r | 31 | return r |
32 | 32 | ||
33 | foreign import ccall "gsl-aux.h fft" c_fft :: CInt -> TCVCV | 33 | foreign import ccall unsafe "gsl-aux.h fft" c_fft :: CInt -> TCVCV |
34 | 34 | ||
35 | 35 | ||
36 | {- | Fast 1D Fourier transform of a 'Vector' @(@'Complex' 'Double'@)@ using /gsl_fft_complex_forward/. It uses the same scaling conventions as GNU Octave. | 36 | {- | Fast 1D Fourier transform of a 'Vector' @(@'Complex' 'Double'@)@ using /gsl_fft_complex_forward/. It uses the same scaling conventions as GNU Octave. |
diff --git a/lib/Numeric/GSL/Integration.hs b/lib/Numeric/GSL/Integration.hs index 2330fc6..b1e7930 100644 --- a/lib/Numeric/GSL/Integration.hs +++ b/lib/Numeric/GSL/Integration.hs | |||
@@ -32,7 +32,7 @@ import System.IO.Unsafe(unsafePerformIO) | |||
32 | 32 | ||
33 | {- | conversion of Haskell functions into function pointers that can be used in the C side | 33 | {- | conversion of Haskell functions into function pointers that can be used in the C side |
34 | -} | 34 | -} |
35 | foreign import ccall "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) | 35 | foreign import ccall unsafe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) |
36 | 36 | ||
37 | -------------------------------------------------------------------- | 37 | -------------------------------------------------------------------- |
38 | {- | Numerical integration using /gsl_integration_qags/ (adaptive integration with singularities). For example: | 38 | {- | Numerical integration using /gsl_integration_qags/ (adaptive integration with singularities). For example: |
@@ -63,7 +63,7 @@ integrateQAGS prec n f a b = unsafePerformIO $ do | |||
63 | freeHaskellFunPtr fp | 63 | freeHaskellFunPtr fp |
64 | return result | 64 | return result |
65 | 65 | ||
66 | foreign import ccall "gsl-aux.h integrate_qags" | 66 | foreign import ccall unsafe "gsl-aux.h integrate_qags" |
67 | c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt | 67 | c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt |
68 | -> Ptr Double -> Ptr Double -> IO CInt | 68 | -> Ptr Double -> Ptr Double -> IO CInt |
69 | 69 | ||
@@ -94,7 +94,7 @@ integrateQNG prec f a b = unsafePerformIO $ do | |||
94 | freeHaskellFunPtr fp | 94 | freeHaskellFunPtr fp |
95 | return result | 95 | return result |
96 | 96 | ||
97 | foreign import ccall "gsl-aux.h integrate_qng" | 97 | foreign import ccall unsafe "gsl-aux.h integrate_qng" |
98 | c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double | 98 | c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double |
99 | -> Ptr Double -> Ptr Double -> IO CInt | 99 | -> Ptr Double -> Ptr Double -> IO CInt |
100 | 100 | ||
@@ -126,7 +126,7 @@ integrateQAGI prec n f = unsafePerformIO $ do | |||
126 | freeHaskellFunPtr fp | 126 | freeHaskellFunPtr fp |
127 | return result | 127 | return result |
128 | 128 | ||
129 | foreign import ccall "gsl-aux.h integrate_qagi" | 129 | foreign import ccall unsafe "gsl-aux.h integrate_qagi" |
130 | c_integrate_qagi :: FunPtr (Double-> Ptr() -> Double) -> Double -> CInt | 130 | c_integrate_qagi :: FunPtr (Double-> Ptr() -> Double) -> Double -> CInt |
131 | -> Ptr Double -> Ptr Double -> IO CInt | 131 | -> Ptr Double -> Ptr Double -> IO CInt |
132 | 132 | ||
@@ -159,7 +159,7 @@ integrateQAGIU prec n f a = unsafePerformIO $ do | |||
159 | freeHaskellFunPtr fp | 159 | freeHaskellFunPtr fp |
160 | return result | 160 | return result |
161 | 161 | ||
162 | foreign import ccall "gsl-aux.h integrate_qagiu" | 162 | foreign import ccall unsafe "gsl-aux.h integrate_qagiu" |
163 | c_integrate_qagiu :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt | 163 | c_integrate_qagiu :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt |
164 | -> Ptr Double -> Ptr Double -> IO CInt | 164 | -> Ptr Double -> Ptr Double -> IO CInt |
165 | 165 | ||
@@ -192,7 +192,7 @@ integrateQAGIL prec n f b = unsafePerformIO $ do | |||
192 | freeHaskellFunPtr fp | 192 | freeHaskellFunPtr fp |
193 | return result | 193 | return result |
194 | 194 | ||
195 | foreign import ccall "gsl-aux.h integrate_qagil" | 195 | foreign import ccall unsafe "gsl-aux.h integrate_qagil" |
196 | c_integrate_qagil :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt | 196 | c_integrate_qagil :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt |
197 | -> Ptr Double -> Ptr Double -> IO CInt | 197 | -> Ptr Double -> Ptr Double -> IO CInt |
198 | 198 | ||
diff --git a/lib/Numeric/GSL/Internal.hs b/lib/Numeric/GSL/Internal.hs index 303e7e1..4267b38 100644 --- a/lib/Numeric/GSL/Internal.hs +++ b/lib/Numeric/GSL/Internal.hs | |||
@@ -26,14 +26,14 @@ iv f n p = f (createV (fromIntegral n) copy "iv") where | |||
26 | return 0 | 26 | return 0 |
27 | 27 | ||
28 | -- | conversion of Haskell functions into function pointers that can be used in the C side | 28 | -- | conversion of Haskell functions into function pointers that can be used in the C side |
29 | foreign import ccall "wrapper" | 29 | foreign import ccall unsafe "wrapper" |
30 | mkVecfun :: (CInt -> Ptr Double -> Double) | 30 | mkVecfun :: (CInt -> Ptr Double -> Double) |
31 | -> IO( FunPtr (CInt -> Ptr Double -> Double)) | 31 | -> IO( FunPtr (CInt -> Ptr Double -> Double)) |
32 | 32 | ||
33 | foreign import ccall "wrapper" | 33 | foreign import ccall unsafe "wrapper" |
34 | mkVecVecfun :: TVV -> IO (FunPtr TVV) | 34 | mkVecVecfun :: TVV -> IO (FunPtr TVV) |
35 | 35 | ||
36 | foreign import ccall "wrapper" | 36 | foreign import ccall unsafe "wrapper" |
37 | mkDoubleVecVecfun :: (Double -> TVV) -> IO (FunPtr (Double -> TVV)) | 37 | mkDoubleVecVecfun :: (Double -> TVV) -> IO (FunPtr (Double -> TVV)) |
38 | 38 | ||
39 | aux_vTov :: (Vector Double -> Vector Double) -> TVV | 39 | aux_vTov :: (Vector Double -> Vector Double) -> TVV |
@@ -46,10 +46,10 @@ aux_vTov f n p nr r = g where | |||
46 | g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral nr) | 46 | g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral nr) |
47 | return 0 | 47 | return 0 |
48 | 48 | ||
49 | foreign import ccall "wrapper" | 49 | foreign import ccall unsafe "wrapper" |
50 | mkVecMatfun :: TVM -> IO (FunPtr TVM) | 50 | mkVecMatfun :: TVM -> IO (FunPtr TVM) |
51 | 51 | ||
52 | foreign import ccall "wrapper" | 52 | foreign import ccall unsafe "wrapper" |
53 | mkDoubleVecMatfun :: (Double -> TVM) -> IO (FunPtr (Double -> TVM)) | 53 | mkDoubleVecMatfun :: (Double -> TVM) -> IO (FunPtr (Double -> TVM)) |
54 | 54 | ||
55 | aux_vTom :: (Vector Double -> Matrix Double) -> TVM | 55 | aux_vTom :: (Vector Double -> Matrix Double) -> TVM |
diff --git a/lib/Numeric/GSL/Minimization.hs b/lib/Numeric/GSL/Minimization.hs index 88acfac..21ac8a1 100644 --- a/lib/Numeric/GSL/Minimization.hs +++ b/lib/Numeric/GSL/Minimization.hs | |||
@@ -122,7 +122,7 @@ minimizeV method eps maxit szv f xiv = unsafePerformIO $ do | |||
122 | return (sol, path) | 122 | return (sol, path) |
123 | 123 | ||
124 | 124 | ||
125 | foreign import ccall "gsl-aux.h minimize" | 125 | foreign import ccall unsafe "gsl-aux.h minimize" |
126 | c_minimize:: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TVVM | 126 | c_minimize:: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TVVM |
127 | 127 | ||
128 | ---------------------------------------------------------------------------------- | 128 | ---------------------------------------------------------------------------------- |
@@ -179,7 +179,7 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do | |||
179 | freeHaskellFunPtr dfp | 179 | freeHaskellFunPtr dfp |
180 | return (sol,path) | 180 | return (sol,path) |
181 | 181 | ||
182 | foreign import ccall "gsl-aux.h minimizeD" | 182 | foreign import ccall unsafe "gsl-aux.h minimizeD" |
183 | c_minimizeD :: CInt | 183 | c_minimizeD :: CInt |
184 | -> FunPtr (CInt -> Ptr Double -> Double) | 184 | -> FunPtr (CInt -> Ptr Double -> Double) |
185 | -> FunPtr TVV | 185 | -> FunPtr TVV |
diff --git a/lib/Numeric/GSL/ODE.hs b/lib/Numeric/GSL/ODE.hs index 2251acd..797ba3f 100644 --- a/lib/Numeric/GSL/ODE.hs +++ b/lib/Numeric/GSL/ODE.hs | |||
@@ -91,7 +91,7 @@ odeSolveV method h epsAbs epsRel f mbjac xiv ts = unsafePerformIO $ do | |||
91 | freeHaskellFunPtr fp | 91 | freeHaskellFunPtr fp |
92 | return sol | 92 | return sol |
93 | 93 | ||
94 | foreign import ccall "ode" | 94 | foreign import ccall unsafe "ode" |
95 | ode_c :: CInt -> Double -> Double -> Double -> FunPtr (Double -> TVV) -> FunPtr (Double -> TVM) -> TVVM | 95 | ode_c :: CInt -> Double -> Double -> Double -> FunPtr (Double -> TVV) -> FunPtr (Double -> TVM) -> TVVM |
96 | 96 | ||
97 | ------------------------------------------------------- | 97 | ------------------------------------------------------- |
diff --git a/lib/Numeric/GSL/Polynomials.hs b/lib/Numeric/GSL/Polynomials.hs index b21b1b6..694c003 100644 --- a/lib/Numeric/GSL/Polynomials.hs +++ b/lib/Numeric/GSL/Polynomials.hs | |||
@@ -55,4 +55,4 @@ polySolve' v | dim v > 1 = unsafePerformIO $ do | |||
55 | return r | 55 | return r |
56 | | otherwise = error "polySolve on a polynomial of degree zero" | 56 | | otherwise = error "polySolve on a polynomial of degree zero" |
57 | 57 | ||
58 | foreign import ccall "gsl-aux.h polySolve" c_polySolve:: TVCV | 58 | foreign import ccall unsafe "gsl-aux.h polySolve" c_polySolve:: TVCV |
diff --git a/lib/Numeric/GSL/Root.hs b/lib/Numeric/GSL/Root.hs index 41f7fb3..4128846 100644 --- a/lib/Numeric/GSL/Root.hs +++ b/lib/Numeric/GSL/Root.hs | |||
@@ -91,7 +91,7 @@ rootGen m f xi epsabs maxit = unsafePerformIO $ do | |||
91 | return (take n $ drop 1 sol, path) | 91 | return (take n $ drop 1 sol, path) |
92 | 92 | ||
93 | 93 | ||
94 | foreign import ccall "root" | 94 | foreign import ccall unsafe "root" |
95 | c_root:: CInt -> FunPtr TVV -> Double -> CInt -> TVM | 95 | c_root:: CInt -> FunPtr TVV -> Double -> CInt -> TVM |
96 | 96 | ||
97 | ------------------------------------------------------------------------- | 97 | ------------------------------------------------------------------------- |
@@ -130,7 +130,7 @@ rootJGen m f jac xi epsabs maxit = unsafePerformIO $ do | |||
130 | return (take n $ drop 1 sol, path) | 130 | return (take n $ drop 1 sol, path) |
131 | 131 | ||
132 | 132 | ||
133 | foreign import ccall "rootj" | 133 | foreign import ccall unsafe "rootj" |
134 | c_rootj:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> CInt -> TVM | 134 | c_rootj:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> CInt -> TVM |
135 | 135 | ||
136 | ------------------------------------------------------- | 136 | ------------------------------------------------------- |
diff --git a/lib/Numeric/GSL/Vector.hs b/lib/Numeric/GSL/Vector.hs index b8c6d04..db34041 100644 --- a/lib/Numeric/GSL/Vector.hs +++ b/lib/Numeric/GSL/Vector.hs | |||
@@ -109,10 +109,10 @@ sumC x = unsafePerformIO $ do | |||
109 | app2 c_sumC vec x vec r "sumC" | 109 | app2 c_sumC vec x vec r "sumC" |
110 | return $ r @> 0 | 110 | return $ r @> 0 |
111 | 111 | ||
112 | foreign import ccall safe "gsl-aux.h sumF" c_sumF :: TFF | 112 | foreign import ccall unsafe "gsl-aux.h sumF" c_sumF :: TFF |
113 | foreign import ccall safe "gsl-aux.h sumR" c_sumR :: TVV | 113 | foreign import ccall unsafe "gsl-aux.h sumR" c_sumR :: TVV |
114 | foreign import ccall safe "gsl-aux.h sumQ" c_sumQ :: TQVQV | 114 | foreign import ccall unsafe "gsl-aux.h sumQ" c_sumQ :: TQVQV |
115 | foreign import ccall safe "gsl-aux.h sumC" c_sumC :: TCVCV | 115 | foreign import ccall unsafe "gsl-aux.h sumC" c_sumC :: TCVCV |
116 | 116 | ||
117 | -- | product of elements | 117 | -- | product of elements |
118 | prodF :: Vector Float -> Float | 118 | prodF :: Vector Float -> Float |
@@ -142,10 +142,10 @@ prodC x = unsafePerformIO $ do | |||
142 | app2 c_prodC vec x vec r "prodC" | 142 | app2 c_prodC vec x vec r "prodC" |
143 | return $ r @> 0 | 143 | return $ r @> 0 |
144 | 144 | ||
145 | foreign import ccall safe "gsl-aux.h prodF" c_prodF :: TFF | 145 | foreign import ccall unsafe "gsl-aux.h prodF" c_prodF :: TFF |
146 | foreign import ccall safe "gsl-aux.h prodR" c_prodR :: TVV | 146 | foreign import ccall unsafe "gsl-aux.h prodR" c_prodR :: TVV |
147 | foreign import ccall safe "gsl-aux.h prodQ" c_prodQ :: TQVQV | 147 | foreign import ccall unsafe "gsl-aux.h prodQ" c_prodQ :: TQVQV |
148 | foreign import ccall safe "gsl-aux.h prodC" c_prodC :: TCVCV | 148 | foreign import ccall unsafe "gsl-aux.h prodC" c_prodC :: TCVCV |
149 | 149 | ||
150 | -- | dot product | 150 | -- | dot product |
151 | dotF :: Vector Float -> Vector Float -> Float | 151 | dotF :: Vector Float -> Vector Float -> Float |
@@ -175,10 +175,10 @@ dotC x y = unsafePerformIO $ do | |||
175 | app3 c_dotC vec x vec y vec r "dotC" | 175 | app3 c_dotC vec x vec y vec r "dotC" |
176 | return $ r @> 0 | 176 | return $ r @> 0 |
177 | 177 | ||
178 | foreign import ccall safe "gsl-aux.h dotF" c_dotF :: TFFF | 178 | foreign import ccall unsafe "gsl-aux.h dotF" c_dotF :: TFFF |
179 | foreign import ccall safe "gsl-aux.h dotR" c_dotR :: TVVV | 179 | foreign import ccall unsafe "gsl-aux.h dotR" c_dotR :: TVVV |
180 | foreign import ccall safe "gsl-aux.h dotQ" c_dotQ :: TQVQVQV | 180 | foreign import ccall unsafe "gsl-aux.h dotQ" c_dotQ :: TQVQVQV |
181 | foreign import ccall safe "gsl-aux.h dotC" c_dotC :: TCVCVCV | 181 | foreign import ccall unsafe "gsl-aux.h dotC" c_dotC :: TCVCVCV |
182 | 182 | ||
183 | ------------------------------------------------------------------ | 183 | ------------------------------------------------------------------ |
184 | 184 | ||
@@ -210,25 +210,25 @@ vectorZipAux fun code u v = unsafePerformIO $ do | |||
210 | toScalarR :: FunCodeS -> Vector Double -> Double | 210 | toScalarR :: FunCodeS -> Vector Double -> Double |
211 | toScalarR oper = toScalarAux c_toScalarR (fromei oper) | 211 | toScalarR oper = toScalarAux c_toScalarR (fromei oper) |
212 | 212 | ||
213 | foreign import ccall safe "gsl-aux.h toScalarR" c_toScalarR :: CInt -> TVV | 213 | foreign import ccall unsafe "gsl-aux.h toScalarR" c_toScalarR :: CInt -> TVV |
214 | 214 | ||
215 | -- | obtains different functions of a vector: norm1, norm2, max, min, posmax, posmin, etc. | 215 | -- | obtains different functions of a vector: norm1, norm2, max, min, posmax, posmin, etc. |
216 | toScalarF :: FunCodeS -> Vector Float -> Float | 216 | toScalarF :: FunCodeS -> Vector Float -> Float |
217 | toScalarF oper = toScalarAux c_toScalarF (fromei oper) | 217 | toScalarF oper = toScalarAux c_toScalarF (fromei oper) |
218 | 218 | ||
219 | foreign import ccall safe "gsl-aux.h toScalarF" c_toScalarF :: CInt -> TFF | 219 | foreign import ccall unsafe "gsl-aux.h toScalarF" c_toScalarF :: CInt -> TFF |
220 | 220 | ||
221 | -- | obtains different functions of a vector: only norm1, norm2 | 221 | -- | obtains different functions of a vector: only norm1, norm2 |
222 | toScalarC :: FunCodeS -> Vector (Complex Double) -> Double | 222 | toScalarC :: FunCodeS -> Vector (Complex Double) -> Double |
223 | toScalarC oper = toScalarAux c_toScalarC (fromei oper) | 223 | toScalarC oper = toScalarAux c_toScalarC (fromei oper) |
224 | 224 | ||
225 | foreign import ccall safe "gsl-aux.h toScalarC" c_toScalarC :: CInt -> TCVV | 225 | foreign import ccall unsafe "gsl-aux.h toScalarC" c_toScalarC :: CInt -> TCVV |
226 | 226 | ||
227 | -- | obtains different functions of a vector: only norm1, norm2 | 227 | -- | obtains different functions of a vector: only norm1, norm2 |
228 | toScalarQ :: FunCodeS -> Vector (Complex Float) -> Float | 228 | toScalarQ :: FunCodeS -> Vector (Complex Float) -> Float |
229 | toScalarQ oper = toScalarAux c_toScalarQ (fromei oper) | 229 | toScalarQ oper = toScalarAux c_toScalarQ (fromei oper) |
230 | 230 | ||
231 | foreign import ccall safe "gsl-aux.h toScalarQ" c_toScalarQ :: CInt -> TQVF | 231 | foreign import ccall unsafe "gsl-aux.h toScalarQ" c_toScalarQ :: CInt -> TQVF |
232 | 232 | ||
233 | ------------------------------------------------------------------ | 233 | ------------------------------------------------------------------ |
234 | 234 | ||
@@ -236,25 +236,25 @@ foreign import ccall safe "gsl-aux.h toScalarQ" c_toScalarQ :: CInt -> TQVF | |||
236 | vectorMapR :: FunCodeV -> Vector Double -> Vector Double | 236 | vectorMapR :: FunCodeV -> Vector Double -> Vector Double |
237 | vectorMapR = vectorMapAux c_vectorMapR | 237 | vectorMapR = vectorMapAux c_vectorMapR |
238 | 238 | ||
239 | foreign import ccall safe "gsl-aux.h mapR" c_vectorMapR :: CInt -> TVV | 239 | foreign import ccall unsafe "gsl-aux.h mapR" c_vectorMapR :: CInt -> TVV |
240 | 240 | ||
241 | -- | map of complex vectors with given function | 241 | -- | map of complex vectors with given function |
242 | vectorMapC :: FunCodeV -> Vector (Complex Double) -> Vector (Complex Double) | 242 | vectorMapC :: FunCodeV -> Vector (Complex Double) -> Vector (Complex Double) |
243 | vectorMapC oper = vectorMapAux c_vectorMapC (fromei oper) | 243 | vectorMapC oper = vectorMapAux c_vectorMapC (fromei oper) |
244 | 244 | ||
245 | foreign import ccall safe "gsl-aux.h mapC" c_vectorMapC :: CInt -> TCVCV | 245 | foreign import ccall unsafe "gsl-aux.h mapC" c_vectorMapC :: CInt -> TCVCV |
246 | 246 | ||
247 | -- | map of real vectors with given function | 247 | -- | map of real vectors with given function |
248 | vectorMapF :: FunCodeV -> Vector Float -> Vector Float | 248 | vectorMapF :: FunCodeV -> Vector Float -> Vector Float |
249 | vectorMapF = vectorMapAux c_vectorMapF | 249 | vectorMapF = vectorMapAux c_vectorMapF |
250 | 250 | ||
251 | foreign import ccall safe "gsl-aux.h mapF" c_vectorMapF :: CInt -> TFF | 251 | foreign import ccall unsafe "gsl-aux.h mapF" c_vectorMapF :: CInt -> TFF |
252 | 252 | ||
253 | -- | map of real vectors with given function | 253 | -- | map of real vectors with given function |
254 | vectorMapQ :: FunCodeV -> Vector (Complex Float) -> Vector (Complex Float) | 254 | vectorMapQ :: FunCodeV -> Vector (Complex Float) -> Vector (Complex Float) |
255 | vectorMapQ = vectorMapAux c_vectorMapQ | 255 | vectorMapQ = vectorMapAux c_vectorMapQ |
256 | 256 | ||
257 | foreign import ccall safe "gsl-aux.h mapQ" c_vectorMapQ :: CInt -> TQVQV | 257 | foreign import ccall unsafe "gsl-aux.h mapQ" c_vectorMapQ :: CInt -> TQVQV |
258 | 258 | ||
259 | ------------------------------------------------------------------- | 259 | ------------------------------------------------------------------- |
260 | 260 | ||
@@ -262,25 +262,25 @@ foreign import ccall safe "gsl-aux.h mapQ" c_vectorMapQ :: CInt -> TQVQV | |||
262 | vectorMapValR :: FunCodeSV -> Double -> Vector Double -> Vector Double | 262 | vectorMapValR :: FunCodeSV -> Double -> Vector Double -> Vector Double |
263 | vectorMapValR oper = vectorMapValAux c_vectorMapValR (fromei oper) | 263 | vectorMapValR oper = vectorMapValAux c_vectorMapValR (fromei oper) |
264 | 264 | ||
265 | foreign import ccall safe "gsl-aux.h mapValR" c_vectorMapValR :: CInt -> Ptr Double -> TVV | 265 | foreign import ccall unsafe "gsl-aux.h mapValR" c_vectorMapValR :: CInt -> Ptr Double -> TVV |
266 | 266 | ||
267 | -- | map of complex vectors with given function | 267 | -- | map of complex vectors with given function |
268 | vectorMapValC :: FunCodeSV -> Complex Double -> Vector (Complex Double) -> Vector (Complex Double) | 268 | vectorMapValC :: FunCodeSV -> Complex Double -> Vector (Complex Double) -> Vector (Complex Double) |
269 | vectorMapValC = vectorMapValAux c_vectorMapValC | 269 | vectorMapValC = vectorMapValAux c_vectorMapValC |
270 | 270 | ||
271 | foreign import ccall safe "gsl-aux.h mapValC" c_vectorMapValC :: CInt -> Ptr (Complex Double) -> TCVCV | 271 | foreign import ccall unsafe "gsl-aux.h mapValC" c_vectorMapValC :: CInt -> Ptr (Complex Double) -> TCVCV |
272 | 272 | ||
273 | -- | map of real vectors with given function | 273 | -- | map of real vectors with given function |
274 | vectorMapValF :: FunCodeSV -> Float -> Vector Float -> Vector Float | 274 | vectorMapValF :: FunCodeSV -> Float -> Vector Float -> Vector Float |
275 | vectorMapValF oper = vectorMapValAux c_vectorMapValF (fromei oper) | 275 | vectorMapValF oper = vectorMapValAux c_vectorMapValF (fromei oper) |
276 | 276 | ||
277 | foreign import ccall safe "gsl-aux.h mapValF" c_vectorMapValF :: CInt -> Ptr Float -> TFF | 277 | foreign import ccall unsafe "gsl-aux.h mapValF" c_vectorMapValF :: CInt -> Ptr Float -> TFF |
278 | 278 | ||
279 | -- | map of complex vectors with given function | 279 | -- | map of complex vectors with given function |
280 | vectorMapValQ :: FunCodeSV -> Complex Float -> Vector (Complex Float) -> Vector (Complex Float) | 280 | vectorMapValQ :: FunCodeSV -> Complex Float -> Vector (Complex Float) -> Vector (Complex Float) |
281 | vectorMapValQ oper = vectorMapValAux c_vectorMapValQ (fromei oper) | 281 | vectorMapValQ oper = vectorMapValAux c_vectorMapValQ (fromei oper) |
282 | 282 | ||
283 | foreign import ccall safe "gsl-aux.h mapValQ" c_vectorMapValQ :: CInt -> Ptr (Complex Float) -> TQVQV | 283 | foreign import ccall unsafe "gsl-aux.h mapValQ" c_vectorMapValQ :: CInt -> Ptr (Complex Float) -> TQVQV |
284 | 284 | ||
285 | ------------------------------------------------------------------- | 285 | ------------------------------------------------------------------- |
286 | 286 | ||
@@ -288,25 +288,25 @@ foreign import ccall safe "gsl-aux.h mapValQ" c_vectorMapValQ :: CInt -> Ptr (Co | |||
288 | vectorZipR :: FunCodeVV -> Vector Double -> Vector Double -> Vector Double | 288 | vectorZipR :: FunCodeVV -> Vector Double -> Vector Double -> Vector Double |
289 | vectorZipR = vectorZipAux c_vectorZipR | 289 | vectorZipR = vectorZipAux c_vectorZipR |
290 | 290 | ||
291 | foreign import ccall safe "gsl-aux.h zipR" c_vectorZipR :: CInt -> TVVV | 291 | foreign import ccall unsafe "gsl-aux.h zipR" c_vectorZipR :: CInt -> TVVV |
292 | 292 | ||
293 | -- | elementwise operation on complex vectors | 293 | -- | elementwise operation on complex vectors |
294 | vectorZipC :: FunCodeVV -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) | 294 | vectorZipC :: FunCodeVV -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) |
295 | vectorZipC = vectorZipAux c_vectorZipC | 295 | vectorZipC = vectorZipAux c_vectorZipC |
296 | 296 | ||
297 | foreign import ccall safe "gsl-aux.h zipC" c_vectorZipC :: CInt -> TCVCVCV | 297 | foreign import ccall unsafe "gsl-aux.h zipC" c_vectorZipC :: CInt -> TCVCVCV |
298 | 298 | ||
299 | -- | elementwise operation on real vectors | 299 | -- | elementwise operation on real vectors |
300 | vectorZipF :: FunCodeVV -> Vector Float -> Vector Float -> Vector Float | 300 | vectorZipF :: FunCodeVV -> Vector Float -> Vector Float -> Vector Float |
301 | vectorZipF = vectorZipAux c_vectorZipF | 301 | vectorZipF = vectorZipAux c_vectorZipF |
302 | 302 | ||
303 | foreign import ccall safe "gsl-aux.h zipF" c_vectorZipF :: CInt -> TFFF | 303 | foreign import ccall unsafe "gsl-aux.h zipF" c_vectorZipF :: CInt -> TFFF |
304 | 304 | ||
305 | -- | elementwise operation on complex vectors | 305 | -- | elementwise operation on complex vectors |
306 | vectorZipQ :: FunCodeVV -> Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float) | 306 | vectorZipQ :: FunCodeVV -> Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float) |
307 | vectorZipQ = vectorZipAux c_vectorZipQ | 307 | vectorZipQ = vectorZipAux c_vectorZipQ |
308 | 308 | ||
309 | foreign import ccall safe "gsl-aux.h zipQ" c_vectorZipQ :: CInt -> TQVQVQV | 309 | foreign import ccall unsafe "gsl-aux.h zipQ" c_vectorZipQ :: CInt -> TQVQVQV |
310 | 310 | ||
311 | ----------------------------------------------------------------------- | 311 | ----------------------------------------------------------------------- |
312 | 312 | ||
@@ -324,4 +324,4 @@ randomVector seed dist n = unsafePerformIO $ do | |||
324 | app1 (c_random_vector (fi seed) ((fi.fromEnum) dist)) vec r "randomVector" | 324 | app1 (c_random_vector (fi seed) ((fi.fromEnum) dist)) vec r "randomVector" |
325 | return r | 325 | return r |
326 | 326 | ||
327 | foreign import ccall safe "random_vector" c_random_vector :: CInt -> CInt -> TV | 327 | foreign import ccall unsafe "random_vector" c_random_vector :: CInt -> CInt -> TV |
diff --git a/lib/Numeric/LinearAlgebra/LAPACK.hs b/lib/Numeric/LinearAlgebra/LAPACK.hs index 7ad58e1..9bc6669 100644 --- a/lib/Numeric/LinearAlgebra/LAPACK.hs +++ b/lib/Numeric/LinearAlgebra/LAPACK.hs | |||
@@ -53,10 +53,10 @@ import System.IO.Unsafe(unsafePerformIO) | |||
53 | 53 | ||
54 | ----------------------------------------------------------------------------------- | 54 | ----------------------------------------------------------------------------------- |
55 | 55 | ||
56 | foreign import ccall "multiplyR" dgemmc :: CInt -> CInt -> TMMM | 56 | foreign import ccall unsafe "multiplyR" dgemmc :: CInt -> CInt -> TMMM |
57 | foreign import ccall "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM | 57 | foreign import ccall unsafe "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM |
58 | foreign import ccall "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM | 58 | foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM |
59 | foreign import ccall "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM | 59 | foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM |
60 | 60 | ||
61 | isT Matrix{order = ColumnMajor} = 0 | 61 | isT Matrix{order = ColumnMajor} = 0 |
62 | isT Matrix{order = RowMajor} = 1 | 62 | isT Matrix{order = RowMajor} = 1 |
@@ -88,10 +88,10 @@ multiplyQ :: Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex | |||
88 | multiplyQ a b = multiplyAux cgemmc "cgemmc" a b | 88 | multiplyQ a b = multiplyAux cgemmc "cgemmc" a b |
89 | 89 | ||
90 | ----------------------------------------------------------------------------- | 90 | ----------------------------------------------------------------------------- |
91 | foreign import ccall "svd_l_R" dgesvd :: TMMVM | 91 | foreign import ccall unsafe "svd_l_R" dgesvd :: TMMVM |
92 | foreign import ccall "svd_l_C" zgesvd :: TCMCMVCM | 92 | foreign import ccall unsafe "svd_l_C" zgesvd :: TCMCMVCM |
93 | foreign import ccall "svd_l_Rdd" dgesdd :: TMMVM | 93 | foreign import ccall unsafe "svd_l_Rdd" dgesdd :: TMMVM |
94 | foreign import ccall "svd_l_Cdd" zgesdd :: TCMCMVCM | 94 | foreign import ccall unsafe "svd_l_Cdd" zgesdd :: TCMCMVCM |
95 | 95 | ||
96 | -- | Full SVD of a real matrix using LAPACK's /dgesvd/. | 96 | -- | Full SVD of a real matrix using LAPACK's /dgesvd/. |
97 | svdR :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) | 97 | svdR :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) |
@@ -211,10 +211,10 @@ leftSVAux f st x = unsafePerformIO $ do | |||
211 | 211 | ||
212 | ----------------------------------------------------------------------------- | 212 | ----------------------------------------------------------------------------- |
213 | 213 | ||
214 | foreign import ccall "LAPACK/lapack-aux.h eig_l_R" dgeev :: TMMCVM | 214 | foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_R" dgeev :: TMMCVM |
215 | foreign import ccall "LAPACK/lapack-aux.h eig_l_C" zgeev :: TCMCMCVCM | 215 | foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_C" zgeev :: TCMCMCVCM |
216 | foreign import ccall "LAPACK/lapack-aux.h eig_l_S" dsyev :: CInt -> TMVM | 216 | foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_S" dsyev :: CInt -> TMVM |
217 | foreign import ccall "LAPACK/lapack-aux.h eig_l_H" zheev :: CInt -> TCMVCM | 217 | foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_H" zheev :: CInt -> TCMVCM |
218 | 218 | ||
219 | eigAux f st m = unsafePerformIO $ do | 219 | eigAux f st m = unsafePerformIO $ do |
220 | l <- createVector r | 220 | l <- createVector r |
@@ -325,10 +325,10 @@ eigOnlyH = vrev . fst. eigSHAux (zheev 1) "eigH'" . fmat | |||
325 | vrev = flatten . flipud . reshape 1 | 325 | vrev = flatten . flipud . reshape 1 |
326 | 326 | ||
327 | ----------------------------------------------------------------------------- | 327 | ----------------------------------------------------------------------------- |
328 | foreign import ccall "linearSolveR_l" dgesv :: TMMM | 328 | foreign import ccall unsafe "linearSolveR_l" dgesv :: TMMM |
329 | foreign import ccall "linearSolveC_l" zgesv :: TCMCMCM | 329 | foreign import ccall unsafe "linearSolveC_l" zgesv :: TCMCMCM |
330 | foreign import ccall "cholSolveR_l" dpotrs :: TMMM | 330 | foreign import ccall unsafe "cholSolveR_l" dpotrs :: TMMM |
331 | foreign import ccall "cholSolveC_l" zpotrs :: TCMCMCM | 331 | foreign import ccall unsafe "cholSolveC_l" zpotrs :: TCMCMCM |
332 | 332 | ||
333 | linearSolveSQAux f st a b | 333 | linearSolveSQAux f st a b |
334 | | n1==n2 && n1==r = unsafePerformIO $ do | 334 | | n1==n2 && n1==r = unsafePerformIO $ do |
@@ -359,10 +359,10 @@ cholSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Comp | |||
359 | cholSolveC a b = linearSolveSQAux zpotrs "cholSolveC" (fmat a) (fmat b) | 359 | cholSolveC a b = linearSolveSQAux zpotrs "cholSolveC" (fmat a) (fmat b) |
360 | 360 | ||
361 | ----------------------------------------------------------------------------------- | 361 | ----------------------------------------------------------------------------------- |
362 | foreign import ccall "LAPACK/lapack-aux.h linearSolveLSR_l" dgels :: TMMM | 362 | foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveLSR_l" dgels :: TMMM |
363 | foreign import ccall "LAPACK/lapack-aux.h linearSolveLSC_l" zgels :: TCMCMCM | 363 | foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveLSC_l" zgels :: TCMCMCM |
364 | foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDR_l" dgelss :: Double -> TMMM | 364 | foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveSVDR_l" dgelss :: Double -> TMMM |
365 | foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDC_l" zgelss :: Double -> TCMCMCM | 365 | foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveSVDC_l" zgelss :: Double -> TCMCMCM |
366 | 366 | ||
367 | linearSolveAux f st a b = unsafePerformIO $ do | 367 | linearSolveAux f st a b = unsafePerformIO $ do |
368 | r <- createMatrix ColumnMajor (max m n) nrhs | 368 | r <- createMatrix ColumnMajor (max m n) nrhs |
@@ -401,8 +401,8 @@ linearSolveSVDC (Just rcond) a b = subMatrix (0,0) (cols a, cols b) $ | |||
401 | linearSolveSVDC Nothing a b = linearSolveSVDC (Just (-1)) (fmat a) (fmat b) | 401 | linearSolveSVDC Nothing a b = linearSolveSVDC (Just (-1)) (fmat a) (fmat b) |
402 | 402 | ||
403 | ----------------------------------------------------------------------------------- | 403 | ----------------------------------------------------------------------------------- |
404 | foreign import ccall "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM | 404 | foreign import ccall unsafe "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM |
405 | foreign import ccall "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM | 405 | foreign import ccall unsafe "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM |
406 | 406 | ||
407 | cholAux f st a = do | 407 | cholAux f st a = do |
408 | r <- createMatrix ColumnMajor n n | 408 | r <- createMatrix ColumnMajor n n |
@@ -427,8 +427,8 @@ mbCholS :: Matrix Double -> Maybe (Matrix Double) | |||
427 | mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" . fmat | 427 | mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" . fmat |
428 | 428 | ||
429 | ----------------------------------------------------------------------------------- | 429 | ----------------------------------------------------------------------------------- |
430 | foreign import ccall "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM | 430 | foreign import ccall unsafe "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM |
431 | foreign import ccall "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM | 431 | foreign import ccall unsafe "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM |
432 | 432 | ||
433 | -- | QR factorization of a real matrix, using LAPACK's /dgeqr2/. | 433 | -- | QR factorization of a real matrix, using LAPACK's /dgeqr2/. |
434 | qrR :: Matrix Double -> (Matrix Double, Vector Double) | 434 | qrR :: Matrix Double -> (Matrix Double, Vector Double) |
@@ -448,8 +448,8 @@ qrAux f st a = unsafePerformIO $ do | |||
448 | mn = min m n | 448 | mn = min m n |
449 | 449 | ||
450 | ----------------------------------------------------------------------------------- | 450 | ----------------------------------------------------------------------------------- |
451 | foreign import ccall "LAPACK/lapack-aux.h hess_l_R" dgehrd :: TMVM | 451 | foreign import ccall unsafe "LAPACK/lapack-aux.h hess_l_R" dgehrd :: TMVM |
452 | foreign import ccall "LAPACK/lapack-aux.h hess_l_C" zgehrd :: TCMCVCM | 452 | foreign import ccall unsafe "LAPACK/lapack-aux.h hess_l_C" zgehrd :: TCMCVCM |
453 | 453 | ||
454 | -- | Hessenberg factorization of a square real matrix, using LAPACK's /dgehrd/. | 454 | -- | Hessenberg factorization of a square real matrix, using LAPACK's /dgehrd/. |
455 | hessR :: Matrix Double -> (Matrix Double, Vector Double) | 455 | hessR :: Matrix Double -> (Matrix Double, Vector Double) |
@@ -469,8 +469,8 @@ hessAux f st a = unsafePerformIO $ do | |||
469 | mn = min m n | 469 | mn = min m n |
470 | 470 | ||
471 | ----------------------------------------------------------------------------------- | 471 | ----------------------------------------------------------------------------------- |
472 | foreign import ccall "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM | 472 | foreign import ccall unsafe "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM |
473 | foreign import ccall "LAPACK/lapack-aux.h schur_l_C" zgees :: TCMCMCM | 473 | foreign import ccall unsafe "LAPACK/lapack-aux.h schur_l_C" zgees :: TCMCMCM |
474 | 474 | ||
475 | -- | Schur factorization of a square real matrix, using LAPACK's /dgees/. | 475 | -- | Schur factorization of a square real matrix, using LAPACK's /dgees/. |
476 | schurR :: Matrix Double -> (Matrix Double, Matrix Double) | 476 | schurR :: Matrix Double -> (Matrix Double, Matrix Double) |
@@ -488,8 +488,8 @@ schurAux f st a = unsafePerformIO $ do | |||
488 | where n = rows a | 488 | where n = rows a |
489 | 489 | ||
490 | ----------------------------------------------------------------------------------- | 490 | ----------------------------------------------------------------------------------- |
491 | foreign import ccall "LAPACK/lapack-aux.h lu_l_R" dgetrf :: TMVM | 491 | foreign import ccall unsafe "LAPACK/lapack-aux.h lu_l_R" dgetrf :: TMVM |
492 | foreign import ccall "LAPACK/lapack-aux.h lu_l_C" zgetrf :: TCMVCM | 492 | foreign import ccall unsafe "LAPACK/lapack-aux.h lu_l_C" zgetrf :: TCMVCM |
493 | 493 | ||
494 | -- | LU factorization of a general real matrix, using LAPACK's /dgetrf/. | 494 | -- | LU factorization of a general real matrix, using LAPACK's /dgetrf/. |
495 | luR :: Matrix Double -> (Matrix Double, [Int]) | 495 | luR :: Matrix Double -> (Matrix Double, [Int]) |
@@ -511,8 +511,8 @@ luAux f st a = unsafePerformIO $ do | |||
511 | type TW a = CInt -> PD -> a | 511 | type TW a = CInt -> PD -> a |
512 | type TQ a = CInt -> CInt -> PC -> a | 512 | type TQ a = CInt -> CInt -> PC -> a |
513 | 513 | ||
514 | foreign import ccall "LAPACK/lapack-aux.h luS_l_R" dgetrs :: TMVMM | 514 | foreign import ccall unsafe "LAPACK/lapack-aux.h luS_l_R" dgetrs :: TMVMM |
515 | foreign import ccall "LAPACK/lapack-aux.h luS_l_C" zgetrs :: TQ (TW (TQ (TQ (IO CInt)))) | 515 | foreign import ccall unsafe "LAPACK/lapack-aux.h luS_l_C" zgetrs :: TQ (TW (TQ (TQ (IO CInt)))) |
516 | 516 | ||
517 | -- | Solve a real linear system from a precomputed LU decomposition ('luR'), using LAPACK's /dgetrs/. | 517 | -- | Solve a real linear system from a precomputed LU decomposition ('luR'), using LAPACK's /dgetrs/. |
518 | lusR :: Matrix Double -> [Int] -> Matrix Double -> Matrix Double | 518 | lusR :: Matrix Double -> [Int] -> Matrix Double -> Matrix Double |