forked from lhayward/ON_Model
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Measure.cpp
66 lines (55 loc) · 2.54 KB
/
Measure.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**********************************************************************************************
************************************ OPE COEFFICIENTS CODE ************************************
***********************************************************************************************
* Lauren E. Hayward Sierens
***********************************************************************************************
* File: Measure.cpp (Abstract Class)
**********************************************************************************************/
#include <fstream>
#include <iostream>
#include "Measure.h"
/********************************** Measure() (constructor) **********************************/
Measure::Measure()
{ }
/********************************** ~Measure() (destructor) **********************************/
Measure::~Measure()
{ }
/*********************** accumulate(std::string label, double newMeas) ***********************/
void Measure::accumulate(std::string label, double newMeas)
{ measurements[label] += newMeas; }
/********************************* insert(std::string label) *********************************/
void Measure::insert(std::string label)
{
measurements.insert( std::pair<std::string,double>(label, 0.0) );
measStrings.push_back( label );
}
/****************************************** print() ******************************************/
void Measure::print()
{
std::cout << "Measurements:" << std::endl;
//Print the measurements in the order the measStrings were added:
for( uint i=0; i<measStrings.size(); i++ )
{ std::cout << " " << measStrings[i] << ": " << measurements[measStrings[i]] << '\n'; }
std::cout << std::endl;
}
/********************** writeAverages(std::ofstream* fout, uint numMeas) *********************/
void Measure::writeAverages(std::ofstream* fout, uint numMeas)
{
//Write the measurement averages in the order the measStrings were added:
for( uint i=0; i<measStrings.size(); i++ )
{ (*fout) << '\t' << (measurements[measStrings[i]]/(1.0*numMeas)); }
}
/**************************** writeMeasNames(std::ofstream* fout) ****************************/
void Measure::writeMeasNames(std::ofstream* fout)
{
//Write the names of each observable to the passed file stream (for clarity when processing
//the bin file):
for( uint i=0; i<measStrings.size(); i++ )
{ (*fout) << '\t' << measStrings[i]; }
}
/******************************************* zero() ******************************************/
void Measure::zero()
{
for( uint i=0; i<measStrings.size(); i++ )
{ measurements[measStrings[i]] = 0.0; }
}