GRASS 8 Programmer's Manual 8.6.0dev(2026)-c83afef6d3
Loading...
Searching...
No Matches
point2d_parallel.c
Go to the documentation of this file.
1/*!
2 * \file point2d_parallel.c
3 *
4 * \author
5 * Lubos Mitas (original program and various modifications)
6 *
7 * \author
8 * C.Y. Liang,
9 * H. Mitasova,
10 * I. Kosinovsky,
11 * D. Gerdes,
12 * D. McCauley
13 * (GRASS4.1 version of the program and GRASS4.2 modifications)
14 *
15 * \author modified by Liang in May 2024
16 * \author modified by McCauley in August 1995
17 * \author modified by Mitasova in August 1995, Nov. 1996
18 *
19 * SPDX-FileCopyrightText: 1993-2006 Helena Mitasova
20 * SPDX-FileCopyrightText: GRASS Development Team
21 * SPDX-License-Identifier: GPL-2.0-or-later
22 */
23
24#include <stdio.h>
25#include <math.h>
26#include <unistd.h>
27#include <grass/gis.h>
28#include <grass/vector.h>
29#include <grass/dbmi.h>
30#include <grass/interpf.h>
31
32/* needed for AIX */
33#ifdef hz
34#undef hz
35#endif
36
37/*!
38 * \brief A parallel version of IL_check_at_points_2d.
39 * Sperate the cross-validation/deviation computing part
40 * and the database writing part.
41 *
42 * \param params interpolation parameters
43 * \param data data in the segment for computing, NULL for writing out
44 * \param b solution of linear equations for computing, NULL for writing out
45 * \param ertot total error for computing, point at single point for writing out
46 * \param zmin min z-value for computing
47 * \param dnorm normalization factor for computing
48 * \param target_point point for computing or writing out
49 *
50 * \return 1
51 *
52 * \todo
53 * Alternative description:
54 * ...calculate the maximum and RMS deviation caused by smoothing.
55 */
57 struct quaddata *data, /*!< current region */
58 double *b, /*!< solution of linear equations */
59 double *ertot, /*!< total error */
60 double zmin, /*!< min z-value */
61 double dnorm, struct triple *target_point)
62{
63 if ((data != NULL) && (b != NULL)) {
64 int n_points = data->n_points; /* number of points */
65 struct triple *points = data->points; /* points for interpolation */
66 double west = data->x_orig;
67 double south = data->y_orig;
68 double /* rfsta2, errmax, */ h, xx, yy, r2, hz, zz, err, xmm, ymm, r;
69 int /* n1, */ m;
70
71 if (params->cv) { /* one point is skipped for cross-validation*/
72 n_points -= 1;
73 }
74
75 h = b[0];
76 for (m = 1; m <= n_points; m++) {
77 xx = target_point->x - points[m - 1].x;
78 yy = target_point->y - points[m - 1].y;
79 r2 = yy * yy + xx * xx;
80 if (r2 != 0.) {
81 /* rfsta2 = fstar2 * r2; */
82 r = r2;
83 h = h + b[m] * params->interp(r, params->fi);
84 }
85 }
86 /* modified by helena january 1997 - normalization of z was
87 removed from segm2d.c and interp2d.c
88 hz = (h * dnorm) + zmin;
89 zz = (points[mm - 1].z * dnorm) + zmin;
90 */
91 hz = h + zmin;
92 zz = target_point->z + zmin;
93 err = hz - zz;
94 xmm = target_point->x * dnorm + params->x_orig + west;
95 ymm = target_point->y * dnorm + params->y_orig + south;
96 (*ertot) += err * err;
97
98 /* take the values out*/
99 target_point->x = xmm;
100 target_point->y = ymm;
101 target_point->z = err;
102 }
103 else {
105 }
106 return 1;
107}
#define NULL
Definition ccmath.h:32
Main header of GRASS DataBase Management Interface.
int IL_write_point_2d(struct triple, double)
A function to write out point and deviation at point to database.
Definition point2d.c:159
int IL_check_at_points_2d_cvdev(struct interp_params *params, struct quaddata *data, double *b, double *ertot, double zmin, double dnorm, struct triple *target_point)
A parallel version of IL_check_at_points_2d. Sperate the cross-validation/deviation computing part an...
double b
Definition r_raster.c:37
double r
Definition r_raster.c:37
interp_fn * interp
Definition interpf.h:136
double fi
Definition interpf.h:97
double x_orig
Definition interpf.h:112
double y_orig
Definition interpf.h:112
double y_orig
Definition dataquad.h:43
double x_orig
Definition dataquad.h:42
struct triple * points
Definition dataquad.h:49
int n_points
Definition dataquad.h:48
double x
Definition dataquad.h:35
double y
Definition dataquad.h:36
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)