Author: bugman
Date: Tue Aug 26 11:07:07 2014
New Revision: 25268
URL: http://svn.gna.org/viewcvs/relax?rev=25268&view=rev
Log:
Modified all of the exponential curve functions and gradients in the C target
function module.
Instead of passing in the parameter vector, now the I0 and R values are passed
in separately. This
is for greater code flexibility as the parameter order does not need to be
known.
Modified:
trunk/target_functions/exponential.c
trunk/target_functions/exponential.h
trunk/target_functions/relax_fit.c
Modified: trunk/target_functions/exponential.c
URL:
http://svn.gna.org/viewcvs/relax/trunk/target_functions/exponential.c?rev=25268&r1=25267&r2=25268&view=diff
==============================================================================
--- trunk/target_functions/exponential.c (original)
+++ trunk/target_functions/exponential.c Tue Aug 26 11:07:07 2014
@@ -25,8 +25,12 @@
#include "exponential.h"
-void exponential(double *params, double *relax_times, double *back_calc, int
num_times) {
- /* Function to back calculate the peak intensities.
+void exponential(double I0, double R, double *relax_times, double *back_calc,
int num_times) {
+ /* Function to back calculate the intensity values from an exponential.
+ *
+ * The function used is::
+ *
+ * I = I0 * exp(-R.t)
*/
/* Declarations */
@@ -35,18 +39,18 @@
/* Loop over the time points */
for (i = 0; i < num_times; i++) {
/* Zero Rx value */
- if (params[0] == 0.0)
- back_calc[i] = params[1];
+ if (R == 0.0)
+ back_calc[i] = I0;
/* Back calculate */
else
- back_calc[i] = params[1] * exp(-relax_times[i] * params[0]);
+ back_calc[i] = I0 * exp(-relax_times[i] * R);
}
}
-void exponential_dI(double *params, double *relax_times, double
back_calc_grad[][MAXTIMES], int num_times) {
- /* Calculate the dI partial derivate of the 2-parameter exponential curve.
+void exponential_dI0(double I0, double R, double *relax_times, double
back_calc_grad[][MAXTIMES], int num_times) {
+ /* Calculate the dI0 partial derivate of the 2-parameter exponential curve.
*/
/* Declarations */
@@ -55,17 +59,17 @@
/* Loop over the time points */
for (i = 0; i < num_times; i++) {
/* Zero Rx value */
- if (params[0] == 0.0)
+ if (R == 0.0)
back_calc_grad[1][i] = 1.0;
/* The partial derivate */
else
- back_calc_grad[1][i] = exp(-relax_times[i] * params[0]);
+ back_calc_grad[1][i] = exp(-relax_times[i] * R);
}
}
-void exponential_dR(double *params, double *relax_times, double
back_calc_grad[][MAXTIMES], int num_times) {
+void exponential_dR(double I0, double R, double *relax_times, double
back_calc_grad[][MAXTIMES], int num_times) {
/* Calculate the dR partial derivate of the 2-parameter exponential curve.
*/
@@ -75,11 +79,11 @@
/* Loop over the time points */
for (i = 0; i < num_times; i++) {
/* Zero Rx value */
- if (params[0] == 0.0)
- back_calc_grad[0][i] = -params[1] * relax_times[i];
+ if (R == 0.0)
+ back_calc_grad[0][i] = -I0 * relax_times[i];
/* The partial derivate */
else
- back_calc_grad[0][i] = -params[1] * relax_times[i] *
exp(-relax_times[i] * params[0]);
+ back_calc_grad[0][i] = -I0 * relax_times[i] * exp(-relax_times[i]
* R);
}
}
Modified: trunk/target_functions/exponential.h
URL:
http://svn.gna.org/viewcvs/relax/trunk/target_functions/exponential.h?rev=25268&r1=25267&r2=25268&view=diff
==============================================================================
--- trunk/target_functions/exponential.h (original)
+++ trunk/target_functions/exponential.h Tue Aug 26 11:07:07 2014
@@ -25,8 +25,8 @@
#define MAXTIMES 50
-void exponential(double *params, double *relax_times, double *back_calc, int
num_times);
-void exponential_dI(double *params, double *relax_times, double
back_calc_grad[][MAXTIMES], int num_times);
-void exponential_dR(double *params, double *relax_times, double
back_calc_grad[][MAXTIMES], int num_times);
+void exponential(double I0, double R, double *relax_times, double *back_calc,
int num_times);
+void exponential_dI0(double I0, double R, double *relax_times, double
back_calc_grad[][MAXTIMES], int num_times);
+void exponential_dR(double I0, double R, double *relax_times, double
back_calc_grad[][MAXTIMES], int num_times);
#endif
Modified: trunk/target_functions/relax_fit.c
URL:
http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_fit.c?rev=25268&r1=25267&r2=25268&view=diff
==============================================================================
--- trunk/target_functions/relax_fit.c (original)
+++ trunk/target_functions/relax_fit.c Tue Aug 26 11:07:07 2014
@@ -108,7 +108,7 @@
}
/* Back calculated the peak intensities */
- exponential(params, relax_times, back_calc, num_times);
+ exponential(params[1], params[0], relax_times, back_calc, num_times);
/* Calculate and return the chi-squared value */
return PyFloat_FromDouble(chi2(values, sd, back_calc, num_times));
@@ -145,11 +145,11 @@
}
/* Back calculated the peak intensities */
- exponential(params, relax_times, back_calc, num_times);
+ exponential(params[1], params[0], relax_times, back_calc, num_times);
/* The partial derivates */
- exponential_dR(params, relax_times, back_calc_grad, num_times);
- exponential_dI(params, relax_times, back_calc_grad, num_times);
+ exponential_dR(params[1], params[0], relax_times, back_calc_grad,
num_times);
+ exponential_dI0(params[1], params[0], relax_times, back_calc_grad,
num_times);
/* The chi-squared gradient */
dchi2(dchi2_vals, values, back_calc, back_calc_grad, sd, num_times,
num_params);
@@ -220,8 +220,8 @@
}
/* The partial derivates */
- exponential_dR(params, relax_times, back_calc_grad, num_times);
- exponential_dI(params, relax_times, back_calc_grad, num_times);
+ exponential_dR(params[1], params[0], relax_times, back_calc_grad,
num_times);
+ exponential_dI0(params[1], params[0], relax_times, back_calc_grad,
num_times);
/* Convert to a Python list of lists */
PyObject *list = PyList_New(0);
_______________________________________________
relax (http://www.nmr-relax.com)
This is the relax-commits mailing list
[email protected]
To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits