ConstrainedOptPack_QPKWIK_Output.cpp

Go to the documentation of this file.
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 
00030 #include "Moocho_ConfigDefs.hpp"
00031 
00032 
00033 #ifdef CONSTRAINED_OPTIMIZATION_PACK_USE_QPKWIK
00034 
00035 
00036 #include "ConstrainedOptPack_QPKWIK_Output.hpp"
00037 #include "Teuchos_F77_wrappers.h"
00038 
00039 namespace QPKWIK_Output {
00040   std::ostream* out = 0;
00041 
00042   set_output::set_output(std::ostream* _out)
00043   { out = _out; }
00044   set_output::~set_output()
00045   { out = 0; }
00046   
00047 } // end namespace QPKWIK_Output
00048 
00049 // implementations.
00050 namespace {
00051 
00052 // scalar
00053 template<class T>
00054 inline
00055 void output(char name[], const T& val) {
00056   *QPKWIK_Output::out << name << " = " << val << "\n";
00057 }
00058 
00059 // array
00060 template<class T>
00061 inline
00062 void output(char name[], const int n, const T array[]) {
00063   *QPKWIK_Output::out << name << " =\n";
00064   for(const T* itr = array; itr != array + n; )
00065     *QPKWIK_Output::out << "\t" << *itr++;
00066   *QPKWIK_Output::out << "\n";
00067 }
00068 
00069 // matrix
00070 template<class T>
00071 inline
00072 void output(char name[], const int m, const int n, const T matrix[]) {
00073   *QPKWIK_Output::out << name << " =\n";
00074   for(int i = 0; i < m; ++i) {
00075     for(int j = 0; j < n; ++j) {
00076       *QPKWIK_Output::out << "\t" << matrix[ i + j * m ];
00077     }
00078     *QPKWIK_Output::out << "\n";
00079   }
00080 }
00081 
00082 } // end namespace
00083 
00084 namespace QPKWIK_Print_Decl {
00085 
00086 using FortranTypes::f_int;
00087 using FortranTypes::f_dbl_prec;
00088 
00089 // Functions that are called by Fortran QPKWIK
00090 
00091 extern "C" {
00092 
00094 FORTRAN_FUNC_DECL_UL_(void,QPKWIK_PRINT_INPUT,qpkwik_print_input) ( const f_int& N, const f_int& M1
00095   , const f_int& M2, const f_int& M3, const f_int& M1D, const f_int& M2D
00096   , const f_int& M3D, const f_dbl_prec GRAD[], const f_dbl_prec Z[]
00097   , const f_int& LDZ, const f_int IBND[]
00098   , const f_dbl_prec BL[], const f_dbl_prec BU[], const f_dbl_prec A[], const f_int& LDA
00099   , const f_dbl_prec YPY[], const f_int& INF, const f_dbl_prec& SMALL
00100   , const f_dbl_prec& VSMALL, const f_dbl_prec& VLARGE, const f_int& N1
00101   , const f_int& M12, const f_int& M23, const f_int& M123 )
00102 {
00103   using QPKWIK_Output::out;
00104   if(!out) return;
00105 
00106   *out  << "\n*** Printing QPKWIK input\n";
00107   output("N",N);
00108   output("M1",M1);
00109   output("M2",M2);
00110   output("M3",M3);
00111   output("M1D",M1D);
00112   output("M2D",M2D);
00113   output("M3D",M3D);
00114   output("GRAD",N,GRAD);
00115   output("Z",LDZ,N1,Z);
00116   output("IBND",M1D,IBND);
00117   output("BL",M1D,BL);
00118   output("BU",M3D,BU);
00119   output("A",LDA,N,A);
00120 //  output("YPY",M1D,YPY);
00121   output("INF",INF);
00122   output("SMALL",SMALL);
00123   output("VSMALL",VSMALL);
00124   output("VLARGE",VLARGE);
00125   output("N1",N1);
00126   output("M12",M12);
00127   output("M23",M23);
00128   output("M123",M123);
00129 }
00130 
00132 FORTRAN_FUNC_DECL_UL_(void,QPKWIK_PRINT_SPARSITY,qpkwik_print_sparsity) ( const f_int& N, const f_int& M2D
00133   , const f_int& ISPARSE, const f_int ISTART[], const f_int IPOINT[] )
00134 {
00135   using QPKWIK_Output::out;
00136   if(!out) return;
00137 
00138   *out  << "\n*** Printing QPKWIK sparsity data\n";
00139 //  output("ISPARSE",ISPARSE);
00140   output("ISTART",M2D+1,ISTART);
00141   output("IPOINT",M2D*N,IPOINT);
00142 }
00143 
00145 FORTRAN_FUNC_DECL_UL_(void,QPKWIK_PRINT_ITERATION_INFO,qpkwik_print_iteration_info) (
00146     const f_int& CALLING_LABLE,  const f_int& N, const f_int& M1
00147   , const f_int& M2, const f_int& M3, const f_int& M1D, const f_int& M2D
00148   , const f_int& M3D, const f_dbl_prec X[]
00149   , const f_int& NACT, const f_int IACT[], const f_dbl_prec UR[]
00150   , const f_int IACTSTORE[], const f_dbl_prec Z[], const f_int& LDZ, const f_dbl_prec AINV[]
00151   , const f_dbl_prec T1[], const f_dbl_prec T2[], const f_dbl_prec R[]
00152   , const f_dbl_prec XX[], const f_int& IYPY, const f_dbl_prec& EXTRA
00153   , const f_int& WARM, const f_int& NACTSTORE, const f_dbl_prec& SUMY
00154   , const f_int& ICHECK, const f_int& I, const f_int& J, const f_int& II
00155   , const f_dbl_prec& SUM, const f_int& KDROP, const f_int& IFLAG
00156   , const f_int& KSTART, const f_dbl_prec& SUMNORM, const f_dbl_prec& CVMAX
00157   , const f_dbl_prec& RES, const f_int& KNEXT, const f_int& IFINISH
00158   , const f_int& IBEGIN, const f_dbl_prec& TEMP, const f_int& INDEX
00159   , const f_dbl_prec& PARNEW, const f_int& LFLAG, const f_dbl_prec& SUMA
00160   , const f_dbl_prec& SUMB, const f_dbl_prec& SUMC, const f_dbl_prec& TEMPA
00161   , const f_dbl_prec& TEMPB, const f_int& IKNEXT, const f_int& JJ, const f_int& JN
00162   , const f_dbl_prec& PARINC, const f_dbl_prec& STEP
00163   , const f_dbl_prec& RATIO, const f_int& ICOUNT, const f_dbl_prec& XMIN
00164   , const f_dbl_prec& BOTTOM, const f_int& IWARM, const f_int& ITEMP
00165   , const f_int& ITEMPP )
00166 {
00167   using QPKWIK_Output::out;
00168   if(!out) return;
00169 
00170   *out  << "\n*** QPKWIK Iteration info, CALLING_LABLE = " << CALLING_LABLE << "\n";
00171   output("X",N,X);
00172   output("NACT",NACT);
00173   output("IACT",NACT,IACT);
00174   output("UR",NACT,UR);
00175   output("IACTSTORE",NACTSTORE,IACTSTORE);
00176   output("Z",LDZ,N+1,Z);
00177   output("AINV",M3D+1,AINV);
00178   output("T1",N+1,T1);
00179   output("T2",N+1,T2);
00180   output("R",(3*(N+1)+(N+1)*(N+1))/2,R);
00181   output("XX",N,XX);
00182   output("IYPY",IYPY);
00183   output("EXTRA",EXTRA);
00184   output("WARM",WARM);
00185   output("NACTSTORE",NACTSTORE);
00186   output("SUMY",SUMY);
00187   output("ICHECK",ICHECK);
00188   output("I",I);
00189   output("J",J);
00190   output("II",II);
00191   output("SUM",SUM);
00192   output("KDROP",KDROP);
00193   output("IFLAG",IFLAG);
00194   output("KSTART",KSTART);
00195   output("SUMNORM",SUMNORM);
00196   output("CVMAX",CVMAX);
00197   output("RES",RES);
00198   output("KNEXT",KNEXT);
00199   output("IFINISH",IFINISH);
00200   output("IBEGIN",IBEGIN);
00201   output("TEMP",TEMP);
00202   output("INDEX",INDEX);
00203   output("PARNEW",PARNEW);
00204   output("LFLAG",LFLAG);
00205   output("SUMA",SUMA);
00206   output("SUMB",SUMB);
00207   output("SUMC",SUMC);
00208   output("TEMPA",TEMPA);
00209   output("TEMPB",TEMPB);
00210   output("IKNEXT",IKNEXT);
00211   output("JJ",JJ);
00212   output("JN",JN);
00213   output("PARINC",PARINC);
00214   output("STEP",STEP);
00215   output("RATIO",RATIO);
00216   output("ICOUNT",ICOUNT);
00217   output("XMIN",XMIN);
00218   output("BOTTOM",BOTTOM);
00219   output("IWARM",IWARM);
00220   output("ITEMP",ITEMP);
00221   output("ITEMPP",ITEMPP);
00222 }
00223 
00224 
00225 } // end extern "C"
00226 
00227 
00228 } // end namespace QPKWIK_Print_Decl
00229 
00230 
00231 #endif // CONSTRAINED_OPTIMIZATION_PACK_USE_QPKWIK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:10:58 2011 for MOOCHO (Single Doxygen Collection) by  doxygen 1.6.3