|
AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects Version of the Day
|
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 <assert.h> 00030 #include <math.h> 00031 00032 #include "AbstractLinAlgPack_VectorSpaceTesterSetOptions.hpp" 00033 #include "OptionsFromStreamPack_StringToBool.hpp" 00034 00035 // Define the options 00036 namespace { 00037 00038 const int local_num_options = 6; 00039 00040 enum local_EOptions { 00041 PRINT_ALL_TESTS 00042 ,PRINT_VECTORS 00043 ,TEST_FOR_EXCEPTION 00044 ,NUM_RANDOM_TESTS 00045 ,WARNING_TOL 00046 ,ERROR_TOL 00047 }; 00048 00049 const char* local_SOptions[local_num_options] = { 00050 "print_all_tests" 00051 ,"print_vectors" 00052 ,"throw_exception" 00053 ,"num_random_tests" 00054 ,"warning_tol" 00055 ,"error_tol" 00056 }; 00057 00058 } 00059 00060 namespace AbstractLinAlgPack { 00061 00062 VectorSpaceTesterSetOptions::VectorSpaceTesterSetOptions( 00063 VectorSpaceTester* target 00064 , const char opt_grp_name[] ) 00065 : OptionsFromStreamPack::SetOptionsFromStreamNode( 00066 opt_grp_name, local_num_options, local_SOptions ) 00067 , OptionsFromStreamPack::SetOptionsToTargetBase< 00068 VectorSpaceTester >( target ) 00069 {} 00070 00071 void VectorSpaceTesterSetOptions::setOption( 00072 int option_num, const std::string& option_value ) 00073 { 00074 using OptionsFromStreamPack::StringToBool; 00075 typedef VectorSpaceTester target_t; 00076 switch( (local_EOptions)option_num ) { 00077 case PRINT_ALL_TESTS: 00078 target().print_all_tests( 00079 StringToBool( "print_all_tests", option_value.c_str() ) 00080 ); 00081 break; 00082 case PRINT_VECTORS: 00083 target().print_vectors( 00084 StringToBool( "print_vectors", option_value.c_str() ) 00085 ); 00086 break; 00087 case TEST_FOR_EXCEPTION: 00088 target().throw_exception( 00089 StringToBool( "throw_exception", option_value.c_str() ) 00090 ); 00091 break; 00092 case NUM_RANDOM_TESTS: 00093 target().num_random_tests(std::abs(std::atoi(option_value.c_str()))); 00094 break; 00095 case WARNING_TOL: 00096 target().warning_tol(std::abs(std::atof(option_value.c_str()))); 00097 break; 00098 case ERROR_TOL: 00099 target().error_tol(std::abs(std::atof(option_value.c_str()))); 00100 break; 00101 default: 00102 TEST_FOR_EXCEPT(true); // Local error only? 00103 } 00104 } 00105 00106 } // end namespace AbstractLinAlgPack
1.7.4