[yoda-svn] r535 - in trunk: . include/YODA include/YODA/Utils tests/Histo2D

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Nov 14 19:22:08 GMT 2012


Author: buckley
Date: Wed Nov 14 19:22:08 2012
New Revision: 535

Log:
Converting linspace, logspace, and their usage to place the nbins argument first.

Modified:
   trunk/ChangeLog
   trunk/TODO
   trunk/include/YODA/Axis1D.h
   trunk/include/YODA/Axis2D.h
   trunk/include/YODA/Utils/MathUtils.h
   trunk/tests/Histo2D/H2DFill.cc

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Fri Oct  5 15:25:07 2012	(r534)
+++ trunk/ChangeLog	Wed Nov 14 19:22:08 2012	(r535)
@@ -1,3 +1,7 @@
+2012-11-14  Andy Buckley  <andy.buckley at cern.ch>
+
+	* Converting linspace, logspace, and their usage to place the nbins argument first.
+
 2012-08-07  Andy Buckley  <andy.buckley at cern.ch>
 
 	* Removing unused (beyond 2nd order) sumWXYZ counter from Dbn3D.

Modified: trunk/TODO
==============================================================================
--- trunk/TODO	Fri Oct  5 15:25:07 2012	(r534)
+++ trunk/TODO	Wed Nov 14 19:22:08 2012	(r535)
@@ -13,7 +13,11 @@
 * Remove non-const bin access from Histos and Profiles?
    cf. David D's point re. consistency via email on 7/8/2012
 
+* Multi-error support on Point types
+   Access by index, with negative (enum) indices for quad/linear/largest combn?
+
 * Add Axis2D -> Histo2D/Profile2D bin adding and erasing. (AB)
+   Adding 2D operator support and bin-adding/erasing
 
 * Make Python interface test scripts (DM)
 
@@ -27,7 +31,6 @@
 
 * Test Histo2D and Scatter2D from Python (AB)
 
-* Adding 2D operator support and bin-adding/erasing
 
 
 
@@ -54,6 +57,8 @@
 
 * Add Scatter1D/Point1D (AB)
 
+* Generalise/expose Axis*D for binning of general objects, e.g. "binned histos"
+
 * Transform 1D differential to integral histos and vice versa.
    Bins have to be contiguous. (AB)
 

Modified: trunk/include/YODA/Axis1D.h
==============================================================================
--- trunk/include/YODA/Axis1D.h	Fri Oct  5 15:25:07 2012	(r534)
+++ trunk/include/YODA/Axis1D.h	Wed Nov 14 19:22:08 2012	(r535)
@@ -65,7 +65,7 @@
     Axis1D(size_t nbins, double lower, double upper)
       : _locked(false)
     {
-      addBins(linspace(lower, upper, nbins));
+      addBins(linspace(nbins, lower, upper));
     }
 
 

Modified: trunk/include/YODA/Axis2D.h
==============================================================================
--- trunk/include/YODA/Axis2D.h	Fri Oct  5 15:25:07 2012	(r534)
+++ trunk/include/YODA/Axis2D.h	Wed Nov 14 19:22:08 2012	(r535)
@@ -75,8 +75,8 @@
            size_t nbinsY, const std::pair<double,double>& rangeY)
       : _isPerfectGrid(true), _locked(false)
     {
-      _addBins(linspace(rangeX.first, rangeX.second, nbinsX),
-               linspace(rangeY.first, rangeY.second, nbinsY));
+      _addBins(linspace(nbinsX, rangeX.first, rangeX.second),
+               linspace(nbinsY, rangeY.first, rangeY.second));
       reset();
     }
 

Modified: trunk/include/YODA/Utils/MathUtils.h
==============================================================================
--- trunk/include/YODA/Utils/MathUtils.h	Fri Oct  5 15:25:07 2012	(r534)
+++ trunk/include/YODA/Utils/MathUtils.h	Wed Nov 14 19:22:08 2012	(r535)
@@ -236,7 +236,7 @@
   //@{
 
   /// Make a list of @a nbins + 1 values equally spaced between @a start and @a end inclusive.
