diff --git a/.gitignore b/.gitignore index 03b3307..7d4b483 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ /cmpfit-1.2.zip +/header_file.patch +/source_file.patch +/mpfit.patch diff --git a/cmpfit.spec b/cmpfit.spec index 3f5befb..b7bec3e 100644 --- a/cmpfit.spec +++ b/cmpfit.spec @@ -4,13 +4,22 @@ Name: cmpfit Version: 1.2 -Release: 2%{?dist} +Release: 3%{?dist} Summary: A MINPACK-1 Least Squares Fitting Library in C License: BSD URL: http://cow.physics.wisc.edu/~craigm/idl/cmpfit.html Source0: http://cow.physics.wisc.edu/~craigm/idl/down/%{name}-%{version}.zip +# patches generated using the updated sources at fityk project +# original author emailed updated package to fityk developer (Marcin Wojdyr) +# sources can be seen here - https://github.com/wojdyr/fityk/tree/master/fityk/cmpfit +Patch0: header_file.patch +Patch1: source_file.patch + +# this patch was authored by fityk developer +Patch2: https://raw.githubusercontent.com/wojdyr/fityk/master/fityk/cmpfit/mpfit.patch + %description CMPFIT uses the Levenberg-Marquardt technique to solve the least-squares problem. In its typical use, CMPFIT will be used to fit a user-supplied @@ -28,7 +37,10 @@ These are the header files and libraries needed to develop a %{name} application. %prep -%setup -q +%setup -q +%patch0 +%patch1 +%patch2 %build # Manual build, makefile only does static library @@ -60,6 +72,11 @@ popd %{_libdir}/libmpfit.so %changelog +* Thu Jun 05 2014 Mukundan Ragavan - 1.2-3 +- Updating package to version available from fityk github repo +- update obtained via email from original author of mpfit by fityk devel +- Added patch from Marcin Wojdyr (fityk github repo) + * Fri Mar 07 2014 Sergio Pascual - 1.2-2 - Add license in DISCLAIMER - Update requires in cmpfit-devel diff --git a/header_file.patch b/header_file.patch new file mode 100644 index 0000000..c5f92af --- /dev/null +++ b/header_file.patch @@ -0,0 +1,26 @@ +--- mpfit.h.orig 2014-06-05 10:00:51.192261275 -0500 ++++ mpfit.h 2014-06-05 10:00:59.485296669 -0500 +@@ -13,7 +13,7 @@ + + /* Header file defining constants, data structures and functions of + mpfit library +- $Id: mpfit.h,v 1.14 2010/11/13 08:15:07 craigm Exp $ ++ $Id: mpfit.h,v 1.15 2013/04/09 17:55:32 craigm Exp $ + */ + + #ifndef MPFIT_H +@@ -74,12 +74,13 @@ + double epsfcn; /* Finite derivative step size Default: MP_MACHEP0 */ + double stepfactor; /* Initial step bound Default: 100.0 */ + double covtol; /* Range tolerance for covariance calculation Default: 1e-14 */ +- int maxiter; /* Maximum number of iterations. If maxiter == 0, ++ int maxiter; /* Maximum number of iterations. If maxiter == MP_NO_ITER, + then basic error checking is done, and parameter + errors/covariances are estimated based on input + parameter values, but no fitting iterations are done. + Default: 200 + */ ++#define MP_NO_ITER (-1) /* No iterations, just checking */ + int maxfev; /* Maximum number of function evaluations, or 0 for no limit + Default: 0 (no limit) */ + int nprint; /* Default: 1 */ diff --git a/mpfit.patch b/mpfit.patch new file mode 100644 index 0000000..838b615 --- /dev/null +++ b/mpfit.patch @@ -0,0 +1,23 @@ +--- mpfit.c.orig 2012-10-01 00:30:51.533258108 +0100 ++++ mpfit.c 2012-10-01 01:46:42.106809470 +0100 +@@ -322,7 +322,7 @@ + if (config->stepfactor > 0) conf.stepfactor = config->stepfactor; + if (config->nprint >= 0) conf.nprint = config->nprint; + if (config->epsfcn > 0) conf.epsfcn = config->epsfcn; +- if (config->maxiter > 0) conf.maxiter = config->maxiter; ++ if (config->maxiter >= 0) conf.maxiter = config->maxiter; + if (config->douserscale != 0) conf.douserscale = config->douserscale; + if (config->covtol > 0) conf.covtol = config->covtol; + if (config->nofinitecheck > 0) conf.nofinitecheck = config->nofinitecheck; +@@ -624,7 +624,10 @@ + */ + if (gnorm <= conf.gtol) info = MP_OK_DIR; + if (info != 0) goto L300; +- if (conf.maxiter == 0) goto L300; ++ if (conf.maxiter == 0) { ++ info = MP_MAXITER; ++ goto L300; ++ } + + /* + * rescale if necessary. diff --git a/source_file.patch b/source_file.patch new file mode 100644 index 0000000..f7dfec3 --- /dev/null +++ b/source_file.patch @@ -0,0 +1,222 @@ +--- mpfit.c.orig 2014-06-05 10:02:14.819618639 -0500 ++++ mpfit.c 2014-06-05 10:02:21.131645649 -0500 +@@ -13,7 +13,7 @@ + */ + + /* Main mpfit library routines (double precision) +- $Id: mpfit.c,v 1.20 2010/11/13 08:15:35 craigm Exp $ ++ $Id: mpfit.c,v 1.23 2013/04/23 04:24:16 craigm Exp $ + */ + + #include +@@ -29,7 +29,8 @@ + double *wa, void *priv, int *nfev, + double *step, double *dstep, int *dside, + int *qulimited, double *ulimit, +- int *ddebug, double *ddrtol, double *ddatol); ++ int *ddebug, double *ddrtol, double *ddatol, ++ double *wa2, double **dvecptr); + static void mp_qrfac(int m, int n, double *a, int lda, + int pivot, int *ipvt, int lipvt, + double *rdiag, double *acnorm, double *wa); +@@ -274,7 +275,7 @@ + { + mp_config conf; + int i, j, info, iflag, nfree, npegged, iter; +- int qanylim = 0, qanypegged = 0; ++ int qanylim = 0; + + int ij,jj,l; + double actred,delta,dirder,fnorm,fnorm1,gnorm, orignorm; +@@ -297,6 +298,7 @@ + double *fvec = 0, *qtf = 0; + double *x = 0, *xnew = 0, *fjac = 0, *diag = 0; + double *wa1 = 0, *wa2 = 0, *wa3 = 0, *wa4 = 0; ++ double **dvecptr = 0; + int *ipvt = 0; + + int ldfjac; +@@ -323,6 +325,7 @@ + if (config->nprint >= 0) conf.nprint = config->nprint; + if (config->epsfcn > 0) conf.epsfcn = config->epsfcn; + if (config->maxiter > 0) conf.maxiter = config->maxiter; ++ if (config->maxiter == MP_NO_ITER) conf.maxiter = 0; + if (config->douserscale != 0) conf.douserscale = config->douserscale; + if (config->covtol > 0) conf.covtol = config->covtol; + if (config->nofinitecheck > 0) conf.nofinitecheck = config->nofinitecheck; +@@ -334,6 +337,7 @@ + nfree = 0; + npegged = 0; + ++ /* Basic error checking */ + if (funct == 0) { + return MP_ERR_FUNC; + } +@@ -442,6 +446,7 @@ + mp_malloc(wa3, double, npar); + mp_malloc(wa4, double, m); + mp_malloc(ipvt, int, npar); ++ mp_malloc(dvecptr, double *, npar); + + /* Evaluate user function with initial parameter values */ + iflag = mp_call(funct, m, npar, xall, fvec, 0, private_data); +@@ -483,30 +488,34 @@ + iflag = mp_fdjac2(funct, m, nfree, ifree, npar, xnew, fvec, fjac, ldfjac, + conf.epsfcn, wa4, private_data, &nfev, + step, dstep, mpside, qulim, ulim, +- ddebug, ddrtol, ddatol); ++ ddebug, ddrtol, ddatol, wa2, dvecptr); + if (iflag < 0) { + goto CLEANUP; + } + + /* Determine if any of the parameters are pegged at the limits */ +- qanypegged = 0; + if (qanylim) { + for (j=0; j 0)) { + ij = j*ldfjac; + for (i=0; i 2 */ + /* COMPUTE THE TWO-SIDED DERIVATIVE */ +- for (i=0; i da + fabs(fjold)*dr))) { + printf(" %10d %10.4g %10.4g %10.4g %10.4g %10.4g\n", +@@ -1196,17 +1208,16 @@ + (fjold == 0)?(0):((fjold-fjac[ij])/fjold)); + } + } +- } ++ } /* end debugging */ + +- } +- } ++ } /* if (dside > 2) */ ++ } /* if (has_numerical_derivative) */ + + if (has_debug_deriv) { + printf("FJAC DEBUG END\n"); + } + + DONE: +- if (dvec) free(dvec); + if (iflag < 0) return iflag; + return 0; + /* +@@ -1305,8 +1316,10 @@ + static double one = 1.0; + static double p05 = 0.05; + +- lda = 0; /* Prevent compiler warning */ +- lipvt = 0; /* Prevent compiler warning */ ++ lda = 0; /* Prevent compiler warning */ ++ lipvt = 0; /* Prevent compiler warning */ ++ if (lda) {} /* Prevent compiler warning */ ++ if (lipvt) {} /* Prevent compiler warning */ + + /* + * compute the initial column norms and initialize several arrays. diff --git a/sources b/sources index a48455e..a427bc8 100644 --- a/sources +++ b/sources @@ -1 +1,4 @@ efa731f55f4ebe29598e5f6d3f04bd2a cmpfit-1.2.zip +0caa25705da53648eb1127bf872929a1 header_file.patch +0ad7ba4cdd07e4378fe8c3b3ba12690f source_file.patch +6eadeddc157ff91ddc337ede4a966332 mpfit.patch