Author: bugman
Date: Tue Aug 26 18:54:25 2014
New Revision: 25311
URL: http://svn.gna.org/viewcvs/relax?rev=25311&view=rev
Log:
Comment fixes and formatting changes in all of the target_functions C files and
headers.
Modified:
trunk/target_functions/c_chi2.c
trunk/target_functions/exponential.c
trunk/target_functions/relax_fit.c
trunk/target_functions/relax_fit.h
Modified: trunk/target_functions/c_chi2.c
URL:
http://svn.gna.org/viewcvs/relax/trunk/target_functions/c_chi2.c?rev=25311&r1=25310&r2=25311&view=diff
==============================================================================
--- trunk/target_functions/c_chi2.c (original)
+++ trunk/target_functions/c_chi2.c Tue Aug 26 18:54:25 2014
@@ -48,7 +48,7 @@
int i;
double chi2 = 0.0;
- /* Loop over the time points and sum the chi-squared components */
+ /* Loop over the time points and sum the chi-squared components. */
for (i = 0; i < num_times; ++i) {
chi2 = chi2 + square((values[i] - back_calc[i]) / sd[i]);
}
Modified: trunk/target_functions/exponential.c
URL:
http://svn.gna.org/viewcvs/relax/trunk/target_functions/exponential.c?rev=25311&r1=25310&r2=25311&view=diff
==============================================================================
--- trunk/target_functions/exponential.c (original)
+++ trunk/target_functions/exponential.c Tue Aug 26 18:54:25 2014
@@ -33,16 +33,16 @@
* I = I0 * exp(-R.t)
*/
- /* Declarations */
+ /* Declarations. */
int i;
- /* Loop over the time points */
+ /* Loop over the time points. */
for (i = 0; i < num_times; i++) {
- /* Zero Rx value */
+ /* Zero Rx value. */
if (R == 0.0)
back_calc[i] = I0;
- /* Back calculate */
+ /* Back calculate. */
else
back_calc[i] = I0 * exp(-relax_times[i] * R);
@@ -53,16 +53,16 @@
/* Calculate the dI0 partial derivate of the 2-parameter exponential curve.
*/
- /* Declarations */
+ /* Declarations. */
int i;
- /* Loop over the time points */
+ /* Loop over the time points. */
for (i = 0; i < num_times; i++) {
- /* Zero Rx value */
+ /* Zero Rx value. */
if (R == 0.0)
back_calc_grad[param_index][i] = 1.0;
- /* The partial derivate */
+ /* The partial derivate. */
else
back_calc_grad[param_index][i] = exp(-relax_times[i] * R);
}
@@ -73,16 +73,16 @@
/* Calculate the dR partial derivate of the 2-parameter exponential curve.
*/
- /* Declarations */
+ /* Declarations. */
int i;
- /* Loop over the time points */
+ /* Loop over the time points. */
for (i = 0; i < num_times; i++) {
- /* Zero Rx value */
+ /* Zero Rx value. */
if (R == 0.0)
back_calc_grad[param_index][i] = -I0 * relax_times[i];
- /* The partial derivate */
+ /* The partial derivate. */
else
back_calc_grad[param_index][i] = -I0 * relax_times[i] *
exp(-relax_times[i] * R);
}
Modified: trunk/target_functions/relax_fit.c
URL:
http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_fit.c?rev=25311&r1=25310&r2=25311&view=diff
==============================================================================
--- trunk/target_functions/relax_fit.c (original)
+++ trunk/target_functions/relax_fit.c Tue Aug 26 18:54:25 2014
@@ -17,13 +17,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/* This include must come first */
+/* This include must come first. */
#include <Python.h>
-/* The header for all functions which will be called */
+/* Include all of the variable definitions. */
#include "relax_fit.h"
-/* functions for chi2 and exponential */
+/* The chi2 and exponential functions. */
#include "c_chi2.h"
#include "exponential.h"
@@ -32,47 +32,47 @@
setup(PyObject *self, PyObject *args, PyObject *keywords) {
/* Set up the module in preparation for calls to the target function. */
- /* Python object declarations */
+ /* Python object declarations. */
PyObject *values_arg, *sd_arg, *relax_times_arg, *scaling_matrix_arg;
PyObject *element;
- /* Normal declarations */
- int i;
-
- /* The keyword list */
+ /* Normal declarations. */
+ int i;
+
+ /* The keyword list. */
static char *keyword_list[] = {"num_params", "num_times", "values", "sd",
"relax_times", "scaling_matrix", NULL};
- /* Parse the function arguments */
+ /* 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))
return NULL;
- /* Place the parameter related arguments into C arrays */
- for (i = 0; i < num_params; i++) {
- /* The diagonalised scaling matrix list argument element */
+ /* Place the parameter related arguments into C arrays. */
+ for (i = 0; i < num_params; i++) {
+ /* The diagonalised scaling matrix list argument element. */
element = PySequence_GetItem(scaling_matrix_arg, i);
scaling_matrix[i] = PyFloat_AsDouble(element);
Py_CLEAR(element);
}
- /* Place the time related arguments into C arrays */
+ /* Place the time related arguments into C arrays. */
for (i = 0; i < num_times; i++) {
- /* The value argument element */
+ /* The value argument element. */
element = PySequence_GetItem(values_arg, i);
values[i] = PyFloat_AsDouble(element);
Py_CLEAR(element);
- /* The sd argument element */
+ /* The sd argument element. */
element = PySequence_GetItem(sd_arg, i);
sd[i] = PyFloat_AsDouble(element);
Py_CLEAR(element);
- /* The relax_times argument element */
+ /* The relax_times argument element. */
element = PySequence_GetItem(relax_times_arg, i);
relax_times[i] = PyFloat_AsDouble(element);
Py_CLEAR(element);
}
- /* The macro for returning the Python None object */
+ /* The macro for returning the Python None object. */
Py_RETURN_NONE;
}
@@ -80,20 +80,20 @@
void param_to_c(PyObject *params_arg) {
/* Convert the Python parameter list to a C array. */
- /* Declarations */
+ /* Declarations. */
PyObject *element;
int i;
- /* Place the parameter array elements into the C array */
- for (i = 0; i < num_params; i++) {
- /* Get the element */
+ /* Place the parameter array elements into the C array. */
+ for (i = 0; i < num_params; i++) {
+ /* Get the element. */
element = PySequence_GetItem(params_arg, i);
/* Convert to a C double, then free the memory. */
params[i] = PyFloat_AsDouble(element);
Py_CLEAR(element);
- /* Scale the parameter */
+ /* Scale the parameter. */
params[i] = params[i] * scaling_matrix[i];
}
}
@@ -106,20 +106,20 @@
* calculated.
*/
- /* Declarations */
+ /* Declarations. */
PyObject *params_arg;
- /* Parse the function arguments, the only argument should be the parameter
array */
+ /* Parse the function arguments, the only argument should be the parameter
array. */
if (!PyArg_ParseTuple(args, "O", ¶ms_arg))
return NULL;
- /* Convert the parameters Python list to a C array */
+ /* Convert the parameters Python list to a C array. */
param_to_c(params_arg);
- /* Back calculated the peak intensities */
+ /* Back calculated the peak intensities. */
exponential(params[index_I0], params[index_R], relax_times, back_calc,
num_times);
- /* Calculate and return the chi-squared value */
+ /* Calculate and return the chi-squared value. */
return PyFloat_FromDouble(chi2(values, sd, back_calc, num_times));
}
@@ -130,25 +130,25 @@
*
*/
- /* Declarations */
+ /* Declarations. */
PyObject *params_arg;
int i;
- /* Parse the function arguments, the only argument should be the parameter
array */
+ /* Parse the function arguments, the only argument should be the parameter
array. */
if (!PyArg_ParseTuple(args, "O", ¶ms_arg))
return NULL;
- /* Convert the parameters Python list to a C array */
+ /* Convert the parameters Python list to a C array. */
param_to_c(params_arg);
- /* Back calculated the peak intensities */
+ /* Back calculated the peak intensities. */
exponential(params[index_I0], params[index_R], relax_times, back_calc,
num_times);
- /* The partial derivates */
+ /* The partial derivates. */
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);
- /* The chi-squared gradient */
+ /* The chi-squared gradient. */
dchi2(dchi2_vals, values, back_calc, back_calc_grad, sd, num_times,
num_params);
/* Convert to a Python list, and scale the values. */
@@ -158,7 +158,7 @@
PyList_Append(list, PyFloat_FromDouble(dchi2_vals[i] *
scaling_matrix[i]));
}
- /* Return the gradient */
+ /* Return the gradient. */
return list;
}
@@ -177,15 +177,15 @@
back_calc_I(PyObject *self, PyObject *args) {
/* Return the back calculated peak intensities as a Python list. */
- /* Declarations */
+ /* Declarations. */
PyObject *back_calc_py = PyList_New(num_times);
int i;
- /* Copy the values out of the C array into the Python array */
+ /* Copy the values out of the C array into the Python array. */
for (i = 0; i < num_times; i++)
PyList_SetItem(back_calc_py, i, PyFloat_FromDouble(back_calc[i]));
- /* Return the Python list */
+ /* Return the Python list. */
return back_calc_py;
}
@@ -194,22 +194,22 @@
jacobian(PyObject *self, PyObject *args) {
/* Return the Jacobian as a Python list of lists. */
- /* Declarations */
+ /* Declarations. */
PyObject *params_arg;
int i, j;
- /* Parse the function arguments, the only argument should be the parameter
array */
+ /* Parse the function arguments, the only argument should be the parameter
array. */
if (!PyArg_ParseTuple(args, "O", ¶ms_arg))
return NULL;
- /* Convert the parameters Python list to a C array */
+ /* Convert the parameters Python list to a C array. */
param_to_c(params_arg);
- /* The partial derivates */
+ /* 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 */
+ /* Convert to a Python list of lists. */
PyObject *list = PyList_New(0);
Py_INCREF(list);
for (i = 0; i < num_params; i++) {
@@ -221,12 +221,12 @@
PyList_Append(list, list2);
}
- /* Return the Jacobian */
+ /* Return the Jacobian. */
return list;
}
-/* The method table for the functions called by Python */
+/* The method table for the functions called by Python. */
static PyMethodDef relax_fit_methods[] = {
{
"setup",
@@ -259,11 +259,11 @@
METH_VARARGS,
"Return the Jacobian matrix as a Python list."
},
- {NULL, NULL, 0, NULL} /* Sentinel */
+ {NULL, NULL, 0, NULL} /* Sentinel. */
};
-/* Define the Python 3 module */
+/* Define the Python 3 module. */
#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
@@ -278,7 +278,7 @@
};
#endif
-/* Initialise as a Python module */
+/* Initialise as a Python module. */
PyMODINIT_FUNC
#if PY_MAJOR_VERSION >= 3
PyInit_relax_fit(void)
Modified: trunk/target_functions/relax_fit.h
URL:
http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_fit.h?rev=25311&r1=25310&r2=25311&view=diff
==============================================================================
--- trunk/target_functions/relax_fit.h (original)
+++ trunk/target_functions/relax_fit.h Tue Aug 26 18:54:25 2014
@@ -21,24 +21,24 @@
/* Get the maximum dimensions. */
#include "dimensions.h"
-/* Python 2.2 and earlier support for Python C modules */
+/* Python 2.2 and earlier support for Python C modules. */
#ifndef PyMODINIT_FUNC
#define PyMODINIT_FUNC void
#endif
/****************************************/
-/* External, hence permanent, variables */
-/****************************************/
+/* External, hence permanent, variables. */
+/*****************************************/
-/* Variables sent to the setup function to be stored for later use */
+/* Variables sent to the setup function to be stored for later use. */
static int num_params, num_times;
/* Hardcoded parameter indices. */
static int index_R = 0;
static int index_I0 = 1;
-/* Variables used for storage during the function calls of optimisation */
+/* Variables used for storage during the function calls of optimisation. */
static double back_calc[MAX_DATA];
static double back_calc_grad[MAX_PARAMS][MAX_DATA];
static double dchi2_vals[MAX_PARAMS];
_______________________________________________
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