| 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 <stdio.h> // for NULL |
| 11 |
|
| 12 |
/* Assemble eigenvectors, return bounds, etc. */ |
| 13 |
void mkeigvecs(struct scanlink *scanlist, /* linked list of fields to do with min ritz vals */ |
| 14 |
double *lambda, /* ritz approximation to eigenvals of A */ |
| 15 |
double *bound, /* on ritz pair approximations to eig pairs of A */ |
| 16 |
int *index, /* the Ritz index of an eigenpair */ |
| 17 |
double *bj, /* beta(j)*(last el. of corr. eigvec s of T) */ |
| 18 |
int d, /* problem dimension = number of eigvecs to find */ |
| 19 |
double *Sres_max, /* Max value of Sres */ |
| 20 |
double *alpha, /* vector of Lanczos scalars */ |
| 21 |
double *beta, /* vector of Lanczos scalars */ |
| 22 |
int j, /* number of Lanczos iterations taken */ |
| 23 |
double *s, /* approximate eigenvector of T */ |
| 24 |
double **y, /* columns of y are eigenvectors of A */ |
| 25 |
int n, /* problem size */ |
| 26 |
double **q /* columns of q are Lanczos basis vectors */ |
| 27 |
) |
| 28 |
{ |
| 29 |
|
| 30 |
int i, k; /* indcies */ |
| 31 |
double Sres; /* how well Tevec calculated eigvec s */ |
| 32 |
struct scanlink *curlnk; /* for traversing the scanlist */ |
| 33 |
|
| 34 |
/* Scan for some data which is used here or later */ |
| 35 |
i = d; |
| 36 |
curlnk = scanlist; |
| 37 |
while (curlnk != NULL) { |
| 38 |
lambda[i] = curlnk->val; |
| 39 |
bound[i] = bj[curlnk->indx]; |
| 40 |
index[i] = curlnk->indx; |
| 41 |
curlnk = curlnk->pntr; |
| 42 |
i--; |
| 43 |
} |
| 44 |
|
| 45 |
/* Assemble the evecs from the Lanczos basis */ |
| 46 |
for (i = 1; i <= d; i++) { |
| 47 |
Sres = Tevec(alpha, beta - 1, j, lambda[i], s); |
| 48 |
if (Sres > *Sres_max) { |
| 49 |
*Sres_max = Sres; |
| 50 |
} |
| 51 |
setvec(y[i], 1, n, 0.0); |
| 52 |
for (k = 1; k <= j; k++) { |
| 53 |
scadd(y[i], 1, n, s[k], q[k]); |
| 54 |
} |
| 55 |
} |
| 56 |
} |