source: issm/branches/trunk-jpl-damage/src/modules/Kriging/Kriging.cpp@ 12258

Last change on this file since 12258 was 12258, checked in by cborstad, 13 years ago

merged trunk-jpl into branches/trunk-jpl-damage through revision 12254

File size: 1.7 KB
Line 
1/*\file Kriging.c
2 *\brief: best linear predictor
3 */
4#include "./Kriging.h"
5
6void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){
7
8 /*Outputs*/
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;
18
19 /*Boot module: */
20 MODULEBOOT();
21
22 /*checks on arguments on the matlab side: */
23 if (nrhs<NRHS || nlhs>NLHS){
24 KrigingUsage(); _error_("Kriging usage error");
25 }
26
27 /*Fetch inputs: */
28 FetchData(&x,&n_obs,X);
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);
34
35 /*Call x layer*/
36 Krigingx(&predictions,&error,x,y,observations,n_obs,x_interp,y_interp,M_interp*N_interp,options);
37
38 /*Generate output Matlab Structures*/
39 if(nlhs>=1) WriteData(PREDICTIONS,predictions,M_interp,N_interp);
40 if(nlhs==2) WriteData(ERROR,error,M_interp,N_interp);
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);
49 xfree((void**)&error);
50
51 /*end module: */
52 MODULEEND();
53}
54
55void 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}
Note: See TracBrowser for help on using the repository browser.