VERB_code_2.2  2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
itlin.h
Go to the documentation of this file.
1 /*
2  Common declarations for programs of the NewtonLib package.
3  (Part iterative linear solvers)
4 
5  * Written by L. Weimann
6  * Version 1.0
7  * Revision May 2006
8  * Latest Change May 2006
9  * Library NewtonLib
10  * Code C, Double Precision
11  * Environment Standard C environment on PC's,
12  workstations and hosts.
13  * Copyright (c) Konrad-Zuse-Zentrum fuer
14  Informationstechnik Berlin (ZIB)
15  Takustrasse 7, D-14195 Berlin-Dahlem
16  phone : + 49/30/84185-0
17  fax : + 49/30/84185-125
18  * Contact Lutz Weimann
19  ZIB, Division Scientific Computing,
20  Department Numerical Analysis and Modelling
21  phone : + 49/30/84185-185
22  fax : + 49/30/84185-107
23  e-mail: weimann@zib.de
24 
25  ---------------------------------------------------------------
26 
27  * Licence
28  You may use or modify this code for your own non commercial
29  purposes for an unlimited time.
30  In any case you should not deliver this code without a special
31  permission of ZIB.
32  In case you intend to use the code commercially, we oblige you
33  to sign an according licence agreement with ZIB.
34 
35  * Warranty
36  This code has been tested up to a certain level. Defects and
37  weaknesses, which may be included in the code, do not establish
38  any warranties by ZIB. ZIB does not take over any liabilities
39  which may follow from acquisition or application of this code.
40 
41  * Software status
42  This code is under care of ZIB and belongs to ZIB software class 2.
43 
44  ------------------------------------------------------------
45 
46 */
47 
48 #ifndef ITLIN_H
49 #define ITLIN_H
50 
51 
52 #define RCODE info->rcode
53 #define MIN(A,B) ( A < B ? A : B )
54 #define MAX(A,B) ( A > B ? A : B )
55 #define SIGN(A) ( A > 0 ? 1 : -1 )
56 
57 #define SMALL 1.0e-150
58 #define EPMACH 1.0e-17
59 
60 typedef enum {None=0, Minimum=1, Verbose=2, Debug=3} PRINT_LEVEL ;
61 typedef enum {False=0, True=1} LOGICAL ;
62 typedef enum { CheckOnRestart=0, CheckEachIter=1 } TERM_CHECK ;
63 typedef enum { Absolute=0, Relative=1 } CONV_CHECK ;
64 
65 //#include "../Diffusion/MatrixSolver.h"
66 
67 /*
68  * ax=b
69  * \param n - size
70  * \param x - x
71  * \param b - rhs
72  * \param a - a, array of diagonals!
73  * \param diag - diagonal numbers
74  */
75 //typedef void MATVEC(int n, double* x, double* b, double** a, int diag);
76 
77 typedef void MATVEC(int n, double* x, double* b);
78 typedef void PRECON(int, double*, double*);
79 
80 struct ITLIN_OPT
81 {
82  double tol, rho;
83  int i_max, maxiter;
84  TERM_CHECK termcheck; /* GMRES only */
85  CONV_CHECK convcheck; /* PCG only */
86  LOGICAL rescale; /* GBIT only */
90  double *scale;
91 };
92 
93 struct ITLIN_INFO
94 {
97 };
98 
99 struct ITLIN_DATA
100 {
101  double *res;
102  double tau, t, normdx, residuum;
103  enum { GMRES=0, GBIT=1, PCG=2 } codeid;
105 };
106 
107 struct ITLIN_IO
108 {
112 };
113 
114 #define ERRORLEVEL itlin_ioctl->errlevel
115 #define MONITORLEVEL itlin_ioctl->monlevel
116 #define DATALEVEL itlin_ioctl->datlevel
117 #define ERROR itlin_ioctl->errfile
118 #define MONITOR itlin_ioctl->monfile
119 #define DATA itlin_ioctl->datfile
120 #define FITER itlin_ioctl->iterfile
121 #define FRES itlin_ioctl->resfile
122 #define FMISC itlin_ioctl->miscfile
123 
124 extern void daxpy_(int *n, double *alpha, double *x, int *incx,
125  double *y, int *incy);
126 
127 /* routines defined in utils.c */
128 int zibnum_fwalloc(int size, double **ptr, char vname[]);
129 int zibnum_iwalloc(int size, int **ptr, char vname[]);
130 int zibnum_pfwalloc(int size, double ***ptr, char vname[]);
131 double zibnum_scaled_norm2(int n, double *v, double *scale);
132 double zibnum_scaled_sprod(int n, double *v1, double *v2, double *scale);
133 double zibnum_norm2(int n, double *v);
134 void zibnum_scale(int n, double *v1, double *v2, double *scale);
135 void zibnum_descale(int n, double *v1, double *v2, double *scale);
136 void itlin_noprecon(int n, double *x, double *z);
137 void itlin_dataout(int k, int n, double *x, struct ITLIN_DATA *data);
139  struct ITLIN_OPT *opt, int itlin_code);
140 
141 #endif