<commit_before>// @(#)root/mathcore:$Id$
// Author: <NAME> Wed Aug 28 15:33:03 2009

/**********************************************************************
 *                                                                    *
 * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
 *                                                                    *
 *                                                                    *
 **********************************************************************/

// Implementation file for class BinData

#include <iostream>
#include <iterator>
#include <algorithm>

#include <vector>
#include <list>

#include <stdexcept>

#include <cmath>

#include "Fit/SparseData.h"

using namespace std;

namespace ROOT { 

   namespace Fit { 

      //This class is a helper. It represents a bin in N
      //dimensions. The change in the name is to avoid name collision.
      class Box
      {
      public:
         // Creates a Box with limits specified by the vectors and
         // content=value and error=error
         Box(const vector<double>& min, const vector<double>& max, 
             const double value = 0.0, const double error = 1.0):
            _min(min), _max(max), _val(value), _error(error)
         { }
         
         // Compares to Boxes to see if they are equal in all its
         // variables. This is to be used by the std::find algorithm
         bool operator==(const Box& b)
         { return (_min == b._min) && (_max == b._max) 
               && (_val == b._val) && (_error == b._error);  }
         
         // Get the list of minimum coordinates
         const vector<double>& getMin() const { return _min; }
         // Get the list of maximum coordinates
         const vector<double>& getMax() const { return _max; }
         // Get the value of the Box
         double getVal() const { return _val; }
         // Get the rror of the Box
         double getError() const { return _error; }
         
         // Add an amount to the content of the Box
         void addVal(const double value) { _val += value; }
         
         friend class BoxContainer;
         friend ostream& operator <<(ostream& os, const Box& b);
         
      private:
         vector<double> _min;
         vector<double> _max;
         double _val;
         double _error;
      };
      
      // This class is just a helper to be used in std::for_each to
      // simplify the code later. It's just a definition of a method
      // that will discern whether a Box is included into another one
      class BoxContainer
      {
      private:
         const Box& _b;
      public:
         //Constructs the BoxContainer object with a Box that is meant
         //to include another one that will be provided later
         BoxContainer(const Box& b): _b(b) {}
         
         bool operator() (const Box& b1)
         { return operator()(_b, b1);  }
         
         // Looks if b2 is included in b1
         bool operator() (const Box& b1, const Box& b2)
         {
            bool isIn = true;
            vector<double>::const_iterator boxit = b2._min.begin();
            vector<double>::const_iterator bigit = b1._max.begin();
            while ( isIn && boxit != b2._min.end() )
            {
               if ( (*boxit) >= (*bigit) ) isIn = false;
               boxit++;
               bigit++;
            }
            
            boxit = b2._max.begin();
            bigit = b1._min.begin();
            while ( isIn && boxit != b2._max.end() )
            {
               if ( (*boxit) <= (*bigit) ) isIn = false;
               boxit++;
               bigit++;
            }
            
            return isIn;
         }
      };
      
      // Another helper class to be used in std::for_each to simplify
      // the code later. It implements the operator() to know if a
      // specified Box is big enough to contain any 'space' inside.
      class AreaComparer
      {
      public:
         AreaComparer(vector<double>::iterator iter, double cmpLimit = 1e-16): <commit_msg>fix a precision problem observed on 32 bits machines  (tolerance for comparing doubles was too small)<commit_after>// @(#)root/mathcore:$Id$
// Author: <NAME> Wed Aug 28 15:33:03 2009

/**********************************************************************
 *                                                                    *
 * Copyright (c) 2006  LCG ROOT Math Team, CERN/PH-SFT                *
 *                                                                    *
 *                                                                    *
 **********************************************************************/

// Implementation file for class BinData

#include <iostream>
#include <iterator>
#include <algorithm>

#include <vector>
#include <list>

#include <stdexcept>

#include <cmath>

#include "Fit/SparseData.h"

#include <limits>

using namespace std;

namespace ROOT { 

   namespace Fit { 

      //This class is a helper. It represents a bin in N
      //dimensions. The change in the name is to avoid name collision.
      class Box
      {
      public:
         // Creates a Box with limits specified by the vectors and
         // content=value and error=error
         Box(const vector<double>& min, const vector<double>& max, 
             const double value = 0.0, const double error = 1.0):
            _min(min), _max(max), _val(value), _error(error)
         { }
         
         // Compares to Boxes to see if they are equal in all its
         // variables. This is to be used by the std::find algorithm
         bool operator==(const Box& b)
         { return (_min == b._min) && (_max == b._max) 
               && (_val == b._val) && (_error == b._error);  }
         
         // Get the list of minimum coordinates
         const vector<double>& getMin() const { return _min; }
         // Get the list of maximum coordinates
         const vector<double>& getMax() const { return _max; }
         // Get the value of the Box
         double getVal() const { return _val; }
         // Get the rror of the Box
         double getError() const { return _error; }
         
         // Add an amount to the content of the Box
         void addVal(const double value) { _val += value; }
         
         friend class BoxContainer;
         friend ostream& operator <<(ostream& os, const Box& b);
         
      private:
         vector<double> _min;
         vector<double> _max;
         double _val;
         double _error;
      };
      
      // This class is just a helper to be used in std::for_each to
      // simplify the code later. It's just a definition of a method
      // that will discern whether a Box is included into another one
      class BoxContainer
      {
      private:
         const Box& _b;
      public:
         //Constructs the BoxContainer object with a Box that is meant
         //to include another one that will be provided later
         BoxContainer(const Box& b): _b(b) {}
         
         bool operator() (const Box& b1)
         { return operator()(_b, b1);  }
         
         // Looks if b2 is included in b1
         bool operator() (const Box& b1, const Box& b2)
         {
            bool isIn = true;
            vector<double>::const_iterator boxit = b2._min.begin();
            vector<double>::const_iterator bigit = b1._max.begin();
            while ( isIn && boxit != b2._min.end() )
            {
               if ( (*boxit) >= (*bigit) ) isIn = false;
               boxit++;
               bigit++;
            }
            
            boxit = b2._max.begin();
            bigit = b1._min.begin();
            while ( isIn && boxit != b2._max.end() )
            {
               if ( (*boxit) <= (*bigit) ) isIn = false;
               boxit++;
               bigit++;
            }
            
            return isIn;
         }
      };
      
      // Another helper class to be used in std::for_each to simplify
      // the code later. It implements the operator() to know if a
      // specified Box is big enough to contain any 'space' inside.
      class AreaComparer
      {
      public:
         AreaComparer(vector<double>::iterator iter, double cmpLimit = 8*std::numeric_limits<double>::epsilon() ): 
{'fraction_non_alphanumeric': 0.1291139240506329, 'fraction_numerical': 0.008438818565400843, 'mean_word_length': 1.5510455104551046, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '797135', 'n_tokens_mistral': 2189, 'n_tokens_neox': 2106, 'n_words': 777}