File: setparams.c

package info (click to toggle)
spooles 2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 19,012 kB
  • sloc: ansic: 146,834; csh: 3,615; makefile: 2,040; perl: 74
file content (215 lines) | stat: -rw-r--r-- 5,762 bytes parent folder | download | duplicates (7)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
/*  setparams.c  */

#include "../Bridge.h"

/*--------------------------------------------------------------------*/
/*
   -------------------------------------------
   purpose -- to set the matrix parameters
 
   return value --
     1 -- normal return
    -1 -- bridge object is NULL
    -2 -- neqns <= 0
    -3 -- type is invalid
    -4 -- symmetryflag is invalid
    -5 -- matrix is hermitian but type is real
 
   created -- 98sep25, cca
   -------------------------------------------
*/
int
Bridge_setMatrixParams (
   Bridge   *bridge,
   int      neqns,
   int      type,
   int      symmetryflag
) {
if ( bridge == NULL ) {
   fprintf(stderr, "\n\n error in Bridge_setMatrixParams()"
           "\n bridge is NULL\n") ;
   return(-1) ;
}
if ( neqns <= 0 ) {
   fprintf(stderr, "\n\n error in Bridge_setMatrixParams()"
           "\n neqns = %d\n", neqns) ;
   return(-2) ;
}
if ( type != SPOOLES_REAL && type != SPOOLES_COMPLEX ) {
   fprintf(stderr, "\n\n error in Bridge_setMatrixParams()"
           "\n type = %d\n", type) ;
   return(-3) ;
}
switch ( symmetryflag ) {
case SPOOLES_SYMMETRIC :
   break ;
case SPOOLES_HERMITIAN :
   if ( type != SPOOLES_COMPLEX ) {
      fprintf(stderr, "\n\n error in Bridge_setMatrixParams()"
              "\n type = %d\n", type) ;
      return(-5) ;
   }
   break ;
case SPOOLES_NONSYMMETRIC :
   break ;
default :
   if ( type != SPOOLES_COMPLEX ) {
      fprintf(stderr, "\n\n error in Bridge_setMatrixParams()"
              "\n symmetryflag = %d\n", symmetryflag) ;
      return(-4) ;
   }
   break ;
}
bridge->neqns        = neqns        ;
bridge->type         = type         ;
bridge->symmetryflag = symmetryflag ;
 
return(1) ; }
 
/*--------------------------------------------------------------------*/
/*
   -------------------------------------------
   purpose -- to set the ordering parameters
 
   return value --
     1 -- normal return
    -1 -- bridge object is NULL
    -2 -- maxdomainsize <= 0
    -3 -- maxsize <= 0
    -4 -- compressCutoff > 1.0
 
   created -- 98sep25, cca
   -------------------------------------------
*/
int
Bridge_setOrderingParams (
   Bridge   *bridge,
   int      maxdomainsize,
   int      maxnzeros,
   int      maxsize,
   int      seed,
   double   compressCutoff
) {
if ( bridge == NULL ) {
   fprintf(stderr, "\n\n error in Bridge_setOrderingParams()"
           "\n bridge is NULL\n") ;
   return(-1) ;
}
if ( maxdomainsize <= 0 ) {
   fprintf(stderr, "\n\n error in Bridge_setOrderingParams()"
           "\n maxdomainsize = %d\n", maxdomainsize) ;
   return(-2) ;
}
if ( maxsize <= 0 ) {
   fprintf(stderr, "\n\n error in Bridge_setOrderingParams()"
           "\n maxsize = %d\n", maxsize) ;
   return(-3) ;
}
if ( compressCutoff > 1.0 ) {
   fprintf(stderr, "\n\n error in Bridge_setOrderingParams()"
           "\n compressCutoff = %f\n", compressCutoff) ;
   return(-4) ;
}
bridge->maxdomainsize  = maxdomainsize  ;
bridge->maxnzeros      = maxnzeros      ;
bridge->maxsize        = maxsize        ;
bridge->seed           = seed           ;
bridge->compressCutoff = compressCutoff ;
 
return(1) ; }

/*--------------------------------------------------------------------*/
/*
   ----------------------------------------------
   purpose -- to set the factorization parameters
 
   return value --
     1 -- normal return
    -1 -- bridge object is NULL
    -2 -- sparsityflag is invalid
    -3 -- pivotingflag is invalid
    -4 -- tau < 2.0
    -5 -- droptol < 0.0
 
   created -- 98sep25, cca
   ----------------------------------------------
*/
int
Bridge_setFactorParams (
   Bridge           *bridge,
   int              sparsityflag,
   int              pivotingflag,
   double           tau,
   double           droptol,
   PatchAndGoInfo   *patchinfo
) {
if ( bridge == NULL ) {
   fprintf(stderr, "\n\n error in Bridge_setFactorParams()"
           "\n bridge is NULL\n") ;
   return(-1) ;
}
if (  sparsityflag != FRONTMTX_DENSE_FRONTS
   && sparsityflag != FRONTMTX_SPARSE_FRONTS ) {
   fprintf(stderr, "\n\n error in Bridge_setFactorParams()"
           "\n sparsityflag = %d\n", sparsityflag) ;
   return(-2) ;
}
if (  pivotingflag != SPOOLES_PIVOTING
   && pivotingflag != SPOOLES_NO_PIVOTING ) {
   fprintf(stderr, "\n\n error in Bridge_setFactorParams()"
           "\n pivotingflag = %d\n", pivotingflag) ;
   return(-3) ;
}
if (  tau < 2.0 ) {
   fprintf(stderr, "\n\n error in Bridge_setFactorParams()"
           "\n invalid value %f for tau", tau) ;
   return(-4) ;
}
if (  droptol < 0.0 ) {
   fprintf(stderr, "\n\n error in Bridge_setFactorParams()"
           "\n invalid value %f for droptol", droptol) ;
   return(-5) ;
}
bridge->sparsityflag = sparsityflag ;
bridge->pivotingflag = pivotingflag ;
bridge->tau          = tau          ;
bridge->droptol      = droptol      ;
bridge->patchinfo    = patchinfo    ;
 
return(1) ; }
 
/*--------------------------------------------------------------------*/
/*
   -------------------------------------
   purpose -- to set the message info

   return value --
     1 -- normal return
    -1 -- bridge object is NULL
    -2 -- msglvl > 0 and msgFile is NULL

   created -- 98sep18, cca
   -------------------------------------
*/
int
Bridge_setMessageInfo (
   Bridge   *bridge,
   int      msglvl,
   FILE     *msgFile 
) {
if ( bridge == NULL ) {
   fprintf(stderr, "\n\n error in Bridge_setMessageInfo()"
           "\n bridge is NULL\n") ;
   return(-1) ;
}
if ( msglvl > 0 && msgFile == NULL ) {
   fprintf(stderr, "\n\n error in Bridge_setMessageInfo()"
           "\n msglvl is > 0 and msgFile is NULL\n") ;
   return(-2) ;
}
bridge->msglvl  = msglvl  ;
bridge->msgFile = msgFile ;

return(1) ; }
   
/*--------------------------------------------------------------------*/