mailr25438 - /trunk/target_functions/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 29, 2014 - 16:20:
Author: bugman
Date: Fri Aug 29 16:20:44 2014
New Revision: 25438

URL: http://svn.gna.org/viewcvs/relax?rev=25438&view=rev
Log:
Reintroduced the original target_functions.relax_fit.jacobian() function.

The new function for the Jacobian of the chi-squared function has been 
renamed to
target_functions.relax_fit.jacobian_chi2() so that both Python functions are 
accessible within the C
module.


Modified:
    trunk/target_functions/relax_fit.c

Modified: trunk/target_functions/relax_fit.c
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_fit.c?rev=25438&r1=25437&r2=25438&view=diff
==============================================================================
--- trunk/target_functions/relax_fit.c  (original)
+++ trunk/target_functions/relax_fit.c  Fri Aug 29 16:20:44 2014
@@ -235,6 +235,43 @@
 
 static PyObject *
 jacobian(PyObject *self, PyObject *args) {
+    /* Return the Jacobian as a Python list of lists. */
+
+    /* Declarations. */
+    PyObject *params_arg;
+    PyObject *list, *list2;
+    int i, j;
+
+    /* Parse the function arguments, the only argument should be the 
parameter array. */
+    if (!PyArg_ParseTuple(args, "O", &params_arg))
+        return NULL;
+
+    /* Convert the parameters Python list to a C array. */
+    param_to_c(params_arg);
+
+    /* The partial derivatives. */
+    exponential_dR(params[index_I0], params[index_R], index_R, relax_times, 
back_calc_grad, num_times);
+    exponential_dI0(params[index_I0], params[index_R], index_I0, 
relax_times, back_calc_grad, num_times);
+
+    /* Convert to a Python list of lists. */
+    list = PyList_New(0);
+    Py_INCREF(list);
+    for (i = 0; i < num_params; i++) {
+        list2 = PyList_New(0);
+        Py_INCREF(list2);
+        for (j = 0; j < num_times; j++) {
+            PyList_Append(list2, PyFloat_FromDouble(back_calc_grad[i][j]));
+        }
+        PyList_Append(list, list2);
+    }
+
+    /* Return the Jacobian. */
+    return list;
+}
+
+
+static PyObject *
+jacobian_chi2(PyObject *self, PyObject *args) {
     /* Return the Jacobian as a Python list of lists.
 
     The Jacobian




Related Messages


Powered by MHonArc, Updated Fri Aug 29 16:40:02 2014