\section{/home/peifer/diffit/create\-Spline.cc File Reference}
\label{createSpline_8cc}\index{/home/peifer/diffit/createSpline.cc@{/home/peifer/diffit/createSpline.cc}}
{\tt \#include $<$iostream$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$fstream$>$}\par
{\tt \#include $<$math.h$>$}\par
{\tt \#include $<$string$>$}\par
{\tt \#include $<$getopt.h$>$}\par
{\tt \#include \char`\"{}nr.h\char`\"{}}\par
\subsection*{Namespaces}
\begin{CompactItemize}
\item 
namespace {\bf std}
\end{CompactItemize}
\subsection*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf TRUE}~1
\item 
\#define {\bf FALSE}~0
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf parse\-The\-Opts} (int argc, char $\ast$argv[$\,$], glob $\ast$globs)
\item 
{\bf main} (int argc, char $\ast$argv[$\,$])
\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
char {\bf usage} [$\,$]
\end{CompactItemize}


\subsection{Define Documentation}
\index{createSpline.cc@{create\-Spline.cc}!FALSE@{FALSE}}
\index{FALSE@{FALSE}!createSpline.cc@{create\-Spline.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define FALSE~0}\label{createSpline_8cc_a93f0eb578d23995850d61f7d61c55c1}




Definition at line 12 of file create\-Spline.cc.

Referenced by damp\-It(), decondense(), free\-Mem(), initialise(), init\-Values\-OK(), mex\-Function(), out\-Fit(), parseopts(), parse\-The\-Opts(), set\-Mesh(), and solv\-Lin().\index{createSpline.cc@{create\-Spline.cc}!TRUE@{TRUE}}
\index{TRUE@{TRUE}!createSpline.cc@{create\-Spline.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define TRUE~1}\label{createSpline_8cc_a8cecfc5c5c054d2875c03e77b7be15d}




Definition at line 11 of file create\-Spline.cc.

Referenced by call\_\-odessa(), damp\-It(), f(), fitness(), initialise(), init\-Values\-OK(), main(), mex\-Function(), parseopts(), parse\-The\-Opts(), and tabulate\-Values().

\subsection{Function Documentation}
\index{createSpline.cc@{create\-Spline.cc}!main@{main}}
\index{main@{main}!createSpline.cc@{create\-Spline.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}main (int {\em argc}, char $\ast$ {\em argv}[$\,$])}\label{createSpline_8cc_e0665038b72011f5c680c660fcb59459}




Definition at line 202 of file create\-Spline.cc.

References dvector(), free\_\-dvector(), parse\-The\-Opts(), splines(), splines\_\-gcv(), and TRUE.

\footnotesize\begin{verbatim}203 {
204 
205   glob globs;
206   long i,n;
207   double *g,*gam,alpha;
208 
209   ofstream out;
210   
211   parseTheOpts(argc,argv,&globs);
212   
213   n=globs.nKnots;
214   g=dvector(1,n);
215   gam=dvector(1,n);
216   out.open(globs.outFile);
217   alpha=globs.alpha;
218   
219   if(alpha > globs.maxLambda)
220     alpha=globs.maxLambda;
221 
222   if(globs.gcv==TRUE)
223     splines_gcv(globs.t,globs.y,globs.sig,n,&alpha,g,gam,globs.maxLambda);
224   else
225     splines(globs.t,globs.y,globs.sig,n,alpha,g,gam);
226 
227   //writing output
228 
229   out << n <<endl;
230   out << globs.t[1] << "\t" << g[1] << "\t" << "0" << endl;
231   for(i=2;i<=n-1;i++)
232     out << globs.t[i] << "\t" << g[i] << "\t" << gam[i-1] << endl;
233   out << globs.t[n] << "\t" << g[n] << "\t" << "0" << endl;
234 
235   out.close();
236   //free memory
237   delete globs.inFile;
238   if(globs.outset==TRUE)
239     delete globs.outFile;
240   free_dvector(globs.y,1,n);
241   free_dvector(globs.t,1,n);
242   free_dvector(globs.sig,1,n);
243   free_dvector(g,1,n);
244   free_dvector(gam,1,n);
245 }
\end{verbatim}\normalsize 


\index{createSpline.cc@{create\-Spline.cc}!parseTheOpts@{parseTheOpts}}
\index{parseTheOpts@{parseTheOpts}!createSpline.cc@{create\-Spline.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void parse\-The\-Opts (int {\em argc}, char $\ast$ {\em argv}[$\,$], glob $\ast$ {\em globs})}\label{createSpline_8cc_ff284807414522b6e7e76c00560ac054}




Definition at line 39 of file create\-Spline.cc.

References FALSE, TRUE, and usage.

Referenced by main().

\footnotesize\begin{verbatim}40 {
41   int longindex,opt;
42   long i,j,columns=0,colvor=0;
43   double dum;
44   char cdum;
45   
46   ifstream in,inp;
47   
48   //option definition
49   static struct option longopts[]={
50     {"help", 0, 0,  'h'},
51     {"help", 0, 0,  '?'},
52     {"alpha"  , 1, 0,   1 },
53     {"nogcv"  , 0, 0,   2 },
54     {"max"   , 1, 0,   3 },
55     {"o"      , 1, 0,   4 },
56     {0, 0, 0, 0}
57   };
58 
59   //initialise struct glob
60   globs->alpha=1;
61   globs->gcv=TRUE;
62   globs->maxLambda=1e10;
63   globs->nKnots=0;
64   globs->outset=FALSE;
65   
66   while ((opt=getopt_long_only(argc,argv,"h?",longopts,&longindex)) != -1)
67     {
68       switch(opt)
69         {
70         case 'h':
71           cout << usage << endl;
72           exit(1);
73           break;
74         case '?':
75           cerr << usage << endl;
76           exit(1);      
77           break;
78         }
79     }
80   //getFileName
81   if((argc-optind)!=1)
82     {
83       cerr << "No/Too many datafile(s) specified.  \n\n";
84       exit(1);
85     }
86   else
87     {
88       globs->inFile = new char[strlen(argv[optind])+1];
89       strcpy(globs->inFile,argv[optind]);
90     }
91 
92 #ifdef DEBUG
93   cout << "Debug ->  Input filename : " << globs->inFile << endl;
94 #endif 
95   optind=0;
96 
97   //determine data structure and read data
98 
99   in.open(globs->inFile);
100   if(in==NULL)
101     {
102       cerr << "Input file does not exist.\n";
103       exit(1);
104     }
105 
106   i=0; 
107   while(!in.eof())
108     {
109       cdum=in.peek();
110       while((cdum == ' ' || cdum == '\t' || cdum == '\n'))
111         {
112           if(cdum=='\n')
113             {
114               if(i==0)
115                 colvor=columns;
116               i=1;
117               if((columns != 2 && columns != 3)|| colvor != columns)
118                 {
119                   cerr << "Insufficient data format in line " <<  globs->nKnots+1 << ".\n";
120                   exit(1);
121                 }
122               globs->nKnots++;
123               colvor=columns;
124               columns=0;
125             }
126           cdum=in.get();
127           cdum=in.peek();
128         }
129       columns++;
130       in >> dum;    
131     }
132   columns=colvor;
133 #ifdef DEBUG
134   cout << "Debug -> Columns & Lines : "<< columns << "  " << globs->nKnots << endl;
135 #endif
136   // allocate memory
137   in.close();
138 
139   globs->t=dvector(1,globs->nKnots);
140   globs->y=dvector(1,globs->nKnots);
141   globs->sig=dvector(1,globs->nKnots);
142 
143   //finally, read the data
144 
145   inp.open(globs->inFile);
146   for(i=1;i<=globs->nKnots;i++)
147     {
148       if(columns==2)
149         {
150           inp >> globs->t[i] >> globs->y[i];
151           globs->sig[i]=1.;
152         }
153       else 
154         inp>> globs->t[i] >> globs->y[i] >> globs->sig[i];
155 #ifdef DEBUG
156       cout << globs->t[i] << "\t" <<  globs->y[i] << "\t" <<  globs->sig[i] << endl;
157 #endif
158     }
159   inp.close();
160 
161   //Parse the remaining parameters
162   
163   while ((opt=getopt_long_only(argc,argv,"h?",longopts,&longindex)) != -1)
164     {
165       switch(opt)
166         {
167         case 'h':
168           cout << usage << endl;
169           exit(1);
170           break;
171         case '?':
172           cerr << usage << endl;
173           exit(1);      
174           break;
175         case 1:
176           globs->alpha=fabs(atof(optarg));
177           break;
178         case 2:
179           globs->gcv=FALSE;
180           break;
181         case 3:
182           globs->maxLambda=fabs(atof(optarg));
183           break;
184         case 4:
185           globs->outFile=new char[strlen(optarg)+1];
186           strcpy(globs->outFile,optarg);
187           globs->outset=TRUE;
188           break;
189         default:
190           cerr << endl;
191           cerr << "Parsing parameters produced errors.\n\n";
192           exit(1);
193         }
194     }
195 
196   if(globs->outset==FALSE)
197     globs->outFile="spline.dat";
198 }
\end{verbatim}\normalsize 




\subsection{Variable Documentation}
\index{createSpline.cc@{create\-Spline.cc}!usage@{usage}}
\index{usage@{usage}!createSpline.cc@{create\-Spline.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}char {\bf usage}[$\,$]}\label{createSpline_8cc_c272052a23799ed4af95e9876ba00fac}


{\bf Initial value:}

\footnotesize\begin{verbatim}"\n\t    --- createSpline : Creating spline data for diffit ---\n \
 createSpline, v 1.0 25/Jul./2005  Univ. of Freiburg, Author: Martin Peifer\n\n \
      SYNOPSIS \n \t createSpline  [Options]  <File>\n\n \
      DESCRIPTION\n \
      \t -h -? -help \t help\n \
      \t -alpha <val> \t smoothing parameter\n \
      \t -nogcv \t switches cross validation off\n \
      \t -max  <val> \t upper bound for linesearch\n \
      \t -o     <file>\t output file\n"
\end{verbatim}\normalsize 


Definition at line 14 of file create\-Spline.cc.

Referenced by parse\-The\-Opts().