úÎr`m^6      !"#$%&'()*+,-./012345!6789:;<=>?@ABCDEFGHIJKLMNOPQRSTUV6789:;<=>?GHIJKLMNOPQRSTUV6789:;<=>?GHIJKLMNOPQRSTUV ExperimentalWRoel van Dijk <vandijk.roel@gmail.com> Bas van Dijk <v.dijk.bas@gmail.com>9"Cannot solve a problem with fewer ( measurements than unknowns. In case ) linear constraints are provided, this * error is also returned 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. %At least one lower bound exceeds the  upper one. %A 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. 7Stopped because model function returned invalid values , (i.e. NaN or Inf). This is a user error. Stopped because of small ||e||_2. .Stopped because no further error reduction is $ possible. Restart with increased %. 9Stopped because of singular matrix. Restart from current ' estimated parameters with increased %. 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. ||Dp||_2% at estimated parameters. mu/ max[J^T J]_ii ] at estimated parameters. Number of iterations. Reason for terminating.  Number of function evaluations.  Number of jacobian evaluations. !Number of linear systems solved, % i.e. attempts for reducing error. Optional lower bounds Optional upper bounds !Optional weights "Optional linear constraints #Minimization options $%Scale 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 ) with central differences which are more ) accurate (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 W and X. ,#The Levenberg-Marquardt algorithm. Model Optional jacobian Initial parameters Samples Maximum iterations Minimization options  Constraints -The jacobian of the ./ 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]  ] .HA 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  ] Y 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)) Model Optional jacobian Initial parameters Samples Maximum iterations Options  Constraints Z[/Default minimization options \0!Constraints where all fields are ]. ^_`a1  !"#$%&'()*+,-./01.-+,*#$%&'()/ !"0  1    !" !"#$%&'()$%&'()*+,,-./0 ExperimentalWRoel van Dijk <vandijk.roel@gmail.com> Bas van Dijk <v.dijk.bas@gmail.com>1-This type synonym expresses that usually the a in 2 r a $ equals the type of the parameters. 2The jacobian of the 4/ 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 5. 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 :: Num r => 2 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.) 3-This type synonym expresses that usually the a in 4 r a $ equals the type of the parameters. 4HA 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 5. $For example, the quadratic function f(x) = a*x^2 + b*x + c can be  written as:  quad :: Num r => 4 r r  quad [a, b, c] x = a*x^2 + b*x + c 5AThe Levenberg-Marquardt algorithm specialised for curve-fitting. Model Optional jacobian Initial parameters Samples Maximum iterations Minimization options  Constraints , #$%&'()*+/12345,4321+5*#$%&'()/  12345b      !"#$%&'()*+,-./012.3/-456789:;+<=>?@ABCDEFGHIJKLMNOPQRSTUVTUWXYZ[\]^_`abc levmar-0.3Numeric.LevMarNumeric.LevMar.FittingBindings.LevMar.CurryFriendly LevMarErrorTooFewMeasurementsConstraintMatrixNotFullRowRankConstraintMatrixRowsGtColsMemoryAllocationFailureFailedBoxCheck LapackError CovarMatrix StopReason InvalidValues SmallNorm2E SmallestErrorSingularMatrix MaxIterationsSmallDp SmallGradientInfo infNorm2initE infNorm2EinfNormInfJacTe infNorm2Dp infMuDivMax infNumIter infStopReasoninfNumFuncEvalsinfNumJacobEvalsinfNumLinSysSolved Constraints lowerBounds upperBoundsweightslinearConstraintsOptionsOptsoptScaleInitMuoptStopNormInfJacTeoptStopNorm2Dp optStopNorm2EoptDeltaLinearConstraints LevMarablelevmarJacobianModel defaultOpts noConstraintsSimpleJacobian SimpleModel LevMarBLecDer LevMarBLecDif LevMarLecDer LevMarLecDif LevMarBCDer LevMarBCDif LevMarDer LevMarDifBoxConstraints mk_levmar_dermk_levmar_bc_difmk_levmar_bc_dermk_levmar_lec_difmk_levmar_lec_dermk_levmar_blec_difmk_levmar_blec_der slevmar_dif dlevmar_dif slevmar_der dlevmar_derslevmar_bc_difdlevmar_bc_difslevmar_bc_derdlevmar_bc_derslevmar_lec_difdlevmar_lec_difslevmar_lec_derdlevmar_lec_derslevmar_blec_difdlevmar_blec_difslevmar_blec_derdlevmar_blec_derghc-prim GHC.TypesDoubleFloat gen_levmar convertModelconvertJacobian optsToListbase Data.MaybeNothingmaybeWithArray listToInfolevmarCErrorToLevMarErrorconvertLevMarError