AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects Version of the Day
AbstractLinAlgPack_MA28Solver.hpp
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 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 
00038 // 
00039 // ***********************************************************************
00040 // @HEADER
00041 //
00042 // This is a class for encapsulsting the MA28 package as
00043 // and object so that multiple sparse matrix systems can
00044 // be solved at the same time.
00045 
00046 #ifndef SSP_MA28_SOLVER_H
00047 #define SSP_MA28_SOLVER_H
00048 
00049 #include "AbstractLinAlgPack_MA28CommonBlockEncap.hpp"
00050 
00051 namespace MA28_Cpp {
00052 
00053 // Adobt some of the declarations from MA29_CppDecl
00054 using MA28_CppDecl::f_int;
00055 using MA28_CppDecl::f_logical;
00056 using MA28_CppDecl::f_real;
00057 using MA28_CppDecl::f_dbl_prec;
00058 
00069 class MA28Solver {
00070 public:
00071 
00073   MA28Solver();
00074 
00076   MA28Solver(const MA28Solver& s);
00077 
00078   // MA28 interface functions
00079 
00081   void ma28ad(const f_int& n, const f_int& nz, f_dbl_prec a[], const f_int& licn
00082     , f_int irn[], const f_int& lirn, f_int icn[], const f_dbl_prec& u
00083     , f_int ikeep[], f_int iw[], f_dbl_prec w[], f_int* iflag)
00084   { 
00085     set_common_block_data();
00086     MA28_CppDecl::ma28ad(n,nz,a,licn,irn,lirn,icn,u,ikeep,iw,w,iflag);
00087     get_common_block_data();
00088   }
00089 
00091   void ma28bd(const f_int& n, const f_int& nz, f_dbl_prec a[], const f_int& licn
00092     , const f_int ivect[], const f_int jvect[], const f_int icn[]
00093     , const f_int ikeep[], f_int iw[], f_dbl_prec w[], f_int* iflag)
00094   { 
00095     set_common_block_data();
00096     MA28_CppDecl::ma28bd(n,nz,a,licn,ivect,jvect,icn,ikeep,iw,w,iflag);
00097     get_common_block_data();
00098   }
00099 
00101   void ma28cd(const f_int& n, const f_dbl_prec a[], const f_int& licn, const f_int icn[]
00102     , const f_int ikeep[], f_dbl_prec rhs[], f_dbl_prec w[], const f_int& mtype)
00103   { 
00104     set_common_block_data();
00105     MA28_CppDecl::ma28cd(n,a,licn,icn,ikeep,rhs,w,mtype);
00106     get_common_block_data();
00107   }
00108 
00109   // Common block data setting and retrieval functions
00110 
00112   void    lp(f_int lp)
00113   { changed_=true; common_blocks_.ma28ed_.lp=lp; }
00115   f_int   lp()
00116   { return common_blocks_.ma28ed_.lp; }
00118   void    mp(f_int mp)
00119   { changed_=true; common_blocks_.ma28ed_.mp=mp; }
00121   f_int   mp()
00122   { return common_blocks_.ma28ed_.mp; }
00124   void    lblock(f_logical lblock)
00125   { changed_=true; common_blocks_.ma28ed_.lblock=lblock; }
00127   f_logical lblock()
00128   { return common_blocks_.ma28ed_.lblock; }
00130   void    grow(f_logical grow)
00131   { changed_=true; common_blocks_.ma28ed_.grow=grow; }
00133   f_logical grow()
00134   { return common_blocks_.ma28ed_.grow; }
00136   void    eps(f_dbl_prec eps)
00137   { changed_=true; common_blocks_.ma28fd_.eps=eps; }
00139   f_dbl_prec  eps()
00140   { return common_blocks_.ma28fd_.eps; }
00142   void    rmin(f_dbl_prec rmin)
00143   { changed_=true; common_blocks_.ma28fd_.rmin=rmin; }
00145   f_dbl_prec  rmin()
00146   { return common_blocks_.ma28fd_.rmin; }
00148   void    resid(f_dbl_prec resid)
00149   { changed_=true; common_blocks_.ma28fd_.resid=resid; }
00151   f_dbl_prec  resid()
00152   { return common_blocks_.ma28fd_.resid; }
00154   void    irncp(f_int irncp)
00155   { changed_=true; common_blocks_.ma28fd_.irncp=irncp; }
00157   f_int   irncp()
00158   { return common_blocks_.ma28fd_.irncp; }
00160   void    icncp(f_int icncp)
00161   { changed_=true; common_blocks_.ma28fd_.icncp=icncp; }
00163   f_int   icncp()
00164   { return common_blocks_.ma28fd_.icncp; }
00166   void    minirn(f_int minirn)
00167   { changed_=true; common_blocks_.ma28fd_.minirn=minirn; }
00169   f_int   minirn()
00170   { return common_blocks_.ma28fd_.minirn; }
00172   void    minicn(f_int minicn)
00173   { changed_=true; common_blocks_.ma28fd_.minicn=minicn; }
00175   f_int   minicn()
00176   { return common_blocks_.ma28fd_.minicn; }
00178   void    irank(f_int irank)
00179   { changed_=true; common_blocks_.ma28fd_.irank=irank; }
00181   f_int   irank()
00182   { return common_blocks_.ma28fd_.irank; }
00184   void    abort1(f_logical abort1)
00185   { changed_=true; common_blocks_.ma28fd_.abort1=abort1; }
00187   f_logical abort1()
00188   { return common_blocks_.ma28fd_.abort1; }
00190   void    abort2(f_logical abort2)
00191   { changed_=true; common_blocks_.ma28fd_.abort2=abort2; }
00193   f_logical abort2()
00194   { return common_blocks_.ma28fd_.abort2; }
00196   void    idisp(f_int val, f_int i)
00197   { changed_=true; common_blocks_.ma28gd_.idisp[i]=val; }
00199   f_int   idisp(f_int i)
00200   { return common_blocks_.ma28gd_.idisp[i]; }
00202   void    tol(f_dbl_prec tol)
00203   { changed_=true; common_blocks_.ma28hd_.tol=tol; }
00205   f_dbl_prec  tol()
00206   { return common_blocks_.ma28hd_.tol; }
00208   void    themax(f_dbl_prec themax)
00209   { changed_=true; common_blocks_.ma28hd_.themax=themax; }
00211   f_dbl_prec  themax()
00212   { return common_blocks_.ma28hd_.themax; }
00214   void    big(f_dbl_prec big)
00215   { changed_=true; common_blocks_.ma28hd_.big=big; }
00217   f_dbl_prec  big()
00218   { return common_blocks_.ma28hd_.big; }
00220   void    dxmax(f_dbl_prec dxmax)
00221   { changed_=true; common_blocks_.ma28hd_.dxmax=dxmax; }
00223   f_dbl_prec  dxmax()
00224   { return common_blocks_.ma28hd_.dxmax; }
00226   void    errmax(f_dbl_prec errmax)
00227   { changed_=true; common_blocks_.ma28hd_.errmax=errmax; }
00229   f_dbl_prec  errmax()
00230   { return common_blocks_.ma28hd_.errmax; }
00232   void    dres(f_dbl_prec dres)
00233   { changed_=true; common_blocks_.ma28hd_.dres=dres; }
00235   f_dbl_prec  dres()
00236   { return common_blocks_.ma28hd_.dres; }
00238   void    cgce(f_dbl_prec cgce)
00239   { changed_=true; common_blocks_.ma28hd_.cgce=cgce; }
00241   f_dbl_prec  cgce()
00242   { return common_blocks_.ma28hd_.cgce; }
00244   void    ndrop(f_int ndrop)
00245   { changed_=true; common_blocks_.ma28hd_.ndrop=ndrop; }
00247   f_int   ndrop()
00248   { return common_blocks_.ma28hd_.ndrop; }
00250   void    maxit(f_int maxit)
00251   { changed_=true; common_blocks_.ma28hd_.maxit=maxit; }
00253   f_int   maxit()
00254   { return common_blocks_.ma28hd_.maxit; }
00256   void    noiter(f_int noiter)
00257   { changed_=true; common_blocks_.ma28hd_.noiter=noiter; }
00259   f_int   noiter()
00260   { return common_blocks_.ma28hd_.noiter; }
00262   void    nsrch(f_int nsrch)
00263   { changed_=true; common_blocks_.ma28hd_.nsrch=nsrch; }
00265   f_int   nsrch()
00266   { return common_blocks_.ma28hd_.nsrch; }
00268   void    istart(f_int istart)
00269   { changed_=true; common_blocks_.ma28hd_.istart=istart; }
00271   f_int   istart()
00272   { return common_blocks_.ma28hd_.istart; }
00274   void    lbig(f_logical lbig)
00275   { changed_=true; common_blocks_.ma28hd_.lbig=lbig; }
00277   f_logical lbig()
00278   { return common_blocks_.ma28hd_.lbig; }
00279 
00281   void dump_common_blocks(std::ostream& o)
00282   { common_blocks_.dump_values(o); }
00283 
00285   MA28Solver& operator=(const MA28Solver& solver)
00286   { changed_ = true; common_blocks_ = solver.common_blocks_; return *this; }
00287 
00288   // ///////////////////////////////////
00289   // Static member functions
00290 
00292   static void dump_ma28_common_blocks(std::ostream& o)
00293   { ma28_common_blocks_.dump_values(o); }
00294 
00295 private:
00296 
00297   // ////////////////////////////////////
00298   // Private member functions
00299 
00300   // Copy the local copy the common block data to MA28 before a MA28 call.
00301   void set_common_block_data();
00302 
00303   // Retrieve the common block data after a ma28 call.
00304   void get_common_block_data();
00305   
00306   // ///////////////////////////////////
00307   // Private member data
00308 
00309   // Common block data for this solver object
00310    MA28CommonBlockStorage common_blocks_;
00311 
00312   // Flag for if the common bock data has changed
00313   bool changed_;
00314 
00315   // ///////////////////////////////////
00316   // Static member data
00317 
00318   // Copies of the default values for the 
00319   // common block data.
00320   static MA28CommonBlockStorage default_common_blocks_;
00321 
00322   // References to the MA28 common blocks
00323   static MA28CommonBlockReferences ma28_common_blocks_;
00324 
00325   // Pointer variable who's purpose it to identify
00326   // what solver object is the current one.
00327   static MA28Solver* curr_solver_;
00328   
00329 };
00330 
00331 } // end namespace MA28_Cpp
00332 
00333 #endif // SSP_MA28_SOLVER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends