Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.. makes compilation easier and removes a dependency for what is effectively 2 C-source files. .. additionally, getting the lmfit lib to compile on windows with cmake was frought with issues. .. also fix a debug message left behind by previous commit.
- Loading branch information
1 parent
73ef4ff
commit f5055aa
Showing
8 changed files
with
1,587 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Library: lmfit (Levenberg-Marquardt least squares fitting) | ||
* | ||
* File: lmcurve.c | ||
* | ||
* Contents: Implements lmcurve, a simplified API for curve fitting | ||
* using the generic Levenberg-Marquardt routine lmmin. | ||
* | ||
* Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013) | ||
* | ||
* License: see ../COPYING (FreeBSD) | ||
* | ||
* Homepage: apps.jcns.fz-juelich.de/lmfit | ||
* | ||
* Note to programmers: Don't patch and fork, but copy and modify! | ||
* If you need to compute residues differently, then please do not patch | ||
* lmcurve.h and lmcurve.c, but copy them, and create differently named | ||
* versions of lmcurve_data_struct, lmcurve_evaluate, and lmcurve of your own. | ||
*/ | ||
|
||
#include "lmmin.h" | ||
|
||
|
||
typedef struct { | ||
const double *const t; | ||
const double *const y; | ||
double (*const g) (const double t, const double *par); | ||
} lmcurve_data_struct; | ||
|
||
|
||
void lmcurve_evaluate( | ||
const double *const par, const int m_dat, const void *const data, | ||
double *const fvec, int *const info) | ||
{ | ||
for (int i = 0; i < m_dat; i++ ) | ||
fvec[i] = | ||
((lmcurve_data_struct*)data)->y[i] - | ||
((lmcurve_data_struct*)data)->g( | ||
((lmcurve_data_struct*)data)->t[i], par ); | ||
} | ||
|
||
|
||
void lmcurve( | ||
const int n_par, double *const par, const int m_dat, | ||
const double *const t, const double *const y, | ||
double (*const g)(const double t, const double *const par), | ||
const lm_control_struct *const control, lm_status_struct *const status) | ||
{ | ||
lmcurve_data_struct data = {t, y, g}; | ||
lmmin(n_par, par, m_dat, NULL, (const void *const) &data, | ||
lmcurve_evaluate, control, status); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Library: lmfit (Levenberg-Marquardt least squares fitting) | ||
* | ||
* File: lmcurve.h | ||
* | ||
* Contents: Declares lmcurve, a simplified API for curve fitting | ||
* using the generic Levenberg-Marquardt routine lmmin. | ||
* | ||
* Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013) | ||
* | ||
* License: see ../COPYING (FreeBSD) | ||
* | ||
* Homepage: apps.jcns.fz-juelich.de/lmfit | ||
* | ||
* Note to programmers: Don't patch and fork, but copy and variate! | ||
* If you need to compute residues differently, then please do not patch | ||
* lmcurve.h, but copy it to a differently named file, and change lmcurve() | ||
* into a differently named function declaration, like we have done in | ||
* lmcurve_tyd.h. | ||
*/ | ||
|
||
#ifndef LMCURVE_H | ||
#define LMCURVE_H | ||
#undef __BEGIN_DECLS | ||
#undef __END_DECLS | ||
#ifdef __cplusplus | ||
#define __BEGIN_DECLS extern "C" { | ||
#define __END_DECLS } | ||
#else | ||
#define __BEGIN_DECLS /* empty */ | ||
#define __END_DECLS /* empty */ | ||
#endif | ||
|
||
#include<lmstruct.h> | ||
|
||
__BEGIN_DECLS | ||
|
||
void lmcurve( | ||
const int n_par, double* par, const int m_dat, | ||
const double* t, const double* y, | ||
double (*g)(const double t, const double* par), | ||
const lm_control_struct* control, lm_status_struct* status); | ||
|
||
__END_DECLS | ||
#endif /* LMCURVE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Library: lmfit (Levenberg-Marquardt least squares fitting) | ||
* | ||
* File: lmcurve_tyd.h | ||
* | ||
* Contents: Declares lmcurve_tyd(), a variant of lmcurve() that weighs | ||
* data points y(t) with the inverse of the standard deviations dy. | ||
* | ||
* Copyright: Joachim Wuttke, Forschungszentrum Juelich GmbH (2004-2013) | ||
* | ||
* License: see ../COPYING (FreeBSD) | ||
* | ||
* Homepage: apps.jcns.fz-juelich.de/lmfit | ||
*/ | ||
|
||
#ifndef LMCURVETYD_H | ||
#define LMCURVETYD_H | ||
#undef __BEGIN_DECLS | ||
#undef __END_DECLS | ||
#ifdef __cplusplus | ||
#define __BEGIN_DECLS extern "C" { | ||
#define __END_DECLS } | ||
#else | ||
#define __BEGIN_DECLS /* empty */ | ||
#define __END_DECLS /* empty */ | ||
#endif | ||
|
||
#include <lmstruct.h> | ||
|
||
__BEGIN_DECLS | ||
|
||
void lmcurve_tyd( | ||
const int n_par, double* par, const int m_dat, | ||
const double* t, const double* y, const double* dy, | ||
double (*f)(double t, const double* par), | ||
const lm_control_struct* control, lm_status_struct* status); | ||
|
||
__END_DECLS | ||
#endif /* LMCURVETYD_H */ |
Oops, something went wrong.