|
[yoda-svn] r293 - trunk/include/YODAblackhole at projects.hepforge.org blackhole at projects.hepforge.orgThu Aug 18 19:00:06 BST 2011
Author: mkawalec Date: Thu Aug 18 19:00:06 2011 New Revision: 293 Log: Made an equality operator on Axis2D (and by interdependence, on Histo2D) to work in a bit more intelligent way, if the Axis2D describes a whole grid (it checks if there exists a bin in the Axis 2D on the right side of an equality sign at a location being considered that has the same dimensions as a bin on the left side of equality sign and if it is true for all the bins then return that two Histos/Axises are the same). For a more reasonable explanation, please see the code in Axis2D.h, ~line 485. It is not yet tested, as noted in the comments. I really, really don't want to do it in the same way when an axis is not a full grid, because in such case we need to do O(n^2) comparisons which with 40k bins (200x200) would take forever. Or I think it would, it is yet to be tested. Modified: trunk/include/YODA/Axis2D.h trunk/include/YODA/HistoBin2D.h Modified: trunk/include/YODA/Axis2D.h ============================================================================== --- trunk/include/YODA/Axis2D.h Thu Aug 18 18:16:35 2011 (r292) +++ trunk/include/YODA/Axis2D.h Thu Aug 18 19:00:06 2011 (r293) @@ -479,8 +479,21 @@ //@{ /// Equality operator + /// @todo TEST!!11! bool operator == (const Axis2D& other) const { - return _binHashSparse == other._binHashSparse; + if(isGrid) { + for(size_t i = 0; i < _bins.size(); ++i) { + /// Omit ghost bins while checking + if(!_bins[i].second) continue; + int index=other.getBinIndex(_bins[i].first.midpoint().first, _bins[i].first.midpoint().second); + if(index != -1){ + if(other.bin(index) != _bins[i].first) return false; + } + else return false; + } + return true; + } + else return _binHashSparse == other._binHashSparse; } /// Non-equality operator Modified: trunk/include/YODA/HistoBin2D.h ============================================================================== --- trunk/include/YODA/HistoBin2D.h Thu Aug 18 18:16:35 2011 (r292) +++ trunk/include/YODA/HistoBin2D.h Thu Aug 18 19:00:06 2011 (r293) @@ -123,6 +123,16 @@ /// @name Operators //@{ + /// Equality operator that checks if the location + /// of the two bins is the same + bool operator == (const HistoBin2D& other) const { + return _edges == other._edges; + } + + bool operator != (const HistoBin2D& other) const { + return ! operator == (other); + } + /// Addition operator HistoBin2D& operator += (const HistoBin2D& toAdd) { return add(toAdd);
More information about the yoda-svn mailing list |