Author: bugman Date: Thu Mar 16 05:42:41 2006 New Revision: 2391 URL: http://svn.gna.org/viewcvs/relax?rev=2391&view=rev Log: Merged the fixes to the relaxation curve-fitting C modules from the 'c_modules' branch to the main development line '1.2'. Revisions r2386:2390 of 'c_modules' were merged. Modified: 1.2/maths_fns/c_chi2.c 1.2/maths_fns/exponential.c 1.2/maths_fns/relax_fit.c 1.2/maths_fns/relax_fit.h Modified: 1.2/maths_fns/c_chi2.c URL: http://svn.gna.org/viewcvs/relax/1.2/maths_fns/c_chi2.c?rev=2391&r1=2390&r2=2391&view=diff ============================================================================== --- 1.2/maths_fns/c_chi2.c (original) +++ 1.2/maths_fns/c_chi2.c Thu Mar 16 05:42:41 2006 @@ -44,14 +44,14 @@ */ /* Declarations */ - extern int *num_times; + extern int num_times; extern double *values, *sd; extern double back_calc[]; int i; double chi2 = 0.0; /* Loop over the time points and sum the chi-squared components */ - for (i = 0; i < (int)num_times; ++i) { + for (i = 0; i < num_times; ++i) { chi2 = chi2 + square((values[i] - back_calc[i]) / sd[i]); } Modified: 1.2/maths_fns/exponential.c URL: http://svn.gna.org/viewcvs/relax/1.2/maths_fns/exponential.c?rev=2391&r1=2390&r2=2391&view=diff ============================================================================== --- 1.2/maths_fns/exponential.c (original) +++ 1.2/maths_fns/exponential.c Thu Mar 16 05:42:41 2006 @@ -35,7 +35,7 @@ */ /* Declarations */ - extern int *num_times; + extern int num_times; extern double *params, *relax_times; extern double back_calc[]; double Rx, I0; @@ -44,7 +44,7 @@ /* Loop over the time points */ /* for (i = 0; i < num_times; i++) { */ - for (i = 0; i < (int)num_times; i++) { + for (i = 0; i < num_times; i++) { /* Zero Rx value */ if (params[0] == 0.0) back_calc[i] = 0.0; Modified: 1.2/maths_fns/relax_fit.c URL: http://svn.gna.org/viewcvs/relax/1.2/maths_fns/relax_fit.c?rev=2391&r1=2390&r2=2391&view=diff ============================================================================== --- 1.2/maths_fns/relax_fit.c (original) +++ 1.2/maths_fns/relax_fit.c Thu Mar 16 05:42:41 2006 @@ -33,19 +33,18 @@ setup(PyObject *self, PyObject *args, PyObject *keywords) { /* Python declarations */ PyObject *values_arg, *sd_arg, *relax_times_arg, *scaling_matrix_arg; - extern PyArrayObject *numpy_values, *numpy_sd, *numpy_relax_times, *numpy_scaling_matrix; + PyArrayObject *numpy_values, *numpy_sd, *numpy_relax_times, *numpy_scaling_matrix; /* Normal declarations */ extern double *values, *sd, *relax_times, *scaling_matrix; - extern double *relax_time_array; - extern int *num_params, *num_times; + extern double relax_time_array; + extern int num_params, num_times; /* The keyword list */ static char *keyword_list[] = {"num_params", "num_times", "values", "sd", "relax_times", "scaling_matrix", NULL}; - /* Parse the function arguments */ - if (!PyArg_ParseTupleAndKeywords(args, keywords, "iiOOOO", keyword_list, &num_params, &num_times, &values_arg, &sd, &relax_times_arg, &scaling_matrix_arg)) + if (!PyArg_ParseTupleAndKeywords(args, keywords, "iiOOOO", keyword_list, &num_params, &num_times, &values_arg, &sd_arg, &relax_times_arg, &scaling_matrix_arg)) return NULL; /* Make the Numeric arrays contiguous */ @@ -128,7 +127,7 @@ /* Test code (convert aaa to a Numeric array */ /* aaa_numpy = (PyArrayObject *) PyArray_FromDimsAndData(1, num_params, PyArray_DOUBLE, aaa_pointer); */ - aaa_numpy = (PyArrayObject *) PyArray_FromDims(1, num_params, PyArray_DOUBLE); + aaa_numpy = (PyArrayObject *) PyArray_FromDims(1, &num_params, PyArray_DOUBLE); aaa_pointer = (double *) aaa_numpy->data; /* Fill the Numeric array */ @@ -152,14 +151,14 @@ /* Declarations */ extern double back_calc[]; - extern int *num_times; + extern int num_times; int i; - PyObject *back_calc_py = PyList_New((int)num_times); + PyObject *back_calc_py = PyList_New(num_times); assert(PyList_Check(back_calc_py)); /* Copy the values out of the C array into the Python array */ - for (i = 0; i < (int)num_times; i++) + for (i = 0; i < num_times; i++) PyList_SetItem(back_calc_py, i, Py_BuildValue("f", back_calc[i])); /* Return the Numeric array */ Modified: 1.2/maths_fns/relax_fit.h URL: http://svn.gna.org/viewcvs/relax/1.2/maths_fns/relax_fit.h?rev=2391&r1=2390&r2=2391&view=diff ============================================================================== --- 1.2/maths_fns/relax_fit.h (original) +++ 1.2/maths_fns/relax_fit.h Thu Mar 16 05:42:41 2006 @@ -37,7 +37,7 @@ /* Variables sent to the setup function to be stored for later use */ PyArrayObject *numpy_values, *numpy_sd, *numpy_relax_times, *numpy_scaling_matrix; -int *num_params, *num_times; +int num_params, num_times; double *sd; /* Variables sent to 'func', 'dfunc', and 'd2func' during optimisation */