AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AbstractLinAlgPack_MA28Solver.hpp
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 //
42 // This is a class for encapsulsting the MA28 package as
43 // and object so that multiple sparse matrix systems can
44 // be solved at the same time.
45 
46 #ifndef SSP_MA28_SOLVER_H
47 #define SSP_MA28_SOLVER_H
48 
49 #include "AbstractLinAlgPack_MA28CommonBlockEncap.hpp"
50 
51 namespace MA28_Cpp {
52 
53 // Adobt some of the declarations from MA29_CppDecl
54 using MA28_CppDecl::f_int;
55 using MA28_CppDecl::f_logical;
56 using MA28_CppDecl::f_real;
57 using MA28_CppDecl::f_dbl_prec;
58 
69 class MA28Solver {
70 public:
71 
73  MA28Solver();
74 
76  MA28Solver(const MA28Solver& s);
77 
78  // MA28 interface functions
79 
81  void ma28ad(const f_int& n, const f_int& nz, f_dbl_prec a[], const f_int& licn
82  , f_int irn[], const f_int& lirn, f_int icn[], const f_dbl_prec& u
83  , f_int ikeep[], f_int iw[], f_dbl_prec w[], f_int* iflag)
84  {
85  set_common_block_data();
86  MA28_CppDecl::ma28ad(n,nz,a,licn,irn,lirn,icn,u,ikeep,iw,w,iflag);
87  get_common_block_data();
88  }
89 
91  void ma28bd(const f_int& n, const f_int& nz, f_dbl_prec a[], const f_int& licn
92  , const f_int ivect[], const f_int jvect[], const f_int icn[]
93  , const f_int ikeep[], f_int iw[], f_dbl_prec w[], f_int* iflag)
94  {
95  set_common_block_data();
96  MA28_CppDecl::ma28bd(n,nz,a,licn,ivect,jvect,icn,ikeep,iw,w,iflag);
97  get_common_block_data();
98  }
99 
101  void ma28cd(const f_int& n, const f_dbl_prec a[], const f_int& licn, const f_int icn[]
102  , const f_int ikeep[], f_dbl_prec rhs[], f_dbl_prec w[], const f_int& mtype)
103  {
104  set_common_block_data();
105  MA28_CppDecl::ma28cd(n,a,licn,icn,ikeep,rhs,w,mtype);
106  get_common_block_data();
107  }
108 
109  // Common block data setting and retrieval functions
110 
112  void lp(f_int lp)
113  { changed_=true; common_blocks_.ma28ed_.lp=lp; }
115  f_int lp()
116  { return common_blocks_.ma28ed_.lp; }
118  void mp(f_int mp)
119  { changed_=true; common_blocks_.ma28ed_.mp=mp; }
121  f_int mp()
122  { return common_blocks_.ma28ed_.mp; }
124  void lblock(f_logical lblock)
125  { changed_=true; common_blocks_.ma28ed_.lblock=lblock; }
127  f_logical lblock()
128  { return common_blocks_.ma28ed_.lblock; }
130  void grow(f_logical grow)
131  { changed_=true; common_blocks_.ma28ed_.grow=grow; }
133  f_logical grow()
134  { return common_blocks_.ma28ed_.grow; }
136  void eps(f_dbl_prec eps)
137  { changed_=true; common_blocks_.ma28fd_.eps=eps; }
139  f_dbl_prec eps()
140  { return common_blocks_.ma28fd_.eps; }
142  void rmin(f_dbl_prec rmin)
143  { changed_=true; common_blocks_.ma28fd_.rmin=rmin; }
145  f_dbl_prec rmin()
146  { return common_blocks_.ma28fd_.rmin; }
148  void resid(f_dbl_prec resid)
149  { changed_=true; common_blocks_.ma28fd_.resid=resid; }
151  f_dbl_prec resid()
152  { return common_blocks_.ma28fd_.resid; }
154  void irncp(f_int irncp)
155  { changed_=true; common_blocks_.ma28fd_.irncp=irncp; }
157  f_int irncp()
158  { return common_blocks_.ma28fd_.irncp; }
160  void icncp(f_int icncp)
161  { changed_=true; common_blocks_.ma28fd_.icncp=icncp; }
163  f_int icncp()
164  { return common_blocks_.ma28fd_.icncp; }
166  void minirn(f_int minirn)
167  { changed_=true; common_blocks_.ma28fd_.minirn=minirn; }
169  f_int minirn()
170  { return common_blocks_.ma28fd_.minirn; }
172  void minicn(f_int minicn)
173  { changed_=true; common_blocks_.ma28fd_.minicn=minicn; }
175  f_int minicn()
176  { return common_blocks_.ma28fd_.minicn; }
178  void irank(f_int irank)
179  { changed_=true; common_blocks_.ma28fd_.irank=irank; }
181  f_int irank()
182  { return common_blocks_.ma28fd_.irank; }
184  void abort1(f_logical abort1)
185  { changed_=true; common_blocks_.ma28fd_.abort1=abort1; }
187  f_logical abort1()
188  { return common_blocks_.ma28fd_.abort1; }
190  void abort2(f_logical abort2)
191  { changed_=true; common_blocks_.ma28fd_.abort2=abort2; }
193  f_logical abort2()
194  { return common_blocks_.ma28fd_.abort2; }
196  void idisp(f_int val, f_int i)
197  { changed_=true; common_blocks_.ma28gd_.idisp[i]=val; }
199  f_int idisp(f_int i)
200  { return common_blocks_.ma28gd_.idisp[i]; }
202  void tol(f_dbl_prec tol)
203  { changed_=true; common_blocks_.ma28hd_.tol=tol; }
205  f_dbl_prec tol()
206  { return common_blocks_.ma28hd_.tol; }
208  void themax(f_dbl_prec themax)
209  { changed_=true; common_blocks_.ma28hd_.themax=themax; }
211  f_dbl_prec themax()
212  { return common_blocks_.ma28hd_.themax; }
214  void big(f_dbl_prec big)
215  { changed_=true; common_blocks_.ma28hd_.big=big; }
217  f_dbl_prec big()
218  { return common_blocks_.ma28hd_.big; }
220  void dxmax(f_dbl_prec dxmax)
221  { changed_=true; common_blocks_.ma28hd_.dxmax=dxmax; }
223  f_dbl_prec dxmax()
224  { return common_blocks_.ma28hd_.dxmax; }
226  void errmax(f_dbl_prec errmax)
227  { changed_=true; common_blocks_.ma28hd_.errmax=errmax; }
229  f_dbl_prec errmax()
230  { return common_blocks_.ma28hd_.errmax; }
232  void dres(f_dbl_prec dres)
233  { changed_=true; common_blocks_.ma28hd_.dres=dres; }
235  f_dbl_prec dres()
236  { return common_blocks_.ma28hd_.dres; }
238  void cgce(f_dbl_prec cgce)
239  { changed_=true; common_blocks_.ma28hd_.cgce=cgce; }
241  f_dbl_prec cgce()
242  { return common_blocks_.ma28hd_.cgce; }
244  void ndrop(f_int ndrop)
245  { changed_=true; common_blocks_.ma28hd_.ndrop=ndrop; }
247  f_int ndrop()
248  { return common_blocks_.ma28hd_.ndrop; }
250  void maxit(f_int maxit)
251  { changed_=true; common_blocks_.ma28hd_.maxit=maxit; }
253  f_int maxit()
254  { return common_blocks_.ma28hd_.maxit; }
256  void noiter(f_int noiter)
257  { changed_=true; common_blocks_.ma28hd_.noiter=noiter; }
259  f_int noiter()
260  { return common_blocks_.ma28hd_.noiter; }
262  void nsrch(f_int nsrch)
263  { changed_=true; common_blocks_.ma28hd_.nsrch=nsrch; }
265  f_int nsrch()
266  { return common_blocks_.ma28hd_.nsrch; }
268  void istart(f_int istart)
269  { changed_=true; common_blocks_.ma28hd_.istart=istart; }
271  f_int istart()
272  { return common_blocks_.ma28hd_.istart; }
274  void lbig(f_logical lbig)
275  { changed_=true; common_blocks_.ma28hd_.lbig=lbig; }
277  f_logical lbig()
278  { return common_blocks_.ma28hd_.lbig; }
279 
281  void dump_common_blocks(std::ostream& o)
282  { common_blocks_.dump_values(o); }
283 
286  { changed_ = true; common_blocks_ = solver.common_blocks_; return *this; }
287 
288  // ///////////////////////////////////
289  // Static member functions
290 
292  static void dump_ma28_common_blocks(std::ostream& o)
293  { ma28_common_blocks_.dump_values(o); }
294 
295 private:
296 
297  // ////////////////////////////////////
298  // Private member functions
299 
300  // Copy the local copy the common block data to MA28 before a MA28 call.
301  void set_common_block_data();
302 
303  // Retrieve the common block data after a ma28 call.
304  void get_common_block_data();
305 
306  // ///////////////////////////////////
307  // Private member data
308 
309  // Common block data for this solver object
310  MA28CommonBlockStorage common_blocks_;
311 
312  // Flag for if the common bock data has changed
313  bool changed_;
314 
315  // ///////////////////////////////////
316  // Static member data
317 
318  // Copies of the default values for the
319  // common block data.
320  static MA28CommonBlockStorage default_common_blocks_;
321 
322  // References to the MA28 common blocks
323  static MA28CommonBlockReferences ma28_common_blocks_;
324 
325  // Pointer variable who's purpose it to identify
326  // what solver object is the current one.
327  static MA28Solver* curr_solver_;
328 
329 };
330 
331 } // end namespace MA28_Cpp
332 
333 #endif // SSP_MA28_SOLVER_H
void ma28ad(const f_int &n, const f_int &nz, f_dbl_prec a[], const f_int &licn, f_int irn[], const f_int &lirn, f_int icn[], const f_dbl_prec &u, f_int ikeep[], f_int iw[], f_dbl_prec w[], f_int *iflag)
void ma28bd(const f_int &n, const f_int &nz, f_dbl_prec a[], const f_int &licn, const f_int ivect[], const f_int jvect[], const f_int icn[], const f_int ikeep[], f_int iw[], f_dbl_prec w[], f_int *iflag)
MA28Solver & operator=(const MA28Solver &solver)
Copy the state of one solver to another.
void dump_common_blocks(std::ostream &o)
Dump the common block infomation for this solver object.
static void dump_ma28_common_blocks(std::ostream &o)
Dump the common block infomation for ma28 common blocks.
void ma28cd(const f_int &n, const f_dbl_prec a[], const f_int &licn, const f_int icn[], const f_int ikeep[], f_dbl_prec rhs[], f_dbl_prec w[], const f_int &mtype)
MA28Solver()
Construct a solver object that is initialized with the default common block data variables.
MA28 Basic Encapsulation Class.