Changeset dd3a80
- Timestamp:
- Mar 3, 2010, 7:10:36 PM (16 years ago)
- Children:
- bc46c1
- Parents:
- f78203
- git-author:
- Frederik Heber <heber@…> (03/03/10 18:41:03)
- git-committer:
- Frederik Heber <heber@…> (03/03/10 19:10:36)
- Location:
- molecuilder/src
- Files:
-
- 2 edited
-
analysis_correlation.cpp (modified) (1 diff)
-
analysis_correlation.hpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
molecuilder/src/analysis_correlation.cpp
rf78203 rdd3a80 342 342 }; 343 343 344 /** Returns the startof the bin for a given value.344 /** Returns the index of the bin for a given value. 345 345 * \param value value whose bin to look for 346 346 * \param BinWidth width of bin 347 347 * \param BinStart first bin 348 348 */ 349 doubleGetBin ( const double value, const double BinWidth, const double BinStart )350 { 351 Info FunctionInfo(__func__); 352 double bin =(double) (floor((value - BinStart)/BinWidth));353 return (bin *BinWidth+BinStart);349 int GetBin ( const double value, const double BinWidth, const double BinStart ) 350 { 351 Info FunctionInfo(__func__); 352 int bin =(int) (floor((value - BinStart)/BinWidth)); 353 return (bin); 354 354 }; 355 355 -
molecuilder/src/analysis_correlation.hpp
rf78203 rdd3a80 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 55 void OutputPairCorrelation( ofstream * const file, const BinPairMap * const map ); … … 101 101 { 102 102 BinPairMap *outmap = new BinPairMap; 103 double bin = 0.;103 int bin = 0; 104 104 double start = 0.; 105 105 double end = 0.; … … 117 117 start = BinStart; 118 118 end = BinEnd; 119 for ( double runner = start; runner <= end; runner += BinWidth)120 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) ); 121 121 } 122 122 123 123 for (typename T::iterator runner = map->begin(); runner != map->end(); ++runner) { 124 124 bin = GetBin (runner->first, BinWidth, start); 125 BinPairMapInserter = outmap->insert ( pair<double, int> ( bin, 1) );125 BinPairMapInserter = outmap->insert ( pair<double, int> ((double)bin*BinWidth+start, 1) ); 126 126 if (!BinPairMapInserter.second) { // bin already present, increase 127 127 BinPairMapInserter.first->second += 1;
Note:
See TracChangeset
for help on using the changeset viewer.
