úÎ Ü—×>[      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV W X Y Z [ firstDeriv f! returns the first derivative of f. \/A constant infinitely differentiable function. ] idDAt n ps maps each parameter in ps to a constant % infinitely differentiable function ( const . pureD), except the nth / parameter is replaced with the differentiable identity function  (idD). ^replace i r xs replaces the ith element in xs with r. _[\]^_[\]^EA value-level natural indexed with an equivalent type-level natural. "Class of all type-level naturals. "Case analysis on natural numbers.  Type-level natural denoting the S(uccessor of another type-level natural. !Type-level natural denoting zero +The axiom of induction on natural numbers.  See:  Fhttp://en.wikipedia.org/wiki/Mathematical_induction#Axiom_of_induction  The value of witnessNat :: n is the natural number of type n.  For example:  * *TypeLevelNat> witnessNat :: S (S (S Z))  S (S (S Z))       KA list which is indexed with a type-level natural that denotes the size of  the list. Fold a binary operator over a  SizedList. >Fold a binary operator yielding a value with a natural number  indexed type over a  SizedList.  Convert a  SizedList to a normal list. Returns the length of the  SizedList. Convert a normal list to a  SizedList. If the length of the given  list does not equal n, Nothing is returned. Convert a normal list to a SizeList. If the length of the given  list does not equal n, an error is thrown. replicate x :: SizedList n a returns a  SizedList of n xs.     Composition of NFunctions. Note that the n and a arguments are used by the type  checker to select the right ComposeN instance. They are  usally given as (witnessNat :: n) and (undefined :: a). A NFunction n a b is a function which takes n arguments of  type a and returns a b.  For example: 0NFunction (S (S (S Z))) a b ~ (a -> a -> a -> b) f $* xs applies the n-arity function f to each of the arguments in  the n -sized list xs.  Experimental,vandijk.roel@gmail.com, v.dijk.bas@gmail.com(>Cannot solve a problem with fewer measurements than unknowns. H In case linear constraints are provided, this error is also returned J when the number of measurements is smaller than the number of unknowns - minus the number of equality constraints. ,Constraints matrix is not of full row rank. >The matrix of constraints cannot have more rows than columns.  A call to malloc, failed in the underlying C levmar library. 0At least one lower bound exceeds the upper one. IA call to a lapack subroutine failed in the underlying C levmar library. !&Generic error (not one of the others) "0Covariance matrix corresponding to LS solution. #Reason for terminating. $`Stopped because model function returned invalid values (i.e. NaN or Inf). This is a user error. %Stopped because of small ||e||_2. &OStopped because no further error reduction is possible. Restart with increased 9. ']Stopped because of singular matrix. Restart from current estimated parameters with increased 9. (0Stopped because maximum iterations was reached. )Stopped because of small Dp. *"Stopped because of small gradient J^T e. +(Information regarding the minimization. -||e||_2& at initial parameters. .||e||_2& at estimated parameters. / ||J^T e||_inf at estimated parameters. 0||Dp||_2% at estimated parameters. 1mu/ max[J^T J]_ii ] at estimated parameters. 2Number of iterations. 3Reason for terminating. 4 Number of function evaluations. 5 Number of jacobian evaluations. 6CNumber of linear systems solved, i.e. attempts for reducing error. 7Minimization options 9Scale factor for initial mu. :Stopping thresholds for  ||J^T e||_inf. ;Stopping thresholds for ||Dp||_2. <Stopping thresholds for ||e||_2. =;Step used in the difference approximation to the Jacobian.  If optDelta<0, the Jacobian is approximated 4 with central differences which are more accurate 5 (but slower!) compared to the forward differences  employed by default. >7Linear constraints consisting of a constraints matrix, kxm and $ a right hand constraints vector, kx1 where m is the number of  parameters and k is the number of constraints. ?;The Levenberg-Marquardt algorithm is overloaded to work on `  and a . @#The Levenberg-Marquardt algorithm. AThe jacobian of the B/ function. Expressed as a function from a list Oof parameters to a list of lists which for each expected measurement describes +the partial derivatives of the parameters. See:  <http://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant O Ensure that the length of the parameter list equals the length of the initial  parameter list in @. 1 Ensure that the output matrix has the dimension nxm where n is the  number of samples and m is the number of parameters. &For example the jacobian of the above hatfldc model is:  hatfldc_jac :: Jacobian Double Bhatfldc_jac _ p1 p2 _ = [ [1.0, 0.0, 0.0, 0.0] % , [1.0, -0.5 / sqrt p1, 0.0, 0.0] 4 , [0.0, 1.0, -0.5 / sqrt p2, 0.0] B , [0.0, 0.0, 0.0, 1.0]  ] BHA functional relation describing measurements represented as a function >from a list of parameters to a list of expected measurements. H Ensure that the length of the parameters list equals the length of the  initial parameters list in @. K Ensure that the length of the ouput list equals the length of the samples  list in @.  For example:  hatfldc :: Model Double hatfldc [p0, p1, p2, p3] = [ p0 - 1.0 * , p0 - sqrt p1 * , p1 - sqrt p2 & , p3 - 1.0  ] b gen_levmar2 takes the low-level C functions as arguments and Iexecutes one of them depending on the optional jacobian and constraints. Preconditions:  length ys >= length ps isJust mLowBs &&' length (fromJust mLowBs) == length ps  && isJust mUpBs &&' length (fromJust mUpBs) == length ps boxConstrained && (all $ zipWith (<'=) (fromJust mLowBs) (fromJust mUpBs)) CDefault minimization options * !"#$%&'()*+,-./0123456789:;<=>?@ABC*BA?@>789:;<=C+,-./0123456#*)('&%$"! *!  !"#*)('&%$$%&'()*+ ,-./0123456,-./0123456789:;<=89:;<=>?@@ABC Experimental,vandijk.roel@gmail.com, v.dijk.bas@gmail.comDBThe Levenberg-Marquardt algorithm that automatically computes the  Jacobian8 using automatic differentiation of the model function. Warning: Don't apply D to Bs that apply methods of  the c and d. classes to the parameters. These methods are  undefined for ':~>'!!! E Compute the A of the B using Automatic  Differentiation. + !"#$%&'()*+,-./0123456789:;<=>?ABCDE+BAE?D>789:;<=C+,-./0123456#*)('&%$"! DE Experimental,vandijk.roel@gmail.com, v.dijk.bas@gmail.comF-This type synonym expresses that usually the a in G r a $ equals the type of the parameters. GThe jacobian of the I/ function. Expressed as a function from a list Kof parameters and an x-value to the partial derivatives of the parameters. See:  <http://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant P Ensure that the length of the parameters list equals the lenght of the initial  parameters list in J. L Ensure that the length of the output parameter derivatives list equals the ( length of the input parameters list. 'For example, the jacobian of the above quad model can be written as:    quadJacob :: e r => G N3 r r quadJacob [_, _, _]" x = [ x^2 -- with respect to a 5 , x -- with respect to b 5 , 1 -- with respect to c  ] Notice you don't have to differentiate for x. H-This type synonym expresses that usually the a in I r a $ equals the type of the parameters. IHA functional relation describing measurements represented as a function Efrom a list of parameters and an x-value to an expected measurement. P Ensure that the length of the parameters list equals the lenght of the initial  parameters list in J. $For example, the quadratic function f(x) = a*x^2 + b*x + c can be  written as:  quad :: e r => I r r  quad [a, b, c] x = a*x^2 + b*x + c JAThe Levenberg-Marquardt algorithm specialised for curve-fitting. , !"#$%&'()*+,-./0123456789:;<=>?CFGHIJ,IHGF?J>789:;<=C+,-./0123456#*)('&%$"! FGHIJ Experimental,vandijk.roel@gmail.com, v.dijk.bas@gmail.comK@The Levenberg-Marquardt algorithm specialised for curve-fitting ! that automatically computes the Jacobian using automatic ( differentiation of the model function. Warning: Don't apply K to Is that apply methods of  the c and d. classes to the parameters. These methods are  undefined for ':~>'!!! L Compute the G of the I using Automatic  Differentiation. - !"#$%&'()*+,-./0123456789:;<=>?CFGHIKL-IHGFL?K>789:;<=C+,-./0123456#*)('&%$"! KLM0Covariance matrix corresponding to LS solution. NA nxm matrix is a sized list of n sized lists of length m. O7Linear constraints consisting of a constraints matrix, kxn and $ a right hand constraints vector, kx1 where n is the number of  parameters and k is the number of constraints. P?Value to denote the absense of any linear constraints over the 7 parameters of the model function. Use this instead of f E because the type parameter which contains the number of constraints  can't be inferred. MNOPghMNOPgh Experimental,vandijk.roel@gmail.com, v.dijk.bas@gmail.comQ-This type synonym expresses that usually the a in R m r a $ equals the type of the parameters. RThe jacobian of the T( function. Expressed as a function from n !parameters and an x-value to the m( partial derivatives of the parameters. See:  <http://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant 4For example, the jacobian of the quadratic function f(x) = a*x^2 + b*x + c can be written as:    type N3 =  ( ( ))   quadJacob :: e r => R N3 r r 1quadJacob _ _ _ x = x^2 -- with respect to a 1 ::: x -- with respect to b 1 ::: 1 -- with respect to c  :::  Notice you don't have to differentiate for x. S-This type synonym expresses that usually the a in T m r a $ equals the type of the parameters. THA functional relation describing measurements represented as a function from m7 parameters and an x-value to an expected measurement. $For example, the quadratic function f(x) = a*x^2 + b*x + c can be  written as:   type N3 =  ( ( ))  quad :: e r => T N3 r r quad a b c x = a*x^2 + b*x + c UAThe Levenberg-Marquardt algorithm specialised for curve-fitting. 5  !#$%&'()*+,-./0123456789:;<=?CMNOPQRSTU5TSRQ?UOPN789:;<=C+,-./0123456#*)('&%$M!   QRSTU  Experimental,vandijk.roel@gmail.com, v.dijk.bas@gmail.comV@The Levenberg-Marquardt algorithm specialised for curve-fitting ! that automatically computes the Jacobian using automatic ( differentiation of the model function. Warning: Don't apply V  to Is that apply methods of  the c and d. classes to the parameters. These methods are  undefined for ':~>'!!! 3  !#$%&'()*+,-./0123456789:;<=?CMNOPSTV3TS?VOPN789:;<=C+,-./0123456#*)('&%$M!   V  Experimental,vandijk.roel@gmail.com, v.dijk.bas@gmail.comWThe jacobian of the X # function. Expressed as a function from m parameters to a nxm matrix which for each of the n #expected measurement describes the m partial derivatives of the  parameters. See:  <http://en.wikipedia.org/wiki/Jacobian_matrix_and_determinant &For example the jacobian of the above hatfldc model is:   type N4 =   (  (  (   )))  %hatfldc_jac :: Jacobian N4 N4 Double Xhatfldc_jac _ p1 p2 _ = (1.0 ::: 0.0 ::: 0.0 ::: 0.0 ::: Nil) * ::: (1.0 ::: -0.5 /- sqrt p1 ::: 0.0 ::: 0.0 ::: Nil) = ::: (0.0 ::: 1.0 ::: -0.5 / sqrt p2 ::: 0.0 ::: Nil) X ::: (0.0 ::: 0.0 ::: 0.0 ::: 1.0 ::: Nil)  ::: Nil XHA functional relation describing measurements represented as a function from m parameters to n expected measurements. An example from Demo.hs:   type N4 =   (  (  (   )))  hatfldc :: Model N4 N4 Double #hatfldc p0 p1 p2 p3 = p0 - 1.0 ' ::: p0 - sqrt p1 ' ::: p1 - sqrt p2 # ::: p3 - 1.0  ::: Nil Y#The Levenberg-Marquardt algorithm. 3  !#$%&'()*+,-./0123456789:;<=?CMNOPWXY3XW?YOPN789:;<=C+,-./0123456#*)('&%$M!   WXY  Experimental,vandijk.roel@gmail.com, v.dijk.bas@gmail.comZBThe Levenberg-Marquardt algorithm that automatically computes the  Jacobian8 using automatic differentiation of the model function. Warning: Don't apply Z  to X s that apply methods of  the c and d. classes to the parameters. These methods are  undefined for ':~>'!!! 2  !#$%&'()*+,-./0123456789:;<=?CMNOPXZ2X?ZOPN789:;<=C+,-./0123456#*)('&%$M!   Zi !"#$%&'()*+,-./01+23456789:;;<=>?@ABCDEFGHIJKLMNOPQROSTPUQOOS2VMWTPUQO O P Q O O X Y Z [ \ ] ^_`a`bcdefgh levmar-0.2.1 TypeLevelNat SizedList NFunctionLevMar.IntermediateLevMar.Intermediate.ADLevMar.Intermediate.FittingLevMar.Intermediate.Fitting.ADLevMar.FittingLevMar.Fitting.ADLevMar LevMar.ADLevMar.Utils.ADghc-prim GHC.TypesbaseData.EqData.OrdPrelude LevMar.Utils Data.MaybeNSuccZeroNatcaseNatSZ induction witnessNatnat:::NilfoldrfoldrNtoListlengthfromListunsafeFromList replicateComposeNcompose$* LevMarErrorTooFewMeasurementsConstraintMatrixNotFullRowRankConstraintMatrixRowsGtColsMemoryAllocationFailureFailedBoxCheck LapackError CovarMatrix StopReason InvalidValues SmallNorm2E SmallestErrorSingularMatrix MaxIterationsSmallDp SmallGradientInfo infNorm2initE infNorm2EinfNormInfJacTe infNorm2Dp infMuDivMax infNumIter infStopReasoninfNumFuncEvalsinfNumJacobEvalsinfNumLinSysSolvedOptionsOptsoptScaleInitMuoptStopNormInfJacTeoptStopNorm2Dp optStopNorm2EoptDeltaLinearConstraints LevMarablelevmarJacobianModel defaultOpts jacobianOfSimpleJacobian SimpleModelMatrixnoLinearConstraints firstDerivconstantidDAtreplacevalueDoubleFloat gen_levmar GHC.ClassesEqOrdGHC.NumNumNothingconvertLinearConstraints convertResult