Teuchos Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
parameterlist/test/ParameterList/cxx_main.cpp
Go to the documentation of this file.
1// @HEADER
2// ***********************************************************************
3//
4// Teuchos: Common Tools Package
5// Copyright (2004) 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 Michael A. Heroux (maherou@sandia.gov)
38//
39// ***********************************************************************
40// @HEADER
41
45#include "Teuchos_getConst.hpp"
46#include "Teuchos_Version.hpp"
49#include "Teuchos_ArrayRCP.hpp"
51
52#ifdef HAVE_TEUCHOS_EXTENDED
54#include <fstream>
55#endif
56
57#ifdef HAVE_MPI
58#include "mpi.h"
59#endif
60
63using Teuchos::getParameter;
64typedef ParameterList::PrintOptions PLPrintOptions;
66using Teuchos::OSTab;
67using Teuchos::rcp;
68using Teuchos::inoutArg;
69
70void print_break() { std::cout << "---------------------------------------------------" << std::endl; }
71double Plus ( double a, double b ) { return a+b; }
72
73int main( int argc, char *argv[] )
74{
75
76 using std::cout;
77 using std::endl;
78
79 bool verbose = true;
80 int FailedTests = 0;
81 bool result;
82
83 Teuchos::GlobalMPISession mpiSession(&argc,&argv);
84 const int procRank = Teuchos::GlobalMPISession::getRank();
85
86 bool success = true;
87
88 try {
89
90 // Read options from the command line.
91 CommandLineProcessor clp(false); // Don't throw exceptions
92 clp.setOption( "verbose", "quiet", &verbose, "Set if output is printed or not." );
93 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
94 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) {
95 cout << "Processor "<< procRank <<", parse_return "<< parse_return << std::endl;
96 cout << "End Result: TEST FAILED" << std::endl;
97 return parse_return;
98 }
99
100 // Only print on 0 processor
101 if (procRank != 0 && verbose)
102 verbose = false;
103
104 if (verbose)
105 cout << Teuchos::Teuchos_Version() << std::endl << std::endl;
106
107 //-----------------------------------------------------------
108 // Create Main Parameter List / Sublist Structure
109 //-----------------------------------------------------------
110
111 ParameterList PL_Main("PL_Main");
112 const std::string Direction_Doc = "This sublist controls how direction is computed.";
113 ParameterList& PL_Direction = PL_Main.sublist("Direction",false,Direction_Doc);
114 ParameterList& PL_Newton = PL_Direction.sublist("Newton");
115 ParameterList& PL_LinSol = PL_Newton.sublist("Linear Solver");
116 ParameterList& PL_LineSearch = PL_Main.sublist("Line Search");
117
118 //-----------------------------------------------------------
119 // Check Parameter List Structure
120 //-----------------------------------------------------------
121 if (verbose) {
122 print_break();
123 cout << "Empty Parameter List Structure" << std::endl;
124 print_break();
125 cout<<PL_Main<< std::endl;
126 }
127 if (verbose) cout << "Is 'Direction' recognized as a sublist of 'Main' ... ";
128 if ( PL_Main.isSublist( "Direction" ) ) {
129 if (verbose) cout << "yes"<< std::endl;
130 } else {
131 if (verbose) cout << "no"<< std::endl;
132 FailedTests++;
133 }
134 if (verbose) cout << "Is 'Newton' recognized as a sublist of 'Direction' ... ";
135 if ( PL_Direction.isSublist( "Newton" ) ) {
136 if (verbose) cout << "yes"<< std::endl;
137 } else {
138 if (verbose) cout << "no"<< std::endl;
139 FailedTests++;
140 }
141 if (verbose) cout << "Is 'Linear Solver' recognized as a sublist of 'Newton' ... ";
142 if ( PL_Newton.isSublist( "Linear Solver" ) ) {
143 if (verbose) cout << "yes"<< std::endl;
144 } else {
145 if (verbose) cout << "no"<< std::endl;
146 FailedTests++;
147 }
148 if (verbose) cout << "Is 'Line Search' recognized as a sublist of 'Main' ... ";
149 if ( PL_Main.isSublist( "Line Search" ) ) {
150 if (verbose) cout << "yes"<< std::endl;
151 } else {
152 if (verbose) cout << "no"<< std::endl;
153 FailedTests++;
154 }
155
156 if (verbose) cout << "Is subist documentation std::string maintained ...\n";
157 {
158 Teuchos::OSTab tab(cout);
160 *paramEntry = PL_Main.getEntryPtr("Direction");
161 TEUCHOS_TEST_FOR_EXCEPT(0==paramEntry);
162 const std::string extracted_Direction_Doc = paramEntry->docString();
163 if (verbose) tab.o() << "Expected doc std::string = \"" << Direction_Doc << "\"\n";
164 if (verbose) tab.o() << "Extracted doc std::string = \"" << extracted_Direction_Doc << "\"\n";
165 if (extracted_Direction_Doc == Direction_Doc) {
166 if (verbose) tab.o() << "passed! They match :-)\n";
167 }
168 else {
169 if (verbose) tab.o() << "failed! They do not match :-("<< std::endl;
170 FailedTests++;
171 }
172 }
173
174
175 //-----------------------------------------------------------
176 // Fill in Direction Sublist
177 //-----------------------------------------------------------
178
179 double tol = 0.0;
180 bool RBNS = false;
181 PL_Direction.get("Method", "Newton");
182 PL_LinSol.set("Tol",1e-5);
183 tol = PL_LinSol.get("Tolerance",1e-10);
184 (void)tol; // Not used, bad test!
185 RBNS = PL_Newton.get("Rescue Bad Newton Solve", true );
186 (void)RBNS; // Not used, bad test!
187
188 //-----------------------------------------------------------
189 // Print out Direction Sublist
190 //-----------------------------------------------------------
191 if (verbose) {
192 print_break();
193 cout << "Direction Parameter List" << std::endl;
194 print_break();
195 PL_Direction.print(cout);
196 }
197 if (verbose) cout << "Is 'Newton' recognized as a parameter of 'Direction' ... ";
198 if ( PL_Direction.isParameter( "Newton" ) ) {
199 if (verbose) cout << "yes"<< std::endl;
200 } else {
201 if (verbose) cout << "no"<< std::endl;
202 FailedTests++;
203 }
204 if (verbose) cout << "Is 'Tolerance' recognized as a parameter of 'Newton' ... ";
205 if ( PL_Newton.isParameter( "Tolerance" ) ) {
206 if (verbose) cout << "yes (should be no)"<< std::endl;
207 FailedTests++;
208 } else {
209 if (verbose) cout << "no (as expected)"<< std::endl;
210 }
211 if (verbose) cout << "Is 'Tolerance' recognized as a parameter of 'Linear Solver' ... ";
212 if ( PL_LinSol.isParameter( "Tolerance" ) ) {
213 if (verbose) cout << "yes"<< std::endl;
214 } else {
215 if (verbose) cout << "no"<< std::endl;
216 FailedTests++;
217 }
218 if (verbose) cout << "Is 'Rescue Bad Newton Solve' recognized as a parameter of 'Newton' ... ";
219 if ( PL_Newton.isParameter( "Rescue Bad Newton Solve" ) ) {
220 if (verbose) cout << "yes"<< std::endl;
221 } else {
222 if (verbose) cout << "no"<< std::endl;
223 FailedTests++;
224 }
225
226 //-----------------------------------------------------------
227 // Line Search Sublist
228 // (if there are no failures, this will be constructed and added)
229 //-----------------------------------------------------------
230 if (!FailedTests) {
231 int ARI = 0, default_step = 0, max_iter_inc = 0, rec_step = 0;
232 double alpha_factor = 0.0, min_bnds_factor = 0.0, max_bnds_factor = 0.0;
233 bool force_interp = true, use_cntrs = false;
234 std::string ls_method = "Polynomial";
235 // This is to force a char* to be passed into the get method to see if the template
236 // specialization for char* is working.
237 char* ls_method_char = const_cast<char *>(ls_method.c_str());
238 ParameterList PL_My_LineSearch("PL_My_LineSearch");
239 ls_method = PL_My_LineSearch.get("Method", ls_method_char);
240 ParameterList& PL_Polynomial = PL_My_LineSearch.sublist("Polynomial");
241 ARI = PL_Polynomial.get("Allowed Relative Increase", 100 );
242 (void)ARI; // Not used, bad test!
243 alpha_factor = PL_Polynomial.get("Alpha Factor", 0.0001 );
244 (void)alpha_factor; // Not used, bad test!
245 default_step = PL_Polynomial.get("Default Step", 1 );
246 (void)default_step; // Not used, bad test!
247 force_interp = PL_Polynomial.get("Force Interpolation", false );
248 (void)force_interp; // Not used, bad test!
249 std::string interp_type = PL_Polynomial.get("Interpolation Type", "Cubic" );
250 max_bnds_factor = PL_Polynomial.get("Max Bounds Factor", 0.5 );
251 (void)max_bnds_factor; // Not used, bad test!
252 PL_Polynomial.set("Max Iters", 3 );
253 max_iter_inc = PL_Polynomial.get("Maximum Iteration for Increase", 0 );
254 (void)max_iter_inc; // Not used, bad test!
255 min_bnds_factor = PL_Polynomial.get("Min Bounds Factor", 0.1 );
256 (void)min_bnds_factor; // Not used, bad test!
257 rec_step = PL_Polynomial.get("Recovery Step", 1 );
258 (void)rec_step; // Not used, bad test!
259 std::string rec_step_type = PL_Polynomial.get("Recovery Step Type", "Constant");
260 std::string suff_dec_cond = PL_Polynomial.get("Sufficient Decrease Condition", "Armijo-Goldstein" );
261 use_cntrs = PL_Polynomial.get("Use Counters", true );
262 (void)use_cntrs; // Not used, bad test!
263 PL_Main.set("Nonlinear Solver", "Line Search Based");
264
265 //-----------------------------------------------------------
266 // Set the Line Search Parameter List equal to the one just constructed
267 //-----------------------------------------------------------
268 PL_LineSearch.setParameters(PL_My_LineSearch);
269 ParameterList& PL_My_Polynomial = PL_LineSearch.sublist("Polynomial");
270 if (verbose) cout<< "Is 'operator=' functional ... ";
271 if ( PL_My_Polynomial.isParameter("Recovery Step Type") ) {
272 if (verbose) cout<< "yes" << std::endl;
273 } else {
274 if (verbose) cout<< "no" << std::endl;
275 FailedTests++;
276 }
277
278 //-----------------------------------------------------------
279 // Set Copying of parameter sublists and names
280 //-----------------------------------------------------------
281
282 if (verbose) {
283 print_break();
284 if (verbose) cout << "Test copying of sublist\n";
285 print_break();
286 PL_Direction.print(cout);
287 }
288 {
289 const ParameterList
290 &linearSolverPL = PL_Main.sublist("Direction").sublist("Newton").sublist("Line Search");
291 const ParameterList
292 linearSolverPL_copy(linearSolverPL);
293 if (verbose) cout << "linearSolverPL.name() = " << linearSolverPL.name() << endl;
294 if (verbose) cout << "linearSolverPL_copy.name() = " << linearSolverPL_copy.name() << endl;
295 if (verbose) cout << "linearSolverPL_copy == linearSolverPL.name() : ";
296 if (linearSolverPL_copy == linearSolverPL.name()) {
297 if (verbose) cout << "passed" << endl;
298 }
299 else {
300 if (verbose) cout << "failed" << endl;
301 FailedTests++;
302 }
303 }
304
305 if (verbose) {
306 print_break();
307 if (verbose) cout << "General tests\n";
308 print_break();
309 PL_Direction.print(cout);
310 }
311
312 ParameterList Copied_PL_Main(PL_Main);
313
314 if (verbose) cout << "Copied_PL_Main.name() == PL_Main.name() : ";
315 if (Copied_PL_Main.name() == PL_Main.name()) {
316 if (verbose) cout << "passed" << endl;
317 }
318 else {
319 if (verbose) cout << "failed" << endl;
320 FailedTests++;
321 if (verbose) cout << "Copyed_PL_Main.name() = " << Copied_PL_Main.name() << endl;
322 }
323
324 if (verbose) cout<< "Is the copy constructor functional ... ";
325 if ( Copied_PL_Main.isParameter("Nonlinear Solver") ) {
326 if (verbose) cout<< "yes" << std::endl;
327 } else {
328 if (verbose) cout<< "no" << std::endl;
329 FailedTests++;
330 }
331
332 bool tempMeth = true;
333
334 //-----------------------------------------------------------
335 // Check the templated 'get' method.
336 //-----------------------------------------------------------
337 //
338 //-----------------------------------------------------------
339 // Retrieve some information from the parameter list using templated "get" method.
340 // (This will be tested using the INVALID_TEMPLATE_QUALIFIER which indicates whether a
341 // non-templated code needs ".template" before the method name )
342 //-----------------------------------------------------------
343 int max_iters = 0, max_iters_again = 0;
344 std::string nonlin_solver;
345 tempMeth = true;
346 try {
347 max_iters = PL_My_Polynomial.INVALID_TEMPLATE_QUALIFIER get<int>("Max Iters");
348 max_iters_again = Teuchos::getConst(PL_My_Polynomial).INVALID_TEMPLATE_QUALIFIER get<int>("Max Iters");
349 nonlin_solver = PL_Main.INVALID_TEMPLATE_QUALIFIER get<std::string>("Nonlinear Solver");
350 }
351 catch( const Teuchos::Exceptions::InvalidParameter&) { tempMeth = false; }
352 if (verbose) {
353 cout<< "Is the templated 'get' method functional ... "<<std::endl;
354 cout<< " Can we retrieve information using the CORRECT variable type ... ";
355 }
356 if (tempMeth && max_iters==3) { if (verbose) cout << "yes" << std::endl; }
357 else { if (verbose) cout << "no" << std::endl; FailedTests++; }
358 if (verbose) {
359 cout<< " Can we retrieve const information using the CORRECT variable type ... ";
360 }
361 if (tempMeth && max_iters_again==3) { if (verbose) cout << "yes" << std::endl; }
362 else { if (verbose) cout << "no" << std::endl; FailedTests++; }
363
364 //-----------------------------------------------------------
365 // Retrieve some information from the parameter list that we know is a bad "get".
366 // (This will be tested using the INVALID_TEMPLATE_QUALIFIER which indicates whether a
367 // non-templated code needs ".template" before the method name )
368 //-----------------------------------------------------------
369 float mbf = 0.0;
370 tempMeth = false;
371 try {
372 mbf = PL_LinSol.INVALID_TEMPLATE_QUALIFIER get<float>( "Tol" );
373 (void)mbf; // Not used, bad test!
374 FailedTests++;
375 }
377 tempMeth = true;
378 }
379 if (verbose) {
380 cout<< " Can we retrieve information using the WRONG variable type ... ";
381 }
382 if (tempMeth) { if (verbose) cout << "no" << std::endl; }
383 else { if (verbose) cout << "yes" << std::endl; }
384
385 //-----------------------------------------------------------
386 // Retrieve some information from the parameter list using templated "get" method.
387 // (This will be tested using the INVALID_TEMPLATE_QUALIFIER which indicates whether a
388 // non-templated code needs ".template" before the method name )
389 //-----------------------------------------------------------
390 tempMeth = true;
391 try {
392 max_iters = PL_My_Polynomial.INVALID_TEMPLATE_QUALIFIER get<int>("Max Iters");
393 nonlin_solver = PL_Main.INVALID_TEMPLATE_QUALIFIER get<std::string>("Nonlinear Solver");
394 }
395 catch( const Teuchos::Exceptions::InvalidParameter&) { tempMeth = false; }
396 if (verbose) {
397 cout<< "Is the templated 'get' method functional ... "<<std::endl;
398 cout<< " Can we retrieve information using the CORRECT variable type ... ";
399 }
400 if (tempMeth && max_iters==3) { if (verbose) cout << "yes" << std::endl; }
401 else { if (verbose) cout << "no" << std::endl; FailedTests++; }
402
403 //-----------------------------------------------------------
404 // Retrieve some information from the parameter list that we know is a bad "get".
405 //-----------------------------------------------------------
406 tempMeth = false;
407 try {
408 mbf = PL_LinSol.INVALID_TEMPLATE_QUALIFIER get<float>( "Tol" );
409 (void)mbf; // Not used, bad test!
410 FailedTests++;
411 }
413 tempMeth = true;
414 }
415 if (verbose) {
416 cout<< " Can we retrieve information using the WRONG variable type ... ";
417 }
418 if (tempMeth) { if (verbose) cout << "no" << std::endl; }
419 else { if (verbose) cout << "yes" << std::endl; }
420
421 //-----------------------------------------------------------
422 // Check the templated 'getPtr' method.
423 //-----------------------------------------------------------
424
425 //-----------------------------------------------------------
426 // Retrieve some information from the parameter list using templated "get" method.
427 // (This will be tested using the INVALID_TEMPLATE_QUALIFIER which indicates whether a
428 // non-templated code needs ".template" before the method name )
429 //-----------------------------------------------------------
430 int *max_iters_ptr = 0;
431 const int *max_iters_ptr_again = 0;
432 std::string* nonlin_solver_ptr;
433
434 max_iters_ptr = PL_My_Polynomial.INVALID_TEMPLATE_QUALIFIER getPtr<int>("Max Iters");
435 max_iters_ptr_again = Teuchos::getConst(PL_My_Polynomial).INVALID_TEMPLATE_QUALIFIER getPtr<int>("Max Iters");
436 nonlin_solver_ptr = PL_Main.INVALID_TEMPLATE_QUALIFIER getPtr<std::string>("Nonlinear Solver");
437
438 if (verbose) {
439 cout<< "Is the templated 'getPtr' method functional ... "<<std::endl;
440 cout<< " Can we retrieve information using the CORRECT variable type ... ";
441 }
442 if (max_iters_ptr) {
443 if ((*max_iters_ptr)==3) {
444 if (verbose) cout << "yes" << std::endl;
445 }
446 else { if (verbose) cout << "no" << std::endl; FailedTests++; }
447 }
448 if (verbose) {
449 cout<< " Can we retrieve const information using the CORRECT variable type ... ";
450 }
451 if (max_iters_ptr_again) {
452 if ((*max_iters_ptr_again)==3) {
453 if (verbose) cout << "yes" << std::endl;
454 }
455 else { if (verbose) cout << "no" << std::endl; FailedTests++; }
456 }
457
458 //-----------------------------------------------------------
459 // Retrieve some information from the parameter list that we know is a bad "get".
460 // (This will be tested using the INVALID_TEMPLATE_QUALIFIER which indicates whether a
461 // non-templated code needs ".template" before the method name )
462 //-----------------------------------------------------------
463 float* mbf_ptr = 0;
464
465 mbf_ptr = PL_LinSol.INVALID_TEMPLATE_QUALIFIER getPtr<float>( "Tol" );
466
467 if (mbf_ptr)
468 ++FailedTests;
469
470 if (verbose) {
471 cout<< " Can we retrieve information using the WRONG variable type ... ";
472 }
473 if (!mbf_ptr) { if (verbose) cout << "no" << std::endl; }
474 else { if (verbose) cout << "yes" << std::endl; }
475
476 //-----------------------------------------------------------
477 // Retrieve some information from the parameter list using templated "get" method.
478 // (This will be tested using the INVALID_TEMPLATE_QUALIFIER which indicates whether a
479 // non-templated code needs ".template" before the method name )
480 //-----------------------------------------------------------
481
482 max_iters_ptr = PL_My_Polynomial.INVALID_TEMPLATE_QUALIFIER getPtr<int>("Max Iters");
483 nonlin_solver_ptr = PL_Main.INVALID_TEMPLATE_QUALIFIER getPtr<std::string>("Nonlinear Solver");
484 (void)nonlin_solver_ptr; // Not used, bad test!
485
486 if (verbose) {
487 cout<< "Is the templated 'getPtr' method functional ... "<<std::endl;
488 cout<< " Can we retrieve information using the CORRECT variable type ... ";
489 }
490 if (max_iters_ptr) {
491 if ((*max_iters_ptr)==3) {
492 if (verbose) cout << "yes" << std::endl;
493 }
494 else { if (verbose) cout << "no" << std::endl; FailedTests++; }
495 }
496
497 //-----------------------------------------------------------
498 // Retrieve some information from the parameter list that we know is a bad "get".
499 // (This will be tested using the INVALID_TEMPLATE_QUALIFIER which indicates whether a
500 // non-templated code needs ".template" before the method name )
501 //-----------------------------------------------------------
502
503 mbf_ptr = PL_LinSol.INVALID_TEMPLATE_QUALIFIER getPtr<float>( "Tol" );
504
505 if (mbf_ptr)
506 ++FailedTests;
507
508 if (verbose) {
509 cout<< " Can we retrieve information using the WRONG variable type ... ";
510 }
511 if (!mbf_ptr) { if (verbose) cout << "no" << std::endl; }
512 else { if (verbose) cout << "yes" << std::endl; }
513
514 //-----------------------------------------------------------
515 // Check the 'getParameter' helper function.
516 //-----------------------------------------------------------
517 int def_step = 0;
518 double alpha_fact = 0.0;
519 tempMeth = true;
520 try {
521 def_step = Teuchos::getParameter<int>(PL_Polynomial, "Default Step");
522 alpha_fact = Teuchos::getParameter<double>(PL_Polynomial, "Alpha Factor");
523 (void)alpha_fact; // Not used, bad test!
524 }
525 catch( const Teuchos::Exceptions::InvalidParameter&) { tempMeth = false; }
526 if (verbose && def_step==1) {
527 cout<< "Is the helper function 'getParameter' functional ... ";
528 }
529 if (tempMeth) { if (verbose) cout << "yes" << std::endl; }
530 else { if (verbose) cout << "no" << std::endl; FailedTests++; }
531
532 //-----------------------------------------------------------
533 // Check templated isType functionality
534 // (This will be tested using the INVALID_TEMPLATE_QUALIFIER which indicates whether a
535 // non-templated code needs ".template" before the method name )
536 //-----------------------------------------------------------
537 bool PT1, PT2, PT3;
538 PT1 = PL_Polynomial.INVALID_TEMPLATE_QUALIFIER isType<int>("Default Step");
539 PT2 = PL_Polynomial.INVALID_TEMPLATE_QUALIFIER isType<long int>("Default Step");
540 PT3 = PL_Polynomial.INVALID_TEMPLATE_QUALIFIER isType<std::string>("Interpolation Type");
541 if (verbose) {
542 cout<< "Is the templated 'isType' method functional ... "<<std::endl;
543 cout<< " Is the 'Default Step' of type 'int' ... ";
544 }
545 if (PT1) { if (verbose) cout<< "yes" << std::endl; }
546 else { if (verbose) cout<< "no" << std::endl; FailedTests++; }
547 if (verbose) {
548 cout<< " Is the 'Default Step' of type 'long int' ... ";
549 }
550 if (PT2) { if (verbose) cout<< "yes" << std::endl; FailedTests++; }
551 else { if (verbose) cout<< "no (as expected)" << std::endl; }
552 if (verbose) {
553 cout<< " Is the 'Interpolation Type' of type 'std::string' ... ";
554 }
555 if (PT3) { if (verbose) cout<< "yes" << std::endl; }
556 else { if (verbose) cout<< "no" << std::endl; FailedTests++; }
557
558 //-----------------------------------------------------------
559 // Check the 'isParameterType' helper function.
560 //-----------------------------------------------------------
561 bool PT4, PT5;
562 PT4 = Teuchos::isParameterType<double>(PL_Polynomial, "Max Bounds Factor");
563 PT5 = Teuchos::isParameterType<float>(PL_Polynomial, "Max Bounds Factor");
564 if (verbose) {
565 cout<< "Is the helper function 'isParameterType' functional ... "<<std::endl;
566 cout<< " Is the 'Max Bounds Factor' of type 'double' ... ";
567 }
568 if (PT4) { if (verbose) cout<< "yes" <<std::endl; }
569 else { if (verbose) cout<< "no" << std::endl; FailedTests++; }
570 if (verbose) {
571 cout<< " Is the 'Max Bounds Factor' of type 'float' ... ";
572 }
573 if (PT5) { if (verbose) cout<< "yes" <<std::endl; FailedTests++; }
574 else { if (verbose) cout<< "no (as expected)" << std::endl; }
575
576 //-----------------------------------------------------------
577 // Can we pass a pointer to a std::vector to the parameter list.
578 //-----------------------------------------------------------
579 Teuchos::ArrayRCP<double> tempvec1_arcp = Teuchos::arcp<double>(10);
580 {
581 double * tempvec1 = tempvec1_arcp.get();
582 for (int i=0; i<10; i++) { tempvec1[i] = i; }
583 PL_Main.set( "Address of Norm Vector", tempvec1 );
584 double* tempvec2 = Teuchos::getParameter<double*>( PL_Main, "Address of Norm Vector" );
585 tempvec1[4] = 2.0; tempvec1[6] = 1.0;
586 if (verbose) {
587 cout<< "Can we pass a pointer to a std::vector to a parameter list ... ";
588 }
589 if ((tempvec2[4]-tempvec1[4])!=0.0 || (tempvec2[6]-tempvec1[6])!=0.0) {
590 if (verbose) { cout<<"no"<<std::endl; }
591 FailedTests++;
592 } else {
593 if (verbose) { cout<<"yes"<<std::endl; }
594 }
595 }
596
597 //-----------------------------------------------------------
598 // We can add Array<T> objects of various types T as std::string parameters!
599 //-----------------------------------------------------------
600 if(verbose) {
601 print_break();
602 cout << "Setting int and double array objects as std::string parameters ...\n";
603 print_break();
604 }
606 intArray = Teuchos::tuple<int>(0,1,2,3,4,5,6);
608 doubleArray = Teuchos::tuple<double>(0,1.0,2.0,3.0,4.0,5.0,6.0);
609 //const Teuchos::Array<bool>
610 //boolArray = Teuchos::tuple<bool>(true,true,false,false);
611 Teuchos::setStringParameterFromArray("Int Array",intArray,&PL_Main);
612 Teuchos::setStringParameterFromArray("Double Array",doubleArray,&PL_Main);
613 //Teuchos::setStringParameterFromArray("Bool Array",boolArray,&PL_Main);
614 if(verbose) {
615 print_break();
616 cout << "Testing retrieval of set array objects ...\n";
617 print_break();
618 }
619 {
620
622 readIntArray = Teuchos::getArrayFromStringParameter<int>(PL_Main,"Int Array");
623 result = readIntArray == intArray;
624 if(!result) ++FailedTests;
625 if(verbose)
626 cout
627 << "readIntArray = " << readIntArray << " == intArray = " << intArray << " ? "
628 << (result ? "passed" : "failed")
629 << "\n";
630
632 readDoubleAsIntArray = Teuchos::getArrayFromStringParameter<int>(PL_Main,"Double Array");
633 result = readDoubleAsIntArray == intArray;
634 if(!result) ++FailedTests;
635 if(verbose)
636 cout
637 << "readDoubleAsIntArray = " << readDoubleAsIntArray << " == intArray = " << intArray << " ? "
638 << (result ? "passed" : "failed")
639 << "\n";
640
641/*
642 const Teuchos::Array<bool>
643 readBoolArray = Teuchos::getArrayFromStringParameter<bool>(PL_Main,"Bool Array");
644 result = readBoolArray == boolArray;
645 if(!result) ++FailedTests;
646 if(verbose)
647 cout
648 << "readBoolArray = " << readBoolArray << " == boolArray = " << boolArray << " ? "
649 << (result ? "passed" : "failed")
650 << "\n";
651*/
652
653 if(verbose) {
654 print_break();
655 }
656
657 }
658
659 //-----------------------------------------------------------
660 // We can directly set the array strings!
661 //-----------------------------------------------------------
662
663 if(verbose) {
664 print_break();
665 cout << "Setting a array of doubles as a std::string parameter directly ...\n";
666 print_break();
667 }
668
669 PL_Main.set(
670 "Double Array"
671 ," {\n"
672 " 0.00000\n"
673 " ,1.0e0\n"
674 " ,0.2e1\n"
675 " ,30.0e-1\n"
676 " ,4\n"
677 " ,5.0000\n"
678 " ,6\n"
679 " }\n "
680 );
681
682 {
683
685 readDoubleArray = Teuchos::getArrayFromStringParameter<double>(PL_Main,"Double Array");
687 doubleAsIntArray(readDoubleArray.size());
688 for(int i=0;i<static_cast<int>(readDoubleArray.size());++i)
689 doubleAsIntArray[i] = static_cast<int>(readDoubleArray[i]);
690 result = doubleAsIntArray == intArray;
691 if(!result) ++FailedTests;
692 if(verbose)
693 cout
694 << "doubleAsIntArray = " << doubleAsIntArray << " == intArray = " << intArray << " ? "
695 << (result ? "passed" : "failed")
696 << "\n";
697
698 if(verbose) {
699 print_break();
700 }
701
702 }
703
704 //-----------------------------------------------------------
705 // Can we pass a pointer to a function to the parameter list.
706 // Use a simple function, pass it in and get it back out ...
707 // ( HKT 03/23/2004 This test is not supported on Janus )
708 //-----------------------------------------------------------
709#ifndef JANUS_STLPORT
710 double (*pt2Function) (double, double);
711 PL_Main.set( "Address to Simple Function", &Plus );
712 pt2Function = Teuchos::getParameter<double(*)(double,double)>( PL_Main, "Address to Simple Function" );
713 if (verbose) {
714 cout<< "Can we pass a pointer to a function to a parameter list ... ";
715 }
716 if ( pt2Function( 1.0, 2.0 ) != 3.0 ) {
717 if (verbose) cout<<"no"<<std::endl;
718 FailedTests++;
719 } else {
720 if (verbose) cout<<"yes"<<std::endl;
721 }
722#endif
723 }
724
725 //-----------------------------------------------------------
726 // We can store and retrieve void* pointers!
727 //-----------------------------------------------------------
728
729 {
730 ParameterList pl;
731 int someInt = 1;
732 void *someIntPtr = &someInt;
733 pl.set("Some Pointer", someIntPtr);
734 void *someIntPtrRtn = getParameter<void*>(pl, "Some Pointer");
735 TEUCHOS_TEST_FOR_EXCEPT(someIntPtrRtn != someIntPtr);
736 if (verbose)
737 cout << "someIntPtrRtn = " << someIntPtrRtn << " == " << someIntPtr << " : ";
738 if (someIntPtrRtn == someIntPtr) {
739 if (verbose) cout << "passed\n";
740 }
741 else {
742 if (verbose) cout << "failed\n";
743 FailedTests++;
744 }
745 }
746
747 //-----------------------------------------------------------
748 // Print using the public iterators
749 // KL - 7 August 2004
750 //-----------------------------------------------------------
752
753 if (verbose)
754 {
755 print_break();
756 cout << " printing using public iterators "
757 << std::endl;
758 print_break();
759 }
760 for (iter = PL_Main.begin(); iter != PL_Main.end(); ++iter)
761 {
762 const ParameterEntry& val = PL_Main.entry(iter);
763 const std::string& name = PL_Main.name(iter);
764 if (val.isList())
765 {
766 if (verbose) cout << name << std::endl;
767 const ParameterList& sublist = Teuchos::getValue<ParameterList>(val);
769 for (i=sublist.begin(); i != sublist.end(); ++i)
770 {
771 const std::string& nm = sublist.name(i);
772 const ParameterEntry& v = sublist.entry(i);
773 if (v.isList())
774 {
775 if (verbose) cout << " " << nm << std::endl;
776 if (verbose) Teuchos::getValue<ParameterList>(v).print(cout, 6);
777 }
778 else
779 {
780 if (verbose) cout << " " << nm << " " << v << std::endl;
781 }
782 }
783 }
784 else
785 {
786 if (verbose) cout << name << " " << val << std::endl;
787 }
788 }
789
790
791#if defined(HAVE_TEUCHOS_EXTENDED)
792
793 try {
794
795 if (verbose) {
796
797 print_break();
798 cout << "writing to XML std::ostream" << std::endl;
799 print_break();
800 writeParameterListToXmlOStream(PL_Main,cout);
801
802 print_break();
803 cout << "writing to XML file" << std::endl;
804 print_break();
805 writeParameterListToXmlFile(PL_Main,"PL_Main.xml");
806
807 print_break();
808 cout << "reading from XML file" << std::endl;
809 print_break();
810 ParameterList readBack;
811 updateParametersFromXmlFile("PL_Main.xml", inoutArg(readBack));
812 if (verbose) readBack.print(cout);
813
814 print_break();
815 cout << "reading from XML std::string" << std::endl;
816 print_break();
817 std::ifstream xmlInFile("PL_Main.xml");
818 std::string xmlStr;
819 while(!xmlInFile.eof()) {
820 std::string line;
821 std::getline(xmlInFile,line);
822 xmlStr += line + "\n";
823 }
824 readBack = ParameterList();
825 updateParametersFromXmlString(xmlStr, inoutArg(readBack));
826 if (verbose) readBack.print(cout);
827
828 }
829
830 }
831 catch(const std::exception& e)
832 {
833 if(verbose) {
834 std::cerr << "caught std::exception:\n\n";
835 OSTab tab(std::cerr);
836 std::cerr << e.what() << std::endl;
837 }
838 FailedTests++;
839 }
840
841#endif // defined(HAVE_TEUCHOS_EXTENDED)
842
843 //-----------------------------------------------------------
844 // Print out main list
845 //-----------------------------------------------------------
846
847 if (verbose) {
848 print_break();
849 cout << "The Final Parameter List" << std::endl;
850 print_break();
851 PL_Main.print(cout);
852 print_break();
853 cout << "The unused parameters" << std::endl;
854 PL_Main.unused(cout);
855 }
856
857 //-----------------------------------------------------------
858 // Show error outputs
859 //-----------------------------------------------------------
860
861 if (verbose) {
862 print_break();
863 cout << "Accessing a sublist using the wrong name (should throw a Teuchos::Exceptions::InvalidParameterName std::exception)...\n";
864 print_break();
865 }
866 try {
867 PL_Main.sublist("Direction").sublist("Newton").sublist("Linear Solvers",true);
868 if (verbose) cout << "Did not throw std::exception, error!\n";
869 ++FailedTests;
870 }
872 std::cerr << "caught expected Teuchos::Exceptions::InvalidParameterName:\n\n";
873 OSTab tab(std::cerr);
874 std::cerr << e.what() << std::endl;
875 }
876 if (verbose) {
877 print_break();
878 cout << "Accessing a parameter using the wrong name (should throw a Teuchos::Exceptions::InvalidParameterName std::exception)...\n";
879 print_break();
880 }
881 try {
882 Teuchos::getParameter<int>(PL_Main.sublist("Direction").sublist("Newton").sublist("Linear Solver"),"Tolerances");
883 if (verbose) cout << "Did not throw std::exception, error!\n";
884 ++FailedTests;
885 }
887 if(verbose) {
888 std::cerr << "caught expected Teuchos::Exceptions::InvalidParameterName:\n\n";
889 OSTab tab(std::cerr);
890 std::cerr << e.what() << std::endl;
891 }
892 }
893 catch(const std::exception &e) {
894 if(verbose) {
895 std::cerr << "caught unexpected std::exception:\n\n";
896 OSTab tab(std::cerr);
897 std::cerr << e.what() << std::endl;
898 }
899 ++FailedTests;
900 }
901
902 if (verbose) {
903 print_break();
904 cout << "Accessing a parameter using the wrong parameter type (should throw a Teuchos::Exceptions::InvalidParameterType std::exception)...\n";
905 print_break();
906 }
907 try {
908 Teuchos::getParameter<int>(PL_Main.sublist("Direction").sublist("Newton").sublist("Linear Solver"),"Tolerance");
909 if (verbose) cout << "Did not throw std::exception, error!\n";
910 ++FailedTests;
911 }
913 if(verbose) {
914 std::cerr << "caught expected Teuchos::Exceptions::InvalidParameterType:\n\n";
915 OSTab tab(std::cerr);
916 std::cerr << e.what() << std::endl;
917 }
918 }
919 catch(const std::exception &e) {
920 if(verbose) {
921 std::cerr << "caught unexpected std::exception:\n\n";
922 OSTab tab(std::cerr);
923 std::cerr << e.what() << std::endl;
924 }
925 ++FailedTests;
926 }
927
928 //-----------------------------------------------------------
929 // Validate the parameter list
930 //-----------------------------------------------------------
931
932 // Create a validator version of PL_Main that we will validate against!
933 Teuchos::ParameterList PL_Main_valid("PL_Main_copy");
934 PL_Main_valid.setParameters(PL_Main);
935
936 // Create a validator for the "Nonlinear Solver" parameter
937 Teuchos::setStringToIntegralParameter<int>(
938 "Nonlinear Solver", "Line Search Based",
939 "Selects the type of nonlinear solver to use",
940 Teuchos::tuple<std::string>("Line Search Based","Trust Region Based"),
941 &PL_Main
942 );
943
944/*
945 Teuchos::RCP<Teuchos::StringToIntegralParameterEntryValidator<int> >
946 nonlinearSolverValidator = rcp(
947 new Teuchos::StringToIntegralParameterEntryValidator<int>(
948 Teuchos::tuple<std::string>("Line Search Based","Trust Region Based")
949 ,"Nonlinear Solver"
950 )
951 );
952 PL_Main_valid.set(
953 "Nonlinear Solver", "Line Search Based"
954 ,"Selects the type of nonlinear solver to use"
955 ,nonlinearSolverValidator
956 );
957*/
958
959 // Create a validator for the parameter "Line Search"->"Polynomial"->"Max Iters"
960 // that accepts an 'int', a 'double' or a 'std::string' value!
963 linesearchMaxItersValiator = rcp(
966 AcceptedTypes(false).allowInt(true).allowDouble(true).allowString(true)
967 )
968 );
969 PL_Main_valid.sublist("Line Search").sublist("Polynomial").set(
970 "Max Iters",3
971 ,"The maximum number of inner linear search iterations allowed."
972 ,linesearchMaxItersValiator
973 );
974
975 // Create a validator for the parameter "Direction"->"Newton"->"Linear Solver"->"Tol"
976 // that accepts a 'double' or a 'std::string' value!
979 linSolveTolValidator = rcp(
982 AcceptedTypes(false).allowDouble(true).allowString(true)
983 )
984 );
985 PL_Main_valid.sublist("Direction",true).sublist("Newton",true)
986 .sublist("Linear Solver",true).set(
987 "Tol", double(1e-5)
988 ,"Select the linear solve tolerance"
989 ,linSolveTolValidator
990 );
991
992 if (verbose) {
993 print_break();
994 cout << "Validating the parameter list against itself (should not throw std::exception)...\n";
995 print_break();
996 }
997 try {
998 PL_Main.validateParameters(PL_Main_valid);
999 if (verbose) cout << "Did not throw std::exception, success!\n\n";
1000 }
1001 catch(const std::exception &e) {
1002 if(verbose) {
1003 std::cerr << "caught unexpected std::exception:\n\n";
1004 OSTab tab(std::cerr);
1005 std::cerr << e.what() << std::endl;
1006 }
1007 ++FailedTests;
1008 }
1009
1010 if (verbose) {
1011 print_break();
1012 cout << "Adding an invalid parameter type then validating (should throw a Teuchos::Exceptions::InvalidParameterType std::exception)...\n";
1013 print_break();
1014 }
1015 try {
1016 PL_Main.sublist("Line Search").sublist("Polynomial").set("Max Iters",(short int)(3)); // Should be an int!
1017 PL_Main.validateParameters(PL_Main_valid);
1018 if (verbose) cout << "Did not throw std::exception, error!\n";
1019 ++FailedTests;
1020 }
1022 if(verbose) {
1023 std::cerr << "caught expected Teuchos::Exceptions::InvalidParameterType:\n\n";
1024 OSTab tab(std::cerr);
1025 std::cerr << e.what() << std::endl;
1026 }
1027 }
1028 catch(const std::exception &e) {
1029 if(verbose) {
1030 std::cerr << "caught unexpected std::exception:\n\n";
1031 OSTab tab(std::cerr);
1032 std::cerr << e.what() << std::endl;
1033 }
1034 ++FailedTests;
1035 }
1036 PL_Main.sublist("Line Search").sublist("Polynomial").set("Max Iters",3); // Put back the valid int!
1037
1038 if (verbose) {
1039 print_break();
1040 cout << "Adding an invalid parameter name then validating (should throw a Teuchos::Exceptions::InvalidParameterName std::exception)...\n";
1041 print_break();
1042 }
1043 try {
1044 PL_Main.sublist("Line Search").sublist("Polynomial").set("Max Iter",10);
1045 PL_Main.validateParameters(PL_Main_valid);
1046 if (verbose) cout << "Did not throw std::exception, error!\n";
1047 ++FailedTests;
1048 }
1050 if(verbose) {
1051 std::cerr << "caught expected Teuchos::Exceptions::InvalidParameterName:\n\n";
1052 OSTab tab(std::cerr);
1053 std::cerr << e.what() << std::endl;
1054 }
1055 }
1056 catch(const std::exception &e) {
1057 if(verbose) {
1058 std::cerr << "caught unexpected std::exception:\n\n";
1059 OSTab tab(std::cerr);
1060 std::cerr << e.what() << std::endl;
1061 }
1062 ++FailedTests;
1063 }
1064 PL_Main.sublist("Line Search").sublist("Polynomial").remove("Max Iter");
1065
1066 if (verbose) {
1067 print_break();
1068 cout << "Adding an invalid parameter type then validating using validator (should throw a Teuchos::Exceptions::InvalidParameterType std::exception)...\n";
1069 print_break();
1070 }
1071 try {
1072 PL_Main.set("Nonlinear Solver",int(0)); // Should be a std::string!
1073 PL_Main.validateParameters(PL_Main_valid);
1074 if (verbose) cout << "Did not throw std::exception, error!\n";
1075 ++FailedTests;
1076 }
1078 if(verbose) {
1079 std::cerr << "caught expected Teuchos::Exceptions::InvalidParameterType:\n\n";
1080 OSTab tab(std::cerr);
1081 std::cerr << e.what() << std::endl;
1082 }
1083 }
1084 catch(const std::exception &e) {
1085 if(verbose) {
1086 std::cerr << "caught unexpected std::exception:\n\n";
1087 OSTab tab(std::cerr);
1088 std::cerr << e.what() << std::endl;
1089 }
1090 ++FailedTests;
1091 }
1092 PL_Main.set("Nonlinear Solver","Line Search Based"); // Put back the valid value!
1093
1094 if (verbose) {
1095 print_break();
1096 cout << "Adding an invalid parameter value then validating using validator (should throw a Teuchos::Exceptions::InvalidParameterValue std::exception)...\n";
1097 print_break();
1098 }
1099 try {
1100 PL_Main.set("Nonlinear Solver","LineSearch Based"); // Should be "Line Search Based"!
1101 PL_Main.validateParameters(PL_Main_valid);
1102 if (verbose) cout << "Did not throw std::exception, error!\n";
1103 ++FailedTests;
1104 }
1106 if(verbose) {
1107 std::cerr << "caught expected Teuchos::Exceptions::InvalidParameterValue:\n\n";
1108 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1109 }
1110 }
1111 catch(const std::exception &e) {
1112 if(verbose) {
1113 std::cerr << "caught unexpected std::exception:\n\n";
1114 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1115 }
1116 ++FailedTests;
1117 }
1118 PL_Main.set("Nonlinear Solver","Line Search Based"); // Put back the valid value!
1119
1120 if (verbose) {
1121 print_break();
1122 cout << "Use the validator to access integral value (should *not* throw std::exception)...\n";
1123 print_break();
1124 }
1125 try {
1126 const int
1127 nonlinearSolverValue = Teuchos::getIntegralValue<int>(PL_Main,"Nonlinear Solver");
1128 const bool
1129 l_result = (nonlinearSolverValue == 0);
1130 cout
1131 << "Read value = " << nonlinearSolverValue << " == 0 : "
1132 << ( l_result ? "passed" : "failed") << "\n";
1133 if(!l_result) ++FailedTests;
1134 }
1135 catch(const std::exception &e) {
1136 if(verbose) {
1137 std::cerr << "caught unexpected std::exception:\n\n";
1138 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1139 }
1140 ++FailedTests;
1141 }
1142
1143 if (verbose) {
1144 print_break();
1145 cout << "Use the validator to access std::string value (should *not* throw std::exception)...\n";
1146 print_break();
1147 }
1148 try {
1149 const std::string
1150 nonlinearSolverValue = Teuchos::getStringValue<int>(PL_Main,"Nonlinear Solver");
1151 const bool
1152 l_result = (nonlinearSolverValue == "Line Search Based");
1153 cout
1154 << "Read value = \"" << nonlinearSolverValue << " == \"Line Search Based\" : "
1155 << ( l_result ? "passed" : "failed") << "\n";
1156 if(!l_result) ++FailedTests;
1157 }
1158 catch(const std::exception &e) {
1159 if(verbose) {
1160 std::cerr << "caught unexpected std::exception:\n\n";
1161 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1162 }
1163 ++FailedTests;
1164 }
1165
1166 //-----------------------------------------------------------
1167 // Validate and set defaults
1168 //-----------------------------------------------------------
1169
1170 // Set the default parameters for an emplty list
1171 ParameterList validatedPL;
1172
1173 if (verbose) {
1174 print_break();
1175 cout << "Validating and setting defaults for an empty parameter list (should not throw) ...\n";
1176 print_break();
1177 }
1178 try {
1179 validatedPL.validateParametersAndSetDefaults(PL_Main_valid);
1180 if (verbose) cout << "Did not throw std::exception, success!\n\n";
1181 }
1182 catch(const std::exception &e) {
1183 if(verbose) {
1184 std::cerr << "caught unexpected std::exception:\n\n";
1185 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1186 }
1187 ++FailedTests;
1188 }
1189
1190 if (verbose) {
1191 print_break();
1192 cout << "Parameter list with defaults set:" << std::endl;
1193 print_break();
1194 validatedPL.print(cout,PLPrintOptions().showTypes(true).showDoc(true));
1195 print_break();
1196 }
1197
1198 if (verbose) {
1199 print_break();
1200 cout << "Checking that validatedPL and PL_Main_valid have the same values : ";
1201 }
1202 result = haveSameValues(validatedPL,PL_Main_valid);
1203 if(!result)
1204 ++FailedTests;
1205 if (verbose) {
1206 cout << ( result ? "passed" : "failed" ) << "\n";
1207 print_break();
1208 }
1209
1210 //
1211 // Testing access of numbers using validator where validator is not buried
1212 // in the parameter
1213 //
1214
1215 for( int type_i = 0; type_i < 3; ++type_i ) {
1216
1217 ParameterList &Polynomial_sublist
1218 = PL_Main.sublist("Line Search",true).sublist("Polynomial",true);
1219
1220 std::string typeName;
1221
1222 // Set the input type
1223
1224 switch(type_i) {
1225 case 0:
1226 typeName = "int";
1227 Polynomial_sublist.set("Max Iters",(int)(3));
1228 break;
1229 case 1:
1230 typeName = "double";
1231 Polynomial_sublist.set("Max Iters",(double)(3.0));
1232 break;
1233 case 2:
1234 typeName = "std::string";
1235 Polynomial_sublist.set("Max Iters",(std::string)("3"));
1236 break;
1237 default:
1239 }
1240
1241 // Extract using external validator
1242
1243 if (verbose) {
1244 print_break();
1245 cout << "Use the external number validator to access a "<<typeName<<" as an int ...\n";
1246 print_break();
1247 }
1248 try {
1249 const int
1250 lineserchMaxIters
1251 = linesearchMaxItersValiator->getInt(
1252 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1253 ,"Max Iters",0
1254 );
1255 const bool
1256 l_result = (lineserchMaxIters == int(3));
1257 cout
1258 << "Read value = " << lineserchMaxIters << " == 3 : "
1259 << ( l_result ? "passed" : "failed") << "\n";
1260 if(!l_result) ++FailedTests;
1261 }
1262 catch(const std::exception &e) {
1263 if(verbose) {
1264 std::cerr << "caught unexpected std::exception:\n\n";
1265 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1266 }
1267 ++FailedTests;
1268 }
1269
1270 if (verbose) {
1271 print_break();
1272 cout << "Use the external number validator to access a "<<typeName<<" as a double ...\n";
1273 print_break();
1274 }
1275 try {
1276 const double
1277 lineserchMaxIters
1278 = linesearchMaxItersValiator->getDouble(
1279 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1280 ,"Max Iters",0.0
1281 );
1282 const bool
1283 l_result = (lineserchMaxIters == double(3.0));
1284 cout
1285 << "Read value = " << lineserchMaxIters << " == 3 : "
1286 << ( l_result ? "passed" : "failed") << "\n";
1287 if(!l_result) ++FailedTests;
1288 }
1289 catch(const std::exception &e) {
1290 if(verbose) {
1291 std::cerr << "caught unexpected std::exception:\n\n";
1292 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1293 }
1294 ++FailedTests;
1295 }
1296
1297 if (verbose) {
1298 print_break();
1299 cout << "Use the external number validator to access a "<<typeName<<" as a std::string ...\n";
1300 print_break();
1301 }
1302 try {
1303 const std::string
1304 lineserchMaxIters
1305 = linesearchMaxItersValiator->getString(
1306 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1307 ,"Max Iters","0"
1308 );
1309 const bool
1310 l_result = (lineserchMaxIters == "3");
1311 cout
1312 << "Read value = \"" << lineserchMaxIters << "\" == \"3\" : "
1313 << ( l_result ? "passed" : "failed") << "\n";
1314 if(!l_result) ++FailedTests;
1315 }
1316 catch(const std::exception &e) {
1317 if(verbose) {
1318 std::cerr << "caught unexpected std::exception:\n\n";
1319 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1320 }
1321 ++FailedTests;
1322 }
1323
1324 // Extract using nonmember functions
1325
1326 if (verbose) {
1327 print_break();
1328 cout << "Use the nomember help function to access a "<<typeName<<" as an int ...\n";
1329 print_break();
1330 }
1331 try {
1332 const int
1333 lineserchMaxIters
1334 = Teuchos::getIntParameter(
1335 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1336 ,"Max Iters"
1337 );
1338 const bool
1339 l_result = (lineserchMaxIters == int(3));
1340 cout
1341 << "Read value = " << lineserchMaxIters << " == 3 : "
1342 << ( l_result ? "passed" : "failed") << "\n";
1343 if(!l_result) ++FailedTests;
1344 }
1345 catch(const std::exception &e) {
1346 if(verbose) {
1347 std::cerr << "caught unexpected std::exception:\n\n";
1348 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1349 }
1350 ++FailedTests;
1351 }
1352
1353 if (verbose) {
1354 print_break();
1355 cout << "Use the nomember help function to access a "<<typeName<<" as a double ...\n";
1356 print_break();
1357 }
1358 try {
1359 const double
1360 lineserchMaxIters
1361 = Teuchos::getDoubleParameter(
1362 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1363 ,"Max Iters"
1364 );
1365 const bool
1366 l_result = (lineserchMaxIters == double(3.0));
1367 cout
1368 << "Read value = " << lineserchMaxIters << " == 3 : "
1369 << ( l_result ? "passed" : "failed") << "\n";
1370 if(!l_result) ++FailedTests;
1371 }
1372 catch(const std::exception &e) {
1373 if(verbose) {
1374 std::cerr << "caught unexpected std::exception:\n\n";
1375 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1376 }
1377 ++FailedTests;
1378 }
1379
1380 if (verbose) {
1381 print_break();
1382 cout << "Use the nomember help function to access a "<<typeName<<" as a std::string ...\n";
1383 print_break();
1384 }
1385 try {
1386 const std::string
1387 lineserchMaxIters
1388 = Teuchos::getNumericStringParameter(
1389 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1390 ,"Max Iters"
1391 );
1392 const bool
1393 l_result = (lineserchMaxIters == "3");
1394 cout
1395 << "Read value = \"" << lineserchMaxIters << "\" == \"3\" : "
1396 << ( l_result ? "passed" : "failed") << "\n";
1397 if(!l_result) ++FailedTests;
1398 }
1399 catch(const std::exception &e) {
1400 if(verbose) {
1401 std::cerr << "caught unexpected std::exception:\n\n";
1402 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1403 }
1404 ++FailedTests;
1405 }
1406
1407 }
1408
1409 //
1410 // Testing access of numbers using validator where validator is buried in
1411 // the parameter
1412 //
1413
1414 for( int type_i = 0; type_i < 4; ++type_i ) {
1415
1416 ParameterList &Polynomial_sublist
1417 = PL_Main.sublist("Line Search",true).sublist("Polynomial",true);
1418
1419 std::string typeName;
1420
1421 // Set the input type
1422
1423 switch(type_i) {
1424 case 0:
1425 typeName = "int";
1426 Teuchos::setIntParameter("Max Iters",3,"",&Polynomial_sublist);
1427 break;
1428 case 1:
1429 typeName = "double";
1430 Teuchos::setDoubleParameter("Max Iters",3.0,"",&Polynomial_sublist);
1431 break;
1432 case 2:
1433 typeName = "std::string";
1434 Teuchos::setNumericStringParameter("Max Iters","3","",&Polynomial_sublist);
1435 break;
1436 case 3:
1437 typeName = "long long";
1438 Teuchos::setLongLongParameter("Max Iters",3,"",&Polynomial_sublist);
1439 break;
1440 default:
1442 }
1443
1444 // Extract using nonmember functions (which should use the internal validator)
1445
1446 if (verbose) {
1447 print_break();
1448 cout << "Use the nomember help function to access a "<<typeName<<" as an int ...\n";
1449 print_break();
1450 }
1451 try {
1452 const int
1453 lineserchMaxIters
1454 = Teuchos::getIntParameter(
1455 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1456 ,"Max Iters"
1457 );
1458 const bool
1459 l_result = (lineserchMaxIters == int(3));
1460 cout
1461 << "Read value = " << lineserchMaxIters << " == 3 : "
1462 << ( l_result ? "passed" : "failed") << "\n";
1463 if(!l_result) ++FailedTests;
1464 }
1465 catch(const std::exception &e) {
1466 if(verbose) {
1467 std::cerr << "caught unexpected std::exception:\n\n";
1468 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1469 }
1470 ++FailedTests;
1471 }
1472
1473 if (verbose) {
1474 print_break();
1475 cout << "Use the nomember help function to access a "<<typeName<<" as a double ...\n";
1476 print_break();
1477 }
1478 try {
1479 const double
1480 lineserchMaxIters
1481 = Teuchos::getDoubleParameter(
1482 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1483 ,"Max Iters"
1484 );
1485 const bool
1486 l_result = (lineserchMaxIters == double(3.0));
1487 cout
1488 << "Read value = " << lineserchMaxIters << " == 3 : "
1489 << ( l_result ? "passed" : "failed") << "\n";
1490 if(!l_result) ++FailedTests;
1491 }
1492 catch(const std::exception &e) {
1493 if(verbose) {
1494 std::cerr << "caught unexpected std::exception:\n\n";
1495 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1496 }
1497 ++FailedTests;
1498 }
1499
1500 if (verbose) {
1501 print_break();
1502 cout << "Use the nomember help function to access a "<<typeName<<" as a std::string ...\n";
1503 print_break();
1504 }
1505 try {
1506 const std::string
1507 lineserchMaxIters
1508 = Teuchos::getNumericStringParameter(
1509 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1510 ,"Max Iters"
1511 );
1512 const bool
1513 l_result = (lineserchMaxIters == "3");
1514 cout
1515 << "Read value = \"" << lineserchMaxIters << "\" == \"3\" : "
1516 << ( l_result ? "passed" : "failed") << "\n";
1517 if(!l_result) ++FailedTests;
1518 }
1519 catch(const std::exception &e) {
1520 if(verbose) {
1521 std::cerr << "caught unexpected std::exception:\n\n";
1522 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1523 }
1524 ++FailedTests;
1525 }
1526
1527 if (verbose) {
1528 print_break();
1529 cout << "Use the nomember help function to access a "<<typeName<<" as an long long ...\n";
1530 print_break();
1531 }
1532 try {
1533 const long long
1534 lineserchMaxIters
1535 = Teuchos::getLongLongParameter(
1536 PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1537 ,"Max Iters"
1538 );
1539 const bool
1540 l_result = (lineserchMaxIters == (long long)(3));
1541 cout
1542 << "Read value = " << lineserchMaxIters << " == 3 : "
1543 << ( l_result ? "passed" : "failed") << "\n";
1544 if(!l_result) ++FailedTests;
1545 }
1546 catch(const std::exception &e) {
1547 if(verbose) {
1548 std::cerr << "caught unexpected std::exception:\n\n";
1549 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1550 }
1551 ++FailedTests;
1552 }
1553
1554 }
1555
1556 //
1557 // Testing access of numbers where correct number is set using
1558 // validateParametersAndSetDefaults(...) with no special access.
1559 //
1560
1561 for( int type_i = 0; type_i < 3; ++type_i ) {
1562
1563 ParameterList valid_PL_Main(PL_Main);
1564
1565 ParameterList &Polynomial_sublist
1566 = PL_Main.sublist("Line Search",true).sublist("Polynomial",true);
1567
1568 std::string typeName;
1569
1570 // Set the input type
1571
1572 switch(type_i) {
1573 case 0:
1574 typeName = "int";
1575 Teuchos::setIntParameter("Max Iters",3,"",&Polynomial_sublist);
1576 break;
1577 case 1:
1578 typeName = "double";
1579 Teuchos::setDoubleParameter("Max Iters",3.0,"",&Polynomial_sublist);
1580 break;
1581 case 2:
1582 typeName = "std::string";
1583 Teuchos::setNumericStringParameter("Max Iters","3","",&Polynomial_sublist);
1584 break;
1585 default:
1587 }
1588
1589 // Extract using nonmember functions (which should use the internal validator)
1590
1591 if (verbose) {
1592 print_break();
1593 cout << "Use validateParemetersAndSetDefaults(...) to access a "<<typeName<<" as an int ...\n";
1594 print_break();
1595 }
1596 try {
1597 Teuchos::setIntParameter(
1598 "Max Iters", 0, "",
1599 &valid_PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1600 );
1601 ParameterList copied_PL_Main(PL_Main);
1602 copied_PL_Main.validateParametersAndSetDefaults(valid_PL_Main);
1603 const int
1604 lineserchMaxIters
1605 = Teuchos::getParameter<int>(
1606 copied_PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1607 ,"Max Iters"
1608 );
1609 const bool
1610 l_result = (lineserchMaxIters == int(3));
1611 cout
1612 << "Read value = " << lineserchMaxIters << " == 3 : "
1613 << ( l_result ? "passed" : "failed") << "\n";
1614 if(!l_result) ++FailedTests;
1615 }
1616 catch(const std::exception &e) {
1617 if(verbose) {
1618 std::cerr << "caught unexpected std::exception:\n\n";
1619 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1620 }
1621 ++FailedTests;
1622 }
1623
1624 if (verbose) {
1625 print_break();
1626 cout << "Use validateParemetersAndSetDefaults(...) to access a "<<typeName<<" as a double ...\n";
1627 print_break();
1628 }
1629 try {
1630 Teuchos::setDoubleParameter(
1631 "Max Iters", 0.0, "",
1632 &valid_PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1633 );
1634 ParameterList copied_PL_Main(PL_Main);
1635 copied_PL_Main.validateParametersAndSetDefaults(valid_PL_Main);
1636 const double
1637 lineserchMaxIters
1638 = Teuchos::getParameter<double>(
1639 copied_PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1640 ,"Max Iters"
1641 );
1642 const bool
1643 l_result = (lineserchMaxIters == double(3.0));
1644 cout
1645 << "Read value = " << lineserchMaxIters << " == 3 : "
1646 << ( l_result ? "passed" : "failed") << "\n";
1647 if(!l_result) ++FailedTests;
1648 }
1649 catch(const std::exception &e) {
1650 if(verbose) {
1651 std::cerr << "caught unexpected std::exception:\n\n";
1652 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1653 }
1654 ++FailedTests;
1655 }
1656
1657 if (verbose) {
1658 print_break();
1659 cout << "Use validateParemetersAndSetDefaults(...) to access a "<<typeName<<" as a std::string ...\n";
1660 print_break();
1661 }
1662 try {
1663 Teuchos::setNumericStringParameter(
1664 "Max Iters", "0", "",
1665 &valid_PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1666 );
1667 ParameterList copied_PL_Main(PL_Main);
1668 copied_PL_Main.validateParametersAndSetDefaults(valid_PL_Main);
1669 const std::string
1670 lineserchMaxIters
1671 = Teuchos::getParameter<std::string>(
1672 copied_PL_Main.sublist("Line Search",true).sublist("Polynomial",true)
1673 ,"Max Iters"
1674 );
1675 const bool
1676 l_result = (lineserchMaxIters == "3");
1677 cout
1678 << "Read value = \"" << lineserchMaxIters << "\" == \"3\" : "
1679 << ( l_result ? "passed" : "failed") << "\n";
1680 if(!l_result) ++FailedTests;
1681 }
1682 catch(const std::exception &e) {
1683 if(verbose) {
1684 std::cerr << "caught unexpected std::exception:\n\n";
1685 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1686 }
1687 ++FailedTests;
1688 }
1689
1690 }
1691
1692 if (verbose) {
1693 print_break();
1694 cout << "Adding an invalid sublist then validating (should throw a Teuchos::Exceptions::InvalidParameterName std::exception)...\n";
1695 print_break();
1696 }
1697 try {
1698 PL_Main.sublist("Line Search").sublist("Polynomials").set("Max Iters",3); // param correct, sublist wrong
1699 PL_Main.validateParameters(PL_Main_valid);
1700 if (verbose) cout << "Did not throw std::exception, error!\n";
1701 ++FailedTests;
1702 }
1704 if(verbose) {
1705 std::cerr << "caught expected Teuchos::Exceptions::InvalidParameterName:\n\n";
1706 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1707 }
1708 }
1709 catch(const std::exception &e) {
1710 if(verbose) {
1711 std::cerr << "caught unexpected std::exception:\n\n";
1712 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1713 }
1714 ++FailedTests;
1715 }
1716 PL_Main.sublist("Line Search").remove("Polynomials");
1717
1718 if (verbose) {
1719 print_break();
1720 cout << "Validating only the top level list (should not throw std::exception)...\n";
1721 print_break();
1722 }
1723 try {
1724 PL_Main.validateParameters(PL_Main_valid,0);
1725 if (verbose) cout << "Did not throw std::exception, success!\n\n";
1726 }
1727 catch(const std::exception &e) {
1728 if(verbose) {
1729 std::cerr << "caught unexpected std::exception:\n\n";
1730 OSTab tab(std::cerr); std::cerr << e.what() << std::endl;
1731 }
1732 ++FailedTests;
1733 }
1734
1735 //-----------------------------------------------------------
1736 // Compare lists
1737 //-----------------------------------------------------------
1738
1739 if (verbose) {
1740 print_break();
1741 cout << "Checking that PL_Main == PL_Main == true : ";
1742 }
1743 result = (PL_Main == PL_Main);
1744 if(!result)
1745 ++FailedTests;
1746 if (verbose) {
1747 cout << ( result ? "passed" : "failed" ) << "\n";
1748 print_break();
1749 }
1750
1751 if (verbose) {
1752 print_break();
1753 cout << "Checking that PL_Main != PL_Main == false : ";
1754 }
1755 result = !(PL_Main != PL_Main);
1756 if(!result)
1757 ++FailedTests;
1758 if (verbose) {
1759 cout << ( result ? "passed" : "failed" ) << "\n";
1760 print_break();
1761 }
1762
1763 if (verbose) {
1764 print_break();
1765 cout << "Checking that PL_Main and PL_Main have the same values : ";
1766 }
1767 result = haveSameValues(PL_Main,PL_Main);
1768 if(!result)
1769 ++FailedTests;
1770 if (verbose) {
1771 cout << ( result ? "passed" : "failed" ) << "\n";
1772 print_break();
1773 }
1774
1775 if (verbose) {
1776 print_break();
1777 cout << "Create copy PL_Main_copy, change PL_Main_copy, and check that PL_Main != PL_Main == true : ";
1778 }
1779 ParameterList PL_Main_copy(PL_Main);
1780 PL_Main_copy.sublist("Line Search",true).sublist("Polynomial",true).set("Max Iters",100); // Not the default!
1781 result = (PL_Main_copy != PL_Main);
1782 if(!result)
1783 ++FailedTests;
1784 if (verbose) {
1785 cout << ( result ? "passed" : "failed" ) << "\n";
1786 print_break();
1787 }
1788
1789 //-----------------------------------------------------------
1790 // Print out main list showing the types
1791 //-----------------------------------------------------------
1792
1793 if (verbose) {
1794 print_break();
1795 cout << "The Final Parameter List with Types and Documentation" << std::endl;
1796 print_break();
1797 PL_Main.print(cout,PLPrintOptions().showTypes(true).showDoc(true));
1798 print_break();
1799 cout << "The unused parameters" << std::endl;
1800 PL_Main.unused(cout);
1801 print_break();
1802 cout << "Number of Failed Tests : " << FailedTests << std::endl;
1803 print_break();
1804 }
1805
1806 //-----------------------------------------------------------
1807 // Return -1 if there are any failed tests,
1808 // else 0 will be returned indicating a clean finish!
1809 //-----------------------------------------------------------
1810
1811 } // end try
1812 TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose,std::cerr,success);
1813 if(!success) ++FailedTests;
1814
1815 if ( FailedTests > 0 ) {
1816 cout << "End Result: TEST FAILED" << std::endl;
1817 return 1; // Can't return negative numbers from main()!
1818 }
1819
1820 if ( FailedTests == 0 )
1821 cout << "End Result: TEST PASSED" << std::endl;
1822
1823 return 0;
1824
1825}
1826
Basic command line parser for input from (argc,argv[])
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Templated Parameter List class.
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
Simple helper functions that make it easy to read and write XML to and from a parameterlist.
Standard implementation of a ParameterEntryValidator that accepts numbers from a number of different ...
Reference-counted smart pointer for managing arrays.
T * get() const
Get the raw C++ pointer to the underlying object.
Replacement for std::vector that is compatible with the Teuchos Memory Management classes.
size_type size() const
Class that helps parse command line input arguments from (argc,argv[]) and set options.
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
Set a boolean option.
EParseCommandLineReturn
Return value for CommandLineProcessor::parse(). Note: These enums are all given non-negative values s...
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
Parse a command line.
Initialize, finalize, and query the global MPI session.
static int getRank()
The rank of the calling process in MPI_COMM_WORLD.
This object is held as the "value" in the Teuchos::ParameterList std::map.
std::string docString() const
Return the (optional) documentation std::string.
bool isList() const
Return whether or not the value itself is a list.
A list of parameters of arbitrary type.
ParameterList & setParameters(const ParameterList &source)
const ParameterEntry & entry(ConstIterator i) const
Access to ParameterEntry (i.e., returns i->second)
ConstIterator end() const
An iterator pointing beyond the last entry.
void validateParameters(ParameterList const &validParamList, int const depth=1000, EValidateUsed const validateUsed=VALIDATE_USED_ENABLED, EValidateDefaults const validateDefaults=VALIDATE_DEFAULTS_ENABLED) const
Validate the parameters in this list given valid selections in the input list.
void unused(std::ostream &os) const
Print out unused parameters in the ParameterList.
void validateParametersAndSetDefaults(ParameterList const &validParamList, int const depth=1000)
Validate the parameters in this list given valid selections in the input list and set defaults for th...
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Creates an empty sublist and returns a reference to the sublist name. If the list already exists,...
ParameterList & set(std::string const &name, T const &value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Set a parameter whose value has type T.
void print() const
Print function to use in debugging in a debugger.
const std::string & name() const
The name of this ParameterList.
bool isSublist(const std::string &name) const
Whether the given sublist exists in this list.
ParameterEntry * getEntryPtr(const std::string &name)
Retrieves the pointer for an entry with the name name if it exists.
params_t::ConstIterator ConstIterator
Parameter container const iterator typedef.
ConstIterator begin() const
An iterator pointing to the first entry.
bool isParameter(const std::string &name) const
Whether the given parameter exists in this list.
T & get(const std::string &name, T def_value)
Return the parameter's value, or the default value if it is not there.
bool remove(std::string const &name, bool throwIfNotExists=true)
Remove a parameter (does not depend on the type of the parameter).
Smart reference counting pointer class for automatic garbage collection.
Tabbing class for helping to create formated, indented output for a basic_FancyOStream object.
basic_FancyOStream< CharT, Traits > & o() const
int main()
Definition: evilMain.cpp:75
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
This macro is designed to be a short version of TEUCHOS_TEST_FOR_EXCEPTION() that is easier to call.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
const T & getConst(T &t)
Return a constant reference to an object given a non-const reference.
std::string Teuchos_Version()
double Plus(double a, double b)
ParameterList::PrintOptions PLPrintOptions