|
AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization 00005 // Copyright (2003) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 // 00029 // This is a class for encapsulsting the MA28 package as 00030 // and object so that multiple sparse matrix systems can 00031 // be solved at the same time. 00032 00033 #ifndef SSP_MA28_SOLVER_H 00034 #define SSP_MA28_SOLVER_H 00035 00036 #include "AbstractLinAlgPack_MA28CommonBlockEncap.hpp" 00037 00038 namespace MA28_Cpp { 00039 00040 // Adobt some of the declarations from MA29_CppDecl 00041 using MA28_CppDecl::f_int; 00042 using MA28_CppDecl::f_logical; 00043 using MA28_CppDecl::f_real; 00044 using MA28_CppDecl::f_dbl_prec; 00045 00056 class MA28Solver { 00057 public: 00058 00060 MA28Solver(); 00061 00063 MA28Solver(const MA28Solver& s); 00064 00065 // MA28 interface functions 00066 00068 void ma28ad(const f_int& n, const f_int& nz, f_dbl_prec a[], const f_int& licn 00069 , f_int irn[], const f_int& lirn, f_int icn[], const f_dbl_prec& u 00070 , f_int ikeep[], f_int iw[], f_dbl_prec w[], f_int* iflag) 00071 { 00072 set_common_block_data(); 00073 MA28_CppDecl::ma28ad(n,nz,a,licn,irn,lirn,icn,u,ikeep,iw,w,iflag); 00074 get_common_block_data(); 00075 } 00076 00078 void ma28bd(const f_int& n, const f_int& nz, f_dbl_prec a[], const f_int& licn 00079 , const f_int ivect[], const f_int jvect[], const f_int icn[] 00080 , const f_int ikeep[], f_int iw[], f_dbl_prec w[], f_int* iflag) 00081 { 00082 set_common_block_data(); 00083 MA28_CppDecl::ma28bd(n,nz,a,licn,ivect,jvect,icn,ikeep,iw,w,iflag); 00084 get_common_block_data(); 00085 } 00086 00088 void ma28cd(const f_int& n, const f_dbl_prec a[], const f_int& licn, const f_int icn[] 00089 , const f_int ikeep[], f_dbl_prec rhs[], f_dbl_prec w[], const f_int& mtype) 00090 { 00091 set_common_block_data(); 00092 MA28_CppDecl::ma28cd(n,a,licn,icn,ikeep,rhs,w,mtype); 00093 get_common_block_data(); 00094 } 00095 00096 // Common block data setting and retrieval functions 00097 00099 void lp(f_int lp) 00100 { changed_=true; common_blocks_.ma28ed_.lp=lp; } 00102 f_int lp() 00103 { return common_blocks_.ma28ed_.lp; } 00105 void mp(f_int mp) 00106 { changed_=true; common_blocks_.ma28ed_.mp=mp; } 00108 f_int mp() 00109 { return common_blocks_.ma28ed_.mp; } 00111 void lblock(f_logical lblock) 00112 { changed_=true; common_blocks_.ma28ed_.lblock=lblock; } 00114 f_logical lblock() 00115 { return common_blocks_.ma28ed_.lblock; } 00117 void grow(f_logical grow) 00118 { changed_=true; common_blocks_.ma28ed_.grow=grow; } 00120 f_logical grow() 00121 { return common_blocks_.ma28ed_.grow; } 00123 void eps(f_dbl_prec eps) 00124 { changed_=true; common_blocks_.ma28fd_.eps=eps; } 00126 f_dbl_prec eps() 00127 { return common_blocks_.ma28fd_.eps; } 00129 void rmin(f_dbl_prec rmin) 00130 { changed_=true; common_blocks_.ma28fd_.rmin=rmin; } 00132 f_dbl_prec rmin() 00133 { return common_blocks_.ma28fd_.rmin; } 00135 void resid(f_dbl_prec resid) 00136 { changed_=true; common_blocks_.ma28fd_.resid=resid; } 00138 f_dbl_prec resid() 00139 { return common_blocks_.ma28fd_.resid; } 00141 void irncp(f_int irncp) 00142 { changed_=true; common_blocks_.ma28fd_.irncp=irncp; } 00144 f_int irncp() 00145 { return common_blocks_.ma28fd_.irncp; } 00147 void icncp(f_int icncp) 00148 { changed_=true; common_blocks_.ma28fd_.icncp=icncp; } 00150 f_int icncp() 00151 { return common_blocks_.ma28fd_.icncp; } 00153 void minirn(f_int minirn) 00154 { changed_=true; common_blocks_.ma28fd_.minirn=minirn; } 00156 f_int minirn() 00157 { return common_blocks_.ma28fd_.minirn; } 00159 void minicn(f_int minicn) 00160 { changed_=true; common_blocks_.ma28fd_.minicn=minicn; } 00162 f_int minicn() 00163 { return common_blocks_.ma28fd_.minicn; } 00165 void irank(f_int irank) 00166 { changed_=true; common_blocks_.ma28fd_.irank=irank; } 00168 f_int irank() 00169 { return common_blocks_.ma28fd_.irank; } 00171 void abort1(f_logical abort1) 00172 { changed_=true; common_blocks_.ma28fd_.abort1=abort1; } 00174 f_logical abort1() 00175 { return common_blocks_.ma28fd_.abort1; } 00177 void abort2(f_logical abort2) 00178 { changed_=true; common_blocks_.ma28fd_.abort2=abort2; } 00180 f_logical abort2() 00181 { return common_blocks_.ma28fd_.abort2; } 00183 void idisp(f_int val, f_int i) 00184 { changed_=true; common_blocks_.ma28gd_.idisp[i]=val; } 00186 f_int idisp(f_int i) 00187 { return common_blocks_.ma28gd_.idisp[i]; } 00189 void tol(f_dbl_prec tol) 00190 { changed_=true; common_blocks_.ma28hd_.tol=tol; } 00192 f_dbl_prec tol() 00193 { return common_blocks_.ma28hd_.tol; } 00195 void themax(f_dbl_prec themax) 00196 { changed_=true; common_blocks_.ma28hd_.themax=themax; } 00198 f_dbl_prec themax() 00199 { return common_blocks_.ma28hd_.themax; } 00201 void big(f_dbl_prec big) 00202 { changed_=true; common_blocks_.ma28hd_.big=big; } 00204 f_dbl_prec big() 00205 { return common_blocks_.ma28hd_.big; } 00207 void dxmax(f_dbl_prec dxmax) 00208 { changed_=true; common_blocks_.ma28hd_.dxmax=dxmax; } 00210 f_dbl_prec dxmax() 00211 { return common_blocks_.ma28hd_.dxmax; } 00213 void errmax(f_dbl_prec errmax) 00214 { changed_=true; common_blocks_.ma28hd_.errmax=errmax; } 00216 f_dbl_prec errmax() 00217 { return common_blocks_.ma28hd_.errmax; } 00219 void dres(f_dbl_prec dres) 00220 { changed_=true; common_blocks_.ma28hd_.dres=dres; } 00222 f_dbl_prec dres() 00223 { return common_blocks_.ma28hd_.dres; } 00225 void cgce(f_dbl_prec cgce) 00226 { changed_=true; common_blocks_.ma28hd_.cgce=cgce; } 00228 f_dbl_prec cgce() 00229 { return common_blocks_.ma28hd_.cgce; } 00231 void ndrop(f_int ndrop) 00232 { changed_=true; common_blocks_.ma28hd_.ndrop=ndrop; } 00234 f_int ndrop() 00235 { return common_blocks_.ma28hd_.ndrop; } 00237 void maxit(f_int maxit) 00238 { changed_=true; common_blocks_.ma28hd_.maxit=maxit; } 00240 f_int maxit() 00241 { return common_blocks_.ma28hd_.maxit; } 00243 void noiter(f_int noiter) 00244 { changed_=true; common_blocks_.ma28hd_.noiter=noiter; } 00246 f_int noiter() 00247 { return common_blocks_.ma28hd_.noiter; } 00249 void nsrch(f_int nsrch) 00250 { changed_=true; common_blocks_.ma28hd_.nsrch=nsrch; } 00252 f_int nsrch() 00253 { return common_blocks_.ma28hd_.nsrch; } 00255 void istart(f_int istart) 00256 { changed_=true; common_blocks_.ma28hd_.istart=istart; } 00258 f_int istart() 00259 { return common_blocks_.ma28hd_.istart; } 00261 void lbig(f_logical lbig) 00262 { changed_=true; common_blocks_.ma28hd_.lbig=lbig; } 00264 f_logical lbig() 00265 { return common_blocks_.ma28hd_.lbig; } 00266 00268 void dump_common_blocks(std::ostream& o) 00269 { common_blocks_.dump_values(o); } 00270 00272 MA28Solver& operator=(const MA28Solver& solver) 00273 { changed_ = true; common_blocks_ = solver.common_blocks_; return *this; } 00274 00275 // /////////////////////////////////// 00276 // Static member functions 00277 00279 static void dump_ma28_common_blocks(std::ostream& o) 00280 { ma28_common_blocks_.dump_values(o); } 00281 00282 private: 00283 00284 // //////////////////////////////////// 00285 // Private member functions 00286 00287 // Copy the local copy the common block data to MA28 before a MA28 call. 00288 void set_common_block_data(); 00289 00290 // Retrieve the common block data after a ma28 call. 00291 void get_common_block_data(); 00292 00293 // /////////////////////////////////// 00294 // Private member data 00295 00296 // Common block data for this solver object 00297 MA28CommonBlockStorage common_blocks_; 00298 00299 // Flag for if the common bock data has changed 00300 bool changed_; 00301 00302 // /////////////////////////////////// 00303 // Static member data 00304 00305 // Copies of the default values for the 00306 // common block data. 00307 static MA28CommonBlockStorage default_common_blocks_; 00308 00309 // References to the MA28 common blocks 00310 static MA28CommonBlockReferences ma28_common_blocks_; 00311 00312 // Pointer variable who's purpose it to identify 00313 // what solver object is the current one. 00314 static MA28Solver* curr_solver_; 00315 00316 }; 00317 00318 } // end namespace MA28_Cpp 00319 00320 #endif // SSP_MA28_SOLVER_H
1.7.4