23 #include <grass/interpf.h> 51 double zmin,
double zmax,
52 double *zminac,
double *zmaxac,
53 double *gmin,
double *gmax,
54 double *c1min,
double *c1max,
55 double *c2min,
double *c2max,
61 double xmn, xmx, ymn, ymx, distx, disty, distxp, distyp, temp1, temp2;
62 int i, npt, nptprev, MAXENC;
64 static int cursegm = 0;
65 static double *
b =
NULL;
66 static int *indx =
NULL;
67 static double **matrix =
NULL;
68 double ew_res, ns_res;
69 static int first_time = 1;
75 int m_skip, skip_index, j, k, segtest;
95 for (i = 0; i < 4; i++) {
97 bitmask, zmin, zmax, zminac, zmaxac, gmin,
98 gmax, c1min, c1max, c2min, c2max, ertot,
99 totsegm, offset1, dnorm);
120 pr = pow(2., (xmx - xmn) / smseg - 1.);
122 params->
kmin * (pr / (1 + params->
kmin * pr / params->
KMAX2));
127 xmx + distx, ymx + disty, 0, 0,
131 while ((npt < MINPTS) || (npt > params->
KMAX2)) {
133 G_warning(
_(
"Taking too long to find points for interpolation - " 134 "please change the region to area where your points are. " 135 "Continuing calculations..."));
139 if (npt > params->
KMAX2)
146 distx = distxp - fabs(distx - temp1) * 0.5;
149 disty = distyp - fabs(disty - temp2) * 0.5;
159 disty = fabs(disty - temp1) * 0.5 + distyp;
160 distx = fabs(distx - temp2) * 0.5 + distxp;
168 data->
x_orig = xmn - distx;
169 data->
y_orig = ymn - disty;
170 data->
xmax = xmx + distx;
171 data->
ymax = ymx + disty;
227 for (i = 0; i < data->
n_points; i++) {
257 for (skip_index = 0; skip_index < m_skip; skip_index++) {
261 xx = point[skip_index].
x * dnorm + data->
x_orig +
263 yy = point[skip_index].
y * dnorm + data->
y_orig +
265 zz = point[skip_index].
z;
271 skip_point.
x = point[skip_index].
x;
272 skip_point.
y = point[skip_index].
y;
273 skip_point.
z = point[skip_index].
z;
274 for (k = 0; k < m_skip; k++) {
275 if (k != skip_index && params->
cv) {
290 else if (segtest == 1) {
297 for (i = 0; i < data->
n_points; i++)
302 params->
check_points(params, data, b, ertot, zmin, dnorm,
305 else if (segtest == 1) {
306 for (i = 0; i < data->
n_points - 1; i++)
310 params->
check_points(params, data, b, ertot, zmin, dnorm,
320 if (params->
grid_calc(params, data, bitmask,
321 zmin, zmax, zminac, zmaxac, gmin, gmax,
322 c1min, c1max, c2min, c2max, ertot, b,
329 if (totsegm < cursegm)
330 G_debug(1,
"%d %d", totsegm, cursegm);
348 static int first_time = 1;
350 static double minside;
358 for (ii = 0; ii < n_leafs; ii++) {
int * G_alloc_ivector(size_t)
Vector matrix memory allocation.
int IL_interp_segments_2d(struct interp_params *params, struct tree_info *info, struct multtree *tree, struct BM *bitmask, double zmin, double zmax, double *zminac, double *zmaxac, double *gmin, double *gmax, double *c1min, double *c1max, double *c2min, double *c2max, double *ertot, int totsegm, off_t offset1, double dnorm)
double smallest_segment(struct multtree *tree, int n_leafs)
void G_free(void *)
Free allocated memory.
double ** G_alloc_matrix(int, int)
Matrix memory allocation.
struct quaddata * quad_data_new(double x_or, double y_or, double xmax, double ymax, int rows, int cols, int n_points, int kmax)
double * G_alloc_vector(size_t)
Vector matrix memory allocation.
check_points_fn * check_points
void G_percent(long, long, int)
Print percent complete messages.
int MT_region_data(struct tree_info *info, struct multtree *tree, struct quaddata *data, int MAX, int n_leafs)
void G_warning(const char *,...) __attribute__((format(printf
void G_lubksb(double **a, int n, int *indx, double b[])
LU backward substitution.
int G_debug(int, const char *,...) __attribute__((format(printf