[12164] | 1 | /*\file Kriging.c
|
---|
| 2 | *\brief: best linear predictor
|
---|
| 3 | */
|
---|
| 4 | #include "./Kriging.h"
|
---|
| 5 |
|
---|
| 6 | void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
|
---|
| 7 |
|
---|
| 8 | /*Outputs*/
|
---|
[12258] | 9 | double *x = NULL;
|
---|
| 10 | double *y = NULL;
|
---|
| 11 | double *observations = NULL;
|
---|
| 12 | double *x_interp = NULL;
|
---|
| 13 | double *y_interp = NULL;
|
---|
| 14 | double *predictions = NULL;
|
---|
| 15 | double *error = NULL;
|
---|
| 16 | Options *options = NULL;
|
---|
| 17 | int N_interp,M_interp,M,N,n_obs;
|
---|
[12164] | 18 |
|
---|
| 19 | /*Boot module: */
|
---|
| 20 | MODULEBOOT();
|
---|
| 21 |
|
---|
| 22 | /*checks on arguments on the matlab side: */
|
---|
[12258] | 23 | if (nrhs<NRHS || nlhs>NLHS){
|
---|
| 24 | KrigingUsage(); _error_("Kriging usage error");
|
---|
| 25 | }
|
---|
[12164] | 26 |
|
---|
| 27 | /*Fetch inputs: */
|
---|
| 28 | FetchData(&x,&n_obs,X);
|
---|
[12258] | 29 | FetchData(&y,&N,Y); if(n_obs!=N) _error_("x and y should have the same size");
|
---|
| 30 | FetchData(&observations,&N,OBSERVATIONS); if(n_obs!=N) _error_("x and observations should have the same size");
|
---|
| 31 | FetchData(&x_interp,&M_interp,&N_interp,XINTERP);
|
---|
| 32 | FetchData(&y_interp,&M,&N,YINTERP); if(N!=N_interp || M!=M_interp) _error_("x_interp and y_interp should have the same size");
|
---|
| 33 | FetchData(&options,NRHS,nrhs,prhs);
|
---|
[12164] | 34 |
|
---|
| 35 | /*Call x layer*/
|
---|
[12258] | 36 | Krigingx(&predictions,&error,x,y,observations,n_obs,x_interp,y_interp,M_interp*N_interp,options);
|
---|
[12164] | 37 |
|
---|
| 38 | /*Generate output Matlab Structures*/
|
---|
[12258] | 39 | if(nlhs>=1) WriteData(PREDICTIONS,predictions,M_interp,N_interp);
|
---|
| 40 | if(nlhs==2) WriteData(ERROR,error,M_interp,N_interp);
|
---|
[12164] | 41 |
|
---|
| 42 | /*Free ressources: */
|
---|
| 43 | xfree((void**)&x);
|
---|
| 44 | xfree((void**)&y);
|
---|
| 45 | xfree((void**)&observations);
|
---|
| 46 | xfree((void**)&x_interp);
|
---|
| 47 | xfree((void**)&y_interp);
|
---|
| 48 | xfree((void**)&predictions);
|
---|
[12258] | 49 | xfree((void**)&error);
|
---|
[12164] | 50 |
|
---|
| 51 | /*end module: */
|
---|
| 52 | MODULEEND();
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | void KrigingUsage(void){
|
---|
| 56 | _printf_(true,"\n");
|
---|
| 57 | _printf_(true," usage: predictions=%s(x,y,observations,x_interp,y_interp);\n",__FUNCT__);
|
---|
| 58 | _printf_(true,"\n");
|
---|
| 59 | }
|
---|