GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
hevmax.c
Go to the documentation of this file.
1
/* hevmax.c CCMATH mathematics library source code.
2
*
3
* Copyright (C) 2000 Daniel A. Atkinson All rights reserved.
4
* This code may be redistributed under the terms of the GNU library
5
* public license (LGPL). ( See the lgpl.license file for details.)
6
* ------------------------------------------------------------------------
7
*/
8
#include <stdlib.h>
9
#include "
ccmath.h
"
10
double
hevmax
(
Cpx
* a,
Cpx
* u,
int
n)
11
{
12
Cpx
*
x
, *p, h;
13
14
double
e, ep, s,
t
, te = 1.e-12;
15
16
int
k, j;
17
18
x = (
Cpx
*) calloc(n,
sizeof
(
Cpx
));
19
x[0].
re
= 1.;
20
e = 0.;
21
do
{
22
for
(k = 0, p = a, s = t = 0.; k < n; ++k) {
23
for
(j = 0, h.
re
= h.
im
= 0.; j < n; ++j, ++p) {
24
h.
re
+= p->
re
* x[j].
re
- p->
im
* x[j].
im
;
25
h.
im
+= p->
im
* x[j].
re
+ p->
re
* x[j].
im
;
26
}
27
s += h.
re
* h.
re
+ h.
im
* h.
im
;
28
t += h.
re
* x[k].
re
+ h.
im
* x[k].
im
;
29
u[k] = h;
30
}
31
ep = e;
32
e = s /
t
;
33
s = 1. / sqrt(s);
34
for
(k = 0; k < n; ++k) {
35
u[k].
re
*= s;
36
u[k].
im
*= s;
37
x[k] = u[k];
38
}
39
}
while
(fabs(e - ep) > fabs(te * e));
40
free
(x);
41
return
e;
42
}
free
void free(void *)
x
#define x
ccmath.h
t
double t
Definition:
r_raster.c:39
complex::re
double re
Definition:
ccmath.h:38
hevmax
double hevmax(Cpx *a, Cpx *u, int n)
Definition:
hevmax.c:10
complex::im
double im
Definition:
ccmath.h:38
complex
Definition:
la.h:54
lib
external
ccmath
hevmax.c
Generated on Mon May 31 2021 05:21:29 for GRASS GIS 7 Programmer's Manual by
1.8.13