NumericFileComparison Class Reference

#include <NumericFileComparison.hpp>

Inherits AbstractFileComparison.

Collaboration diagram for NumericFileComparison:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 NumericFileComparison (std::string fileName1, std::string fileName2, bool calledCollectively=true, bool suppressOutput=false)
 NumericFileComparison (const FileFinder &rFileName1, const FileFinder &rFileName2, bool calledCollectively=true, bool suppressOutput=false)
bool CompareFiles (double absTol=DBL_EPSILON, unsigned ignoreFirstFewLines=0, double relTol=DBL_EPSILON, bool doTsAssert=true)

Private Member Functions

void ReadNextToken (std::ifstream *pFile, double &rData)

Detailed Description

Compare files of numbers to see if they match to within a given tolerance.

Any differences in words are ignored, as are comment lines starting with '#' or '!'.

Definition at line 52 of file NumericFileComparison.hpp.


Constructor & Destructor Documentation

NumericFileComparison::NumericFileComparison ( std::string  fileName1,
std::string  fileName2,
bool  calledCollectively = true,
bool  suppressOutput = false 
) [inline]

Specify two files to compare, and open them for reading. Actual comparison is done by calling CompareFiles.

Parameters:
fileName1 first file
fileName2 second file
calledCollectively If true there will be a barrier before opening files, and only master compares contents.
suppressOutput If true then no errors will go to TS_TRACE(). Should only be set for the test of this class.

Definition at line 100 of file NumericFileComparison.hpp.

NumericFileComparison::NumericFileComparison ( const FileFinder rFileName1,
const FileFinder rFileName2,
bool  calledCollectively = true,
bool  suppressOutput = false 
) [inline]

Specify two files to compare, and open them for reading. Actual comparison is done by calling CompareFiles.

Parameters:
rFileName1 first file
rFileName2 second file
calledCollectively If true there will be a barrier before opening files, and only master compares contents.
suppressOutput If true then no errors will go to TS_TRACE(). Should only be set for the test of this class.

Definition at line 114 of file NumericFileComparison.hpp.


Member Function Documentation

bool NumericFileComparison::CompareFiles ( double  absTol = DBL_EPSILON,
unsigned  ignoreFirstFewLines = 0,
double  relTol = DBL_EPSILON,
bool  doTsAssert = true 
) [inline]
Returns:
true if the files are identical to within tolerance. Compare the files under both relative and absolute tolerances. The comparison only fails if neither tolerance holds. The default settings effectively require numbers to match exactly.
Parameters:
absTol absolute tolerance on difference between numbers
ignoreFirstFewLines how many lines to ignore from the comparison
relTol relative tolerance on difference between numbers
doTsAssert Whether to throw a TS_ASSERT internally (switched off for testing only)

Definition at line 131 of file NumericFileComparison.hpp.

References PetscTools::AmMaster(), AbstractFileComparison::mCalledCollectively, AbstractFileComparison::mFilename1, AbstractFileComparison::mFilename2, AbstractFileComparison::mpFile1, AbstractFileComparison::mpFile2, AbstractFileComparison::mSuppressOutput, ReadNextToken(), AbstractFileComparison::ResetFiles(), AbstractFileComparison::SkipHeaderLines(), and CompareDoubles::WithinAnyTolerance().

void NumericFileComparison::ReadNextToken ( std::ifstream *  pFile,
double rData 
) [inline, private]

Read the next token in the file as a double.

If we detect a comment skip the line. If we detect a word assign the value A_WORD. If we find nothing to read assign NOTHING_TO_READ.

Parameters:
pFile The file from which to attempt to read a double.
rData The double to assign a value to.

Definition at line 65 of file NumericFileComparison.hpp.

Referenced by CompareFiles().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2