| 1 |
/* |
| 2 |
* Copyright(C) 1999-2020, 2023 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 |
#include "defs.h" |
| 10 |
#include "structs.h" // for orthlink, orthlink_float |
| 11 |
|
| 12 |
void sorthog(double *vec, /* vector to be orthogonalized */ |
| 13 |
int n, /* length of the columns of orth */ |
| 14 |
struct orthlink **solist, /* set of vecs to orth. against */ |
| 15 |
int ngood /* number of vecs in solist */ |
| 16 |
) |
| 17 |
{ |
| 18 |
double alpha; |
| 19 |
double *dir; |
| 20 |
int i; |
| 21 |
|
| 22 |
for (i = 1; i <= ngood; i++) { |
| 23 |
dir = (solist[i])->vec; |
| 24 |
alpha = -dot(vec, 1, n, dir) / dot(dir, 1, n, dir); |
| 25 |
scadd(vec, 1, n, alpha, dir); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
void sorthog_float(float *vec, /* vector to be orthogonalized */ |
| 30 |
int n, /* length of the columns of orth */ |
| 31 |
struct orthlink_float **solist, /* set of vecs to orth. against */ |
| 32 |
int ngood /* number of vecs in solist */ |
| 33 |
) |
| 34 |
{ |
| 35 |
float alpha; |
| 36 |
float *dir; |
| 37 |
int i; |
| 38 |
|
| 39 |
for (i = 1; i <= ngood; i++) { |
| 40 |
dir = (solist[i])->vec; |
| 41 |
alpha = -dot_float(vec, 1, n, dir) / dot_float(dir, 1, n, dir); |
| 42 |
scadd_float(vec, 1, n, alpha, dir); |
| 43 |
} |
| 44 |
} |