source: issm/trunk/src/wrappers/Kriging/Kriging.cpp@ 13975

Last change on this file since 13975 was 13250, checked in by Mathieu Morlighem, 13 years ago

CHG: getting rid of xfree

File size: 3.0 KB
Line 
1/*\file Kriging.c
2 *\brief: best linear predictor
3 */
4#include "./Kriging.h"
5
6void KrigingUsage(void){/*{{{*/
7 _pprintLine_("");
8 _pprintLine_(" usage: predictions=" << __FUNCT__ << "(x,y,observations,x_interp,y_interp,'options');");
9 _pprintLine_(" available options:");
10 _pprintLine_(" -'model': Available variogram models 'gaussian' (default),'spherical','power','exponential'");
11 _pprintLine_(" -'nugget': nugget effect (default 0.2)");
12 _pprintLine_(" -'range': for gaussian, spherical and exponential models (default sqrt(3))");
13 _pprintLine_(" -'sill': for gaussian, spherical and exponential models (default 1)");
14 _pprintLine_(" -'slope': for power model (default 1)");
15 _pprintLine_(" -'power': for power model (default 1)");
16 _pprintLine_(" -'searchradius': search radius for each prediction (default is observations span)");
17 _pprintLine_(" -'boxlength': minimum length of quadtree boxes (useful to decrease the number of observations)");
18 _pprintLine_(" -'maxdata': minimum number of observations for a prediction (default is 50)");
19 _pprintLine_(" -'mindata': maximum number of observations for a prediction (default is 1)");
20 _pprintLine_(" -'maxtrimming': maximum trimming value (default is -1.e+21)");
21 _pprintLine_(" -'mintrimming': minimum trimming value (default is +1.e+21)");
22 _pprintLine_(" -'minspacing': minimum distance between observation (default is 0.01)");
23 _pprintLine_("");
24}/*}}}*/
25WRAPPER(Kriging){
26
27 /*Outputs*/
28 double *x = NULL;
29 double *y = NULL;
30 double *observations = NULL;
31 double *x_interp = NULL;
32 double *y_interp = NULL;
33 double *predictions = NULL;
34 double *error = NULL;
35 Options *options = NULL;
36 int N_interp,M_interp,M,N,n_obs;
37
38 /*Boot module: */
39 MODULEBOOT();
40
41 /*checks on arguments on the matlab side: */
42 if (nrhs<NRHS || nlhs>NLHS){
43 KrigingUsage(); _error_("Kriging usage error");
44 }
45
46 /*Fetch inputs: */
47 FetchData(&x,&n_obs,X);
48 FetchData(&y,&N,Y); if(n_obs!=N) _error_("x and y should have the same size");
49 FetchData(&observations,&N,OBSERVATIONS); if(n_obs!=N) _error_("x and observations should have the same size");
50 FetchData(&x_interp,&M_interp,&N_interp,XINTERP);
51 FetchData(&y_interp,&M,&N,YINTERP); if(N!=N_interp || M!=M_interp) _error_("x_interp and y_interp should have the same size");
52 FetchData(&options,NRHS,nrhs,prhs);
53
54 /*Call x layer*/
55 Krigingx(&predictions,&error,x,y,observations,n_obs,x_interp,y_interp,M_interp*N_interp,options);
56
57 /*Generate output Matlab Structures*/
58 if(nlhs>=1) WriteData(PREDICTIONS,predictions,M_interp,N_interp);
59 if(nlhs==2) WriteData(ERROR,error,M_interp,N_interp);
60
61 /*Free ressources: */
62 xDelete<double>(x);
63 xDelete<double>(y);
64 xDelete<double>(observations);
65 xDelete<double>(x_interp);
66 xDelete<double>(y_interp);
67 xDelete<double>(predictions);
68 xDelete<double>(error);
69 delete options;
70
71 /*end module: */
72 MODULEEND();
73}
Note: See TracBrowser for help on using the repository browser.