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

Last change on this file since 15396 was 15396, checked in by Mathieu Morlighem, 12 years ago

merged trunk-jpl and trunk for revision 15394

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