59 namespace AbstractLinAlgPack {
70 :test_level_(test_level)
71 ,print_tests_(print_tests)
73 ,throw_exception_(throw_exception)
74 ,num_random_tests_(num_random_tests)
75 ,warning_tol_(warning_tol)
76 ,error_tol_(error_tol)
85 namespace rcp = MemMngPack;
103 bool success =
true, result, lresult;
107 small_num =
::pow(std::numeric_limits<value_type>::epsilon(),0.25),
116 <<
"\nCheck: alpha*op(op(inv("<<M_name<<
"))*op("<<M_name<<
"))*v == alpha*v ...";
131 for(
int side_i = 0; side_i < 2; ++side_i ) {
132 for(
int trans_i = 0; trans_i < 2; ++trans_i ) {
137 <<
"\n" << side_i+1 <<
"." << trans_i+1 <<
") "
138 <<
"Check: (t2 = "<<(t_side==
left?
"inv(":
"alpha * ")<< M_name<<(t_trans==
trans?
"\'":
"")<<(t_side==
left?
")":
"")
139 <<
" * (t1 = "<<(t_side==
right?
"inv(":
"alpha * ")<<M_name<<(t_trans==
trans?
"\'":
"")<<(t_side==
right?
")":
"")
140 <<
" * v)) == alpha * v ...";
160 for(
int k = 1; k <= num_random_tests(); ++k ) {
165 <<
"\n"<<side_i+1<<
"."<<trans_i+1<<
"."<<k<<
") random vector " << k
166 <<
" ( ||v||_1 / n = " << (v->
norm_1() / v->
dim()) <<
" )\n";
167 if(dump_all() && print_tests() >=
PRINT_ALL)
168 *out <<
"\nv =\n" << *v;
171 if( t_side ==
right ) {
177 V_StMtV( t1, alpha, M, t_trans, *v );
180 if( t_side ==
left ) {
186 V_StMtV( t2, alpha, M, t_trans, *t1 );
190 sum_av = alpha*
sum(*v);
194 calc_err = ::fabs( ( sum_av - sum_t2 )
195 /( ::fabs(sum_av) + ::fabs(sum_t2) + small_num ) );
198 <<
"\nrel_err(sum(alpha*v),sum(t2)) = "
199 <<
"rel_err(" << sum_av <<
"," << sum_t2 <<
") = "
200 << calc_err << std::endl;
201 if( calc_err >= warning_tol() ) {
205 << ( calc_err >= error_tol() ?
"Error" :
"Warning" )
206 <<
", rel_err(sum(alpha*v),sum(t2)) = "
207 <<
"rel_err(" << sum_av <<
"," << sum_t2 <<
") = "
210 << ( calc_err >= error_tol() ?
"error_tol" :
"warning_tol" )
212 << ( calc_err >= error_tol() ? error_tol() : warning_tol() )
214 if(calc_err >= error_tol()) {
215 if(dump_all() && print_tests() >=
PRINT_ALL) {
216 *out <<
"\nalpha = " << alpha << std::endl;
217 *out <<
"\nv =\n" << *v;
218 *out <<
"\nt1 =\n" << *t2;
219 *out <<
"\nt2 =\n" << *t2;
224 if(!lresult) result =
false;
226 if(!result) success =
false;
228 *out <<
" : " << ( result ?
"passed" :
"failed" )
234 *out <<
" : " << ( success ?
"passed" :
"failed" );
virtual const VectorSpace & space_rows() const =0
Vector space for vectors that are compatible with the rows of the matrix.
COOMatrixPartitionedViewUtilityPack::TransposedPartition< T_Indice, T_Value > trans(COOMatrixPartitionedViewUtilityPack::Partition< T_Indice, T_Value > &part)
Create a transposed view of a partition object.
void pow(DVectorSlice *vs_lhs, const DVectorSlice &vs_rhs1, const DVectorSlice &vs_rhs2)
vs_lhs = pow(vs_rhs1,vs_rhs2)
virtual value_type norm_1() const
One norm. ||v||_1 = sum( |v(i)|, i = 1,,,this->dim() )
void V_StMtV(SpVector *sv_lhs, value_type alpha, const GenPermMatrixSlice &P_rhs1, BLAS_Cpp::Transp P_rhs1_trans, const DVectorSlice &vs_rhs2)
sv_lhs = alpha * op(P_rhs1) * vs_rhs2.
bool test_matrix(const MatrixOpNonsing &M, const char M_name[], std::ostream *out)
Test a MatrixOpNonsing object.
RTOp_value_type value_type
void Vp_StV(VectorMutable *v_lhs, const value_type &alpha, const Vector &v_rhs)
v_lhs = alpha * v_rhs + v_lhs
void V_StV(VectorMutable *v_lhs, value_type alpha, const V &V_rhs)
v_lhs = alpha * V_rhs.
void V_StMtV(VectorMutable *v_lhs, value_type alpha, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const V &V_rhs2)
v_lhs = alpha * op(M_rhs1) * V_rhs2.
Print greater detail about the tests.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
RTOp_index_type size_type
void V_VpV(VectorMutable *v_lhs, const V1 &V1_rhs1, const V2 &V2_rhs2)
const LAPACK_C_Decl::f_int & M
Print only very basic info.
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
bool assert_print_nan_inf(const value_type &val, const char name[], bool throw_excpt, std::ostream *out)
This function asserts if a value_type scalare is a NaN or Inf and optionally prints out these entires...
MatrixOpNonsingTester(ETestLevel test_level=TEST_LEVEL_2_BLAS, EPrintTestLevel print_tests=PRINT_NONE, 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)
value_type dot(const Vector &v_rhs1, const Vector &v_rhs2)
result = v_rhs1' * v_rhs2
virtual index_type dim() const
Return the dimension of this vector.
void V_MtV(VectorMutable *v_lhs, const MatrixOp &M_rhs1, BLAS_Cpp::Transp trans_rhs1, const V &V_rhs2)
v_lhs = op(M_rhs1) * V_rhs2.
virtual const VectorSpace & space_cols() const =0
Vector space for vectors that are compatible with the columns of the matrix.
Abstract interface for mutable coordinate vectors {abstract}.
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...
Print everything all the tests in great detail but output is independent of problem size...
virtual vec_mut_ptr_t create_member() const =0
Create a vector member from the vector space.
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.