Debian Codegraph @

packages/seacas/libraries/chaco/eigen/orthog1.c

raw
1 /*
2 * Copyright(C) 1999-2020 National Technology & Engineering Solutions
3 * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
4 * NTESS, the U.S. Government retains certain rights in this software.
5 *
6 * See packages/seacas/LICENSE for details
7 */
8
9 /* Orthogonalize a double vector to all one's */
10 void orthog1(double *x, int beg, int end)
11 {
12 int i;
13 double *pntr;
14 double sum;
15 int len;
16
17 len = end - beg + 1;
18 sum = 0.0;
19 pntr = x + beg;
20 for (i = len; i; i--) {
21 sum += *pntr++;
22 }
23 sum /= len;
24 pntr = x + beg;
25 for (i = len; i; i--) {
26 *pntr++ -= sum;
27 }
28 }
29
30 /* Orthogonalize a float vector to all one's */
31 void orthog1_float(float *x, int beg, int end)
32 {
33 int i;
34 float *pntr;
35 float sum;
36 int len;
37
38 len = end - beg + 1;
39 sum = 0.0;
40 pntr = x + beg;
41 for (i = len; i; i--) {
42 sum += *pntr++;
43 }
44 sum /= len;
45 pntr = x + beg;
46 for (i = len; i; i--) {
47 *pntr++ -= sum;
48 }
49 }