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

Generated on Tue Oct 20 12:51:45 2009 for MOOCHO (Single Doxygen Collection) by doxygen 1.4.7