CMS 3D CMS Logo

Public Member Functions | Public Attributes

DDCompareDBLVEC Struct Reference

#include <DDCompareTools.h>

Inheritance diagram for DDCompareDBLVEC:
binary_function

List of all members.

Public Member Functions

 DDCompareDBLVEC ()
 DDCompareDBLVEC (double tol)
bool operator() (const std::vector< double > &lhs, const std::vector< double > &rhs) const

Public Attributes

double tol_

Detailed Description

Definition at line 60 of file DDCompareTools.h.


Constructor & Destructor Documentation

DDCompareDBLVEC::DDCompareDBLVEC ( )

Definition at line 277 of file DDCompareTools.cc.

: tol_(0.0004) { }
DDCompareDBLVEC::DDCompareDBLVEC ( double  tol)

Definition at line 279 of file DDCompareTools.cc.

: tol_(tol) { }

Member Function Documentation

bool DDCompareDBLVEC::operator() ( const std::vector< double > &  lhs,
const std::vector< double > &  rhs 
) const

Definition at line 282 of file DDCompareTools.cc.

References gather_cfg::cout, i, runTheMatrix::ret, and tol_.

{
  bool ret(true);
  std::ios_base::fmtflags originalFlags = std::cout.flags();
  int originalPrecision = std::cout.precision();
  if( lhs.size() != rhs.size())
  {
    ret = false;
    std::cout << "Size of vectors do not match." << std::endl;
  }
  else
  {
    for( size_t i = 0; i < lhs.size() ; ++i )
    {
      if( std::fabs( lhs[i] - rhs[i] ) > tol_ )
      {
        ret = false;
        std::cout << "Vector content at index " << i << " does not match " ;
        std::cout << std::setw(12) << std::fixed << std::setprecision(4) << lhs[i] << " != " << rhs[i] << std::endl;
        break;
      }
    }
  }
  // Now set everything back to defaults
  std::cout.flags( originalFlags );
  std::cout.precision( originalPrecision );
  return ret;
}

Member Data Documentation

Definition at line 64 of file DDCompareTools.h.

Referenced by operator()().