GRASS Programmer's Manual
6.5.svn(2014)-r66266
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
dmaxe.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <math.h>
4
#include "
local_proto.h
"
5
6
7
double
*
dmax_exp
(
double
*x,
int
n
)
8
{
9
static
double
y
[2];
10
double
mean = 0.0, zmax, tmax, *xcopy, t, z, fx;
11
int
i;
12
13
if
((xcopy = (
double
*)
malloc
(n *
sizeof
(
double
))) ==
NULL
) {
14
fprintf(stderr,
"Memory error in dmax_exp\n"
);
15
exit(EXIT_FAILURE);
16
}
17
18
for
(i = 0; i <
n
; ++i) {
19
xcopy[i] = x[i];
20
mean += x[i];
21
}
22
mean /=
n
;
23
24
qsort(xcopy, n,
sizeof
(
double
),
dcmp
);
25
26
for
(i = 0; i <
n
; ++i) {
27
fx = 1 - exp(-xcopy[i] / mean);
28
z = (double)(i + 1) / (double)n - fx;
29
t = fx - (double)i / (
double
)
n
;
30
if
(i == 0 || z > zmax)
31
zmax = z;
32
33
if
(i == 0 || t > tmax)
34
tmax = t;
35
}
36
37
y[0] = zmax;
38
y[1] = tmax;
39
40
free
(xcopy);
41
42
return
y
;
43
}
dcmp
int dcmp(const void *i, const void *j)
Definition:
dcmp.c:1
y
int y
Definition:
plot.c:34
malloc
void * malloc(YYSIZE_T)
local_proto.h
NULL
return NULL
Definition:
dbfopen.c:1394
free
void free(void *)
dmax_exp
double * dmax_exp(double *x, int n)
Definition:
dmaxe.c:7
n
int n
Definition:
dataquad.c:291
lib
cdhc
dmaxe.c
Generated on Sat Jan 2 2016 01:46:47 for GRASS Programmer's Manual by
1.8.5