mailr25305 - in /trunk/target_functions: c_chi2.h dimensions.h exponential.c exponential.h relax_fit.h


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on August 26, 2014 - 18:25:
Author: bugman
Date: Tue Aug 26 18:25:19 2014
New Revision: 25305

URL: http://svn.gna.org/viewcvs/relax?rev=25305&view=rev
Log:
Standardisation of the array dimensionality in the target function C code.

The new target_functions/dimensions.h header file defines MAX_PARAMS and 
MAX_DATA which is then
included in the header files of all the other C files.  All array 
declarations now explicitly
specify the length of each dimension.

The values of MAX_PARAMS and MAX_DATA have increased from 3 and 50 to 20 and 
5000.  This is to allow
for models with more parameters and to allow a much larger number of input 
data points to be
supported before memory corruptions happen.  The data structures now take up 
more memory, but as the
functions do not loop up to maximum but only the number of parameters and 
points specified, this
will not make the code slower.


Added:
    trunk/target_functions/dimensions.h   (with props)
Modified:
    trunk/target_functions/c_chi2.h
    trunk/target_functions/exponential.c
    trunk/target_functions/exponential.h
    trunk/target_functions/relax_fit.h

Modified: trunk/target_functions/c_chi2.h
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/c_chi2.h?rev=25305&r1=25304&r2=25305&view=diff
==============================================================================
--- trunk/target_functions/c_chi2.h     (original)
+++ trunk/target_functions/c_chi2.h     Tue Aug 26 18:25:19 2014
@@ -19,12 +19,10 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "dimensions.h"
+
 #ifndef RELAX_C_CHI2 
 #define RELAX_C_CHI2
-
-/* The maximum number of parameters and data points */
-#define MAX_PARAMS 10
-#define MAX_DATA 50
 
 double chi2(double values[], double sd[], double back_calc[], int num_times);
 void dchi2(double dchi2[], double data[], double back_calc_vals[], double 
back_calc_grad[][MAX_DATA], double errors[], int num_times, int M);

Added: trunk/target_functions/dimensions.h
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/dimensions.h?rev=25305&view=auto
==============================================================================
--- trunk/target_functions/dimensions.h (added)
+++ trunk/target_functions/dimensions.h Tue Aug 26 18:25:19 2014
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2014 Edward d'Auvergne
+ *
+ * This file is part of the program relax (http://www.nmr-relax.com).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef RELAX_DIMENSIONS
+#define RELAX_DIMENSIONS
+
+/* The maximum number of parameters. */
+#define MAX_PARAMS 20
+
+/* The maximum number of data points. */
+#define MAX_DATA 5000
+
+#endif

Propchange: trunk/target_functions/dimensions.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: trunk/target_functions/exponential.c
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/exponential.c?rev=25305&r1=25304&r2=25305&view=diff
==============================================================================
--- trunk/target_functions/exponential.c        (original)
+++ trunk/target_functions/exponential.c        Tue Aug 26 18:25:19 2014
@@ -25,7 +25,7 @@
 #include "exponential.h"
 
 
-void exponential(double I0, double R, double relax_times[], double 
back_calc[], int num_times) {
+void exponential(double I0, double R, double relax_times[MAX_DATA], double 
back_calc[MAX_DATA], int num_times) {
     /* Function to back calculate the intensity values from an exponential.
      *
      * The function used is::
@@ -49,7 +49,7 @@
     }
 }
 
-void exponential_dI0(double I0, double R, int param_index, double 
relax_times[], double back_calc_grad[][MAXTIMES], int num_times) {
+void exponential_dI0(double I0, double R, int param_index, double 
relax_times[MAX_DATA], double back_calc_grad[MAX_PARAMS][MAX_DATA], int 
num_times) {
     /* Calculate the dI0 partial derivate of the 2-parameter exponential 
curve.
     */
 
@@ -69,7 +69,7 @@
 }
 
 
-void exponential_dR(double I0, double R, int param_index, double 
relax_times[], double back_calc_grad[][MAXTIMES], int num_times) {
+void exponential_dR(double I0, double R, int param_index, double 
relax_times[MAX_DATA], double back_calc_grad[MAX_PARAMS][MAX_DATA], int 
num_times) {
     /* Calculate the dR partial derivate of the 2-parameter exponential 
curve.
     */
 

Modified: trunk/target_functions/exponential.h
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/exponential.h?rev=25305&r1=25304&r2=25305&view=diff
==============================================================================
--- trunk/target_functions/exponential.h        (original)
+++ trunk/target_functions/exponential.h        Tue Aug 26 18:25:19 2014
@@ -18,15 +18,14 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+
+#include "dimensions.h"
+
 #ifndef RELAX_EXPONENTIAL 
 #define RELAX_EXPONENTIAL
 
-/* The maximum number of spectral time points */
-#define MAXTIMES 50
-
-
-void exponential(double I0, double R, double relax_times[], double 
back_calc[], int num_times);
-void exponential_dI0(double I0, double R, int param_index, double 
relax_times[], double back_calc_grad[][MAXTIMES], int num_times);
-void exponential_dR(double I0, double R, int param_index, double 
relax_times[], double back_calc_grad[][MAXTIMES], int num_times);
+void exponential(double I0, double R, double relax_times[MAX_DATA], double 
back_calc[MAX_DATA], int num_times);
+void exponential_dI0(double I0, double R, int param_index, double 
relax_times[MAX_DATA], double back_calc_grad[MAX_PARAMS][MAX_DATA], int 
num_times);
+void exponential_dR(double I0, double R, int param_index, double 
relax_times[MAX_DATA], double back_calc_grad[MAX_PARAMS][MAX_DATA], int 
num_times);
 
 #endif

Modified: trunk/target_functions/relax_fit.h
URL: 
http://svn.gna.org/viewcvs/relax/trunk/target_functions/relax_fit.h?rev=25305&r1=25304&r2=25305&view=diff
==============================================================================
--- trunk/target_functions/relax_fit.h  (original)
+++ trunk/target_functions/relax_fit.h  Tue Aug 26 18:25:19 2014
@@ -18,11 +18,7 @@
  */
 
 
-/* The maximum number of parameters for this function */
-#define MAXPARAMS 3
-
-/* The maximum number of spectral time points */
-#define MAXTIMES 50
+#include "dimensions.h"
 
 /* Python 2.2 and earlier support for Python C modules */
 #ifndef PyMODINIT_FUNC
@@ -42,11 +38,11 @@
 static int index_I0 = 1;
 
 /* Variables used for storage during the function calls of optimisation */
-static double back_calc[MAXTIMES];
-static double back_calc_grad[MAXPARAMS][MAXTIMES];
-static double dchi2_vals[MAXPARAMS];
-static double params[MAXPARAMS];
-static double values[MAXTIMES];
-static double sd[MAXTIMES];
-static double relax_times[MAXTIMES];
-static double scaling_matrix[MAXPARAMS];
+static double back_calc[MAX_DATA];
+static double back_calc_grad[MAX_PARAMS][MAX_DATA];
+static double dchi2_vals[MAX_PARAMS];
+static double params[MAX_PARAMS];
+static double values[MAX_DATA];
+static double sd[MAX_DATA];
+static double relax_times[MAX_DATA];
+static double scaling_matrix[MAX_PARAMS];




Related Messages


Powered by MHonArc, Updated Tue Aug 26 18:40:02 2014