Author: semor
Date: Fri Aug 26 10:10:59 2011
New Revision: 14465
URL: http://svn.gna.org/viewcvs/relax?rev=14465&view=rev
Log:
A further step at getting the chosen equation passed from Python to C.
Not clear if it works.
Need for fixing the dependency check, as relax thinks the C module is
not compiled, although compilation seems to happen without error...
Modified:
branches/inversion-recovery/maths_fns/relax_fit.c
Modified: branches/inversion-recovery/maths_fns/relax_fit.c
URL:
http://svn.gna.org/viewcvs/relax/branches/inversion-recovery/maths_fns/relax_fit.c?rev=14465&r1=14464&r2=14465&view=diff
==============================================================================
--- branches/inversion-recovery/maths_fns/relax_fit.c (original)
+++ branches/inversion-recovery/maths_fns/relax_fit.c Fri Aug 26 10:10:59
2011
@@ -32,20 +32,21 @@
static PyObject *
setup(PyObject *self, PyObject *args, PyObject *keywords) {
/* Python object declarations */
- PyObject *values_arg, *sd_arg, *relax_times_arg, *scaling_matrix_arg;
+ PyObject *curve_type_arg, *values_arg, *sd_arg, *relax_times_arg,
*scaling_matrix_arg;
PyObject *element;
/* Normal declarations */
+ extern char *curve_type;
extern double *params, *values, *sd, *relax_times, *scaling_matrix;
extern double relax_time_array;
extern int num_params, num_times;
int i;
/* The keyword list */
- static char *keyword_list[] = {"num_params", "num_times", "values",
"sd", "relax_times", "scaling_matrix", NULL};
+ static char *keyword_list[] = {"curve_type", "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_arg,
&relax_times_arg, &scaling_matrix_arg))
+ if (!PyArg_ParseTupleAndKeywords(args, keywords, "iiOOOO",
keyword_list, &curve_type, &num_params, &num_times, &values_arg, &sd_arg,
&relax_times_arg, &scaling_matrix_arg))
return NULL;
/* Dynamic C arrays */
@@ -55,6 +56,15 @@
relax_times = (double *) malloc(sizeof(double)*num_times);
scaling_matrix = (double *) malloc(sizeof(double)*num_params);
+ /* Place the curve_type element into the C array */
+ for (i = 0; i < PySequence_Fast_GET_SIZE(curve_type); i++) {
+ /* Get the element */
+ element = PySequence_GetItem(curve_type_arg, i);
+
+ /* Convert to a C char array */
+ curve_type[i] = PyString_AsChar(element);
+ }
+
/* Place the value elements into the C array */
for (i = 0; i < num_times; i++) {
/* Get the element */
@@ -107,6 +117,7 @@
/* Declarations */
PyObject *params_arg;
PyObject *element;
+ char *curve_type;
extern double *params;
int i;
@@ -124,9 +135,9 @@
}
/* Back calculated the peak intensities */
- if(sizeof(num_params) == 2)
+ if (curve_type == "exp_2param_neg")
exp_2param_neg(params, relax_times, back_calc, num_times);
- if(sizeof(num_params) == 3)
+ if (curve_type == "exp_3param_inv_neg")
exp_3param_inv_neg(params, relax_times, back_calc, num_times);
/* Calculate and return the chi-squared value */
@@ -139,9 +150,11 @@
/* Function for calculating and returning the chi-squared gradient. */
/* Declarations */
+ PyObject *curve_type_arg;
PyObject *params_arg;
/* Temp Declarations */
+ char *curve_type;
double aaa[MAXPARAMS] = {1.0, 2.0};
int i;
double *params;
@@ -151,9 +164,9 @@
return NULL;
/* Back calculated the peak intensities */
- if(sizeof(num_params) == 2)
+ if (curve_type == "exp_2param_neg")
exp_2param_neg(params, relax_times, back_calc, num_times);
- if(sizeof(num_params) == 3)
+ if (curve_type == "exp_3param_inv_neg")
exp_3param_inv_neg(params, relax_times, back_calc, num_times);
_______________________________________________
relax (http://nmr-relax.com)
This is the relax-commits mailing list
relax-commits@xxxxxxx
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