GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 }
double hevmax(Cpx *a, Cpx *u, int n)
Definition: hevmax.c:10
double re
Definition: ccmath.h:38
double im
Definition: ccmath.h:38
void free(void *)
Definition: ccmath.h:38
int n
Definition: dataquad.c:291
tuple h
panel.defaultSize = wx.CheckBox(panel, id = wx.ID_ANY, label = _(&quot;Use default size&quot;)) panel...