GRASS 8 Programmer's Manual 8.6.0dev(2026)-ddeab64dbf
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 * \copyright
20 * (C) 1993-2006 by Helena Mitasova and the GRASS Development Team
21 *
22 * \copyright
23 * This program is free software under the
24 * GNU General Public License (>=v2).
25 * Read the file COPYING that comes with GRASS for details.
26 */
27
28#include <stdio.h>
29#include <math.h>
30#include <unistd.h>
31#include <grass/gis.h>
32#include <grass/vector.h>
33#include <grass/dbmi.h>
34#include <grass/interpf.h>
35
36/* needed for AIX */
37#ifdef hz
38#undef hz
39#endif
40
41/*!
42 * \brief A parallel version of IL_check_at_points_2d.
43 * Sperate the cross-validation/deviation computing part
44 * and the database writing part.
45 *
46 * \param params interpolation parameters
47 * \param data data in the segment for computing, NULL for writing out
48 * \param b solution of linear equations for computing, NULL for writing out
49 * \param ertot total error for computing, point at single point for writing out
50 * \param zmin min z-value for computing
51 * \param dnorm normalization factor for computing
52 * \param target_point point for computing or writing out
53 *
54 * \return 1
55 *
56 * \todo
57 * Alternative description:
58 * ...calculate the maximum and RMS deviation caused by smoothing.
59 */
61 struct quaddata *data, /*!< current region */
62 double *b, /*!< solution of linear equations */
63 double *ertot, /*!< total error */
64 double zmin, /*!< min z-value */
65 double dnorm, struct triple *target_point)
66{
67 if ((data != NULL) && (b != NULL)) {
68 int n_points = data->n_points; /* number of points */
69 struct triple *points = data->points; /* points for interpolation */
70 double west = data->x_orig;
71 double south = data->y_orig;
72 double /* rfsta2, errmax, */ h, xx, yy, r2, hz, zz, err, xmm, ymm, r;
73 int /* n1, */ m;
74
75 if (params->cv) { /* one point is skipped for cross-validation*/
76 n_points -= 1;
77 }
78
79 h = b[0];
80 for (m = 1; m <= n_points; m++) {
81 xx = target_point->x - points[m - 1].x;
82 yy = target_point->y - points[m - 1].y;
83 r2 = yy * yy + xx * xx;
84 if (r2 != 0.) {
85 /* rfsta2 = fstar2 * r2; */
86 r = r2;
87 h = h + b[m] * params->interp(r, params->fi);
88 }
89 }
90 /* modified by helena january 1997 - normalization of z was
91 removed from segm2d.c and interp2d.c
92 hz = (h * dnorm) + zmin;
93 zz = (points[mm - 1].z * dnorm) + zmin;
94 */
95 hz = h + zmin;
96 zz = target_point->z + zmin;
97 err = hz - zz;
98 xmm = target_point->x * dnorm + params->x_orig + west;
99 ymm = target_point->y * dnorm + params->y_orig + south;
100 (*ertot) += err * err;
101
102 /* take the values out*/
103 target_point->x = xmm;
104 target_point->y = ymm;
105 target_point->z = err;
106 }
107 else {
109 }
110 return 1;
111}
#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:163
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:39
double r
Definition r_raster.c:39
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:47
double x_orig
Definition dataquad.h:46
struct triple * points
Definition dataquad.h:53
int n_points
Definition dataquad.h:52
double x
Definition dataquad.h:39
double y
Definition dataquad.h:40
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)