| 1 |
/* |
| 2 |
* Copyright(C) 1999-2020, 2023, 2024 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 fprintf, printf, NULL, FILE |
| 11 |
|
| 12 |
/* Check an extended eigenpair of A by direct multiplication. Uses |
| 13 |
the Ay = extval*y + Dg form of the problem for convenience. */ |
| 14 |
|
| 15 |
double checkeig_ext(double *err, double *work, /* work vector of length n */ |
| 16 |
struct vtx_data **A, double *y, int n, double extval, double *vwsqrt, |
| 17 |
double *gvec, double eigtol, |
| 18 |
int warnings /* don't want to see warning messages in one of the |
| 19 |
contexts this is called */ |
| 20 |
) |
| 21 |
{ |
| 22 |
extern FILE *Output_File; /* output file or null */ |
| 23 |
extern int DEBUG_EVECS; /* print debugging output? */ |
| 24 |
extern int WARNING_EVECS; /* print warning messages? */ |
| 25 |
double resid; /* the extended eigen residual */ |
| 26 |
double ch_norm(double *vec, int beg, int end); /* vector norm */ |
| 27 |
|
| 28 |
splarax(err, A, n, y, vwsqrt, work); |
| 29 |
scadd(err, 1, n, -extval, y); |
| 30 |
cpvec(work, 1, n, gvec); /* only need if going to reuse gvec */ |
| 31 |
scale_diag(work, 1, n, vwsqrt); |
| 32 |
scadd(err, 1, n, -1.0, work); |
| 33 |
resid = ch_norm(err, 1, n); |
| 34 |
|
| 35 |
if (DEBUG_EVECS > 0) { |
| 36 |
printf(" extended residual: %g\n", resid); |
| 37 |
if (Output_File != NULL) { |
| 38 |
fprintf(Output_File, " extended residual: %g\n", resid); |
| 39 |
} |
| 40 |
} |
| 41 |
if (warnings && WARNING_EVECS > 0 && resid > eigtol) { |
| 42 |
printf("WARNING: Extended residual (%g) greater than tolerance (%g).\n", resid, eigtol); |
| 43 |
if (Output_File != NULL) { |
| 44 |
fprintf(Output_File, "WARNING: Extended residual (%g) greater than tolerance (%g).\n", resid, |
| 45 |
eigtol); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
return (resid); |
| 50 |
} |