GRASS 8 Programmer's Manual
8.6.0dev(2026)-1878fdfec5
Loading...
Searching...
No Matches
gammavol.c
Go to the documentation of this file.
1
/****************************************************************************
2
* MODULE: R-Tree library
3
*
4
* AUTHOR(S): Antonin Guttman - original code
5
* Daniel Green (green@superliminal.com) - major clean-up
6
* and implementation of bounding spheres
7
* Markus Metz - file-based and memory-based R*-tree
8
*
9
* PURPOSE: Multidimensional index
10
*
11
* SPDX-FileCopyrightText: 2010 GRASS Development Team
12
* SPDX-License-Identifier: GPL-2.0-or-later
13
*****************************************************************************/
14
15
#include <
stdio.h
>
16
#include <math.h>
17
18
#ifndef ABS
19
#define ABS(a) ((a) > 0 ? (a) : -(a))
20
#endif
21
22
#define EP .0000000001
23
24
double
sphere_volume
(
double
dimension)
25
{
26
double
log_gamma
,
log_volume
;
27
28
log_gamma
=
lgamma
(dimension / 2.0 + 1);
29
log_volume
= dimension / 2.0 *
log
(
M_PI
) -
log_gamma
;
30
return
exp
(
log_volume
);
31
}
32
33
int
main
(
void
)
34
{
35
double
dim = 0,
delta
= 1;
36
37
while
(
ABS
(
delta
) >
EP
)
38
if
(
sphere_volume
(dim +
delta
) >
sphere_volume
(dim))
39
dim +=
delta
;
40
else
41
delta
/= -2;
42
fprintf
(
stdout
,
"max volume = %.10f at dimension %.10f\n"
,
43
sphere_volume
(dim), dim);
44
return
0;
45
}
AMI_STREAM
Definition
ami_stream.h:153
sphere_volume
double sphere_volume(double dimension)
Definition
gammavol.c:24
main
int main(void)
Definition
gammavol.c:33
EP
#define EP
Definition
gammavol.c:22
ABS
#define ABS(a)
Definition
gammavol.c:19
M_PI
#define M_PI
Definition
gis.h:154
stdio.h
lib
vector
rtree
gammavol.c
Generated on Wed Sep 9 2026 06:57:45 for GRASS 8 Programmer's Manual by
1.9.8