GRASS GIS 8 Programmer's Manual
8.4.1(2025)-45ca3179ab
Loading...
Searching...
No Matches
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
9
#include <stdlib.h>
10
#include "
ccmath.h
"
11
12
double
hevmax
(
Cpx
*a,
Cpx
*u,
int
n)
13
{
14
Cpx
*
x
, *p, h;
15
16
double
e, ep, s,
t
, te = 1.e-12;
17
18
int
k, j;
19
20
x
= (
Cpx
*)calloc(n,
sizeof
(
Cpx
));
21
x
[0].re = 1.;
22
e = 0.;
23
do
{
24
for
(k = 0, p = a, s =
t
= 0.; k < n; ++k) {
25
for
(j = 0, h.re = h.im = 0.; j < n; ++j, ++p) {
26
h.re += p->
re
*
x
[j].re - p->
im
*
x
[j].im;
27
h.im += p->
im
*
x
[j].re + p->
re
*
x
[j].im;
28
}
29
s += h.re * h.re + h.im * h.im;
30
t
+= h.re *
x
[k].re + h.im *
x
[k].im;
31
u[k] = h;
32
}
33
ep = e;
34
e = s /
t
;
35
s = 1. / sqrt(s);
36
for
(k = 0; k < n; ++k) {
37
u[k].
re
*= s;
38
u[k].
im
*= s;
39
x
[k] = u[k];
40
}
41
}
while
(fabs(e - ep) > fabs(te * e));
42
free(
x
);
43
return
e;
44
}
ccmath.h
Cpx
struct complex Cpx
Definition
ccmath.h:41
t
double t
Definition
driver/set_window.c:5
hevmax
double hevmax(Cpx *a, Cpx *u, int n)
Definition
hevmax.c:12
complex::re
double re
Definition
ccmath.h:39
complex::im
double im
Definition
ccmath.h:39
x
#define x
external
ccmath
hevmax.c
Generated on Sat Jun 21 2025 21:07:27 for GRASS GIS 8 Programmer's Manual by
1.13.2