\section{/home/peifer/diffit/modules/compute\-Right.cc File Reference}
\label{computeRight_8cc}\index{/home/peifer/diffit/modules/computeRight.cc@{/home/peifer/diffit/modules/computeRight.cc}}
{\tt \#include $<$iostream$>$}\par
{\tt \#include $<$math.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include \char`\"{}../def.h\char`\"{}}\par
{\tt \#include \char`\"{}../model.h\char`\"{}}\par
{\tt \#include \char`\"{}../nr.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
double {\bf objective\-F} ({\bf Glob} $\ast$globs, {\bf Glob\-Exp} $\ast$ex)
\item 
double {\bf compute\-Right} ({\bf Glob} $\ast$globs, {\bf Glob\-Exp} $\ast$ex)
\end{CompactItemize}


\subsection{Function Documentation}
\index{computeRight.cc@{compute\-Right.cc}!computeRight@{computeRight}}
\index{computeRight@{computeRight}!computeRight.cc@{compute\-Right.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double compute\-Right ({\bf Glob} $\ast$ {\em globs}, {\bf Glob\-Exp} $\ast$ {\em ex})}\label{computeRight_8cc_6d52e05b0106034e961975936240e279}




Definition at line 39 of file compute\-Right.cc.

References Glob\-Exp::h, Glob\-Exp::n\-Measure, Glob\-Exp::nobs, Glob::npar, Glob\-Exp::n\-Points, and Glob\-Exp::nvar.

\footnotesize\begin{verbatim}40 {
41     long i,j,k;
42 
43     // calculate discrepancies, residues and constraints
44     long nPoints=ex->nPoints, nvar=ex->nvar;
45     long nMeasure=ex->nMeasure, nobs=ex->nobs;
46     long nP=globs->npar;
47 
48     // no continuity constraints for first and last mesh point
49     for (j=1;j<=nvar;++j) {
50         ex->h[1][j]=0;
51         ex->h[nPoints][j]=0;
52     }
53     for (i=2;i<nPoints;++i)
54       {
55         for (j=1;j<=nvar;++j)
56           ex->h[i][j]=ex->yComp[i][j]-ex->yTry[i][j];
57       }
58     for (i=1;i<=nMeasure;++i)
59       {
60         for (j=1;j<=nobs;++j)
61           ex->residues[i][j]=ex->yPred[i][j]-ex->yMeasure[i][j];
62       }
63 
64     //extra equality and inequality constraints
65     R2(globs,ex, TRUE);
66     R3(globs,ex ,TRUE);
67 
68 #ifdef PRINTDERIVS
69     for (i=1; i<=nPoints; ++i) {
70         *dbg << "dyds[" << i << "] = (";
71         for (j=1; j<=nvar; ++j) {
72             for (k=1; k<=nvar; ++k)
73                 *dbg << " " << ex->dyds[i][j][k];
74             *dbg << ", ";
75         }
76         *dbg << ")\ndydp[" << i << "] = (";
77         for (j=1; j<=nvar; ++j) {
78             for (k=1; k<=nP; ++k)
79                 *dbg << " " << ex->dydp[i][j][k];
80             *dbg << ", ";
81         }
82         *dbg << ")\n";
83     }
84     for (i=1; i<=nMeasure; ++i) {
85         *dbg << "dmds[" << i << "] = (";
86         for (j=1; j<=nobs; ++j) {
87             for (k=1; k<=nvar; ++k)
88                 *dbg << " " << ex->dmds[i][j][k];
89             *dbg << ", ";
90         }
91         *dbg << ")\ndmdp[" << i << "] = (";
92         for (j=1; j<=nobs; ++j) {
93             for (k=1; k<=nP; ++k)
94                 *dbg << " " << ex->dmdp[i][j][k];
95             *dbg << ", ";
96         }
97         *dbg << ")\n";
98     }
99     for (i=1; i<=ex->me; ++i) {
100         *dbg << "dR2ds[" << i << "] = (";
101         for (j=1; j<=nPoints; ++j) {
102             for (k=1; k<=nvar; ++k)
103                 *dbg << " " << ex->dR2ds[i][j][k];
104             *dbg << ", ";
105         }
106         *dbg << ")\n";
107         *dbg << "dR2dp[" << i << "] = (";
108         for (j=1; j<=nP; ++j)
109             *dbg << " " << ex->dR2dp[i][j];
110         *dbg << ")\n";
111     }
112     for (i=1; i<=ex->mg; ++i) {
113         *dbg << "dR3ds[" << i << "] = (";
114         for (j=1; j<=nPoints; ++j) {
115             for (k=1; k<=nvar; ++k)
116                 *dbg << " " << ex->dR3ds[i][j][k];
117             *dbg << ", ";
118         }
119         *dbg << ")\n";
120         *dbg << "dR3dp[" << i << "] = (";
121         for (j=1; j<=nP; ++j)
122             *dbg << " " << ex->dR3dp[i][j];
123         *dbg << ")\n";
124     }
125     dbg->flush();
126 #endif
127 
128     return(objectiveF(globs,ex));
129 }
\end{verbatim}\normalsize 


\index{computeRight.cc@{compute\-Right.cc}!objectiveF@{objectiveF}}
\index{objectiveF@{objectiveF}!computeRight.cc@{compute\-Right.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}double objective\-F ({\bf Glob} $\ast$ {\em globs}, {\bf Glob\-Exp} $\ast$ {\em ex})}\label{computeRight_8cc_60b5def6390d3c9dade90a0a3390a3f3}




Definition at line 12 of file compute\-Right.cc.

References dbg, f(), Glob\-Exp::n\-Measure, Glob\-Exp::nobs, Glob\-Exp::residues, and Glob\-Exp::sigma.

\footnotesize\begin{verbatim}13 {
14   int i,j;
15   double df,f;
16   
17   f=0;
18   for (i=1; i<=ex->nMeasure; ++i)
19     {
20       for (j=1; j<=ex->nobs; ++j) 
21         {
22           //residues calculated in function computerRight
23           df = (ex->residues[i][j]*ex->residues[i][j])/
24             (ex->sigma[i][j]!=0 ? (ex->sigma[i][j]*ex->sigma[i][j]) : 1.0);
25 #ifdef DEBUGF
26           if (df>0.1) 
27             *dbg << "f increment " << df << " for i = " << i << ", j = " << j << "\n";
28 #endif
29           f += df;
30         }
31     }
32   ex->objF=f;
33 #ifdef DEBUGF
34   *dbg << "nMeasure = " << ex->nMeasure << ", nobs = " << ex->nobs << ", f = " << f << "\n";
35 #endif
36   return(f);
37 }
\end{verbatim}\normalsize 


