/* * Initialize single point interpolation mode. This just * does the regridding initialization and initial data analysis. */ void c_nnpntinitd(int n, double x[], double y[], double z[]) { #define NXI 2 #define NYI 2 double xi[NXI], yi[NYI], wtmp; single_point = 1; first_single = 1; asflag = 0; horilap_save = horilap; vertlap_save = vertlap; horilap = -1.; vertlap = -1.; /* * Establish the gridded region to contain all of the input * data points plus an extra 10% space around the border. */ xi[0] = armind(n, x); xi[1] = armaxd(n, x); wtmp = xi[1] - xi[0]; xi[0] -= 0.1*wtmp; xi[1] += 0.1*wtmp; yi[0] = armind(n, y); yi[1] = armaxd(n, y); wtmp = yi[1] - yi[0]; yi[0] -= 0.1*wtmp; yi[1] += 0.1*wtmp; Initialized(n, x, y, NXI, NYI, xi, yi); if (ReadDatad(n,x,y,z) != 0) { ErrorHnd(error_status, "c_nnpntinitd", filee, "\n"); } }
double *c_natgridd(int n, double x[], double y[], double z[], int nxi, int nyi, double xi[], double yi[], int *ier) { double **data_out=NULL, *rtrn_val=NULL; double *x_sav, *y_sav, *z_sav, *darray; int n_sav,i; *ier = 0; /* * Check for duplicate input values. Duplicate triples will be * culled, but duplicate coordinates with different data values * will produce an error. */ if (single_point == 0) { n_sav = n; x_sav = (double *) malloc(n*sizeof(double)); y_sav = (double *) malloc(n*sizeof(double)); z_sav = (double *) malloc(n*sizeof(double)); memcpy((void *)x_sav, (void *)x, n*sizeof(double)); memcpy((void *)y_sav, (void *)y, n*sizeof(double)); memcpy((void *)z_sav, (void *)z, n*sizeof(double)); darray = (double *) malloc(3*n*sizeof(double)); for (i = 0; i < n; i++) { darray[3*i ] = x[i]; darray[3*i+1] = y[i]; darray[3*i+2] = z[i]; } qsort( (void *)darray, n, 3*sizeof(double), comp_dtriples); n = cull_dtriples(n_sav, darray); for (i = 0; i < n; i++) { x[i] = darray[3*i ]; y[i] = darray[3*i+1]; z[i] = darray[3*i+2]; } free(darray); } if (single_point == 0) { asflag = 1; Initialized(n, x, y, nxi, nyi, xi, yi); if (ReadDatad(n,x,y,z) != 0) { *ier = error_status; return ( (double *) NULL); } } if (adf) { CircOut(); if (error_status) { *ier = error_status; return ( (double *) NULL); } } if (igrad) { Gradient(); if (error_status) { *ier = error_status; return ( (double *) NULL); } } data_out = MakeGridd(nxi, nyi, xi, yi); if (error_status) { if((data_out !=NULL)&&(data_out[0]!=NULL)) { free(data_out[0]); free(data_out); } *ier = error_status; return ( (double *) NULL); } if (single_point == 0) { Terminate(); } horilap = -1.; vertlap = -1.; rtrn_val = data_out[0]; free(data_out); if (single_point == 0) { memcpy((void *)x, (void *)x_sav, n_sav*sizeof(double)); memcpy((void *)y, (void *)y_sav, n_sav*sizeof(double)); memcpy((void *)z, (void *)z_sav, n_sav*sizeof(double)); free(x_sav); free(y_sav); free(z_sav); } return (rtrn_val); }