GRASS 8 Programmer's Manual
8.6.0dev(2026)-1878fdfec5
Loading...
Searching...
No Matches
func2d.c
Go to the documentation of this file.
1
/*!
2
* \file func2d.c
3
*
4
* \author
5
* Lubos Mitas (original program and various modifications)
6
*
7
* \author
8
* H. Mitasova,
9
* I. Kosinovsky, D. Gerdes,
10
* D. McCauley
11
* (GRASS4.1 version of the program and GRASS4.2 modifications)
12
*
13
* \author
14
* L. Mitas ,
15
* H. Mitasova ,
16
* I. Kosinovsky,
17
* D.Gerdes
18
* D. McCauley (1993, 1995)
19
*
20
* \author modified by McCauley in August 1995
21
* \author modified by Mitasova in August 1995, Nov. 1996
22
*
23
* SPDX-FileCopyrightText: 1993-1999 Lubos Mitas
24
* SPDX-FileCopyrightText: GRASS Development Team
25
* SPDX-License-Identifier: GPL-2.0-or-later
26
*/
27
28
#include <
stdio.h
>
29
#include <math.h>
30
#include <
grass/gis.h
>
31
#include <grass/interpf.h>
32
33
/**
34
* @brief Radial basis function
35
*
36
* Radial basis function - completely regularized spline with tension (d=2)
37
*
38
* parameter description from DESCRIPTION.INTERP
39
*
40
* @param r distance squared
41
* @param fi tension
42
* @return
43
*/
44
double
IL_crst
(
double
r
,
double
fi)
45
{
46
double
rfsta2
= fi * fi *
r
/ 4.;
47
48
static
double
c[4] = {8.5733287401, 18.0590169730, 8.6347608925,
49
0.2677737343};
50
static
double
b
[4] = {9.5733223454, 25.6329561486, 21.0996530827,
51
3.9584969228};
52
double
ce
= 0.57721566;
53
54
static
double
u[10] = {
55
1.e+00,
56
-.25e+00,
57
.055555555555556e+00,
58
-.010416666666667e+00,
/*fixed bug 415.. repl. by 416.. */
59
.166666666666667e-02,
60
-2.31481481481482e-04,
61
2.83446712018141e-05,
62
-3.10019841269841e-06,
63
3.06192435822065e-07,
64
-2.75573192239859e-08};
65
double
x
=
rfsta2
;
66
double
res;
67
68
double
e1,
ea
,
eb
;
69
70
if
(
x
< 1.e+00) {
71
res =
x
*
72
(u[0] +
73
x
* (u[1] +
74
x
* (u[2] +
75
x
* (u[3] +
76
x
* (u[4] +
77
x
* (u[5] +
78
x
* (u[6] +
79
x
* (u[7] +
80
x
* (u[8] +
x
* u[9])))))))));
81
return
(res);
82
}
83
84
if
(
x
> 25.e+00)
85
e1 = 0.00;
86
else
{
87
ea
= c[3] +
x
* (c[2] +
x
* (c[1] +
x
* (c[0] +
x
)));
88
eb
=
b
[3] +
x
* (
b
[2] +
x
* (
b
[1] +
x
* (
b
[0] +
x
)));
89
e1 = (
ea
/
eb
) / (
x
*
exp
(
x
));
90
}
91
res = e1 +
ce
+
log
(
x
);
92
return
(res);
93
}
94
95
/**
96
* @brief Function for calculating derivatives (d=2)
97
*
98
* Derivatives of radial basis function - regularized spline with tension(d=2)
99
*
100
* @param r distance squared
101
* @param fi tension
102
* @param gd1 G1(r)
103
* @param gd2 G2(r)
104
* @return
105
*/
106
int
IL_crstg
(
double
r
,
double
fi,
double
*
gd1
,
double
*
gd2
)
107
{
108
double
r2
=
r
;
109
double
rfsta2
= fi * fi *
r
/ 4.;
110
double
x
,
exm
,
oneme
,
hold
;
111
double
fsta2
= fi * fi / 2.;
112
113
x
=
rfsta2
;
114
if
(
x
< 0.001) {
115
*
gd1
= 1. -
x
/ 2. +
x
*
x
/ 6. -
x
*
x
*
x
/ 24.;
116
*
gd2
=
fsta2
* (-.5 +
x
/ 3. -
x
*
x
/ 8. +
x
*
x
*
x
/ 30.);
117
}
118
else
{
119
if
(
x
< 35.e+00) {
120
exm
=
exp
(-
x
);
121
oneme
= 1. -
exm
;
122
*
gd1
=
oneme
/
x
;
123
hold
=
x
*
exm
-
oneme
;
124
*
gd2
= (
hold
+
hold
) / (
r2
*
x
);
125
}
126
else
{
127
*
gd1
= 1. /
x
;
128
*
gd2
= -2. / (
x
*
r2
);
129
}
130
}
131
return
1;
132
}
AMI_STREAM
Definition
ami_stream.h:153
IL_crst
double IL_crst(double r, double fi)
Radial basis function.
Definition
func2d.c:44
IL_crstg
int IL_crstg(double r, double fi, double *gd1, double *gd2)
Function for calculating derivatives (d=2)
Definition
func2d.c:106
gis.h
b
double b
Definition
r_raster.c:37
r
double r
Definition
r_raster.c:37
stdio.h
x
#define x
lib
rst
interp_float
func2d.c
Generated on Wed Sep 9 2026 06:57:45 for GRASS 8 Programmer's Manual by
1.9.8