GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-112dd97adf
solvps.c
Go to the documentation of this file.
1 /* solvps.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 "ccmath.h"
9 int solvps(double *a, double *b, int n)
10 {
11  double *p, *q, *r, *s, t;
12 
13  int j, k;
14 
15  for (j = 0, p = a; j < n; ++j, p += n + 1) {
16  for (q = a + j * n; q < p; ++q)
17  *p -= *q * *q;
18  if (*p <= 0.)
19  return -1;
20  *p = sqrt(*p);
21  for (k = j + 1, q = p + n; k < n; ++k, q += n) {
22  for (r = a + j * n, s = a + k * n, t = 0.; r < p;)
23  t += *r++ * *s++;
24  *q -= t;
25  *q /= *p;
26  }
27  }
28  for (j = 0, p = a; j < n; ++j, p += n + 1) {
29  for (k = 0, q = a + j * n; k < j;)
30  b[j] -= b[k++] * *q++;
31  b[j] /= *p;
32  }
33  for (j = n - 1, p = a + n * n - 1; j >= 0; --j, p -= n + 1) {
34  for (k = j + 1, q = p + n; k < n; q += n)
35  b[j] -= b[k++] * *q;
36  b[j] /= *p;
37  }
38  return 0;
39 }
double b
Definition: r_raster.c:39
double t
Definition: r_raster.c:39
double r
Definition: r_raster.c:39
int solvps(double *a, double *b, int n)
Definition: solvps.c:9