\section{/home/peifer/diffit/modules/set\-Initial\-Values.cc File Reference}
\label{setInitialValues_8cc}\index{/home/peifer/diffit/modules/setInitialValues.cc@{/home/peifer/diffit/modules/setInitialValues.cc}}
{\tt \#include $<$iostream$>$}\par
{\tt \#include $<$fstream$>$}\par
{\tt \#include \char`\"{}../def.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf set\-Initial\-Values} ({\bf Glob\-Exp} $\ast$ex, int n\-P, double $\ast$parameters, double $\ast$y\-Values)
\end{CompactItemize}


\subsection{Function Documentation}
\index{setInitialValues.cc@{set\-Initial\-Values.cc}!setInitialValues@{setInitialValues}}
\index{setInitialValues@{setInitialValues}!setInitialValues.cc@{set\-Initial\-Values.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void set\-Initial\-Values ({\bf Glob\-Exp} $\ast$ {\em ex}, int {\em n\-P}, double $\ast$ {\em parameters}, double $\ast$ {\em y\-Values})}\label{setInitialValues_8cc_62b20da50932eea5fe90a1d268cf7ea2}




Definition at line 8 of file set\-Initial\-Values.cc.

References Glob\-Exp::mesh, Glob\-Exp::n\-Measure, Glob\-Exp::nobs, Glob\-Exp::n\-Points, Glob\-Exp::nvar, Glob\-Exp::x\-Measure, Glob\-Exp::y\-Measure, and Glob\-Exp::y\-Try.

\footnotesize\begin{verbatim}9 {
10   long i,j,k;
11   double xi, d, w1, w2;
12   long nobs=ex->nobs, nvar=ex->nvar, nMeasure=ex->nMeasure;
13   long nPoints=ex->nPoints;
14   
15   /* set initial values */
16   if (yValues) 
17     {
18       for (j=1; j<=nvar; ++j) 
19         ex->yTry[1][j]=yValues[j];
20       i=2;
21     } 
22   else
23     i=1;
24   k=1;
25   
26   while (i<=nPoints) 
27     {
28       xi=ex->mesh[i];
29       // make educated guess for yTry(xi)
30       
31       // could be improved (polynomial interpolation/extrapolation etc.)
32       
33       if (ex->xMeasure[k]>=xi) 
34         {
35           // before first measurement: take first measured value
36           for (j=1; j<=nvar; ++j)
37             if (j<=nobs)
38               ex->yTry[i][j]=ex->yMeasure[k][j];
39             else
40               ex->yTry[i][j]=1;
41         } else if (k==nMeasure) 
42           {
43             // after last measurement: take last measured value
44             for (j=1; j<=nvar; ++j)
45               if (j<=nobs)
46                 ex->yTry[i][j]=ex->yMeasure[k][j];
47               else
48                 ex->yTry[i][j]=1;
49           } 
50       else 
51         {
52           // interpolate linearly
53           while (k<nMeasure && ex->xMeasure[k]<xi) 
54             ++k;
55           d=ex->xMeasure[k]-ex->xMeasure[k-1];
56           w1=(ex->xMeasure[k]-xi)/d;
57           w2=(xi-ex->xMeasure[k-1])/d;
58           for (j=1; j<=nvar; ++j) 
59             if (j<=nobs)
60               ex->yTry[i][j]=w1*ex->yMeasure[k-1][j] + w2*ex->yMeasure[k][j];
61             else
62               ex->yTry[i][j]=1;
63         }
64       ++i;
65     }  
66 }
\end{verbatim}\normalsize 


