MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConstrainedOptPack_QPKWIK_Output.cpp
Go to the documentation of this file.
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 
43 #include "Moocho_ConfigDefs.hpp"
44 
45 
46 #ifdef CONSTRAINED_OPTIMIZATION_PACK_USE_QPKWIK
47 
48 
50 #include "Teuchos_F77_wrappers.h"
51 
52 namespace QPKWIK_Output {
53  std::ostream* out = 0;
54 
55  set_output::set_output(std::ostream* _out)
56  { out = _out; }
58  { out = 0; }
59 
60 } // end namespace QPKWIK_Output
61 
62 // implementations.
63 namespace {
64 
65 // scalar
66 template<class T>
67 inline
68 void output(const char name[], const T& val) {
69  *QPKWIK_Output::out << name << " = " << val << "\n";
70 }
71 
72 // array
73 template<class T>
74 inline
75 void output(const char name[], const int n, const T array[]) {
76  *QPKWIK_Output::out << name << " =\n";
77  for(const T* itr = array; itr != array + n; )
78  *QPKWIK_Output::out << "\t" << *itr++;
79  *QPKWIK_Output::out << "\n";
80 }
81 
82 // matrix
83 template<class T>
84 inline
85 void output(const char name[], const int m, const int n, const T matrix[]) {
86  *QPKWIK_Output::out << name << " =\n";
87  for(int i = 0; i < m; ++i) {
88  for(int j = 0; j < n; ++j) {
89  *QPKWIK_Output::out << "\t" << matrix[ i + j * m ];
90  }
91  *QPKWIK_Output::out << "\n";
92  }
93 }
94 
95 } // end namespace
96 
97 namespace QPKWIK_Print_Decl {
98 
101 
102 // Functions that are called by Fortran QPKWIK
103 
104 extern "C" {
105 
107 FORTRAN_FUNC_DECL_UL_(void,QPKWIK_PRINT_INPUT,qpkwik_print_input) ( const f_int& N, const f_int& M1
108  , const f_int& M2, const f_int& M3, const f_int& M1D, const f_int& M2D
109  , const f_int& M3D, const f_dbl_prec GRAD[], const f_dbl_prec Z[]
110  , const f_int& LDZ, const f_int IBND[]
111  , const f_dbl_prec BL[], const f_dbl_prec BU[], const f_dbl_prec A[], const f_int& LDA
112  , const f_dbl_prec YPY[], const f_int& INF, const f_dbl_prec& SMALL
113  , const f_dbl_prec& VSMALL, const f_dbl_prec& VLARGE, const f_int& N1
114  , const f_int& M12, const f_int& M23, const f_int& M123 )
115 {
116  using QPKWIK_Output::out;
117  if(!out) return;
118 
119  *out << "\n*** Printing QPKWIK input\n";
120  output("N",N);
121  output("M1",M1);
122  output("M2",M2);
123  output("M3",M3);
124  output("M1D",M1D);
125  output("M2D",M2D);
126  output("M3D",M3D);
127  output("GRAD",N,GRAD);
128  output("Z",LDZ,N1,Z);
129  output("IBND",M1D,IBND);
130  output("BL",M1D,BL);
131  output("BU",M3D,BU);
132  output("A",LDA,N,A);
133 // output("YPY",M1D,YPY);
134  output("INF",INF);
135  output("SMALL",SMALL);
136  output("VSMALL",VSMALL);
137  output("VLARGE",VLARGE);
138  output("N1",N1);
139  output("M12",M12);
140  output("M23",M23);
141  output("M123",M123);
142 }
143 
145 FORTRAN_FUNC_DECL_UL_(void,QPKWIK_PRINT_SPARSITY,qpkwik_print_sparsity) ( const f_int& N, const f_int& M2D
146  , const f_int& ISPARSE, const f_int ISTART[], const f_int IPOINT[] )
147 {
148  using QPKWIK_Output::out;
149  if(!out) return;
150 
151  *out << "\n*** Printing QPKWIK sparsity data\n";
152 // output("ISPARSE",ISPARSE);
153  output("ISTART",M2D+1,ISTART);
154  output("IPOINT",M2D*N,IPOINT);
155 }
156 
158 FORTRAN_FUNC_DECL_UL_(void,QPKWIK_PRINT_ITERATION_INFO,qpkwik_print_iteration_info) (
159  const f_int& CALLING_LABLE, const f_int& N, const f_int& M1
160  , const f_int& M2, const f_int& M3, const f_int& M1D, const f_int& M2D
161  , const f_int& M3D, const f_dbl_prec X[]
162  , const f_int& NACT, const f_int IACT[], const f_dbl_prec UR[]
163  , const f_int IACTSTORE[], const f_dbl_prec Z[], const f_int& LDZ, const f_dbl_prec AINV[]
164  , const f_dbl_prec T1[], const f_dbl_prec T2[], const f_dbl_prec R[]
165  , const f_dbl_prec XX[], const f_int& IYPY, const f_dbl_prec& EXTRA
166  , const f_int& WARM, const f_int& NACTSTORE, const f_dbl_prec& SUMY
167  , const f_int& ICHECK, const f_int& I, const f_int& J, const f_int& II
168  , const f_dbl_prec& SUM, const f_int& KDROP, const f_int& IFLAG
169  , const f_int& KSTART, const f_dbl_prec& SUMNORM, const f_dbl_prec& CVMAX
170  , const f_dbl_prec& RES, const f_int& KNEXT, const f_int& IFINISH
171  , const f_int& IBEGIN, const f_dbl_prec& TEMP, const f_int& INDEX
172  , const f_dbl_prec& PARNEW, const f_int& LFLAG, const f_dbl_prec& SUMA
173  , const f_dbl_prec& SUMB, const f_dbl_prec& SUMC, const f_dbl_prec& TEMPA
174  , const f_dbl_prec& TEMPB, const f_int& IKNEXT, const f_int& JJ, const f_int& JN
175  , const f_dbl_prec& PARINC, const f_dbl_prec& STEP
176  , const f_dbl_prec& RATIO, const f_int& ICOUNT, const f_dbl_prec& XMIN
177  , const f_dbl_prec& BOTTOM, const f_int& IWARM, const f_int& ITEMP
178  , const f_int& ITEMPP )
179 {
180  using QPKWIK_Output::out;
181  if(!out) return;
182 
183  *out << "\n*** QPKWIK Iteration info, CALLING_LABLE = " << CALLING_LABLE << "\n";
184  output("X",N,X);
185  output("NACT",NACT);
186  output("IACT",NACT,IACT);
187  output("UR",NACT,UR);
188  output("IACTSTORE",NACTSTORE,IACTSTORE);
189  output("Z",LDZ,N+1,Z);
190  output("AINV",M3D+1,AINV);
191  output("T1",N+1,T1);
192  output("T2",N+1,T2);
193  output("R",(3*(N+1)+(N+1)*(N+1))/2,R);
194  output("XX",N,XX);
195  output("IYPY",IYPY);
196  output("EXTRA",EXTRA);
197  output("WARM",WARM);
198  output("NACTSTORE",NACTSTORE);
199  output("SUMY",SUMY);
200  output("ICHECK",ICHECK);
201  output("I",I);
202  output("J",J);
203  output("II",II);
204  output("SUM",SUM);
205  output("KDROP",KDROP);
206  output("IFLAG",IFLAG);
207  output("KSTART",KSTART);
208  output("SUMNORM",SUMNORM);
209  output("CVMAX",CVMAX);
210  output("RES",RES);
211  output("KNEXT",KNEXT);
212  output("IFINISH",IFINISH);
213  output("IBEGIN",IBEGIN);
214  output("TEMP",TEMP);
215  output("INDEX",INDEX);
216  output("PARNEW",PARNEW);
217  output("LFLAG",LFLAG);
218  output("SUMA",SUMA);
219  output("SUMB",SUMB);
220  output("SUMC",SUMC);
221  output("TEMPA",TEMPA);
222  output("TEMPB",TEMPB);
223  output("IKNEXT",IKNEXT);
224  output("JJ",JJ);
225  output("JN",JN);
226  output("PARINC",PARINC);
227  output("STEP",STEP);
228  output("RATIO",RATIO);
229  output("ICOUNT",ICOUNT);
230  output("XMIN",XMIN);
231  output("BOTTOM",BOTTOM);
232  output("IWARM",IWARM);
233  output("ITEMP",ITEMP);
234  output("ITEMPP",ITEMPP);
235 }
236 
237 
238 } // end extern "C"
239 
240 
241 } // end namespace QPKWIK_Print_Decl
242 
243 
244 #endif // CONSTRAINED_OPTIMIZATION_PACK_USE_QPKWIK
const f_int const f_int const f_int const f_dbl_prec const f_dbl_prec * BL
const LAPACK_C_Decl::f_int LAPACK_C_Decl::f_dbl_prec const LAPACK_C_Decl::f_int & LDA
FortranTypes::f_int f_int
const f_int const f_int const f_dbl_prec const f_dbl_prec * X
FORTRAN_FUNC_DECL_UL_(void, QPOPT_SET_DEFAULTS, qpopt_set_defaults)()
std::ostream & output(std::ostream &o, const COOMatrix &coom)
Output stream function for COOMatrix.
std::ostream * out
const f_int const f_int const f_int const f_dbl_prec const f_dbl_prec const f_dbl_prec * BU
const f_int const f_int & N
FortranTypes::f_dbl_prec f_dbl_prec