Author: bugman
Date: Mon Aug 25 16:09:16 2014
New Revision: 25250

URL: http://svn.gna.org/viewcvs/relax?rev=25250&view=rev
Log:
Fixes for the new target_functions.relax_fit.jacobian() function.

The Python list of lists is now correctly created and returned.


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=25250&r1=25249&r2=25250&view=diff
==============================================================================
--- trunk/target_functions/relax_fit.c  (original)
+++ trunk/target_functions/relax_fit.c  Mon Aug 25 16:09:16 2014
@@ -169,17 +169,13 @@
 
 static PyObject *
 jacobian(PyObject *self, PyObject *args) {
-    /* Return the Jacobian as a Python list. */
+    /* Return the Jacobian as a Python list of lists. */
 
     /* Declarations */
     PyObject *params_arg;
     PyObject *element;
     int i, j;
 
-    /* The Python list of lists. */
-    PyObject *list = PyList_New(num_params);
-    Py_INCREF(list);
-
     /* Parse the function arguments, the only argument should be the parameter 
array */
     if (!PyArg_ParseTuple(args, "O", &params_arg))
         return NULL;
@@ -201,9 +197,12 @@
     exponential_dR(params, relax_times, back_calc_grad, num_times);
     exponential_dI(params, relax_times, back_calc_grad, num_times);
 
-    /* Convert to a Python list */
-    for (i = 0; i < num_params; i++) {
-        PyObject *list2 = PyList_New(num_times);
+    /* Convert to a Python list of lists */
+    PyObject *list = PyList_New(0);
+    Py_INCREF(list);
+    for (i = 0; i < num_params; i++) {
+        PyObject *list2 = PyList_New(0);
+        Py_INCREF(list2);
         for (j = 0; j < num_times; j++) {
             PyList_Append(list2, PyFloat_FromDouble(back_calc_grad[i][j]));
         }


_______________________________________________
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

Reply via email to