-  inline std::vector<double> linspace(double start, double end, size_t nbins) {
+  inline std::vector<double> linspace(size_t nbins, double start, double end) {
     assert(end >= start);
     assert(nbins > 0);
     std::vector<double> rtn;
@@ -252,13 +252,13 @@
 
 
   /// Make a list of @a nbins + 1 values exponentially spaced between @a start and @a end inclusive.
-  inline std::vector<double> logspace(double start, double end, size_t nbins) {
+  inline std::vector<double> logspace(size_t nbins, double start, double end) {
     assert(end >= start);
     assert(start > 0);
     assert(nbins > 0);
     const double logstart = std::log(start);
     const double logend = std::log(end);
-    const std::vector<double> logvals = linspace(logstart, logend, nbins);
+    const std::vector<double> logvals = linspace(nbins, logstart, logend);
     std::vector<double> rtn;
     for (size_t i = 0; i < logvals.size(); ++i) {
       rtn.push_back(std::exp(logvals[i]));

Modified: trunk/tests/Histo2D/H2DFill.cc
==============================================================================
--- trunk/tests/Histo2D/H2DFill.cc	Fri Oct  5 15:25:07 2012	(r534)
+++ trunk/tests/Histo2D/H2DFill.cc	Wed Nov 14 19:22:08 2012	(r535)
@@ -13,7 +13,7 @@
 int main() {
   ios_base::sync_with_stdio(0);
   Histo2D h(200, 0, 100, 200, 0, 100);
-  
+
   struct timeval startTime;
   struct timeval endTime;
   gettimeofday(&startTime, NULL);
@@ -45,17 +45,17 @@
     for(int j = 0; j < 100000; j++) temp.fill(99, 99, 2);
     gettimeofday(&endTime, NULL);
 
-    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; 
+    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;
     tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
     file << i*i << " " << tE-tS << " ";
     cout << tE-tS << endl;
 
-    Histo2D temp2(logspace(1, 100, i), logspace(1, 100, i));
+    Histo2D temp2(logspace(i, 1, 100), logspace(i, 1, 100));
     gettimeofday(&startTime, NULL);
     for(int j = 0; j < 100000; j++) temp2.fill(99, 99, 2);
     gettimeofday(&endTime, NULL);
 
-    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; 
+    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;
     tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
     file << tE-tS << " ";
     cout << tE-tS << endl;
@@ -65,15 +65,15 @@
     for(int j = 0; j < 1000; j++) temp.fill(99, 99, 2);
     gettimeofday(&endTime, NULL);
 
-    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; 
+    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;
     tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
     file << tE-tS << endl;
     cout << tE-tS << endl;
-    
+
     cout << i << endl;
   }
   cout << endl;
-  
+
   cout << "Doing the second (add/rem/modify) bench  ";
   ofstream file2("bench.dat");
   for(int i=10; i < 310; i+=10){
@@ -84,7 +84,7 @@
       gettimeofday(&startTime, NULL);
       for(int j=0; j < 1000; j++) temp.addBin(i*100, i,(i+1)*100, i+1);
       gettimeofday(&endTime, NULL);
-      tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; 
+      tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;
       tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
       totalTime+= tE-tS;
     }
@@ -94,7 +94,7 @@
       gettimeofday(&startTime, NULL);
       for(int j=0; j<1000; j++) temp.eraseBin(0);
       gettimeofday(&endTime, NULL);
-      tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; 
+      tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;
       tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
       file2 << tE-tS << " ";
       cout << tE-tS << endl;
@@ -105,24 +105,24 @@
     gettimeofday(&startTime, NULL);
     temp2.mergeBins(0, temp2.numBins()-1);
     gettimeofday(&endTime, NULL);
-    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; 
+    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;
     tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
     file2 << tE-tS << endl;
     cout << "Merge: " << tE-tS << endl;*/
    /*
-    
+
     Histo2D temp3(i, 0, 100, i, 0, 100);
     gettimeofday(&startTime, NULL);
     temp3.rebin(temp3.numBinsX()-1, temp3.numBinsY()-1);
     gettimeofday(&endTime, NULL);
-    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000; 
+    tE = (endTime.tv_sec*1000000 + endTime.tv_usec)/(double)1000000;
     tS = (startTime.tv_sec*1000000 + startTime.tv_usec)/(double)1000000;
     file2 << tE-tS << endl;
     cout << "Rebin: " << tE-tS << endl;
 	}
-  */ 
-    
-  
+  */
+
+
 
   // Testing if fill() function does what it should
   cout << "Does fill() do what it should?           ";
@@ -131,6 +131,6 @@
     return -1;
   }
   cout << "PASS" << endl;
-  
+
   return EXIT_SUCCESS;
 }


More information about the yoda-svn mailing list