From f8b7b3734fa6bb8d63914719e09d17940add27d4 Mon Sep 17 00:00:00 2001 From: Clark Gaebel Date: Sat, 10 Mar 2012 18:26:56 -0500 Subject: Removed foreign import safety. --- lib/Data/Packed/Internal/Common.hs | 4 +-- lib/Data/Packed/Internal/Matrix.hs | 22 ++++++------- lib/Data/Packed/Internal/Vector.hs | 24 +++++++------- lib/Numeric/GSL.hs | 2 +- lib/Numeric/GSL/Differentiation.hs | 4 +-- lib/Numeric/GSL/Fitting.hs | 2 +- lib/Numeric/GSL/Fourier.hs | 2 +- lib/Numeric/GSL/Integration.hs | 12 +++---- lib/Numeric/GSL/Internal.hs | 10 +++--- lib/Numeric/GSL/Minimization.hs | 4 +-- lib/Numeric/GSL/ODE.hs | 2 +- lib/Numeric/GSL/Polynomials.hs | 2 +- lib/Numeric/GSL/Root.hs | 4 +-- lib/Numeric/GSL/Vector.hs | 58 ++++++++++++++++----------------- lib/Numeric/LinearAlgebra/LAPACK.hs | 64 ++++++++++++++++++------------------- 15 files changed, 108 insertions(+), 108 deletions(-) (limited to 'lib') 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 -- | clear the fpu -foreign import ccall "asm_finit" finit :: IO () +foreign import ccall unsafe "asm_finit" finit :: IO () -- | check the error code check :: String -> IO CInt -> IO () @@ -158,7 +158,7 @@ check msg f = do return () -- | description of GSL error codes -foreign import ccall "gsl_strerror" gsl_strerror :: CInt -> IO (Ptr CChar) +foreign import ccall unsafe "gsl_strerror" gsl_strerror :: CInt -> IO (Ptr CChar) -- | Error capture and conversion to Maybe 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 = sz = sizeOf (d @> 0) noneed = r1 == 1 || c1 == 1 -foreign import ccall "transF" ctransF :: TFMFM -foreign import ccall "transR" ctransR :: TMM -foreign import ccall "transQ" ctransQ :: TQMQM -foreign import ccall "transC" ctransC :: TCMCM -foreign import ccall "transP" ctransP :: CInt -> CInt -> Ptr () -> CInt -> CInt -> CInt -> Ptr () -> CInt -> IO CInt +foreign import ccall unsafe "transF" ctransF :: TFMFM +foreign import ccall unsafe "transR" ctransR :: TMM +foreign import ccall unsafe "transQ" ctransQ :: TQMQM +foreign import ccall unsafe "transC" ctransC :: TCMCM +foreign import ccall unsafe "transP" ctransP :: CInt -> CInt -> Ptr () -> CInt -> CInt -> CInt -> Ptr () -> CInt -> IO CInt ---------------------------------------------------------------------- @@ -358,19 +358,19 @@ constantAux fun x n = unsafePerformIO $ do constantF :: Float -> Int -> Vector Float constantF = constantAux cconstantF -foreign import ccall "constantF" cconstantF :: Ptr Float -> TF +foreign import ccall unsafe "constantF" cconstantF :: Ptr Float -> TF constantR :: Double -> Int -> Vector Double constantR = constantAux cconstantR -foreign import ccall "constantR" cconstantR :: Ptr Double -> TV +foreign import ccall unsafe "constantR" cconstantR :: Ptr Double -> TV constantQ :: Complex Float -> Int -> Vector (Complex Float) constantQ = constantAux cconstantQ -foreign import ccall "constantQ" cconstantQ :: Ptr (Complex Float) -> TQV +foreign import ccall unsafe "constantQ" cconstantQ :: Ptr (Complex Float) -> TQV constantC :: Complex Double -> Int -> Vector (Complex Double) constantC = constantAux cconstantC -foreign import ccall "constantC" cconstantC :: Ptr (Complex Double) -> TCV +foreign import ccall unsafe "constantC" cconstantC :: Ptr (Complex Double) -> TCV constantP :: Storable a => a -> Int -> Vector a constantP a n = unsafePerformIO $ do @@ -381,7 +381,7 @@ constantP a n = unsafePerformIO $ do poke k a cconstantP (castPtr k) (fi n) (castPtr p) (fi sz) // check "constantP" return v -foreign import ccall "constantP" cconstantP :: Ptr () -> CInt -> Ptr () -> CInt -> IO CInt +foreign import ccall unsafe "constantP" cconstantP :: Ptr () -> CInt -> Ptr () -> CInt -> IO CInt ---------------------------------------------------------------------- @@ -427,7 +427,7 @@ saveMatrix filename fmt m = do free charname free charfmt -foreign import ccall "matrix_fprintf" matrix_fprintf :: Ptr CChar -> Ptr CChar -> CInt -> TM +foreign import ccall unsafe "matrix_fprintf" matrix_fprintf :: Ptr CChar -> Ptr CChar -> CInt -> TM ---------------------------------------------------------------------- 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 return r -foreign import ccall "float2double" c_float2double:: TFV -foreign import ccall "double2float" c_double2float:: TVF +foreign import ccall unsafe "float2double" c_float2double:: TFV +foreign import ccall unsafe "double2float" c_double2float:: TVF --------------------------------------------------------------- @@ -325,8 +325,8 @@ stepD v = unsafePerformIO $ do app2 c_stepD vec v vec r "stepD" return r -foreign import ccall "stepF" c_stepF :: TFF -foreign import ccall "stepD" c_stepD :: TVV +foreign import ccall unsafe "stepF" c_stepF :: TFF +foreign import ccall unsafe "stepD" c_stepD :: TVV --------------------------------------------------------------- @@ -342,8 +342,8 @@ condD x y l e g = unsafePerformIO $ do app6 c_condD vec x vec y vec l vec e vec g vec r "condD" return r -foreign import ccall "condF" c_condF :: CInt -> PF -> CInt -> PF -> CInt -> PF -> TFFF -foreign import ccall "condD" c_condD :: CInt -> PD -> CInt -> PD -> CInt -> PD -> TVVV +foreign import ccall unsafe "condF" c_condF :: CInt -> PF -> CInt -> PF -> CInt -> PF -> TFFF +foreign import ccall unsafe "condD" c_condD :: CInt -> PD -> CInt -> PD -> CInt -> PD -> TVVV -------------------------------------------------------------------------------- @@ -354,11 +354,11 @@ conjugateAux fun x = unsafePerformIO $ do conjugateQ :: Vector (Complex Float) -> Vector (Complex Float) conjugateQ = conjugateAux c_conjugateQ -foreign import ccall "conjugateQ" c_conjugateQ :: TQVQV +foreign import ccall unsafe "conjugateQ" c_conjugateQ :: TQVQV conjugateC :: Vector (Complex Double) -> Vector (Complex Double) conjugateC = conjugateAux c_conjugateC -foreign import ccall "conjugateC" c_conjugateC :: TCVCV +foreign import ccall unsafe "conjugateC" c_conjugateC :: TCVCV -------------------------------------------------------------------------------- @@ -547,7 +547,7 @@ fscanfVector filename n = do free charname return res -foreign import ccall "vector_fscanf" gsl_vector_fscanf:: Ptr CChar -> TV +foreign import ccall unsafe "vector_fscanf" gsl_vector_fscanf:: Ptr CChar -> TV -- | Saves the elements of a vector, with a given format (%f, %e, %g), to an ASCII file. fprintfVector :: FilePath -> String -> Vector Double -> IO () @@ -558,7 +558,7 @@ fprintfVector filename fmt v = do free charname free charfmt -foreign import ccall "vector_fprintf" gsl_vector_fprintf :: Ptr CChar -> Ptr CChar -> TV +foreign import ccall unsafe "vector_fprintf" gsl_vector_fprintf :: Ptr CChar -> Ptr CChar -> TV -- | Loads a vector from a binary file (the number of elements must be known in advance). freadVector :: FilePath -> Int -> IO (Vector Double) @@ -569,7 +569,7 @@ freadVector filename n = do free charname return res -foreign import ccall "vector_fread" gsl_vector_fread:: Ptr CChar -> TV +foreign import ccall unsafe "vector_fread" gsl_vector_fread:: Ptr CChar -> TV -- | Saves the elements of a vector to a binary file. fwriteVector :: FilePath -> Vector Double -> IO () @@ -578,5 +578,5 @@ fwriteVector filename v = do app1 (gsl_vector_fwrite charname) vec v "gsl_vector_fwrite" free charname -foreign import ccall "vector_fwrite" gsl_vector_fwrite :: Ptr CChar -> TV +foreign import ccall unsafe "vector_fwrite" gsl_vector_fwrite :: Ptr CChar -> TV 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 -- | This action removes the GSL default error handler (which aborts the program), so that -- GSL errors can be handled by Haskell (using Control.Exception) and ghci doesn't abort. -foreign import ccall "GSL/gsl-aux.h no_abort_on_error" setErrorHandlerOff :: IO () +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 freeHaskellFunPtr fp return result -foreign import ccall "gsl-aux.h deriv" +foreign import ccall unsafe "gsl-aux.h deriv" c_deriv :: CInt -> FunPtr (Double -> Ptr () -> Double) -> Double -> Double -> Ptr Double -> Ptr Double -> IO CInt @@ -84,4 +84,4 @@ derivBackward = derivGen 2 {- | conversion of Haskell functions into function pointers that can be used in the C side -} -foreign import ccall "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) +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 freeHaskellFunPtr jp return (subVector 2 p sol, path) -foreign import ccall "nlfit" +foreign import ccall unsafe "nlfit" c_nlfit:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> Double -> CInt -> CInt -> TVM ------------------------------------------------------- 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 app2 (c_fft code) vec v vec r "fft" return r -foreign import ccall "gsl-aux.h fft" c_fft :: CInt -> TCVCV +foreign import ccall unsafe "gsl-aux.h fft" c_fft :: CInt -> TCVCV {- | 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) {- | conversion of Haskell functions into function pointers that can be used in the C side -} -foreign import ccall "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) +foreign import ccall unsafe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) -------------------------------------------------------------------- {- | Numerical integration using /gsl_integration_qags/ (adaptive integration with singularities). For example: @@ -63,7 +63,7 @@ integrateQAGS prec n f a b = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall "gsl-aux.h integrate_qags" +foreign import ccall unsafe "gsl-aux.h integrate_qags" c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt @@ -94,7 +94,7 @@ integrateQNG prec f a b = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall "gsl-aux.h integrate_qng" +foreign import ccall unsafe "gsl-aux.h integrate_qng" c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> Ptr Double -> Ptr Double -> IO CInt @@ -126,7 +126,7 @@ integrateQAGI prec n f = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall "gsl-aux.h integrate_qagi" +foreign import ccall unsafe "gsl-aux.h integrate_qagi" c_integrate_qagi :: FunPtr (Double-> Ptr() -> Double) -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt @@ -159,7 +159,7 @@ integrateQAGIU prec n f a = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall "gsl-aux.h integrate_qagiu" +foreign import ccall unsafe "gsl-aux.h integrate_qagiu" c_integrate_qagiu :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt @@ -192,7 +192,7 @@ integrateQAGIL prec n f b = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall "gsl-aux.h integrate_qagil" +foreign import ccall unsafe "gsl-aux.h integrate_qagil" c_integrate_qagil :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt 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 return 0 -- | conversion of Haskell functions into function pointers that can be used in the C side -foreign import ccall "wrapper" +foreign import ccall unsafe "wrapper" mkVecfun :: (CInt -> Ptr Double -> Double) -> IO( FunPtr (CInt -> Ptr Double -> Double)) -foreign import ccall "wrapper" +foreign import ccall unsafe "wrapper" mkVecVecfun :: TVV -> IO (FunPtr TVV) -foreign import ccall "wrapper" +foreign import ccall unsafe "wrapper" mkDoubleVecVecfun :: (Double -> TVV) -> IO (FunPtr (Double -> TVV)) aux_vTov :: (Vector Double -> Vector Double) -> TVV @@ -46,10 +46,10 @@ aux_vTov f n p nr r = g where g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral nr) return 0 -foreign import ccall "wrapper" +foreign import ccall unsafe "wrapper" mkVecMatfun :: TVM -> IO (FunPtr TVM) -foreign import ccall "wrapper" +foreign import ccall unsafe "wrapper" mkDoubleVecMatfun :: (Double -> TVM) -> IO (FunPtr (Double -> TVM)) 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 return (sol, path) -foreign import ccall "gsl-aux.h minimize" +foreign import ccall unsafe "gsl-aux.h minimize" c_minimize:: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TVVM ---------------------------------------------------------------------------------- @@ -179,7 +179,7 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do freeHaskellFunPtr dfp return (sol,path) -foreign import ccall "gsl-aux.h minimizeD" +foreign import ccall unsafe "gsl-aux.h minimizeD" c_minimizeD :: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> 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 freeHaskellFunPtr fp return sol -foreign import ccall "ode" +foreign import ccall unsafe "ode" ode_c :: CInt -> Double -> Double -> Double -> FunPtr (Double -> TVV) -> FunPtr (Double -> TVM) -> TVVM ------------------------------------------------------- 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 return r | otherwise = error "polySolve on a polynomial of degree zero" -foreign import ccall "gsl-aux.h polySolve" c_polySolve:: TVCV +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 return (take n $ drop 1 sol, path) -foreign import ccall "root" +foreign import ccall unsafe "root" c_root:: CInt -> FunPtr TVV -> Double -> CInt -> TVM ------------------------------------------------------------------------- @@ -130,7 +130,7 @@ rootJGen m f jac xi epsabs maxit = unsafePerformIO $ do return (take n $ drop 1 sol, path) -foreign import ccall "rootj" +foreign import ccall unsafe "rootj" c_rootj:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> CInt -> TVM ------------------------------------------------------- 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 app2 c_sumC vec x vec r "sumC" return $ r @> 0 -foreign import ccall safe "gsl-aux.h sumF" c_sumF :: TFF -foreign import ccall safe "gsl-aux.h sumR" c_sumR :: TVV -foreign import ccall safe "gsl-aux.h sumQ" c_sumQ :: TQVQV -foreign import ccall safe "gsl-aux.h sumC" c_sumC :: TCVCV +foreign import ccall unsafe "gsl-aux.h sumF" c_sumF :: TFF +foreign import ccall unsafe "gsl-aux.h sumR" c_sumR :: TVV +foreign import ccall unsafe "gsl-aux.h sumQ" c_sumQ :: TQVQV +foreign import ccall unsafe "gsl-aux.h sumC" c_sumC :: TCVCV -- | product of elements prodF :: Vector Float -> Float @@ -142,10 +142,10 @@ prodC x = unsafePerformIO $ do app2 c_prodC vec x vec r "prodC" return $ r @> 0 -foreign import ccall safe "gsl-aux.h prodF" c_prodF :: TFF -foreign import ccall safe "gsl-aux.h prodR" c_prodR :: TVV -foreign import ccall safe "gsl-aux.h prodQ" c_prodQ :: TQVQV -foreign import ccall safe "gsl-aux.h prodC" c_prodC :: TCVCV +foreign import ccall unsafe "gsl-aux.h prodF" c_prodF :: TFF +foreign import ccall unsafe "gsl-aux.h prodR" c_prodR :: TVV +foreign import ccall unsafe "gsl-aux.h prodQ" c_prodQ :: TQVQV +foreign import ccall unsafe "gsl-aux.h prodC" c_prodC :: TCVCV -- | dot product dotF :: Vector Float -> Vector Float -> Float @@ -175,10 +175,10 @@ dotC x y = unsafePerformIO $ do app3 c_dotC vec x vec y vec r "dotC" return $ r @> 0 -foreign import ccall safe "gsl-aux.h dotF" c_dotF :: TFFF -foreign import ccall safe "gsl-aux.h dotR" c_dotR :: TVVV -foreign import ccall safe "gsl-aux.h dotQ" c_dotQ :: TQVQVQV -foreign import ccall safe "gsl-aux.h dotC" c_dotC :: TCVCVCV +foreign import ccall unsafe "gsl-aux.h dotF" c_dotF :: TFFF +foreign import ccall unsafe "gsl-aux.h dotR" c_dotR :: TVVV +foreign import ccall unsafe "gsl-aux.h dotQ" c_dotQ :: TQVQVQV +foreign import ccall unsafe "gsl-aux.h dotC" c_dotC :: TCVCVCV ------------------------------------------------------------------ @@ -210,25 +210,25 @@ vectorZipAux fun code u v = unsafePerformIO $ do toScalarR :: FunCodeS -> Vector Double -> Double toScalarR oper = toScalarAux c_toScalarR (fromei oper) -foreign import ccall safe "gsl-aux.h toScalarR" c_toScalarR :: CInt -> TVV +foreign import ccall unsafe "gsl-aux.h toScalarR" c_toScalarR :: CInt -> TVV -- | obtains different functions of a vector: norm1, norm2, max, min, posmax, posmin, etc. toScalarF :: FunCodeS -> Vector Float -> Float toScalarF oper = toScalarAux c_toScalarF (fromei oper) -foreign import ccall safe "gsl-aux.h toScalarF" c_toScalarF :: CInt -> TFF +foreign import ccall unsafe "gsl-aux.h toScalarF" c_toScalarF :: CInt -> TFF -- | obtains different functions of a vector: only norm1, norm2 toScalarC :: FunCodeS -> Vector (Complex Double) -> Double toScalarC oper = toScalarAux c_toScalarC (fromei oper) -foreign import ccall safe "gsl-aux.h toScalarC" c_toScalarC :: CInt -> TCVV +foreign import ccall unsafe "gsl-aux.h toScalarC" c_toScalarC :: CInt -> TCVV -- | obtains different functions of a vector: only norm1, norm2 toScalarQ :: FunCodeS -> Vector (Complex Float) -> Float toScalarQ oper = toScalarAux c_toScalarQ (fromei oper) -foreign import ccall safe "gsl-aux.h toScalarQ" c_toScalarQ :: CInt -> TQVF +foreign import ccall unsafe "gsl-aux.h toScalarQ" c_toScalarQ :: CInt -> TQVF ------------------------------------------------------------------ @@ -236,25 +236,25 @@ foreign import ccall safe "gsl-aux.h toScalarQ" c_toScalarQ :: CInt -> TQVF vectorMapR :: FunCodeV -> Vector Double -> Vector Double vectorMapR = vectorMapAux c_vectorMapR -foreign import ccall safe "gsl-aux.h mapR" c_vectorMapR :: CInt -> TVV +foreign import ccall unsafe "gsl-aux.h mapR" c_vectorMapR :: CInt -> TVV -- | map of complex vectors with given function vectorMapC :: FunCodeV -> Vector (Complex Double) -> Vector (Complex Double) vectorMapC oper = vectorMapAux c_vectorMapC (fromei oper) -foreign import ccall safe "gsl-aux.h mapC" c_vectorMapC :: CInt -> TCVCV +foreign import ccall unsafe "gsl-aux.h mapC" c_vectorMapC :: CInt -> TCVCV -- | map of real vectors with given function vectorMapF :: FunCodeV -> Vector Float -> Vector Float vectorMapF = vectorMapAux c_vectorMapF -foreign import ccall safe "gsl-aux.h mapF" c_vectorMapF :: CInt -> TFF +foreign import ccall unsafe "gsl-aux.h mapF" c_vectorMapF :: CInt -> TFF -- | map of real vectors with given function vectorMapQ :: FunCodeV -> Vector (Complex Float) -> Vector (Complex Float) vectorMapQ = vectorMapAux c_vectorMapQ -foreign import ccall safe "gsl-aux.h mapQ" c_vectorMapQ :: CInt -> TQVQV +foreign import ccall unsafe "gsl-aux.h mapQ" c_vectorMapQ :: CInt -> TQVQV ------------------------------------------------------------------- @@ -262,25 +262,25 @@ foreign import ccall safe "gsl-aux.h mapQ" c_vectorMapQ :: CInt -> TQVQV vectorMapValR :: FunCodeSV -> Double -> Vector Double -> Vector Double vectorMapValR oper = vectorMapValAux c_vectorMapValR (fromei oper) -foreign import ccall safe "gsl-aux.h mapValR" c_vectorMapValR :: CInt -> Ptr Double -> TVV +foreign import ccall unsafe "gsl-aux.h mapValR" c_vectorMapValR :: CInt -> Ptr Double -> TVV -- | map of complex vectors with given function vectorMapValC :: FunCodeSV -> Complex Double -> Vector (Complex Double) -> Vector (Complex Double) vectorMapValC = vectorMapValAux c_vectorMapValC -foreign import ccall safe "gsl-aux.h mapValC" c_vectorMapValC :: CInt -> Ptr (Complex Double) -> TCVCV +foreign import ccall unsafe "gsl-aux.h mapValC" c_vectorMapValC :: CInt -> Ptr (Complex Double) -> TCVCV -- | map of real vectors with given function vectorMapValF :: FunCodeSV -> Float -> Vector Float -> Vector Float vectorMapValF oper = vectorMapValAux c_vectorMapValF (fromei oper) -foreign import ccall safe "gsl-aux.h mapValF" c_vectorMapValF :: CInt -> Ptr Float -> TFF +foreign import ccall unsafe "gsl-aux.h mapValF" c_vectorMapValF :: CInt -> Ptr Float -> TFF -- | map of complex vectors with given function vectorMapValQ :: FunCodeSV -> Complex Float -> Vector (Complex Float) -> Vector (Complex Float) vectorMapValQ oper = vectorMapValAux c_vectorMapValQ (fromei oper) -foreign import ccall safe "gsl-aux.h mapValQ" c_vectorMapValQ :: CInt -> Ptr (Complex Float) -> TQVQV +foreign import ccall unsafe "gsl-aux.h mapValQ" c_vectorMapValQ :: CInt -> Ptr (Complex Float) -> TQVQV ------------------------------------------------------------------- @@ -288,25 +288,25 @@ foreign import ccall safe "gsl-aux.h mapValQ" c_vectorMapValQ :: CInt -> Ptr (Co vectorZipR :: FunCodeVV -> Vector Double -> Vector Double -> Vector Double vectorZipR = vectorZipAux c_vectorZipR -foreign import ccall safe "gsl-aux.h zipR" c_vectorZipR :: CInt -> TVVV +foreign import ccall unsafe "gsl-aux.h zipR" c_vectorZipR :: CInt -> TVVV -- | elementwise operation on complex vectors vectorZipC :: FunCodeVV -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) vectorZipC = vectorZipAux c_vectorZipC -foreign import ccall safe "gsl-aux.h zipC" c_vectorZipC :: CInt -> TCVCVCV +foreign import ccall unsafe "gsl-aux.h zipC" c_vectorZipC :: CInt -> TCVCVCV -- | elementwise operation on real vectors vectorZipF :: FunCodeVV -> Vector Float -> Vector Float -> Vector Float vectorZipF = vectorZipAux c_vectorZipF -foreign import ccall safe "gsl-aux.h zipF" c_vectorZipF :: CInt -> TFFF +foreign import ccall unsafe "gsl-aux.h zipF" c_vectorZipF :: CInt -> TFFF -- | elementwise operation on complex vectors vectorZipQ :: FunCodeVV -> Vector (Complex Float) -> Vector (Complex Float) -> Vector (Complex Float) vectorZipQ = vectorZipAux c_vectorZipQ -foreign import ccall safe "gsl-aux.h zipQ" c_vectorZipQ :: CInt -> TQVQVQV +foreign import ccall unsafe "gsl-aux.h zipQ" c_vectorZipQ :: CInt -> TQVQVQV ----------------------------------------------------------------------- @@ -324,4 +324,4 @@ randomVector seed dist n = unsafePerformIO $ do app1 (c_random_vector (fi seed) ((fi.fromEnum) dist)) vec r "randomVector" return r -foreign import ccall safe "random_vector" c_random_vector :: CInt -> CInt -> TV +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) ----------------------------------------------------------------------------------- -foreign import ccall "multiplyR" dgemmc :: CInt -> CInt -> TMMM -foreign import ccall "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM -foreign import ccall "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM -foreign import ccall "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM +foreign import ccall unsafe "multiplyR" dgemmc :: CInt -> CInt -> TMMM +foreign import ccall unsafe "multiplyC" zgemmc :: CInt -> CInt -> TCMCMCM +foreign import ccall unsafe "multiplyF" sgemmc :: CInt -> CInt -> TFMFMFM +foreign import ccall unsafe "multiplyQ" cgemmc :: CInt -> CInt -> TQMQMQM isT Matrix{order = ColumnMajor} = 0 isT Matrix{order = RowMajor} = 1 @@ -88,10 +88,10 @@ multiplyQ :: Matrix (Complex Float) -> Matrix (Complex Float) -> Matrix (Complex multiplyQ a b = multiplyAux cgemmc "cgemmc" a b ----------------------------------------------------------------------------- -foreign import ccall "svd_l_R" dgesvd :: TMMVM -foreign import ccall "svd_l_C" zgesvd :: TCMCMVCM -foreign import ccall "svd_l_Rdd" dgesdd :: TMMVM -foreign import ccall "svd_l_Cdd" zgesdd :: TCMCMVCM +foreign import ccall unsafe "svd_l_R" dgesvd :: TMMVM +foreign import ccall unsafe "svd_l_C" zgesvd :: TCMCMVCM +foreign import ccall unsafe "svd_l_Rdd" dgesdd :: TMMVM +foreign import ccall unsafe "svd_l_Cdd" zgesdd :: TCMCMVCM -- | Full SVD of a real matrix using LAPACK's /dgesvd/. svdR :: Matrix Double -> (Matrix Double, Vector Double, Matrix Double) @@ -211,10 +211,10 @@ leftSVAux f st x = unsafePerformIO $ do ----------------------------------------------------------------------------- -foreign import ccall "LAPACK/lapack-aux.h eig_l_R" dgeev :: TMMCVM -foreign import ccall "LAPACK/lapack-aux.h eig_l_C" zgeev :: TCMCMCVCM -foreign import ccall "LAPACK/lapack-aux.h eig_l_S" dsyev :: CInt -> TMVM -foreign import ccall "LAPACK/lapack-aux.h eig_l_H" zheev :: CInt -> TCMVCM +foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_R" dgeev :: TMMCVM +foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_C" zgeev :: TCMCMCVCM +foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_S" dsyev :: CInt -> TMVM +foreign import ccall unsafe "LAPACK/lapack-aux.h eig_l_H" zheev :: CInt -> TCMVCM eigAux f st m = unsafePerformIO $ do l <- createVector r @@ -325,10 +325,10 @@ eigOnlyH = vrev . fst. eigSHAux (zheev 1) "eigH'" . fmat vrev = flatten . flipud . reshape 1 ----------------------------------------------------------------------------- -foreign import ccall "linearSolveR_l" dgesv :: TMMM -foreign import ccall "linearSolveC_l" zgesv :: TCMCMCM -foreign import ccall "cholSolveR_l" dpotrs :: TMMM -foreign import ccall "cholSolveC_l" zpotrs :: TCMCMCM +foreign import ccall unsafe "linearSolveR_l" dgesv :: TMMM +foreign import ccall unsafe "linearSolveC_l" zgesv :: TCMCMCM +foreign import ccall unsafe "cholSolveR_l" dpotrs :: TMMM +foreign import ccall unsafe "cholSolveC_l" zpotrs :: TCMCMCM linearSolveSQAux f st a b | n1==n2 && n1==r = unsafePerformIO $ do @@ -359,10 +359,10 @@ cholSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Comp cholSolveC a b = linearSolveSQAux zpotrs "cholSolveC" (fmat a) (fmat b) ----------------------------------------------------------------------------------- -foreign import ccall "LAPACK/lapack-aux.h linearSolveLSR_l" dgels :: TMMM -foreign import ccall "LAPACK/lapack-aux.h linearSolveLSC_l" zgels :: TCMCMCM -foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDR_l" dgelss :: Double -> TMMM -foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDC_l" zgelss :: Double -> TCMCMCM +foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveLSR_l" dgels :: TMMM +foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveLSC_l" zgels :: TCMCMCM +foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveSVDR_l" dgelss :: Double -> TMMM +foreign import ccall unsafe "LAPACK/lapack-aux.h linearSolveSVDC_l" zgelss :: Double -> TCMCMCM linearSolveAux f st a b = unsafePerformIO $ do r <- createMatrix ColumnMajor (max m n) nrhs @@ -401,8 +401,8 @@ linearSolveSVDC (Just rcond) a b = subMatrix (0,0) (cols a, cols b) $ linearSolveSVDC Nothing a b = linearSolveSVDC (Just (-1)) (fmat a) (fmat b) ----------------------------------------------------------------------------------- -foreign import ccall "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM -foreign import ccall "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM +foreign import ccall unsafe "LAPACK/lapack-aux.h chol_l_H" zpotrf :: TCMCM +foreign import ccall unsafe "LAPACK/lapack-aux.h chol_l_S" dpotrf :: TMM cholAux f st a = do r <- createMatrix ColumnMajor n n @@ -427,8 +427,8 @@ mbCholS :: Matrix Double -> Maybe (Matrix Double) mbCholS = unsafePerformIO . mbCatch . cholAux dpotrf "cholS" . fmat ----------------------------------------------------------------------------------- -foreign import ccall "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM -foreign import ccall "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM +foreign import ccall unsafe "LAPACK/lapack-aux.h qr_l_R" dgeqr2 :: TMVM +foreign import ccall unsafe "LAPACK/lapack-aux.h qr_l_C" zgeqr2 :: TCMCVCM -- | QR factorization of a real matrix, using LAPACK's /dgeqr2/. qrR :: Matrix Double -> (Matrix Double, Vector Double) @@ -448,8 +448,8 @@ qrAux f st a = unsafePerformIO $ do mn = min m n ----------------------------------------------------------------------------------- -foreign import ccall "LAPACK/lapack-aux.h hess_l_R" dgehrd :: TMVM -foreign import ccall "LAPACK/lapack-aux.h hess_l_C" zgehrd :: TCMCVCM +foreign import ccall unsafe "LAPACK/lapack-aux.h hess_l_R" dgehrd :: TMVM +foreign import ccall unsafe "LAPACK/lapack-aux.h hess_l_C" zgehrd :: TCMCVCM -- | Hessenberg factorization of a square real matrix, using LAPACK's /dgehrd/. hessR :: Matrix Double -> (Matrix Double, Vector Double) @@ -469,8 +469,8 @@ hessAux f st a = unsafePerformIO $ do mn = min m n ----------------------------------------------------------------------------------- -foreign import ccall "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM -foreign import ccall "LAPACK/lapack-aux.h schur_l_C" zgees :: TCMCMCM +foreign import ccall unsafe "LAPACK/lapack-aux.h schur_l_R" dgees :: TMMM +foreign import ccall unsafe "LAPACK/lapack-aux.h schur_l_C" zgees :: TCMCMCM -- | Schur factorization of a square real matrix, using LAPACK's /dgees/. schurR :: Matrix Double -> (Matrix Double, Matrix Double) @@ -488,8 +488,8 @@ schurAux f st a = unsafePerformIO $ do where n = rows a ----------------------------------------------------------------------------------- -foreign import ccall "LAPACK/lapack-aux.h lu_l_R" dgetrf :: TMVM -foreign import ccall "LAPACK/lapack-aux.h lu_l_C" zgetrf :: TCMVCM +foreign import ccall unsafe "LAPACK/lapack-aux.h lu_l_R" dgetrf :: TMVM +foreign import ccall unsafe "LAPACK/lapack-aux.h lu_l_C" zgetrf :: TCMVCM -- | LU factorization of a general real matrix, using LAPACK's /dgetrf/. luR :: Matrix Double -> (Matrix Double, [Int]) @@ -511,8 +511,8 @@ luAux f st a = unsafePerformIO $ do type TW a = CInt -> PD -> a type TQ a = CInt -> CInt -> PC -> a -foreign import ccall "LAPACK/lapack-aux.h luS_l_R" dgetrs :: TMVMM -foreign import ccall "LAPACK/lapack-aux.h luS_l_C" zgetrs :: TQ (TW (TQ (TQ (IO CInt)))) +foreign import ccall unsafe "LAPACK/lapack-aux.h luS_l_R" dgetrs :: TMVMM +foreign import ccall unsafe "LAPACK/lapack-aux.h luS_l_C" zgetrs :: TQ (TW (TQ (TQ (IO CInt)))) -- | Solve a real linear system from a precomputed LU decomposition ('luR'), using LAPACK's /dgetrs/. lusR :: Matrix Double -> [Int] -> Matrix Double -> Matrix Double -- cgit v1.2.3 From 7832cb74240ba06a23a981c20db3c5da8324828a Mon Sep 17 00:00:00 2001 From: Clark Gaebel Date: Sat, 10 Mar 2012 22:47:13 -0500 Subject: Added back some safety. --- lib/Numeric/GSL/Integration.hs | 12 ++++++------ lib/Numeric/GSL/Internal.hs | 10 +++++----- lib/Numeric/GSL/Minimization.hs | 4 ++-- lib/Numeric/GSL/ODE.hs | 2 +- lib/Numeric/GSL/Root.hs | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/Numeric/GSL/Integration.hs b/lib/Numeric/GSL/Integration.hs index b1e7930..defbf80 100644 --- a/lib/Numeric/GSL/Integration.hs +++ b/lib/Numeric/GSL/Integration.hs @@ -32,7 +32,7 @@ import System.IO.Unsafe(unsafePerformIO) {- | conversion of Haskell functions into function pointers that can be used in the C side -} -foreign import ccall unsafe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) +foreign import ccall safe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) -------------------------------------------------------------------- {- | Numerical integration using /gsl_integration_qags/ (adaptive integration with singularities). For example: @@ -63,7 +63,7 @@ integrateQAGS prec n f a b = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qags" +foreign import ccall safe "gsl-aux.h integrate_qags" c_integrate_qags :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt @@ -94,7 +94,7 @@ integrateQNG prec f a b = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qng" +foreign import ccall safe "gsl-aux.h integrate_qng" c_integrate_qng :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> Double -> Ptr Double -> Ptr Double -> IO CInt @@ -126,7 +126,7 @@ integrateQAGI prec n f = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qagi" +foreign import ccall safe "gsl-aux.h integrate_qagi" c_integrate_qagi :: FunPtr (Double-> Ptr() -> Double) -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt @@ -159,7 +159,7 @@ integrateQAGIU prec n f a = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qagiu" +foreign import ccall safe "gsl-aux.h integrate_qagiu" c_integrate_qagiu :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt @@ -192,7 +192,7 @@ integrateQAGIL prec n f b = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h integrate_qagil" +foreign import ccall safe "gsl-aux.h integrate_qagil" c_integrate_qagil :: FunPtr (Double-> Ptr() -> Double) -> Double -> Double -> CInt -> Ptr Double -> Ptr Double -> IO CInt diff --git a/lib/Numeric/GSL/Internal.hs b/lib/Numeric/GSL/Internal.hs index 4267b38..84417ce 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 return 0 -- | conversion of Haskell functions into function pointers that can be used in the C side -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkVecfun :: (CInt -> Ptr Double -> Double) -> IO( FunPtr (CInt -> Ptr Double -> Double)) -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkVecVecfun :: TVV -> IO (FunPtr TVV) -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkDoubleVecVecfun :: (Double -> TVV) -> IO (FunPtr (Double -> TVV)) aux_vTov :: (Vector Double -> Vector Double) -> TVV @@ -46,10 +46,10 @@ aux_vTov f n p nr r = g where g = do unsafeWith v $ \p' -> copyArray r p' (fromIntegral nr) return 0 -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkVecMatfun :: TVM -> IO (FunPtr TVM) -foreign import ccall unsafe "wrapper" +foreign import ccall safe "wrapper" mkDoubleVecMatfun :: (Double -> TVM) -> IO (FunPtr (Double -> TVM)) aux_vTom :: (Vector Double -> Matrix Double) -> TVM diff --git a/lib/Numeric/GSL/Minimization.hs b/lib/Numeric/GSL/Minimization.hs index 21ac8a1..af85135 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 return (sol, path) -foreign import ccall unsafe "gsl-aux.h minimize" +foreign import ccall safe "gsl-aux.h minimize" c_minimize:: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> Double -> CInt -> TVVM ---------------------------------------------------------------------------------- @@ -179,7 +179,7 @@ minimizeVD method eps maxit istep tol f df xiv = unsafePerformIO $ do freeHaskellFunPtr dfp return (sol,path) -foreign import ccall unsafe "gsl-aux.h minimizeD" +foreign import ccall safe "gsl-aux.h minimizeD" c_minimizeD :: CInt -> FunPtr (CInt -> Ptr Double -> Double) -> FunPtr TVV diff --git a/lib/Numeric/GSL/ODE.hs b/lib/Numeric/GSL/ODE.hs index 797ba3f..4d2beed 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 freeHaskellFunPtr fp return sol -foreign import ccall unsafe "ode" +foreign import ccall safe "ode" ode_c :: CInt -> Double -> Double -> Double -> FunPtr (Double -> TVV) -> FunPtr (Double -> TVM) -> TVVM ------------------------------------------------------- diff --git a/lib/Numeric/GSL/Root.hs b/lib/Numeric/GSL/Root.hs index 4128846..cd2982a 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 return (take n $ drop 1 sol, path) -foreign import ccall unsafe "root" +foreign import ccall safe "root" c_root:: CInt -> FunPtr TVV -> Double -> CInt -> TVM ------------------------------------------------------------------------- @@ -130,7 +130,7 @@ rootJGen m f jac xi epsabs maxit = unsafePerformIO $ do return (take n $ drop 1 sol, path) -foreign import ccall unsafe "rootj" +foreign import ccall safe "rootj" c_rootj:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> CInt -> TVM ------------------------------------------------------- -- cgit v1.2.3 From 032fe19ddfa6e4cfba33f76aaa13043b54568fcf Mon Sep 17 00:00:00 2001 From: Clark Gaebel Date: Sun, 11 Mar 2012 11:41:58 -0400 Subject: Missed a couple safe annotations. --- lib/Numeric/GSL/Differentiation.hs | 4 ++-- lib/Numeric/GSL/Fitting.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/Numeric/GSL/Differentiation.hs b/lib/Numeric/GSL/Differentiation.hs index 448ab63..d2a332c 100644 --- a/lib/Numeric/GSL/Differentiation.hs +++ b/lib/Numeric/GSL/Differentiation.hs @@ -48,7 +48,7 @@ derivGen c h f x = unsafePerformIO $ do freeHaskellFunPtr fp return result -foreign import ccall unsafe "gsl-aux.h deriv" +foreign import ccall safe "gsl-aux.h deriv" c_deriv :: CInt -> FunPtr (Double -> Ptr () -> Double) -> Double -> Double -> Ptr Double -> Ptr Double -> IO CInt @@ -84,4 +84,4 @@ derivBackward = derivGen 2 {- | conversion of Haskell functions into function pointers that can be used in the C side -} -foreign import ccall unsafe "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) +foreign import ccall safe "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 e5d0fd5..6343b76 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 freeHaskellFunPtr jp return (subVector 2 p sol, path) -foreign import ccall unsafe "nlfit" +foreign import ccall safe "nlfit" c_nlfit:: CInt -> FunPtr TVV -> FunPtr TVM -> Double -> Double -> CInt -> CInt -> TVM ------------------------------------------------------- -- cgit v1.2.3