Import Geant4 10.6.0 source tree
This commit is contained in:
@@ -51,7 +51,7 @@ inline bool valid_pointer(std::ostream& a_out,const char* a_file,int a_line,CLAS
|
||||
}
|
||||
|
||||
template <class INTEGER>
|
||||
inline bool equal(std::ostream& a_out,const char* a_file,int a_line,const INTEGER a_v,const INTEGER& a_expected) {
|
||||
inline bool equal(std::ostream& a_out,const char* a_file,int a_line,const INTEGER& a_v,const INTEGER& a_expected) {
|
||||
if(a_v!=a_expected) {
|
||||
a_out << "failed in file :" << std::endl
|
||||
<< a_file << std::endl
|
||||
@@ -64,7 +64,20 @@ inline bool equal(std::ostream& a_out,const char* a_file,int a_line,const INTEGE
|
||||
}
|
||||
|
||||
template <class INTEGER>
|
||||
inline bool ge(std::ostream& a_out,const char* a_file,int a_line,const INTEGER a_v,const INTEGER& a_expected) {
|
||||
inline bool not_equal(std::ostream& a_out,const char* a_file,int a_line,const INTEGER& a_v,const INTEGER& a_expected) {
|
||||
if(a_v==a_expected) {
|
||||
a_out << "failed in file :" << std::endl
|
||||
<< a_file << std::endl
|
||||
<< "at line :" << std::endl
|
||||
<< a_line << std::endl
|
||||
<< "value " << a_v << ", expected " << a_expected << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class INTEGER>
|
||||
inline bool ge(std::ostream& a_out,const char* a_file,int a_line,const INTEGER& a_v,const INTEGER& a_expected) {
|
||||
if(a_v<a_expected) {
|
||||
a_out << "failed in file :" << std::endl
|
||||
<< a_file << std::endl
|
||||
@@ -90,6 +103,35 @@ inline bool equal(std::ostream& a_out,const char* a_file,int a_line,const REAL&
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class REAL>
|
||||
inline bool not_equal(std::ostream& a_out,const char* a_file,int a_line,const REAL& a_v,const REAL& a_expected,const REAL& a_tolerance,REAL(*a_fabs)(const REAL&)) {
|
||||
REAL diff = a_fabs(a_v-a_expected);
|
||||
if(diff<a_tolerance) {
|
||||
a_out << "failed in file :" << std::endl
|
||||
<< a_file << std::endl
|
||||
<< "at line :" << std::endl
|
||||
<< a_line << std::endl
|
||||
<< "value " << a_v << ", not expected to be " << a_expected << ",diff " << diff << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// with complex number
|
||||
template <class NUMBER,class PREC>
|
||||
inline bool _equal(std::ostream& a_out,const char* a_file,int a_line,const NUMBER& a_v,const NUMBER& a_expected,const PREC& a_tolerance,PREC(*a_fabs)(const NUMBER&)) {
|
||||
PREC diff = a_fabs(a_v-a_expected);
|
||||
if(diff>=a_tolerance) {
|
||||
a_out << "failed in file :" << std::endl
|
||||
<< a_file << std::endl
|
||||
<< "at line :" << std::endl
|
||||
<< a_line << std::endl
|
||||
<< "value " << a_v << ", expected " << a_expected << ",diff " << diff << std::endl;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class REAL>
|
||||
inline bool equal(std::ostream& a_out,const char* a_file,int a_line,size_t a_size,const REAL* a_v,const REAL* a_expected,const REAL& a_tolerance,REAL(*a_fabs)(const REAL&)){
|
||||
for(size_t index=0;index<a_size;index++) {
|
||||
@@ -98,6 +140,46 @@ inline bool equal(std::ostream& a_out,const char* a_file,int a_line,size_t a_siz
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class VEC,class REAL>
|
||||
inline bool equal(std::ostream& a_out,const char* a_file,int a_line,const VEC& a_1,const VEC& a_2,const REAL& a_tolerance,REAL(*a_fabs)(const REAL&)){
|
||||
if(a_1.dimension()!=a_2.dimension()) {
|
||||
a_out << "failed in file :" << std::endl
|
||||
<< a_file << std::endl
|
||||
<< "at line :" << std::endl
|
||||
<< a_line << std::endl
|
||||
<< "vector dimension " << a_1.dimension() << " != " << a_2.dimension() << std::endl;
|
||||
return false;
|
||||
}
|
||||
for(size_t index=0;index<a_1.dimension();index++) {
|
||||
if(!equal<REAL>(a_out,a_file,a_line,a_1[index],a_2[index],a_tolerance,a_fabs)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class MAT,class REAL>
|
||||
inline bool mat_equal(std::ostream& a_out,const char* a_file,int a_line,const MAT& a_1,const MAT& a_2,const REAL& a_tolerance,REAL(*a_fabs)(const REAL&)){
|
||||
if(a_1.dimension()!=a_2.dimension()) {
|
||||
a_out << "failed in file :" << std::endl
|
||||
<< a_file << std::endl
|
||||
<< "at line :" << std::endl
|
||||
<< a_line << std::endl
|
||||
<< "matrix dimension " << a_1.dimension() << " != " << a_2.dimension() << std::endl;
|
||||
return false;
|
||||
}
|
||||
if(a_1.data_size()!=a_2.data_size()) {
|
||||
a_out << "failed in file :" << std::endl
|
||||
<< a_file << std::endl
|
||||
<< "at line :" << std::endl
|
||||
<< a_line << std::endl
|
||||
<< "matrix data_size " << a_1.data_size() << " != " << a_2.data_size() << std::endl;
|
||||
return false;
|
||||
}
|
||||
for(size_t index=0;index<a_1.data_size();index++) {
|
||||
if(!equal<REAL>(a_out,a_file,a_line,a_1.data()[index],a_2.data()[index],a_tolerance,a_fabs)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include <vector>
|
||||
|
||||
Reference in New Issue
Block a user