module Bindings.LevMar
( _LM_VERSION
, _LM_OPTS_SZ
, _LM_INFO_SZ
, _LM_ERROR
, _LM_ERROR_LAPACK_ERROR
, _LM_ERROR_NO_JACOBIAN
, _LM_ERROR_NO_BOX_CONSTRAINTS
, _LM_ERROR_FAILED_BOX_CHECK
, _LM_ERROR_MEMORY_ALLOCATION_FAILURE
, _LM_ERROR_CONSTRAINT_MATRIX_ROWS_GT_COLS
, _LM_ERROR_CONSTRAINT_MATRIX_NOT_FULL_ROW_RANK
, _LM_ERROR_TOO_FEW_MEASUREMENTS
, _LM_ERROR_SINGULAR_MATRIX
, _LM_ERROR_SUM_OF_SQUARES_NOT_FINITE
, _LM_INIT_MU
, _LM_STOP_THRESH
, _LM_DIFF_DELTA
, Parameters
, Measurements
, Options
, LowerBounds
, UpperBounds
, ConstraintsMatrix
, ConstraintsVector
, Weights
, Info
, Work
, Covar
, AData
, NrOfParameters
, NrOfMeasurements
, NrOfConstraints
, MaxIterations
, Model
, Jacobian
, withModel
, withJacobian
, LevMarDer
, LevMarDif
, LevMarBCDer
, LevMarBCDif
, LevMarLecDer
, LevMarLecDif
, LevMarBLecDer
, LevMarBLecDif
, dlevmar_der
, slevmar_der
, dlevmar_dif
, slevmar_dif
, dlevmar_bc_der
, slevmar_bc_der
, dlevmar_bc_dif
, slevmar_bc_dif
, dlevmar_lec_der
, slevmar_lec_der
, dlevmar_lec_dif
, slevmar_lec_dif
, dlevmar_blec_der
, slevmar_blec_der
, dlevmar_blec_dif
, slevmar_blec_dif
, Errors
, LevMarChkJac
, dlevmar_chkjac
, slevmar_chkjac
, BestFitParameterIx
, LevMarStddev
, LevMarCorCoef
, LevMarR2
, Result
, dlevmar_stddev
, slevmar_stddev
, dlevmar_corcoef
, slevmar_corcoef
, dlevmar_R2
, slevmar_R2
) where
import Foreign.C.Types ( CInt, CFloat, CDouble )
import Foreign.Ptr ( Ptr, FunPtr, freeHaskellFunPtr )
import Control.Exception ( bracket )
_LM_VERSION :: String
_LM_VERSION = "2.4 (April 2009)"
_LM_OPTS_SZ :: Int
_LM_OPTS_SZ = 5
_LM_INFO_SZ :: Int
_LM_INFO_SZ = 10
_LM_ERROR :: CInt
_LM_ERROR = (1)
_LM_ERROR_LAPACK_ERROR :: CInt
_LM_ERROR_LAPACK_ERROR = (2)
_LM_ERROR_NO_JACOBIAN :: CInt
_LM_ERROR_NO_JACOBIAN = (3)
_LM_ERROR_NO_BOX_CONSTRAINTS :: CInt
_LM_ERROR_NO_BOX_CONSTRAINTS = (4)
_LM_ERROR_FAILED_BOX_CHECK :: CInt
_LM_ERROR_FAILED_BOX_CHECK = (5)
_LM_ERROR_MEMORY_ALLOCATION_FAILURE :: CInt
_LM_ERROR_MEMORY_ALLOCATION_FAILURE = (6)
_LM_ERROR_CONSTRAINT_MATRIX_ROWS_GT_COLS :: CInt
_LM_ERROR_CONSTRAINT_MATRIX_ROWS_GT_COLS = (7)
_LM_ERROR_CONSTRAINT_MATRIX_NOT_FULL_ROW_RANK :: CInt
_LM_ERROR_CONSTRAINT_MATRIX_NOT_FULL_ROW_RANK = (8)
_LM_ERROR_TOO_FEW_MEASUREMENTS :: CInt
_LM_ERROR_TOO_FEW_MEASUREMENTS = (9)
_LM_ERROR_SINGULAR_MATRIX :: CInt
_LM_ERROR_SINGULAR_MATRIX = (10)
_LM_ERROR_SUM_OF_SQUARES_NOT_FINITE :: CInt
_LM_ERROR_SUM_OF_SQUARES_NOT_FINITE = (11)
_LM_INIT_MU, _LM_STOP_THRESH, _LM_DIFF_DELTA :: Fractional a => a
_LM_INIT_MU = 1.000000e-03
_LM_STOP_THRESH = 1.000000e-17
_LM_DIFF_DELTA = 1.000000e-06
type Parameters = Ptr
type Measurements = Ptr
type Options = Ptr
type LowerBounds = Ptr
type UpperBounds = Ptr
type ConstraintsMatrix = Ptr
type ConstraintsVector = Ptr
type Weights = Ptr
type Info = Ptr
type Work = Ptr
type Covar = Ptr
type AData = Ptr ()
type NrOfParameters = CInt
type NrOfMeasurements = CInt
type NrOfConstraints = CInt
type MaxIterations = CInt
type Model r = Parameters r
-> Measurements r
-> NrOfParameters
-> NrOfMeasurements
-> AData
-> IO ()
type Jacobian a = Model a
foreign import ccall "wrapper" mkModel :: Model a -> IO (FunPtr (Model a))
mkJacobian :: Jacobian a -> IO (FunPtr (Jacobian a))
mkJacobian = mkModel
withModel :: Model a -> (FunPtr (Model a) -> IO b) -> IO b
withModel m = bracket (mkModel m) freeHaskellFunPtr
withJacobian :: Jacobian a -> (FunPtr (Jacobian a) -> IO b) -> IO b
withJacobian j = bracket (mkJacobian j) freeHaskellFunPtr
type LevMarDer cr = FunPtr (Model cr)
-> FunPtr (Jacobian cr)
-> Parameters cr
-> Measurements cr
-> NrOfParameters
-> NrOfMeasurements
-> MaxIterations
-> Options cr
-> Info cr
-> Work cr
-> Covar cr
-> AData
-> IO CInt
type LevMarDif cr = FunPtr (Model cr)
-> Parameters cr
-> Measurements cr
-> NrOfParameters
-> NrOfMeasurements
-> MaxIterations
-> Options cr
-> Info cr
-> Work cr
-> Covar cr
-> AData
-> IO CInt
type LevMarBCDer cr = FunPtr (Model cr)
-> FunPtr (Jacobian cr)
-> Parameters cr
-> Measurements cr
-> NrOfParameters
-> NrOfMeasurements
-> LowerBounds cr
-> UpperBounds cr
-> MaxIterations
-> Options cr
-> Info cr
-> Work cr
-> Covar cr
-> AData
-> IO CInt
type LevMarBCDif cr = FunPtr (Model cr)
-> Parameters cr
-> Measurements cr
-> NrOfParameters
-> NrOfMeasurements
-> LowerBounds cr
-> UpperBounds cr
-> MaxIterations
-> Options cr
-> Info cr
-> Work cr
-> Covar cr
-> AData
-> IO CInt
type LevMarLecDer cr = FunPtr (Model cr)
-> FunPtr (Jacobian cr)
-> Parameters cr
-> Measurements cr
-> NrOfParameters
-> NrOfMeasurements
-> ConstraintsMatrix cr
-> ConstraintsVector cr
-> NrOfConstraints
-> MaxIterations
-> Options cr
-> Info cr
-> Work cr
-> Covar cr
-> AData
-> IO CInt
type LevMarLecDif cr = FunPtr (Model cr)
-> Parameters cr
-> Measurements cr
-> NrOfParameters
-> NrOfMeasurements
-> ConstraintsMatrix cr
-> ConstraintsVector cr
-> NrOfConstraints
-> MaxIterations
-> Options cr
-> Info cr
-> Work cr
-> Covar cr
-> AData
-> IO CInt
type LevMarBLecDer cr = FunPtr (Model cr)
-> FunPtr (Jacobian cr)
-> Parameters cr
-> Measurements cr
-> NrOfParameters
-> NrOfMeasurements
-> LowerBounds cr
-> UpperBounds cr
-> ConstraintsMatrix cr
-> ConstraintsVector cr
-> NrOfConstraints
-> Weights cr
-> MaxIterations
-> Options cr
-> Info cr
-> Work cr
-> Covar cr
-> AData
-> IO CInt
type LevMarBLecDif cr = FunPtr (Model cr)
-> Parameters cr
-> Measurements cr
-> NrOfParameters
-> NrOfMeasurements
-> LowerBounds cr
-> UpperBounds cr
-> ConstraintsMatrix cr
-> ConstraintsVector cr
-> NrOfConstraints
-> Weights cr
-> MaxIterations
-> Options cr
-> Info cr
-> Work cr
-> Covar cr
-> AData
-> IO CInt
foreign import ccall "slevmar_der" slevmar_der :: LevMarDer CFloat
foreign import ccall "dlevmar_der" dlevmar_der :: LevMarDer CDouble
foreign import ccall "slevmar_dif" slevmar_dif :: LevMarDif CFloat
foreign import ccall "dlevmar_dif" dlevmar_dif :: LevMarDif CDouble
foreign import ccall "slevmar_bc_der" slevmar_bc_der :: LevMarBCDer CFloat
foreign import ccall "dlevmar_bc_der" dlevmar_bc_der :: LevMarBCDer CDouble
foreign import ccall "slevmar_bc_dif" slevmar_bc_dif :: LevMarBCDif CFloat
foreign import ccall "dlevmar_bc_dif" dlevmar_bc_dif :: LevMarBCDif CDouble
foreign import ccall "slevmar_lec_der" slevmar_lec_der :: LevMarLecDer CFloat
foreign import ccall "dlevmar_lec_der" dlevmar_lec_der :: LevMarLecDer CDouble
foreign import ccall "slevmar_lec_dif" slevmar_lec_dif :: LevMarLecDif CFloat
foreign import ccall "dlevmar_lec_dif" dlevmar_lec_dif :: LevMarLecDif CDouble
foreign import ccall "slevmar_blec_der" slevmar_blec_der :: LevMarBLecDer CFloat
foreign import ccall "dlevmar_blec_der" dlevmar_blec_der :: LevMarBLecDer CDouble
foreign import ccall "slevmar_blec_dif" slevmar_blec_dif :: LevMarBLecDif CFloat
foreign import ccall "dlevmar_blec_dif" dlevmar_blec_dif :: LevMarBLecDif CDouble
type Errors = Ptr
type LevMarChkJac cr = FunPtr (Model cr)
-> FunPtr (Jacobian cr)
-> Parameters cr
-> NrOfParameters
-> NrOfMeasurements
-> AData
-> Errors cr
-> IO ()
foreign import ccall "dlevmar_chkjac" dlevmar_chkjac :: LevMarChkJac CDouble
foreign import ccall "slevmar_chkjac" slevmar_chkjac :: LevMarChkJac CFloat
type BestFitParameterIx = CInt
type LevMarStddev cr = Covar cr
-> NrOfParameters
-> BestFitParameterIx
-> IO cr
type LevMarCorCoef cr = Covar cr
-> NrOfParameters
-> BestFitParameterIx
-> BestFitParameterIx
-> IO cr
type LevMarR2 cr = FunPtr (Model cr)
-> Parameters cr
-> Measurements cr
-> NrOfParameters
-> NrOfMeasurements
-> AData
-> Result cr
-> IO CInt
type Result = Ptr
foreign import ccall "dlevmar_stddev" dlevmar_stddev :: LevMarStddev CDouble
foreign import ccall "slevmar_stddev" slevmar_stddev :: LevMarStddev CFloat
foreign import ccall "dlevmar_corcoef" dlevmar_corcoef :: LevMarCorCoef CDouble
foreign import ccall "slevmar_corcoef" slevmar_corcoef :: LevMarCorCoef CFloat
foreign import ccall "dlevmar_R2" dlevmar_R2 :: LevMarR2 CDouble
foreign import ccall "slevmar_R2" slevmar_R2 :: LevMarR2 CFloat