mailr26830 - in /trunk/target_functions: relax_fit.c relax_fit_wrapper.py


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

Header


Content

Posted by edward on November 29, 2014 - 10:26:
Author: bugman
Date: Sat Nov 29 10:26:15 2014
New Revision: 26830

URL: http://svn.gna.org/viewcvs/relax?rev=26830&view=rev
Log:
Renamed all of the relaxation curve-fitting target functions.

This includes all of the C functions which are model specific, by appending 
'_exp' to the current
names to now be func_exp, dfunc_exp, d2func_exp, jacobian_exp, and 
jacobian_chi2_exp.  And all of
the Relax_fit_opt target function class *_wrapper() methods to *_exp().  The 
target function class
is now only aliasing the *_exp() methods when the model is set to 'exp'.


Modified:
    trunk/target_functions/relax_fit.c
    trunk/target_functions/relax_fit_wrapper.py

Modified: trunk/target_functions/relax_fit.c
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_fit.c?rev=26830&r1=26829&r2=26830&view=diff
==============================================================================
--- trunk/target_functions/relax_fit.c  (original)
+++ trunk/target_functions/relax_fit.c  Sat Nov 29 10:26:15 2014
@@ -102,8 +102,8 @@
 }
 
 static PyObject *
-func(PyObject *self, PyObject *args) {
-    /* Target function for calculating and returning the chi-squared value.
+func_exp(PyObject *self, PyObject *args) {
+    /* Target function for the two parameter exponential for calculating and 
returning the chi-squared value.
      *
      * Firstly the back calculated intensities are generated, then the 
chi-squared statistic is
      * calculated.
@@ -128,8 +128,8 @@
 
 
 static PyObject *
-dfunc(PyObject *self, PyObject *args) {
-    /* Target function for calculating and returning the chi-squared 
gradient.
+dfunc_exp(PyObject *self, PyObject *args) {
+    /* Target function for the two parameter exponential for calculating and 
returning the chi-squared gradient.
      * 
      */
 
@@ -167,8 +167,8 @@
 }
 
 static PyObject *
