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