GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
atovm.c
Go to the documentation of this file.
1 /* atovm.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 void atovm(double *v, int n)
9 {
10  double *p0, *q0, *p, *q, *qq;
11 
12  double h, s;
13 
14  int i, j, k, mm;
15 
16  q0 = v + n * n - 1;
17  *q0 = 1.;
18  q0 -= n + 1;
19  p0 = v + n * n - n - n - 1;
20  for (i = n - 2, mm = 1; i >= 0; --i, p0 -= n + 1, q0 -= n + 1, ++mm) {
21  if (i && *(p0 - 1) != 0.) {
22  for (j = 0, p = p0, h = 1.; j < mm; ++j, ++p)
23  h += *p * *p;
24  h = *(p0 - 1);
25  *q0 = 1. - h;
26  for (j = 0, q = q0 + n, p = p0; j < mm; ++j, q += n)
27  *q = -h * *p++;
28  for (k = i + 1, q = q0 + 1; k < n; ++k) {
29  for (j = 0, qq = q + n, p = p0, s = 0.; j < mm; ++j, qq += n)
30  s += *qq * *p++;
31  s *= h;
32  for (j = 0, qq = q + n, p = p0; j < mm; ++j, qq += n)
33  *qq -= s * *p++;
34  *q++ = -s;
35  }
36  }
37  else {
38  *q0 = 1.;
39  for (j = 0, p = q0 + 1, q = q0 + n; j < mm; ++j, q += n)
40  *q = *p++ = 0.;
41  }
42  }
43 }
void atovm(double *v, int n)
Definition: atovm.c:8