-d2func(PyObject *self, PyObject *args) {
-    /* Target function for calculating and returning the chi-squared Hessian.
+d2func_exp(PyObject *self, PyObject *args) {
+    /* Target function for the two parameter exponential for calculating and 
returning the chi-squared Hessian.
      * 
      */
 
@@ -234,8 +234,8 @@
 
 
 static PyObject *
-jacobian(PyObject *self, PyObject *args) {
-    /* Return the Jacobian as a Python list of lists. */
+jacobian_exp(PyObject *self, PyObject *args) {
+    /* Return the Jacobian for the two parameter exponential as a Python 
list of lists. */
 
     /* Declarations. */
     PyObject *params_arg;
@@ -271,8 +271,8 @@
 
 
 static PyObject *
-jacobian_chi2(PyObject *self, PyObject *args) {
-    /* Return the Jacobian as a Python list of lists.
+jacobian_chi2_exp(PyObject *self, PyObject *args) {
+    /* Return the Jacobian for the two parameter exponential as a Python 
list of lists.
 
     The Jacobian
     ============
@@ -345,35 +345,35 @@
         METH_VARARGS | METH_KEYWORDS,
         "Set up the module in preparation for calls to the target function."
     }, {
-        "func",
-        func,
-        METH_VARARGS,
-        "Target function for calculating and returning the chi-squared 
value.\n\nFirstly the back calculated intensities are generated, then the 
chi-squared statistic is calculated."
-    }, {
-        "dfunc",
-        dfunc,
-        METH_VARARGS,
-        "Target function for calculating and returning the chi-squared 
gradient."
-    }, {
-        "d2func",
-        d2func,
-        METH_VARARGS,
-        "Target function for calculating and returning the chi-squared 
Hessian."
+        "func_exp",
+        func_exp,
+        METH_VARARGS,
+        "Target function for the two parameter exponential for calculating 
and returning the chi-squared value.\n\nFirstly the back calculated 
intensities are generated, then the chi-squared statistic is calculated."
+    }, {
+        "dfunc_exp",
+        dfunc_exp,
+        METH_VARARGS,
+        "Target function for the two parameter exponential for calculating 
and returning the chi-squared gradient."
+    }, {
+        "d2func_exp",
+        d2func_exp,
+        METH_VARARGS,
+        "Target function for the two parameter exponential for calculating 
and returning the chi-squared Hessian."
     }, {
         "back_calc_I",
         back_calc_I,
         METH_VARARGS,
         "Return the back calculated peak intensities as a Python list."
     }, {
-        "jacobian",
-        jacobian,
-        METH_VARARGS,
-        "Return the Jacobian matrix as a Python list."
-    }, {
-        "jacobian_chi2",
-        jacobian_chi2,
-        METH_VARARGS,
-        "Return the Jacobian matrix of the chi-squared function as a Python 
list."
+        "jacobian_exp",
+        jacobian_exp,
+        METH_VARARGS,
+        "Return the Jacobian matrix for the two parameter exponential as a 
Python list."
+    }, {
+        "jacobian_chi2_exp",
+        jacobian_chi2_exp,
+        METH_VARARGS,
+        "Return the Jacobian matrix of the chi-squared function for the two 
parameter exponential as a Python list."
     },
         {NULL, NULL, 0, NULL}        /* Sentinel. */
 };

Modified: trunk/target_functions/relax_fit_wrapper.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_fit_wrapper.py?rev=26830&r1=26829&r2=26830&view=diff
==============================================================================
--- trunk/target_functions/relax_fit_wrapper.py (original)
+++ trunk/target_functions/relax_fit_wrapper.py Sat Nov 29 10:26:15 2014
@@ -32,7 +32,7 @@
 
 # C modules.
 if C_module_exp_fn:
-    from target_functions.relax_fit import jacobian, jacobian_chi2, setup, 
func, dfunc, d2func, back_calc_I
+    from target_functions.relax_fit import jacobian_exp, jacobian_chi2_exp, 
setup, func_exp, dfunc_exp, d2func_exp, back_calc_I
 
 
 class Relax_fit_opt:
@@ -62,13 +62,15 @@
         setup(num_params=num_params, num_times=len(relax_times), 
values=values, sd=errors, relax_times=relax_times, 
scaling_matrix=scaling_matrix)
 
         # Alias the target functions.
-        self.func = self.func_wrapper
-        self.dfunc = self.dfunc_wrapper
-        self.d2func = self.d2func_wrapper
+        if model == 'exp':
+            self.func = self.func_exp
+            self.dfunc = self.dfunc_exp
+            self.d2func = self.d2func_exp
 
         # Alias the Jacobian C functions.
-        self.jacobian = jacobian
-        self.jacobian_chi2 = jacobian_chi2
+        if model == 'exp':
+            self.jacobian = jacobian_exp
+            self.jacobian_chi2 = jacobian_chi2_exp
 
 
     def back_calc_data(self):
@@ -82,7 +84,7 @@
         return back_calc_I()
 
 
-    def func_wrapper(self, params):
+    def func_exp(self, params):
         """Wrapper function for the C module, for converting numpy arrays.
 
         @param params:  The parameter array from the minimisation code.
@@ -96,13 +98,13 @@
             params = params.tolist()
 
         # Call the C code.
-        chi2 = func(params)
+        chi2 = func_exp(params)
 
         # Return the chi2 value.
         return nan_to_num(chi2)
 
 
-    def dfunc_wrapper(self, params):
+    def dfunc_exp(self, params):
         """Wrapper function for the C module, for converting numpy arrays.
 
         @param params:  The parameter array from the minimisation code.
@@ -116,13 +118,13 @@
             params = params.tolist()
 
         # Call the C code.
-        dchi2 = dfunc(params)
+        dchi2 = dfunc_exp(params)
 
         # Return the chi2 gradient as a numpy array.
         return array(dchi2, float64)
 
 
-    def d2func_wrapper(self, params):
+    def d2func_exp(self, params):
         """Wrapper function for the C module, for converting numpy arrays.
 
         @param params:  The parameter array from the minimisation code.
@@ -136,7 +138,7 @@
             params = params.tolist()
 
         # Call the C code.
-        d2chi2 = d2func(params)
+        d2chi2 = d2func_exp(params)
 
         # Return the chi2 Hessian as a numpy array.
         return array(d2chi2, float64)




Related Messages


Powered by MHonArc, Updated Sat Nov 29 10:40:02 2014