Changes in src/analysis_correlation.hpp [790807:bd61b41]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/analysis_correlation.hpp
r790807 rbd61b41 51 51 CorrelationToPointMap *PeriodicCorrelationToPoint(MoleculeListClass * const &molecules, const element * const type, const Vector *point, const int ranges[NDIM] ); 52 52 CorrelationToSurfaceMap *PeriodicCorrelationToSurface(MoleculeListClass * const &molecules, const element * const type, const Tesselation * const Surface, const LinkedCell *LC, const int ranges[NDIM] ); 53 doubleGetBin ( const double value, const double BinWidth, const double BinStart );53 int GetBin ( const double value, const double BinWidth, const double BinStart ); 54 54 void OutputCorrelation( ofstream * const file, const BinPairMap * const map ); 55 void OutputPairCorrelation( ofstream * const file, const PairCorrelationMap * const map );56 void OutputCorrelationToPoint( ofstream * const file, const CorrelationToPointMap * const map );57 void OutputCorrelationToSurface( ofstream * const file, const CorrelationToSurfaceMap * const map );55 void OutputPairCorrelation( ofstream * const file, const BinPairMap * const map ); 56 void OutputCorrelationToPoint( ofstream * const file, const BinPairMap * const map ); 57 void OutputCorrelationToSurface( ofstream * const file, const BinPairMap * const map ); 58 58 59 59 … … 90 90 /** Puts given correlation data into bins of given size (histogramming). 91 91 * Note that BinStart and BinEnd are desired to fill the complete range, even where Bins are zero. If this is 92 * not desired, give equal BinStart and BinEnd and the map will contain only Bins where the count is one or greater. If a 93 * certain start value is desired, give BinStart and a BinEnd that is smaller than BinStart, then only BinEnd will be 94 * calculated automatically, i.e. BinStart = 0. and BinEnd = -1. . 92 * not desired, give equal BinStart and BinEnd and the map will contain only Bins where the count is one or greater. 95 93 * Also note that the range is given inclusive, i.e. [ BinStart, BinEnd ]. 96 94 * \param *map map of doubles to count … … 103 101 { 104 102 BinPairMap *outmap = new BinPairMap; 105 double bin = 0.;103 int bin = 0; 106 104 double start = 0.; 107 105 double end = 0.; … … 116 114 if (BinStart == BinEnd) { // if same, find range ourselves 117 115 GetMinMax( map, start, end); 118 } else if (BinEnd < BinStart) { // if BinEnd smaller, just look for new max 119 GetMinMax( map, start, end); 120 start = BinStart; 121 } else { // else take both values 116 } else { // if not, initialise range to zero 122 117 start = BinStart; 123 118 end = BinEnd; 124 for ( double runner = start; runner <= end; runner += BinWidth)125 outmap->insert( pair<double, int> ( runner, 0) );119 for (int runner = 0; runner <= ceil((end-start)/BinWidth); runner++) 120 outmap->insert( pair<double, int> ((double)runner*BinWidth+start, 0) ); 126 121 } 127 122 128 123 for (typename T::iterator runner = map->begin(); runner != map->end(); ++runner) { 129 124 bin = GetBin (runner->first, BinWidth, start); 130 BinPairMapInserter = outmap->insert ( pair<double, int> ( bin, 1) );125 BinPairMapInserter = outmap->insert ( pair<double, int> ((double)bin*BinWidth+start, 1) ); 131 126 if (!BinPairMapInserter.second) { // bin already present, increase 132 127 BinPairMapInserter.first->second += 1;
Note:
See TracChangeset
for help on using the changeset viewer.