|
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 <math.h> 00030 00031 #include <ostream> 00032 00033 #include "AbstractLinAlgPack_VectorSpaceTester.hpp" 00034 #include "AbstractLinAlgPack_VectorSpace.hpp" 00035 #include "AbstractLinAlgPack_VectorMutable.hpp" 00036 #include "AbstractLinAlgPack_VectorStdOps.hpp" 00037 #include "AbstractLinAlgPack_VectorOut.hpp" 00038 #include "TestingHelperPack_update_success.hpp" 00039 #include "Teuchos_TestForException.hpp" 00040 00041 00042 //#define ALAP_VECTOR_SPACE_TESTER_DUMP 00043 00044 #ifdef ALAP_VECTOR_SPACE_TESTER_DUMP 00045 # include "RTOpPack_SPMD_apply_op.hpp" 00046 #endif // ALAP_VECTOR_SPACE_TESTER_DUMP 00047 00048 00049 namespace { 00050 template< class T > 00051 inline 00052 T my_max( const T& v1, const T& v2 ) { return v1 > v2 ? v1 : v2; } 00053 template< class T > 00054 inline 00055 T my_min( const T& v1, const T& v2 ) { return v1 < v2 ? v1 : v2; } 00056 } // end namespace 00057 00058 00059 namespace AbstractLinAlgPack { 00060 00061 00062 VectorSpaceTester::VectorSpaceTester( 00063 bool print_all_tests 00064 ,bool print_vectors 00065 ,bool throw_exception 00066 ,size_type num_random_tests 00067 ,value_type warning_tol 00068 ,value_type error_tol 00069 ) 00070 :print_all_tests_(print_all_tests) 00071 ,print_vectors_(print_vectors) 00072 ,throw_exception_(throw_exception) 00073 ,num_random_tests_(num_random_tests) 00074 ,warning_tol_(warning_tol) 00075 ,error_tol_(error_tol) 00076 {} 00077 00078 bool VectorSpaceTester::check_vector_space( 00079 const VectorSpace &space, 00080 std::ostream *out 00081 ) const 00082 { 00083 00084 using Teuchos::as; 00085 00086 bool success = true, result = false; 00087 00088 try { 00089 00090 // Adapted from test_my_vector_library(...) 00091 00092 const value_type 00093 rand_l = -10.0, 00094 rand_u = +10.0; 00095 00096 typedef VectorMutable::vec_ptr_t vec_ptr_t; 00097 typedef VectorMutable::vec_mut_ptr_t vec_mut_ptr_t; 00098 00099 // Create three random non-mutable vectors 00100 vec_ptr_t v_array[3]; 00101 const Vector* v[3]; 00102 {for(int k = 0; k < 3; ++k) { 00103 vec_mut_ptr_t r = space.create_member(); 00104 random_vector( rand_l, rand_u, r.get() ); 00105 v_array[k] = r; 00106 v[k] = v_array[k].get(); 00107 }} 00108 00109 // Create six random mutable vectors 00110 vec_mut_ptr_t z_array[6]; 00111 VectorMutable* z[6]; 00112 {for(int k = 0; k < 6; ++k) { 00113 random_vector( rand_l, rand_u, (z_array[k]= space.create_member()).get() ); 00114 z[k] = z_array[k].get(); 00115 }} 00116 00117 if(out && print_all_tests()) 00118 *out << std::boolalpha 00119 << "\n**************************************************" 00120 << "\n*** VectorSpaceTester::check_vector_space(...) ***" 00121 << "\n**************************************************\n"; 00122 00123 index_type 00124 n = space.dim(); 00125 RTOp_value_type 00126 err = 0.0, 00127 max_err = 0.0, 00128 sum_err = 0.0; 00129 char z_name[20], v_name[20]; 00130 00131 // Print the vector space dimension 00132 if(out && print_all_tests()) 00133 *out << "\nspace->dim() = " << n << std::endl; 00134 00135 // Print the initial vectors 00136 if(out && print_vectors()) { 00137 *out << "\n*** Printing the immutable vectors\n"; 00138 {for(int j = 0; j < 3; ++j) { 00139 sprintf( v_name, "v[%d]", j ); 00140 *out << std::endl << v_name << " : " << typeName(*v[j]) << std::endl 00141 << *v[j]; 00142 }} 00143 *out << "\n*** Printing the mutable vectors\n"; 00144 {for(int k = 0; k < 6; ++k) { 00145 sprintf( z_name, "z[%d]", k ); 00146 *out << std::endl << z_name << " : " << typeName(*z[k]) << std::endl 00147 << *z[k]; 00148 }} 00149 } 00150 00152 if(out && print_all_tests()) 00153 *out << "\n*** Testing the obvious assertions\n"; 00154 { 00155 {for(int k = 0; k < 6; ++k) { 00156 const Vector *vec = NULL; 00157 if( k < 3 ) { 00158 sprintf( v_name, "v[%d]", k ); 00159 vec = v[k]; 00160 } 00161 else { 00162 sprintf( v_name, "z[%d]", k-3 ); 00163 vec = z[k-3]; 00164 } 00165 00166 result = vec->space().is_compatible(space); 00167 if(out && (print_all_tests() || !result)) 00168 *out << "\ncheck: " << v_name << "->space().is_compatible(space) : " << result << std::endl; 00169 check_test( result ? 0.0 : -10.0 , out, &success ); 00170 00171 result = space.is_compatible(vec->space()); 00172 if(out && (print_all_tests() || !result)) 00173 *out << "check: space.is_compatible(" << v_name << "->space()) : " << result << std::endl; 00174 check_test( result ? 0.0 : -10.0 , out, &success ); 00175 00176 err = vec->dim() - space.dim(); 00177 if(out && (print_all_tests() || !result)) 00178 *out << "check: " << v_name << "->dim() - space.dim() = " << vec->dim() << " - " 00179 << space.dim() << " = " << err << std::endl; 00180 check_test( err , out, &success ); 00181 00182 result = vec->nz() <= space.dim(); 00183 if(out && (print_all_tests() || !result)) 00184 *out << "check: " << v_name << "->nz() <= space.dim() = " << vec->nz() << " <= " << space.dim() 00185 << " : " << result << std::endl; 00186 check_test( result ? 0.0 : -10.0 , out, &success ); 00187 00188 }} 00189 } 00190 00192 if(out && print_all_tests()) 00193 *out << "\n*** Testing scalar assignment and element access methods\n"; 00194 { 00195 const index_type k = 0; 00196 sprintf( z_name, "z[%d]", k ); 00197 if(out && print_all_tests()) 00198 *out << "\n0.0 -> " << z_name << std::endl; 00199 *z[k] = 0.0; 00200 if(out && print_vectors()) 00201 *out << std::endl << z_name << " =\n" << *z[k]; 00202 {for(index_type r = 0; r < num_random_tests(); ++r) { 00203 std::srand( n / (1+r) + r ); // This is very important in a parallel program! 00204 const index_type 00205 i = my_min( 00206 n, 00207 my_max( 00208 as<index_type>(((double)std::rand() / RAND_MAX) * n + 1.0), 00209 as<index_type>(1) 00210 ) 00211 ); 00212 const RTOp_value_type 00213 val = 10.0; 00214 00215 if(out && print_all_tests()) 00216 *out << std::endl << z_name << ".set_ele("<<i<<","<<val<<")\n"; 00217 #ifdef ALAP_VECTOR_SPACE_TESTER_DUMP 00218 RTOpPack::show_spmd_apply_op_dump = true; 00219 #endif 00220 z[k]->set_ele(i,val); 00221 #ifdef ALAP_VECTOR_SPACE_TESTER_DUMP 00222 RTOpPack::show_spmd_apply_op_dump = false; 00223 #endif 00224 if(out && print_vectors()) 00225 *out << std::endl << z_name << " =\n" << *z[k]; 00226 #ifdef ALAP_VECTOR_SPACE_TESTER_DUMP 00227 RTOpPack::show_spmd_apply_op_dump = true; 00228 #endif 00229 RTOp_value_type 00230 val_get = z[k]->get_ele(i); 00231 #ifdef ALAP_VECTOR_SPACE_TESTER_DUMP 00232 RTOpPack::show_spmd_apply_op_dump = false; 00233 #endif 00234 err = val - val_get; 00235 if(out && (print_all_tests() || ::fabs(err) >= warning_tol()) ) 00236 *out << "check: " << val << " - " << z_name << ".get_ele(" << i << ") = " 00237 << val << " - " << val_get << " = " << err << std::endl; 00238 check_test(err,out,&success); 00239 00240 RTOp_value_type 00241 z_k_sum = sum(*z[k]); 00242 err = val - z_k_sum; 00243 if(out && (print_all_tests() || ::fabs(err) >= warning_tol()) ) 00244 *out << "check: " << val << " - sum(" << z_name << ") = " 00245 << val << " - " << z_k_sum << " = " << err << std::endl; 00246 check_test(err,out,&success); 00247 00248 if(out && print_all_tests()) 00249 *out << z_name << ".set_ele("<<i<<",0.0)\n"; 00250 z[k]->set_ele(i,0.0); 00251 if(out && print_vectors()) 00252 *out << std::endl << z_name << " =\n" << *z[k]; 00253 z_k_sum = sum(*z[k]); 00254 err = z_k_sum; 00255 if(out && (print_all_tests() || ::fabs(err) >= warning_tol()) ) 00256 *out << "check: sum(" << z_name << ") = " << z_k_sum << std::endl; 00257 check_test(err,out,&success); 00258 }} 00259 } 00260 00262 if(out && print_all_tests()) 00263 *out << "\n*** Testing vector assignment\n"; 00264 { 00265 {for( int k = 0; k < 3; ++k ) { 00266 sprintf( z_name, "z[%d]", k ); 00267 sprintf( v_name, "v[%d]", k ); 00268 if(out && print_all_tests()) 00269 *out << "\n" << v_name << " -> " << z_name << "\n"; 00270 *z[k] = *v[k]; 00271 const RTOp_value_type 00272 sum_z_k = sum(*z[k]), 00273 sum_v_k = sum(*v[k]); 00274 err = (sum_z_k - sum_v_k)/n; 00275 if(out && (print_all_tests() || ::fabs(err) >= warning_tol()) ) 00276 *out << "check: (sum(" << z_name << ") - sum(" << v_name << "))/n = (" 00277 << sum_z_k << " - " << sum_v_k << ")/" << n << " = " << err << std::endl; 00278 check_test(err,out,&success); 00279 }} 00280 } 00281 00282 /* 00283 00285 if(out && print_all_tests()) 00286 *out << "\n*** Testing sub-vector and sub-space access\n"; 00287 { 00288 const index_type k = 0; 00289 sprintf( z_name, "z[%d]", k ); 00290 if(out && print_all_tests()) 00291 *out << "\n0.0 -> " << z_name << std::endl; 00292 *z[k] = 0.0; 00293 if(out && print_vectors()) 00294 *out << std::endl << z_name << " =\n" << *z[k]; 00295 {for(int r = 0; r < num_random_tests(); ++r) { 00296 index_type 00297 i1 = my_min( n, (index_type)(((double)rand() / RAND_MAX) * n + 1) ), 00298 i2 = my_min( n, (index_type)(((double)rand() / RAND_MAX) * n + 1) ); 00299 if( i1 > i2 ) std::swap( i1, i2 ); 00300 index_type 00301 sub_vec_dim = i2-i1+1; 00302 const RTOp_value_type 00303 val = 10.0; 00304 00305 if(out && print_all_tests()) 00306 *out << "\nsub_vec_mut = " << z_name 00307 << ".sub_view(" << i1 << "," << i2 << ")\n"; 00308 VectorMutable::vec_mut_ptr_t 00309 sub_vec_mut = z[k]->sub_view(i1,i2); 00310 if(out && print_all_tests()) 00311 *out << "sub_vec_mut = " << val << std::endl; 00312 *sub_vec_mut = val; 00313 if(out && print_vectors()) 00314 *out << std::endl << z_name << " =\n" << *z[k]; 00315 00316 err = sub_vec_dim - sub_vec_mut->dim(); 00317 if(out && (print_all_tests() || ::fabs(err) >= warning_tol())) 00318 *out << "check: ("<<i2<<"-"<<i1<<"+1) - sub_vec_mut.dim() = " 00319 << sub_vec_dim <<" - " << sub_vec_mut->dim() << " = " << err << std::endl; 00320 check_test(err,out,&success); 00321 00322 if(out && print_all_tests()) 00323 *out << "\nsub_space = space.sub_space(" << i1 << "," << i2 << ")\n"; 00324 VectorSpace::space_ptr_t 00325 sub_space = space.sub_space(i1,i2); 00326 00327 result = sub_vec_mut->space().is_compatible(*sub_space); 00328 if(out && (print_all_tests() || !result)) 00329 *out << "check: sub_vec_mut->space().is_compatible(*sub_space) : " << result << std::endl; 00330 check_test( result ? 0.0 : -10.0 , out, &success ); 00331 00332 result = sub_space->is_compatible(sub_vec_mut->space()); 00333 if(out && (print_all_tests() || !result)) 00334 *out << "check: sub_space->is_compatible(*sub_vec_mut->space()) : " << result << std::endl; 00335 check_test( result ? 0.0 : -10.0 , out, &success ); 00336 00337 RTOp_value_type 00338 expected_sum = val*sub_vec_dim, 00339 z_k_sum = sum( *z[k] ); 00340 err = (expected_sum - z_k_sum)/sub_vec_mut->dim(); 00341 if(out && (print_all_tests() || ::fabs(err) >= warning_tol())) 00342 *out << "check: ("<<val<<"*("<<i2<<"-"<<i1<<"+1) - sum("<<z_name<<"))/"<<sub_vec_dim 00343 << " = ("<<expected_sum<<" - "<<z_k_sum<<")/"<<sub_vec_dim<<" = "<<err<<std::endl; 00344 check_test(err,out,&success); 00345 00346 if(out && print_all_tests()) 00347 *out << "sub_vec = "<<z_name<<"{const}.sub_view("<<i1<<","<<i2<<")\n"; 00348 Vector::vec_ptr_t 00349 sub_vec = static_cast<const Vector*>(z[k])->sub_view(i1,i2); 00350 00351 err = sub_vec_dim - sub_vec->dim(); 00352 if(out && print_all_tests()) 00353 *out << "check: ("<<i2<<"-"<<i1<<"+1) - sub_vec.dim() = " 00354 << sub_vec_dim << " - " << sub_vec->dim() << " = " << err << std::endl; 00355 check_test(err,out,&success); 00356 00357 expected_sum = val*sub_vec_dim; 00358 z_k_sum = sum(*sub_vec); 00359 err = (expected_sum - z_k_sum)/sub_vec_mut->dim(); 00360 if(out && print_all_tests()) 00361 *out << "check: ("<<val<<"*("<<i2<<"-"<<i1<<"+1) - sum(sub_vec))/"<<sub_vec_dim 00362 << " = ("<<expected_sum<<" - "<<z_k_sum<<")/"<<sub_vec_dim<<" = "<<err<<std::endl; 00363 00364 if(out && print_all_tests()) 00365 *out << "sub_vec_mut = 0.0\n"; 00366 *sub_vec_mut = 0.0; 00367 if(out && print_vectors()) 00368 *out << std::endl << z_name << " =\n" << *z[k]; 00369 }} 00370 } 00371 00373 if(out && print_all_tests()) 00374 *out << "\n*** Testing explicit sub-vector access\n"; 00375 { 00376 const index_type k = 0; 00377 const Vector 00378 &v_from = *v[k]; 00379 sprintf( v_name, "v[%d]", k ); 00380 VectorMutable 00381 &z_to = *z[k]; 00382 sprintf( z_name, "z[%d]", k ); 00383 00384 if(out && print_all_tests()) 00385 *out << "\n0.0 -> " << z_name << std::endl; 00386 *z[k] = 0.0; 00387 if(out && print_vectors()) 00388 *out << std::endl << z_name << " =\n" << *z[k]; 00389 00390 {for(int r = 0; r < num_random_tests(); ++r) { 00391 const index_type // Get random small sub-vectors so parallel efficiency will be good 00392 i1 = my_min( n, (index_type)(((double)rand() / RAND_MAX) * n + 1) ), 00393 i2 = my_min( (index_type)(i1 + ((double)rand() / RAND_MAX) * 9), n ); 00394 const index_type 00395 sub_vec_dim = i2-i1+1; 00396 00397 if(out && print_all_tests()) 00398 *out << std::endl << v_name << ".get_sub_vector(Rang1D("<<i1<<","<<i2<<"),SPARSE,&sub_vec)\n"; 00399 RTOpPack::SubVector sub_vec; 00400 v_from.get_sub_vector(Range1D(i1,i2),&sub_vec); 00401 00402 err = sub_vec_dim - sub_vec.subDim(); 00403 if(out && (print_all_tests() || ::fabs(err) >= warning_tol())) 00404 *out << "check: ("<<i2<<"-"<<i1<<"+1) - sub_vec.subDim() = " 00405 << sub_vec_dim << " - " << sub_vec.subDim() << " = " << err << std::endl; 00406 check_test(err,out,&success); 00407 00408 if(out && print_all_tests()) 00409 *out << z_name << ".set_sub_vector(sub_vec)\n"; 00410 RTOpPack::SparseSubVector spc_sub_vec( sub_vec ); 00411 z_to.set_sub_vector(spc_sub_vec); 00412 if(out && print_vectors()) 00413 *out << std::endl << z_name << " =\n" << z_to; 00414 00415 const RTOp_value_type 00416 v_sub_vec_sum = sum(*v_from.sub_view(i1,i2)), 00417 z_sum = sum(z_to); 00418 err = (v_sub_vec_sum - z_sum)/sub_vec_dim; 00419 if(out && (print_all_tests() || ::fabs(err) >= warning_tol())) 00420 *out << "check: (sum(*"<<v_name<<".sub_view("<<i1<<","<<i2<<"))-sum("<<z_name<<"))/sub_vec.subDim()" 00421 " = ("<<v_sub_vec_sum<<"-"<<z_sum<<")/"<<sub_vec_dim<<" = "<<err<<std::endl; 00422 00423 if(out && print_all_tests()) 00424 *out << v_name << ".free_sub_vector(&sub_vec)\n"; 00425 v_from.free_sub_vector(&sub_vec); 00426 00427 if(out && print_all_tests()) 00428 *out << "*" << z_name<<".sub_view("<<i1<<","<<i2<<") = 0.0\n"; 00429 *z_to.sub_view(i1,i2) = 0.0; 00430 if(out && print_vectors()) 00431 *out << std::endl << z_name << " =\n" << z_to; 00432 00433 }} 00434 } 00435 00436 */ 00437 00439 if(out && print_all_tests()) 00440 *out << "\n*** Testing norms\n"; 00441 if(n > 1) { 00442 const index_type k = 0; 00443 sprintf( z_name, "z[%d]", k ); 00444 00445 const value_type val1 = -2.0, val2 = 3.0; 00446 const index_type i_mid = n/2; 00447 00448 if(out && print_all_tests()) 00449 *out << std::endl << val1 << " -> *" << z_name << ".sub_view(1,"<<i_mid<<")\n"; 00450 *z[k]->sub_view(1,i_mid) = val1; 00451 if(out && print_all_tests()) 00452 *out << val2 << " -> *" << z_name << ".sub_view("<<i_mid+1<<","<<n<<")\n"; 00453 *z[k]->sub_view(i_mid+1,n) = val2; 00454 if(out && print_vectors()) 00455 *out << std::endl << z_name << " =\n" << *z[k] << std::endl; 00456 00457 value_type 00458 norm_1 = z[k]->norm_1(), 00459 expect_norm_1 = (::fabs(val1)*(i_mid) + ::fabs(val2)*(n-i_mid)); 00460 err = (norm_1 - expect_norm_1)/n; 00461 if(out && (print_all_tests() || ::fabs(err) >= warning_tol()) ) 00462 *out << "check: (" << z_name << "->norm_1() - |"<<val1<<"|*("<<i_mid<<")+" 00463 << "|"<<val2<<"|*("<<n<<"-"<<i_mid<<"))/"<<n 00464 <<" = ("<<norm_1<<" - "<<expect_norm_1<<")/"<<n<<" = "<<err<<std::endl; 00465 check_test(err,out,&success); 00466 00467 value_type 00468 norm_2 = z[k]->norm_2(), 00469 expect_norm_2 = ::sqrt(val1*val1*(i_mid) + val2*val2*(n-i_mid)); 00470 err = (norm_2 - expect_norm_2)/n; 00471 if(out && (print_all_tests() || ::fabs(err) >= warning_tol()) ) 00472 *out << "check: (" << z_name << "->norm_2() - ("<<val1<<")^2*("<<i_mid<<")+" 00473 << "("<<val2<<")^2*("<<n<<"-"<<i_mid<<"))/"<<n 00474 <<" = ("<<norm_2<<" - "<<expect_norm_2<<")/"<<n<<" = "<<err<<std::endl; 00475 check_test(err,out,&success); 00476 00477 value_type 00478 norm_inf = z[k]->norm_inf(), 00479 expect_norm_inf = my_max(::fabs(val1),::fabs(val2)); 00480 err = (norm_inf - expect_norm_inf)/n; 00481 if(out && (print_all_tests() || ::fabs(err) >= warning_tol()) ) 00482 *out << "check: (" << z_name << "->norm_inf() - max(|"<<val1<<"|," 00483 << "|"<<val2<<"|)/"<<n<<" = ("<<norm_inf<<" - "<<expect_norm_inf<<")/"<<n 00484 <<" = "<<err<<std::endl; 00485 check_test(err,out,&success); 00486 00487 } 00488 else { 00489 if(out && print_all_tests()) 00490 *out << "space.dim() <= 1, can't test the norms...\n"; 00491 } 00492 00494 if(out && print_all_tests()) 00495 *out << "\n*** Testing clone() method\n"; 00496 { 00497 if(out && print_all_tests()) 00498 *out << "\n(*vec = space.create_member()) = v[0]\n"; 00499 VectorSpace::vec_mut_ptr_t 00500 vec = space.create_member(); 00501 *vec = *v[0]; 00502 if(out && print_all_tests()) 00503 *out << "vec_clone = vec->clone()\n"; 00504 VectorSpace::vec_mut_ptr_t 00505 vec_clone = vec->clone(); 00506 if(out && print_all_tests()) 00507 *out << "vec = NULL\n"; 00508 vec = Teuchos::null; 00509 const value_type 00510 sum_vec = sum(*v[0]), 00511 sum_vec_clone = sum(*vec_clone); 00512 err = (sum_vec - sum_vec_clone)/n; 00513 if(out && (print_all_tests() || ::fabs(err) >= warning_tol()) ) 00514 *out << "check: (sum(v[0]) - sum(vec_clone))/n = (" 00515 << sum_vec << " - " << sum_vec_clone << ")/" << n 00516 << " = " << err << std::endl; 00517 check_test(err,out,&success); 00518 } 00519 00520 } // end try 00521 catch(const std::exception& except) { 00522 if(out) 00523 *out << "Caught a std::exception: " << except.what() << std::endl; 00524 success = false; 00525 if(throw_exception()) 00526 throw; 00527 } 00528 catch(...) { 00529 if(out) 00530 *out << "Caught an unknown exception!\n"; 00531 success = false; 00532 if(throw_exception()) 00533 throw; 00534 } 00535 00536 return success; 00537 } 00538 00539 void VectorSpaceTester::check_test(value_type err, std::ostream* out, bool* success) const 00540 { 00541 if( ::fabs(err) >= error_tol() ) *success = false; 00542 if(out && (print_all_tests() || ::fabs(err) >= warning_tol()) ) { 00543 if( ::fabs(err) >= error_tol() ) 00544 *out << "Error! |" << err << "| = " << ::fabs(err) << " >= error_tol = " 00545 << error_tol() << std::endl; 00546 else if( ::fabs(err) >= warning_tol() ) 00547 *out << "Warning! |" << err << "| = " << ::fabs(err) << " >= warning_tol = " 00548 << warning_tol() << std::endl; 00549 } 00550 TEST_FOR_EXCEPTION( 00551 !*success && this->throw_exception(), std::logic_error 00552 ,"VectorSpaceTester::check_test(...): Error! |" << err << "| = " << ::fabs(err) << " >= error_tol = " 00553 << error_tol() << std::endl ); 00554 } 00555 00556 } // end namespace AbstractLinAlgPack
1.7.4