45 #include "DenseLinAlgPack_MatVecCompare.hpp"
46 #include "DenseLinAlgPack_DMatrixClass.hpp"
47 #include "DenseLinAlgPack_DMatrixAsTriSym.hpp"
51 using DenseLinAlgPack::value_type;
53 using DenseLinAlgPack::sqrt_eps;
57 T my_max(
const T& v1,
const T& v2 ) {
return v1 > v2 ? v1 : v2; }
61 T my_min(
const T& v1,
const T& v2 ) {
return v1 < v2 ? v1 : v2; }
64 bool _comp(value_type val1, value_type val2)
66 const value_type denom = my_max( ::fabs(val1), 1.0 );
67 return ::fabs(val1 - val2) / denom < sqrt_eps;
72 bool DenseLinAlgPack::comp(
const DVectorSlice& vs1,
const DVectorSlice& vs2) {
73 DVectorSlice::const_iterator
74 vs1_itr = vs1.begin(),
75 vs2_itr = vs2.begin();
76 for(; vs1_itr != vs1.end() && vs2_itr != vs2.end(); ++vs1_itr, ++vs2_itr)
77 if( !_comp(*vs1_itr,*vs2_itr) )
return false;
81 bool DenseLinAlgPack::comp(
const DVectorSlice& vs, value_type alpha) {
82 DVectorSlice::const_iterator vs_itr = vs.begin();
83 for(; vs_itr != vs.end(); ++vs_itr)
84 if( !_comp(*vs_itr,alpha) )
return false;
91 for(
size_type i = 1; i < my_min(gms1.cols(),gms2.cols()); ++i)
92 if( !comp( col(gms1,trans1,i) , col( gms2, trans2, i ) ) )
return false;
96 bool DenseLinAlgPack::comp(
const DMatrixSlice& gms, value_type alpha)
99 if( !comp( gms.col(i) , alpha ) )
return false;
103 bool DenseLinAlgPack::comp(
const DMatrixSliceTriEle& tri_gms1,
const DMatrixSliceTriEle& tri_gms2)
112 if( !comp( col(tri_gms1.gms(),trans1,i)(i,n), col(tri_gms2.gms(),trans2,i)(i,n) ) )
118 bool DenseLinAlgPack::comp(
const DMatrixSliceTriEle& tri_gms1, value_type alpha)
126 if( !comp( col(tri_gms1.gms(),trans1,i)(i,n), alpha ) )
132 bool DenseLinAlgPack::comp_less(
const DVectorSlice& vs, value_type alpha)
134 DVectorSlice::const_iterator vs_itr = vs.begin();
135 const value_type denom = my_max( ::fabs(alpha), 1.0 );
136 for(; vs_itr != vs.end(); ++vs_itr)
137 if( *vs_itr > alpha )
return false;
Transp bool_to_trans(bool return_trans)