|
[yoda-svn] r469 - in trunk/include/YODA: . Utilsblackhole at projects.hepforge.org blackhole at projects.hepforge.orgFri May 4 11:03:34 BST 2012
Author: dgrell Date: Fri May 4 11:03:33 2012 New Revision: 469 Log: size_t does not fit into an int on x86_64 Modified: trunk/include/YODA/Axis1D.h trunk/include/YODA/Bin1D.h trunk/include/YODA/Utils/MathUtils.h Modified: trunk/include/YODA/Axis1D.h ============================================================================== --- trunk/include/YODA/Axis1D.h Thu May 3 15:58:31 2012 (r468) +++ trunk/include/YODA/Axis1D.h Fri May 4 11:03:33 2012 (r469) @@ -28,7 +28,7 @@ /// Type used to implement a search table of low bin edges mapped to bin indices. /// An index of -1 indicates a gap interval, without a corresponding bin. - typedef std::map<double, int> BinHash; + typedef std::map<double, long int> BinHash; /// @name Constructors //@{ @@ -118,14 +118,14 @@ /// Return a bin at a given coordinate (non-const) BIN1D& binByCoord(double x) { - const int index = getBinIndex(x); + const long int index = getBinIndex(x); if (index == -1) throw RangeError("There is no bin at the specified x"); return bin(index); } /// Return a bin at a given coordinate (const) const BIN1D& binByCoord(double x) const { - const int index = getBinIndex(x); + const long int index = getBinIndex(x); if (index == -1) throw RangeError("There is no bin at the specified x"); return bin(index); } @@ -167,14 +167,14 @@ //@{ /// Returns an index of a bin at a given coord, -1 if no bin matches - int getBinIndex(double coord) const { + long int getBinIndex(double coord) const { // First check that we are within the axis bounds at all if (coord < lowEdge() || coord > highEdge()) return -1; // Then return the lower-edge lookup from the hash map // NB. both upper_bound and lower_bound return values *greater* than (or equal) to coord, // so we have to step back one iteration to get to the lower-or-equal containing bin edge. BinHash::const_iterator itabove = _binhash.upper_bound(coord); - int index = (--itabove)->second; + long int index = (--itabove)->second; return index; } Modified: trunk/include/YODA/Bin1D.h ============================================================================== --- trunk/include/YODA/Bin1D.h Thu May 3 15:58:31 2012 (r468) +++ trunk/include/YODA/Bin1D.h Fri May 4 11:03:33 2012 (r469) @@ -194,7 +194,7 @@ } /// The effective number of entries - unsigned long effNumEntries() const { + double effNumEntries() const { return _dbn.effNumEntries(); } Modified: trunk/include/YODA/Utils/MathUtils.h ============================================================================== --- trunk/include/YODA/Utils/MathUtils.h Thu May 3 15:58:31 2012 (r468) +++ trunk/include/YODA/Utils/MathUtils.h Fri May 4 11:03:33 2012 (r469) @@ -119,7 +119,7 @@ /// @brief Returns a number floored at the nth decimal place. inline double approx(double a, int n = 5) { - int roundTo = pow(10,n); + double roundTo = pow(10,n); a *= roundTo; a = floor(a); return a/roundTo; @@ -305,9 +305,9 @@ inline double covariance(const std::vector<int>& sample1, const std::vector<int>& sample2) { const double mean1 = mean(sample1); const double mean2 = mean(sample2); - const int N = sample1.size(); + const size_t N = sample1.size(); double cov = 0.0; - for (int i = 0; i < N; i++) { + for (size_t i = 0; i < N; i++) { const double cov_i = (sample1[i] - mean1)*(sample2[i] - mean2); cov += cov_i; }
More information about the yoda-svn mailing list |