\section{/home/peifer/diffit/create\-Spline\_\-mex.cc File Reference}
\label{createSpline__mex_8cc}\index{/home/peifer/diffit/createSpline_mex.cc@{/home/peifer/diffit/createSpline\_\-mex.cc}}
{\tt \#include \char`\"{}mex.h\char`\"{}}\par
{\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*{Defines}
\begin{CompactItemize}
\item 
\#define {\bf TRUE}~1
\item 
\#define {\bf FALSE}~0
\item 
\#define {\bf DATA}~prhs[0]
\item 
\#define {\bf ALPHA}~prhs[1]
\item 
\#define {\bf MAXA}~prhs[2]
\item 
\#define {\bf NOGCV}~prhs[3]
\item 
\#define {\bf SPLINE}~plhs[0]
\item 
\#define {\bf ALPHA\_\-OUT}~plhs[1]
\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf mex\-Function} (int nlhs, mx\-Array $\ast$plhs[$\,$], int nrhs, const mx\-Array $\ast$prhs[$\,$])
\end{CompactItemize}


\subsection{Define Documentation}
\index{createSpline_mex.cc@{create\-Spline\_\-mex.cc}!ALPHA@{ALPHA}}
\index{ALPHA@{ALPHA}!createSpline_mex.cc@{create\-Spline\_\-mex.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define ALPHA~prhs[1]}\label{createSpline__mex_8cc_f5abd28c44c29b7397c84f1fec4b1d84}




Definition at line 29 of file create\-Spline\_\-mex.cc.

Referenced by mex\-Function().\index{createSpline_mex.cc@{create\-Spline\_\-mex.cc}!ALPHA_OUT@{ALPHA\_\-OUT}}
\index{ALPHA_OUT@{ALPHA\_\-OUT}!createSpline_mex.cc@{create\-Spline\_\-mex.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define ALPHA\_\-OUT~plhs[1]}\label{createSpline__mex_8cc_9a7e7e7b1e00185c2af1b3f60be5aae2}




Definition at line 36 of file create\-Spline\_\-mex.cc.\index{createSpline_mex.cc@{create\-Spline\_\-mex.cc}!DATA@{DATA}}
\index{DATA@{DATA}!createSpline_mex.cc@{create\-Spline\_\-mex.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define DATA~prhs[0]}\label{createSpline__mex_8cc_ad9ae913bdfab20dd94ad04ee2d5b045}




Definition at line 28 of file create\-Spline\_\-mex.cc.

Referenced by mex\-Function().\index{createSpline_mex.cc@{create\-Spline\_\-mex.cc}!FALSE@{FALSE}}
\index{FALSE@{FALSE}!createSpline_mex.cc@{create\-Spline\_\-mex.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define FALSE~0}\label{createSpline__mex_8cc_a93f0eb578d23995850d61f7d61c55c1}




Definition at line 13 of file create\-Spline\_\-mex.cc.\index{createSpline_mex.cc@{create\-Spline\_\-mex.cc}!MAXA@{MAXA}}
\index{MAXA@{MAXA}!createSpline_mex.cc@{create\-Spline\_\-mex.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define MAXA~prhs[2]}\label{createSpline__mex_8cc_200013437157fc04a38cbfabc97cdcc6}




Definition at line 30 of file create\-Spline\_\-mex.cc.

Referenced by mex\-Function().\index{createSpline_mex.cc@{create\-Spline\_\-mex.cc}!NOGCV@{NOGCV}}
\index{NOGCV@{NOGCV}!createSpline_mex.cc@{create\-Spline\_\-mex.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define NOGCV~prhs[3]}\label{createSpline__mex_8cc_e6d827f293c2cffcb43f17405e5fa9c4}




Definition at line 31 of file create\-Spline\_\-mex.cc.

Referenced by mex\-Function().\index{createSpline_mex.cc@{create\-Spline\_\-mex.cc}!SPLINE@{SPLINE}}
\index{SPLINE@{SPLINE}!createSpline_mex.cc@{create\-Spline\_\-mex.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define SPLINE~plhs[0]}\label{createSpline__mex_8cc_ff17f6542b197c3e6ef6476daf6fa42d}




Definition at line 35 of file create\-Spline\_\-mex.cc.

Referenced by mex\-Function().\index{createSpline_mex.cc@{create\-Spline\_\-mex.cc}!TRUE@{TRUE}}
\index{TRUE@{TRUE}!createSpline_mex.cc@{create\-Spline\_\-mex.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}\#define TRUE~1}\label{createSpline__mex_8cc_a8cecfc5c5c054d2875c03e77b7be15d}




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

\subsection{Function Documentation}
\index{createSpline_mex.cc@{create\-Spline\_\-mex.cc}!mexFunction@{mexFunction}}
\index{mexFunction@{mexFunction}!createSpline_mex.cc@{create\-Spline\_\-mex.cc}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void mex\-Function (int {\em nlhs}, mx\-Array $\ast$ {\em plhs}[$\,$], int {\em nrhs}, const mx\-Array $\ast$ {\em prhs}[$\,$])}\label{createSpline__mex_8cc_6a215cbfde54f82a3ce599228fc3fce5}




Definition at line 38 of file create\-Spline\_\-mex.cc.

References ALPHA, DATA, dvector(), MAXA, and NOGCV.

\footnotesize\begin{verbatim}43 {
44   
45   glob globs;
46   long i,j,n,col;
47   double *g,*gam,alpha;
48   //mex input
49   double *data_,*alpha_,*maxa_,*nogcv_;
50   //mex output
51   double *spline_,*alpha_out_;
52    
53   //initialise mexstuff
54   data_=mxGetPr(DATA);
55   alpha_=mxGetPr(ALPHA);
56   maxa_=mxGetPr(MAXA);
57   nogcv_=mxGetPr(NOGCV);
58 
59   globs.nKnots=mxGetM(DATA);
60   col=mxGetN(DATA);  
61 
62   n=globs.nKnots;
63   g=dvector(1,n);
64   gam=dvector(1,n);
65 
66   globs.t=dvector(1,n);
67   globs.y=dvector(1,n);
68   globs.sig=dvector(1,n);
69 
70   if(col==2)
71     {
72       for(i=1;i<=n;i++)
73         {
74           globs.t[i]=data_[i-1];
75           globs.y[i]=data_[n+i-1];
76           globs.sig[i]=1.;
77         }
78     }
79   else if(col==3)
80     {
81       for(i=1;i<=n;i++)
82         {
83           globs.t[i]=data_[i-1];
84           globs.y[i]=data_[n+i-1];
85           globs.sig[i]=data_[2*n+i-1];
86         }
87     }
88   else
89     {
90       mexWarnMsgTxt("Insufficient data structure. Exit.\n");
91       return;
92     }
93   
94   alpha=fabs(alpha_[0]);
95   globs.maxLambda=fabs(maxa_[0]);
96   globs.gcv=(int)nogcv_[0];
97 
98 
99   if(alpha > globs.maxLambda)
100     alpha=globs.maxLambda;
101 
102   if(globs.gcv==TRUE)
103     splines_gcv(globs.t,globs.y,globs.sig,n,&alpha,g,gam,globs.maxLambda);
104   else
105     splines(globs.t,globs.y,globs.sig,n,alpha,g,gam);
106 
107   //writing output
108 
109   SPLINE=mxCreateDoubleMatrix(n,3,mxREAL);
110   spline_=mxGetPr(SPLINE);
111   ALPHA_OUT=mxCreateDoubleMatrix(1,1,mxREAL);
112   alpha_out_=mxGetPr(ALPHA_OUT);
113   alpha_out_[0] = alpha;
114 
115   spline_[0]=globs.t[1];
116   spline_[n]=g[1];
117   spline_[2*n]=0.;
118   for(i=2;i<=n-1;i++)
119     {
120       spline_[i-1]=globs.t[i];
121       spline_[n+i-1]=g[i];
122       spline_[2*n+i-1]=gam[i-1];
123     }
124   spline_[n-1]=globs.t[n];
125   spline_[2*n-1]=g[n];
126   spline_[3*n-1]=0.; 
127 
128   //free memory
129   free_dvector(globs.y,1,n);
130   free_dvector(globs.t,1,n);
131   free_dvector(globs.sig,1,n);
132   free_dvector(g,1,n);
133   free_dvector(gam,1,n);
134 }
\end{verbatim}\normalsize 


