GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
evmax.c
Go to the documentation of this file.
1 /* evmax.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 evmax(double *a, double *u, int n)
11 {
12  double *p, *q, *qm, *r, *s, *t;
13 
14  double ev, evm, c, h;
15 
16  int kc;
17 
18  q = (double *)calloc(n, sizeof(double));
19  qm = q + n;
20  *(qm - 1) = 1.;
21  ev = 0.;
22  for (kc = 0; kc < 200; ++kc) {
23  h = c = 0.;
24  evm = ev;
25  for (p = u, r = a, s = q; s < qm;) {
26  *p = 0.;
27  for (t = q; t < qm;)
28  *p += *r++ * *t++;
29  c += *p * *p;
30  h += *p++ * *s++;
31  }
32  ev = c / h;
33  c = sqrt(c);
34  for (p = u, s = q; s < qm;) {
35  *p /= c;
36  *s++ = *p++;
37  }
38  if (((c = ev - evm) < 0. ? -c : c) < 1.e-16 * (ev < 0. ? -ev : ev)) {
39  free(q);
40  return ev;
41  }
42  }
43  free(q);
44  for (kc = 0; kc < n;)
45  u[kc++] = 0.;
46  return 0.;
47 }
tuple q
Definition: forms.py:2019
float r
Definition: named_colr.c:8
double evmax(double *a, double *u, int n)
Definition: evmax.c:10
void free(void *)
int n
Definition: dataquad.c:291
tuple h
panel.defaultSize = wx.CheckBox(panel, id = wx.ID_ANY, label = _(&quot;Use default size&quot;)) panel...