mailr25313 - in /trunk/target_functions: exponential.c exponential.h relax_fit.c


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on August 26, 2014 - 19:14:
Author: bugman
Date: Tue Aug 26 19:13:59 2014
New Revision: 25313

URL: http://svn.gna.org/viewcvs/relax?rev=25313&view=rev
Log:
Implemented the exponential curve second partial derivative C functions.

These are declared in the exponential.h header file and are now used by the 
Python function
target_functions.relax_fit.d2func().


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=25313&r1=25312&r2=25313&view=diff
==============================================================================
--- trunk/target_functions/exponential.c        (original)
+++ trunk/target_functions/exponential.c        Tue Aug 26 19:13:59 2014
@@ -49,6 +49,7 @@
     }
 }
 
+
 void exponential_dI0(double I0, double R, int param_index, double 
relax_times[MAX_DATA], double back_calc_grad[MAX_PARAMS][MAX_DATA], int 
num_times) {
     /* Calculate the dI0 partial derivate of the 2-parameter exponential 
curve.
     */
@@ -87,3 +88,61 @@
             back_calc_grad[param_index][i] = -I0 * relax_times[i] * 
exp(-relax_times[i] * R);
     }
 }
+
+
+void exponential_dI02(double I0, double R, int I0_index, double 
relax_times[MAX_DATA], double 
back_calc_hess[MAX_PARAMS][MAX_PARAMS][MAX_DATA], int num_times) {
+    /* Calculate the dI0 double partial derivate of the 2-parameter 
exponential curve.
+    */
+
+    /* Declarations. */
+    int i;
+
+    /* Loop over the time points. */
+    for (i = 0; i < num_times; i++) {
+        /* Everything is zero! */
+        back_calc_hess[I0_index][I0_index][i] = 0.0;
+    }
+}
+
+
+void exponential_dR_dI0(double I0, double R, int R_index, int IO_index, 
double relax_times[MAX_DATA], double 
back_calc_hess[MAX_PARAMS][MAX_PARAMS][MAX_DATA], int num_times) {
+    /* Calculate the dR, dI0 second partial derivate of the 2-parameter 
exponential curve.
+    */
+
+    /* Declarations. */
+    int i;
+
+    /* Loop over the time points. */
+    for (i = 0; i < num_times; i++) {
+        /* Zero Rx value. */
+        if (R == 0.0)
+            back_calc_hess[IO_index][R_index][i] = -relax_times[i];
+
+        /* The second partial derivate. */
+        else
+            back_calc_hess[IO_index][R_index][i] = -relax_times[i] * 
exp(-relax_times[i] * R);
+
+        /* Hessian symmetry. */
+        back_calc_hess[R_index][IO_index][i] = 
back_calc_hess[IO_index][R_index][i];
+    }
+}
+
+
+void exponential_dR2(double I0, double R, int R_index, double 
relax_times[MAX_DATA], double 
back_calc_hess[MAX_PARAMS][MAX_PARAMS][MAX_DATA], int num_times) {
+    /* Calculate the dR second partial derivate of the 2-parameter 
exponential curve.
+    */
+
+    /* Declarations. */
+    int i;
+
+    /* Loop over the time points. */
+    for (i = 0; i < num_times; i++) {
+        /* Zero Rx value. */
+        if (R == 0.0)
+            back_calc_hess[R_index][R_index][i] = I0 * 
square(relax_times[i]);
+
+        /* The partial derivate. */
+        else
+            back_calc_hess[R_index][R_index][i] = I0 * 
square(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=25313&r1=25312&r2=25313&view=diff
==============================================================================
--- trunk/target_functions/exponential.h        (original)
+++ trunk/target_functions/exponential.h        Tue Aug 26 19:13:59 2014
@@ -29,5 +29,8 @@
 void exponential(double I0, double R, double relax_times[MAX_DATA], double 
back_calc[MAX_DATA], int num_times);
 void exponential_dI0(double I0, double R, int param_index, double 
relax_times[MAX_DATA], double back_calc_grad[MAX_PARAMS][MAX_DATA], int 
num_times);
 void exponential_dR(double I0, double R, int param_index, double 
relax_times[MAX_DATA], double back_calc_grad[MAX_PARAMS][MAX_DATA], int 
num_times);
+void exponential_dI02(double I0, double R, int I0_index, double 
relax_times[MAX_DATA], double 
back_calc_hess[MAX_PARAMS][MAX_PARAMS][MAX_DATA], int num_times);
+void exponential_dR_dI0(double I0, double R, int R_index, int IO_index, 
double relax_times[MAX_DATA], double 
back_calc_hess[MAX_PARAMS][MAX_PARAMS][MAX_DATA], int num_times);
+void exponential_dR2(double I0, double R, int R_index, double 
relax_times[MAX_DATA], double 
back_calc_hess[MAX_PARAMS][MAX_PARAMS][MAX_DATA], 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=25313&r1=25312&r2=25313&view=diff
==============================================================================
--- trunk/target_functions/relax_fit.c  (original)
+++ trunk/target_functions/relax_fit.c  Tue Aug 26 19:13:59 2014
@@ -187,11 +187,9 @@
     exponential_dI0(params[index_I0], params[index_R], index_I0, 
relax_times, back_calc_grad, num_times);
 
     /* The second partial derivatives. */
-    /*
     exponential_dR2(params[index_I0], params[index_R], index_R, relax_times, 
back_calc_hess, num_times);
     exponential_dI02(params[index_I0], params[index_R], index_I0, 
relax_times, back_calc_hess, num_times);
-    exponential_dR2_dI02(params[index_I0], params[index_R], index_R, 
index_I0, relax_times, back_calc_hess, num_times);
-    */
+    exponential_dR_dI0(params[index_I0], params[index_R], index_R, index_I0, 
relax_times, back_calc_hess, num_times);
 
     /* The chi-squared Hessian. */
     d2chi2(d2chi2_vals, values, back_calc, back_calc_grad, back_calc_hess, 
sd, num_times, num_params);




Related Messages


Powered by MHonArc, Updated Tue Aug 26 19:20:02 2014