47 #include "AbstractLinAlgPack_BasisSystemTester.hpp" 48 #include "AbstractLinAlgPack_BasisSystem.hpp" 49 #include "AbstractLinAlgPack_VectorSpace.hpp" 50 #include "AbstractLinAlgPack_VectorMutable.hpp" 51 #include "AbstractLinAlgPack_VectorStdOps.hpp" 52 #include "AbstractLinAlgPack_VectorOut.hpp" 53 #include "AbstractLinAlgPack_MatrixOpNonsing.hpp" 54 #include "AbstractLinAlgPack_MatrixOpOut.hpp" 55 #include "AbstractLinAlgPack_MatrixComposite.hpp" 56 #include "AbstractLinAlgPack_assert_print_nan_inf.hpp" 57 #include "AbstractLinAlgPack_LinAlgOpPack.hpp" 65 ,size_type num_random_tests
66 ,value_type warning_tol
69 :print_tests_(print_tests)
71 ,throw_exception_(throw_exception)
72 ,num_random_tests_(num_random_tests)
73 ,warning_tol_(warning_tol)
74 ,error_tol_(error_tol)
93 using AbstractLinAlgPack::assert_print_nan_inf;
95 using LinAlgOpPack::V_StMtV;
96 using LinAlgOpPack::V_MtV;
103 bool success =
true, result, lresult, llresult;
107 small_num = ::pow(std::numeric_limits<value_type>::epsilon(),0.25),
118 *out <<
"\n*************************************************" 119 <<
"\n*** BasisSystemTester::test_basis_system(...) ***" 120 <<
"\n*************************************************\n";
122 *out <<
"\n||Gc||inf = " << Gc->
calc_norm(mat_nrm_inf).value;
124 *out <<
"\n||C||inf = " << C->
calc_norm(mat_nrm_inf).value;
125 *out <<
"\ncond_inf(C) = " << C->
calc_cond_num(mat_nrm_inf).value;
128 *out <<
"\n||N||inf = " << N_in->
calc_norm(mat_nrm_inf).value;
130 *out <<
"\n||D||inf = " << D->
calc_norm(mat_nrm_inf).value;
132 *out <<
"\n||GcUP||inf = " << GcUP->
calc_norm(mat_nrm_inf).value;
136 *out <<
"\nGc =\n" << *Gc;
138 *out <<
"\nC =\n" << *C;
140 *out <<
"\nN =\n" << *N_in;
142 *out <<
"\nD =\n" << *D;
144 *out <<
"\nGcUP =\n" << *GcUP;
160 <<
"\nbs.var_dep() = ["<<var_dep.
lbound()<<
","<<var_dep.
ubound()<<
"]" 161 <<
"\nbs.var_indep( ) = ["<<var_indep.lbound()<<
","<<var_indep.ubound()<<
"]" 162 <<
"\nbs.equ_decomp() = ["<<equ_decomp.lbound()<<
","<<equ_decomp.ubound()<<
"]" 163 <<
"\nbs.equ_undecomp() = ["<<equ_undecomp.lbound()<<
","<<equ_undecomp.ubound()<<
"]" 168 *out <<
"\n1) Check the partitioning ranges ...";
172 *out <<
"\n\n1.a) check: var_dep.size() != equ_decomp.size() : ";
173 result = var_dep.
size() == equ_decomp.size();
175 *out << ( result ?
"passed" :
"failed" );
176 if(!result) lresult =
false;
180 *out <<
"\n1.b) check: var_dep.size() + var_indep.size() == Gc->rows() : ";
181 result = var_dep.
size() + var_indep.size() == Gc->
rows();
183 *out << ( result ?
"passed" :
"failed" );
184 if(!result) lresult =
false;
189 *out <<
"\n1.d) check: equ_decomp.size() + equ_undecomp.size() == Gc->cols() : ";
190 result = equ_decomp.size() + equ_undecomp.size() == Gc->
cols();
192 *out << ( result ?
"passed" :
"failed" );
193 if(!result) lresult =
false;
199 if(!lresult) success =
false;
201 *out <<
" : " << ( lresult ?
"passed" :
"failed" );
204 Teuchos::RCP<const AbstractLinAlgPack::MatrixOp>
205 N = Teuchos::rcp(N_in,
false);
206 if( Gc && C && N.get() == NULL ) {
209 <<
"\nCreating the matrix N since it was not input by the client ...";
213 Teuchos::RCP<AbstractLinAlgPack::MatrixComposite>
215 if( equ_decomp.size() )
216 N_comp->add_matrix( 0, 0, 1.0, equ_decomp, Gc, Teuchos::null,
BLAS_Cpp::trans, var_indep );
217 N_comp->finish_construction(
221 if( out && dump_all() )
222 *out <<
"\nN =\n" << *N_comp;
227 if( equ_undecomp.size() ) {
228 TEUCHOS_TEST_FOR_EXCEPT(
true);
239 <<
"\n2) Check the compatibility of the vector spaces for C, N, D and Gc ...";
244 <<
"\n2.a) Check consistency of the vector spaces for:" 245 <<
"\n C.space_cols() == N.space_cols()";
248 *out <<
"\n\n2.a.1) C->space_cols().is_compatible(N->space_cols()) == true : ";
251 *out << ( result ?
"passed" :
"failed" )
253 if(!result) llresult =
false;
254 if(!llresult) lresult =
false;
256 *out <<
" : " << ( llresult ?
"passed" :
"failed" );
261 <<
"\n2.b) Check consistency of the vector spaces for:" 262 <<
"\n D.space_cols() == C.space_cols() and D.space_rows() == N.space_rows()";
265 *out <<
"\n2.b.1) D->space_cols().is_compatible(C->space_cols()) == true : ";
268 *out << ( result ?
"passed" :
"failed" );
269 if(!result) llresult =
false;
271 *out <<
"\n2.b.2) D->space_rows().is_compatible(N->space_rows()) == true : ";
274 *out << ( result ?
"passed" :
"failed" )
276 if(!result) llresult =
false;
277 if(!llresult) lresult =
false;
279 *out <<
" : " << ( llresult ?
"passed" :
"failed" );
284 <<
"\n2.c) Check consistency of the vector spaces for:" 285 <<
"\n Gc'(equ_decomp, var_dep) == C";
287 if( equ_decomp.size() ) {
289 *out <<
"\n2.c.1) Gc->space_rows().sub_space(equ_decomp)->is_compatible(*C->space_cols().sub_space(equ_decomp)) == true : ";
292 *out << ( result ?
"passed" :
"failed" );
293 if(!result) llresult =
false;
295 *out <<
"\n2.c.2) Gc->space_cols().sub_space(var_dep)->is_compatible(C->space_rows()) == true : ";
298 *out << ( result ?
"passed" :
"failed" );
299 if(!result) llresult =
false;
303 if(!llresult) lresult =
false;
305 *out <<
" : " << ( llresult ?
"passed" :
"failed" );
309 <<
"\n2.d) Check consistency of the vector spaces for:" 310 <<
"\n Gc'(equ_decomp, var_indep) == N";
312 if( equ_decomp.size() ) {
314 *out <<
"\n2.d.1) Gc->space_rows().sub_space(equ_decomp)->is_compatible(*N->space_cols().sub_space(equ_decomp)) == true : ";
315 result = Gc->
space_rows().
sub_space(equ_decomp)->is_compatible(*N->space_cols().sub_space(equ_decomp));
317 *out << ( result ?
"passed" :
"failed" );
318 if(!result) llresult =
false;
320 *out <<
"\n2.d.2) Gc->space_cols().sub_space(var_indep)->is_compatible(N->space_rows()) == true : ";
323 *out << ( result ?
"passed" :
"failed" );
324 if(!result) llresult =
false;
328 if(!llresult) lresult =
false;
330 *out <<
" : " << ( llresult ?
"passed" :
"failed" )
333 if(!lresult) success =
false;
335 *out <<
" : " << ( lresult ?
"passed" :
"failed" );
339 <<
"\n3) Check the compatibility of the matrices C, N, D and Gc numerically ...";
344 <<
"\n3.a) Check consistency of:" 346 <<
"\n op ( alpha* [ Gc'(equ_decomp, var_dep) Gc'(equ_decomp, var_indep) ] ) * v" 347 <<
"\n \\______________________________________________________________/" 349 <<
"\n == op( alpha*[ C N ] ) * v" 350 <<
"\n \\____________/" 352 <<
"\nfor random vectors v ...";
360 N_v_xI = N->space_rows().create_member(),
361 N_v_chD = N->space_cols().create_member(),
363 v_x_tmp = v_x->space().create_member(),
364 v_chD = C_v_xD->space().create_member(),
365 v_chD_tmp = v_chD->space().create_member();
368 *out <<
"\n\n3.a.1) Testing non-transposed A*v == B*v ...";
372 {
for(
int k = 1; k <= num_random_tests(); ++k ) {
376 <<
"\n3.a.1."<<k<<
") random vector " << k <<
" ( ||v_x||_1 / n = " << (v_x->norm_1() / v_x->dim()) <<
" )\n";
377 if(dump_all() && print_tests >=
PRINT_ALL)
378 *out <<
"\nv_x =\n" << *v_x;
380 if(Gc && equ_decomp.size()) {
381 V_StMtV( Gc_v_c.get(), alpha, *Gc,
trans, *v_x );
382 *v_chD_tmp->sub_view(equ_decomp)
383 = *Gc_v_c->sub_view(equ_decomp);
385 V_StMtV( C_v_chD.get(), alpha, *C,
no_trans, *v_x->sub_view(var_dep) );
386 V_StMtV( N_v_chD.get(), alpha, *N,
no_trans, *v_x->sub_view(var_indep) );
387 V_VpV( v_chD.get(), *C_v_chD, *N_v_chD );
389 sum_Bv =
sum(*v_chD),
390 sum_Av =
sum(*v_chD_tmp);
391 assert_print_nan_inf(sum_Bv,
"sum(B*v_x)",
true,out);
392 assert_print_nan_inf(sum_Av,
"sum(A*v_x)",
true,out);
394 calc_err = ::fabs( ( sum_Av - sum_Bv )
395 /( ::fabs(sum_Av) + ::fabs(sum_Bv) + small_num ) );
398 <<
"\nrel_err(sum(A*v_x),sum(B*v_x)) = " 399 <<
"rel_err(" << sum_Av <<
"," << sum_Bv <<
") = " 400 << calc_err << std::endl;
401 if( calc_err >= warning_tol() ) {
405 << ( calc_err >= error_tol() ?
"Error" :
"Warning" )
406 <<
", rel_err(sum(A*v_x),sum(B*v_x)) = " 407 <<
"rel_err(" << sum_Av <<
"," << sum_Bv <<
") = " 410 << ( calc_err >= error_tol() ?
"error_tol" :
"warning_tol" )
412 << ( calc_err >= error_tol() ? error_tol() : warning_tol() )
414 if(calc_err >= error_tol()) {
415 if(dump_all() && print_tests >=
PRINT_ALL) {
416 *out <<
"\nalpha = " << alpha << std::endl;
417 *out <<
"\nv_x =\n" << *v_x;
418 *out <<
"\nalpha*Gc*v_x =\n" << *Gc_v_c;
419 *out <<
"A*v =\n" << *v_chD_tmp;
420 *out <<
"\nalpha*C*v_x =\n" << *C_v_chD;
421 *out <<
"\nalpha*N*v_x =\n" << *N_v_chD;
422 *out <<
"\nB*v =\n" << *v_chD;
428 if(!llresult) lresult =
false;
430 *out <<
" : " << ( llresult ?
"passed" :
"failed" )
434 *out <<
"\n3.a.2) Testing transposed A'*v == B'*v ...";
438 {
for(
int k = 1; k <= num_random_tests(); ++k ) {
442 <<
"\n3.a.2."<<k<<
") random vector " << k <<
" ( ||v_chD||_1 / n = " << (v_chD->norm_1() / v_chD->dim()) <<
" )\n";
443 if(dump_all() && print_tests >=
PRINT_ALL)
444 *out <<
"\nv_chD =\n" << *v_chD;
447 if(Gc && equ_decomp.size()) {
448 *Gc_v_c->sub_view(equ_decomp) = *v_chD->sub_view(equ_decomp);
449 if(equ_undecomp.size())
450 *Gc_v_c->sub_view(equ_undecomp) = 0.0;
451 V_StMtV( Gc_v_x.get(), alpha, *Gc,
no_trans, *Gc_v_c );
452 Vp_V( v_x_tmp.get(), *Gc_v_x );
454 V_StMtV( C_v_xD.get(), alpha, *C,
trans, *v_chD );
455 *v_x->sub_view(var_dep) = *C_v_xD;
456 V_StMtV( N_v_xI.get(), alpha, *N,
trans, *v_chD );
457 *v_x->sub_view(var_indep) = *N_v_xI;
460 sum_ATv =
sum(*v_x_tmp);
461 assert_print_nan_inf(sum_BTv,
"sum(B'*v_chD)",
true,out);
462 assert_print_nan_inf(sum_ATv,
"sum(A'*v_chD)",
true,out);
464 calc_err = ::fabs( ( sum_ATv - sum_BTv )
465 /( ::fabs(sum_ATv) + ::fabs(sum_BTv) + small_num ) );
468 <<
"\nrel_err(sum(A'*v_chD),sum(B'*v_chD)) = " 469 <<
"rel_err(" << sum_ATv <<
"," << sum_BTv <<
") = " 470 << calc_err << std::endl;
471 if( calc_err >= warning_tol() ) {
475 << ( calc_err >= error_tol() ?
"Error" :
"Warning" )
476 <<
", rel_err(sum(A'*v_chD),sum(B'*v_chD)) = " 477 <<
"rel_err(" << sum_ATv <<
"," << sum_BTv <<
") = " 478 << calc_err << std::endl
480 << ( calc_err >= error_tol() ?
"error_tol" :
"warning_tol" )
482 << ( calc_err >= error_tol() ? error_tol() : warning_tol() )
484 if(calc_err >= error_tol()) {
485 if(dump_all() && print_tests >=
PRINT_ALL) {
486 *out <<
"\nalpha = " << alpha << std::endl;
487 *out <<
"\nv_chD =\n" << *v_chD;
488 if(Gc_v_x.get() && equ_decomp.size()) {
489 *out <<
"\nGc_v_c =\n" << *Gc_v_c;
490 *out <<
"\nalpha*Gc'*[v_chD(equ_decomp); 0] =\n" 493 *out <<
"A'*v =\n" << *v_x_tmp;
494 *out <<
"\nalpha*C*v_chD =\n" << *C_v_xD;
495 *out <<
"\nalpha*N*v_chD =\n" << *N_v_xI;
496 *out <<
"\nB'*v =\n" << *v_x;
502 if(!llresult) lresult =
false;
504 *out <<
" : " << ( llresult ?
"passed" :
"failed" )
510 <<
"\n3.b) Check consistency of:" 511 <<
"\n alpha*op(C)*(op(inv(C)) * v) == alpha*v" 512 <<
"\nfor random vectors v ...";
521 *out <<
"\n\n3.b.1) Testing non-transposed: alpha*C*(inv(C)*v) == alpha*v ...";
525 {
for(
int k = 1; k <= num_random_tests(); ++k ) {
529 <<
"\n\n3.b.1."<<k<<
") random vector " << k <<
" ( ||v_chD||_1 / n = " << (v_chD->norm_1() / v_chD->dim()) <<
" )\n";
530 if(dump_all() && print_tests >=
PRINT_ALL)
531 *out <<
"\nv_chD =\n" << *v_chD;
534 V_StMtV( v_chD_tmp.get(), alpha, *C,
no_trans, *v_xD_tmp );
536 sum_aCICv =
sum(*v_chD_tmp),
537 sum_av = alpha *
sum(*v_chD);
538 assert_print_nan_inf(sum_aCICv,
"sum(alpha*C*(inv(C)*v)",
true,out);
539 assert_print_nan_inf(sum_av,
"sum(alpha*v)",
true,out);
541 calc_err = ::fabs( ( sum_aCICv - sum_av )
542 /( ::fabs(sum_aCICv) + ::fabs(sum_av) + small_num ) );
545 <<
"\nrel_err(sum(alpha*C*(inv(C)*v),sum(alpha*v)) = " 546 <<
"rel_err(" << sum_aCICv <<
"," << sum_av <<
") = " 547 << calc_err << std::endl;
548 if( calc_err >= warning_tol() ) {
552 << ( calc_err >= error_tol() ?
"Error" :
"Warning" )
553 <<
", rel_err(sum(alpha*C*(inv(C)*v)),sum(alpha*v)) = " 554 <<
"rel_err(" << sum_aCICv <<
"," << sum_av <<
") = " 557 << ( calc_err >= error_tol() ?
"error_tol" :
"warning_tol" )
559 << ( calc_err >= error_tol() ? error_tol() : warning_tol() )
561 if(calc_err >= error_tol()) {
562 if(dump_all() && print_tests >=
PRINT_ALL) {
563 *out <<
"\nalpha = " << alpha << std::endl;
564 *out <<
"\nv_chD =\n" << *v_chD;
565 *out <<
"\ninv(C)*v_chD =\n" << *v_xD_tmp;
566 *out <<
"\nalpha*C*inv(C)*v_chD =\n" << *v_chD_tmp;
572 if(!llresult) lresult =
false;
574 *out <<
" : " << ( llresult ?
"passed" :
"failed" )
578 *out <<
"\n3.b.2) Testing transposed: alpha*C'*(inv(C')*v) == alpha*v ...";
582 {
for(
int k = 1; k <= num_random_tests(); ++k ) {
586 <<
"\n3.b.2."<<k<<
") random vector " << k <<
" ( ||v_xD||_1 / n = " << (v_xD->norm_1() / v_xD->dim()) <<
" )\n";
587 if(dump_all() && print_tests >=
PRINT_ALL)
588 *out <<
"\nv_xD =\n" << *v_xD;
591 V_StMtV( v_xD_tmp.get(), alpha, *C,
trans, *v_chD_tmp );
593 sum_aCICv =
sum(*v_xD_tmp),
594 sum_av = alpha *
sum(*v_xD);
595 assert_print_nan_inf(sum_aCICv,
"sum(alpha*C'*(inv(C')*v)",
true,out);
596 assert_print_nan_inf(sum_av,
"sum(alpha*v)",
true,out);
598 calc_err = ::fabs( ( sum_aCICv - sum_av )
599 /( ::fabs(sum_aCICv) + ::fabs(sum_av) + small_num ) );
602 <<
"\nrel_err(sum(alpha*C'*(inv(C')*v)),sum(alpha*v)) = " 603 <<
"rel_err(" << sum_aCICv <<
"," << sum_av <<
") = " 604 << calc_err << std::endl;
605 if( calc_err >= warning_tol() ) {
609 << ( calc_err >= error_tol() ?
"Error" :
"Warning" )
610 <<
", rel_err(sum(alpha*C'*(inv(C')*v)),sum(alpha*v)) = " 611 <<
"rel_err(" << sum_aCICv <<
"," << sum_av <<
") = " 614 << ( calc_err >= error_tol() ?
"error_tol" :
"warning_tol" )
616 << ( calc_err >= error_tol() ? error_tol() : warning_tol() )
618 if(calc_err >= error_tol()) {
619 if(dump_all() && print_tests >=
PRINT_ALL) {
620 *out <<
"\nalpha = " << alpha << std::endl;
621 *out <<
"\nv_xD =\n" << *v_xD;
622 *out <<
"\ninv(C')*v_xD =\n" << *v_chD_tmp;
623 *out <<
"\nalpha*C'*inv(C')*v_xD =\n" << *v_xD_tmp;
629 if(!llresult) lresult =
false;
631 *out <<
" : " << ( llresult ?
"passed" :
"failed" )
638 <<
"\n3.c) Check consistency of:" 639 <<
"\n alpha * op(-inv(C) * N) * v == alpha * op(D) * v" 640 <<
"\nfor random vectors v ...";
645 v_xI = N->space_rows().create_member(),
647 v_xI_tmp = N->space_rows().create_member(),
651 *out <<
"\n\n3.b.1) Testing non-transposed: inv(C)*(-alpha*N*v) == alpha*D*v ...";
655 {
for(
int k = 1; k <= num_random_tests(); ++k ) {
659 <<
"\n\n3.b.1."<<k<<
") random vector " << k <<
" ( ||v_xI||_1 / n = " << (v_xI->norm_1() / v_xI->dim()) <<
" )\n";
660 if(dump_all() && print_tests >=
PRINT_ALL)
661 *out <<
"\nv_xI =\n" << *v_xI;
663 V_StMtV( v_chD_tmp.get(), -alpha, *N,
no_trans, *v_xI );
665 V_StMtV( v_xD.get(), alpha, *D,
no_trans, *v_xI );
667 sum_ICaNv =
sum(*v_xD_tmp),
668 sum_aDv =
sum(*v_xD);
669 assert_print_nan_inf(sum_ICaNv,
"sum(inv(C)*(-alpha*N*v))",
true,out);
670 assert_print_nan_inf(sum_aDv,
"sum(alpha*D*v)",
true,out);
672 calc_err = ::fabs( ( sum_ICaNv - sum_aDv )
673 /( ::fabs(sum_ICaNv) + ::fabs(sum_aDv) + small_num ) );
676 <<
"\nrel_err(sum(inv(C)*(-alpha*N*v)),sum(alpha*D*v)) = " 677 <<
"rel_err(" << sum_ICaNv <<
"," << sum_aDv <<
") = " 678 << calc_err << std::endl;
679 if( calc_err >= warning_tol() ) {
683 << ( calc_err >= error_tol() ?
"Error" :
"Warning" )
684 <<
", rel_err(sum(inv(C)*(-alpha*N*v))),sum(alpha*D*v)) = " 685 <<
"rel_err(" << sum_ICaNv <<
"," << sum_aDv <<
") = " 688 << ( calc_err >= error_tol() ?
"error_tol" :
"warning_tol" )
690 << ( calc_err >= error_tol() ? error_tol() : warning_tol() )
692 if(calc_err >= error_tol()) {
693 if(dump_all() && print_tests >=
PRINT_ALL) {
694 *out <<
"\nalpha = " << alpha << std::endl;
695 *out <<
"\nv_xI =\n" << *v_xI;
696 *out <<
"\n-alpha*N*v_xI =\n" << *v_chD_tmp;
697 *out <<
"\ninv(C)*(-alpha*N*v_xI) =\n" << *v_xD_tmp;
698 *out <<
"\nalpha*D*v_xI =\n" << *v_xD;
704 if(!llresult) lresult =
false;
706 *out <<
" : " << ( llresult ?
"passed" :
"failed" )
710 *out <<
"\n3.b.1) Testing transposed: -alpha*N'*(inv(C')*v) == alpha*D'*v ...";
714 {
for(
int k = 1; k <= num_random_tests(); ++k ) {
718 <<
"\n\n3.b.1."<<k<<
") random vector " << k <<
" ( ||v_xD||_1 / n = " << (v_xD->norm_1() / v_xD->dim()) <<
" )\n";
719 if(dump_all() && print_tests >=
PRINT_ALL)
720 *out <<
"\nv_xD =\n" << *v_xD;
723 V_StMtV( v_xI_tmp.get(), -alpha, *N,
trans, *v_chD_tmp );
724 V_StMtV( v_xI.get(), alpha, *D,
trans, *v_xD );
726 sum_aNTICTv =
sum(*v_xI_tmp),
727 sum_aDTv =
sum(*v_xI);
728 assert_print_nan_inf(sum_aNTICTv,
"sum(-alpha*N'*(inv(C')*v))",
true,out);
729 assert_print_nan_inf(sum_aDTv,
"sum(alpha*D'*v)",
true,out);
731 calc_err = ::fabs( ( sum_aNTICTv - sum_aDTv )
732 /( ::fabs(sum_aNTICTv) + ::fabs(sum_aDTv) + small_num ) );
735 <<
"\nrel_err(sum(-alpha*N'*(inv(C')*v)),sum(alpha*D'*v)) = " 736 <<
"rel_err(" << sum_aNTICTv <<
"," << sum_aDTv <<
") = " 737 << calc_err << std::endl;
738 if( calc_err >= warning_tol() ) {
742 << ( calc_err >= error_tol() ?
"Error" :
"Warning" )
743 <<
", rel_err(sum(-alpha*N'*(inv(C')*v))),sum(alpha*D'*v)) = " 744 <<
"rel_err(" << sum_aNTICTv <<
"," << sum_aDTv <<
") = " 747 << ( calc_err >= error_tol() ?
"error_tol" :
"warning_tol" )
749 << ( calc_err >= error_tol() ? error_tol() : warning_tol() )
751 if(calc_err >= error_tol()) {
752 if(dump_all() && print_tests >=
PRINT_ALL) {
753 *out <<
"\nalpha = " << alpha << std::endl;
754 *out <<
"\nv_xD =\n" << *v_xD;
755 *out <<
"\ninv(C')**v_xD =\n" << *v_chD_tmp;
756 *out <<
"\n-alpha*N'*(inv(C')**v_xD) =\n" << *v_xI_tmp;
757 *out <<
"\nalpha*D*'v_xD =\n" << *v_xI;
763 if(!llresult) lresult =
false;
765 *out <<
" : " << ( llresult ?
"passed" :
"failed" )
772 TEUCHOS_TEST_FOR_EXCEPT(
true);
775 if(!lresult) success =
false;
777 *out <<
" : " << ( lresult ?
"passed" :
"failed" );
782 *out <<
"\nCongradulations! The BasisSystem object and its associated matrix objects seem to check out!\n";
784 *out <<
"\nOops! At last one of the tests did not check out!\n";
786 *out <<
"\nEnd BasisSystemTester::test_basis_system(...)\n";
Interface for the creation and maintainance of a basis matrix for a decomposition of linearlized cons...
virtual Range1D equ_undecomp() const
Range of undecomposed general equality constriants.
virtual vec_mut_ptr_t create_member() const =0
Create a vector member from the vector space.
virtual Range1D var_dep() const =0
Range of dependent (basic) variables.
bool test_basis_system(const BasisSystem &basis_sys, const MatrixOp *Gc, const MatrixOpNonsing *C, const MatrixOp *N, const MatrixOp *D, const MatrixOp *GcUP, std::ostream *out)
Test a BasisSystem object after BasisSystem::update_basis() is called.
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs
The induced infinity norm ||M||inf, i.e. max abs row sum.
virtual bool is_compatible(const VectorSpace &vec_spc) const =0
Compare the compatibility of two vector spaces.
void V_StV(VectorMutable *v_lhs, value_type alpha, const V &V_rhs)
v_lhs = alpha * V_rhs.
The print option has not been selected (will default to PRINT_NONE if not set)
virtual space_ptr_t sub_space(const Range1D &rng) const
Create a transient sub-space of the current vector space.
virtual const VectorSpace & space_cols() const =0
Vector space for vectors that are compatible with the columns of the matrix.
Print greater detail about the tests.
virtual size_type cols() const
Return the number of columns in the matrix.
virtual const VectorSpace & space_rows() const =0
Vector space for vectors that are compatible with the rows of the matrix.
void V_VpV(VectorMutable *v_lhs, const V1 &V1_rhs1, const V2 &V2_rhs2)
void V_InvMtV(VectorMutable *v_lhs, const MatrixNonsing &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const Vector &v_rhs2)
v_lhs = inv(op(M_rhs1)) * v_rhs2
BasisSystemTester(EPrintTestLevel print_tests=PRINT_NOT_SELECTED, bool dump_all=false, bool throw_exception=true, size_type num_random_tests=1, value_type warning_tol=1e-14, value_type error_tol=1e-8)
Constructor (default options)
Base class for all matrices that support basic matrix operations.
Don't print anything.
const MatNorm calc_norm(EMatNormType requested_norm_type=MAT_NORM_1, bool allow_replacement=false) const
Compute a norm of this matrix.
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
result = v_rhs1' * v_rhs2
Print only very basic info.
EMatNormType
Type of matrix norm.
virtual Range1D equ_decomp() const
Range of decomposed general equality constraints.
const MatNorm calc_cond_num(EMatNormType requested_norm_type=MAT_NORM_1, bool allow_replacement=false) const
Compute an estimate of the condition number of this matrix.
value_type sum(const Vector &v_rhs)
result = sum( v_rhs(i), i = 1,,,dim )
Abstract base class for all nonsingular polymorphic matrices that can be used to compute matrix-vecto...
Teuchos::RCP< VectorMutable > vec_mut_ptr_t
virtual size_type rows() const
Return the number of rows in the matrix.
Print everything all the tests in great detail but output is independent of problem size...
Matrix class for matrices composed out of a set of other matrices and vectors.
void random_vector(value_type l, value_type u, VectorMutable *v)
Generate a random vector with elements uniformly distrubuted elements.
void Vp_V(VectorMutable *v_lhs, const V &V_rhs)
v_lhs += V_rhs.
virtual Range1D var_indep() const =0
Range of independnet (nonbasic) variables.