-
Notifications
You must be signed in to change notification settings - Fork 17
/
maxchange.c
51 lines (33 loc) · 1.32 KB
/
maxchange.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* ------- file: -------------------------- maxchange.c -------------
Version: rh2.0
Author: Han Uitenbroek ([email protected])
Last modified: Tue Jan 25 13:40:59 2000 --
-------------------------- ----------RH-- */
/* --- Prints maximum change between iterations using
the Ng structure. -- -------------- */
#include <math.h>
#include "rh.h"
#include "accelerate.h"
#include "error.h"
#include "inputs.h"
/* --- Function prototypes -- -------------- */
/* --- Global variables -- -------------- */
extern CommandLine commandline;
extern char messageStr[];
/* ------- begin -------------------------- MaxChange.c ------------- */
double MaxChange(struct Ng *Ngs, char *text, bool_t quiet)
{
register int k;
double dmax = 0.0, *old, *new;
if (Ngs->count < 2) return dmax;
old = Ngs->previous[(Ngs->count - 2) % (Ngs->Norder + 2)];
new = Ngs->previous[(Ngs->count - 1) % (Ngs->Norder + 2)];
for (k = 0; k < Ngs->N; k++) {
if (new[k])
dmax = MAX(dmax, fabs((new[k] - old[k]) / new[k]));
}
if (!quiet)
fprintf(commandline.logfile, "%s delta = %6.4E", text, dmax);
return dmax;
}
/* ------- end ---------------------------- MaxChange.c ------------- */