<commit_before>// @(#)root/mathcore:$Id$ 
// Author: <NAME> 2010
/**********************************************************************
 *                                                                    *
 * Copyright (c) 2010  LCG ROOT Math Team, CERN/PH-SFT                *
 *                                                                    *
 *                                                                    *
 **********************************************************************/

// implementation file for static methods of GenAlgoOptions
// this file contains also the pointer to the static map<algorithm name, options> 

#include "Math/GenAlgoOptions.h"
#include <cassert>

// for toupper
#include <algorithm>
#include <functional>
#include <ctype.h>   // need to use c version of tolower defined here

namespace ROOT { 
namespace Math { 

typedef std::map<std::string, ROOT::Math::GenAlgoOptions > OptionsMap; 

namespace GenAlgoOptUtil {

   // map with the generic options for all ROOT::Math numerical algorithm 
   static OptionsMap gAlgoOptions; 
 

   IOptions * DoFindDefault(std::string & algoname, OptionsMap & gOpts) { 
      // internal function to retrieve the 
      // default extra options for the given algorithm type 
      // return zero if not found
      // store always name in upper case
      std::transform(algoname.begin(), algoname.end(), algoname.begin(), (int(*)(int)) toupper ); 
      
      OptionsMap::iterator pos = gOpts.find(algoname); 
      if (pos !=  gOpts.end() ) { 
         return &(pos->second); 
      }
      return 0; 
   }
}
   
   IOptions * GenAlgoOptions::FindDefault(const char * algo) { 
      // find default options - return 0 if not found
      std::string algoname(algo);
      OptionsMap & gOpts = GenAlgoOptUtil::gAlgoOptions; 
      return GenAlgoOptUtil::DoFindDefault(algoname, gOpts); 
   }

   IOptions & GenAlgoOptions::Default(const char * algo) { 
      // create default extra options for the given algorithm type 
      std::string algoname(algo);
      OptionsMap & gOpts = GenAlgoOptUtil::gAlgoOptions; 
      IOptions * opt = GenAlgoOptUtil::DoFindDefault(algoname, gOpts); 
      if (opt == 0) { 
         // create new extra options for the given type
         std::pair<OptionsMap::iterator,bool> ret = gOpts.insert( OptionsMap::value_type(algoname, ROOT::Math::GenAlgoOptions()) );
         assert(ret.second);
         opt = &((ret.first)->second);
      }
      return *opt;
   }

   void PrintAllDefault(std::ostream & os) { 
      const OptionsMap & gOpts = GenAlgoOptUtil::gAlgoOptions; 
      for (  OptionsMap::const_iterator pos = gOpts.begin(); <commit_msg>fix PrintAllDefault method<commit_after>// @(#)root/mathcore:$Id$ 
// Author: <NAME> Nov 2010
/**********************************************************************
 *                                                                    *
 * Copyright (c) 2010  LCG ROOT Math Team, CERN/PH-SFT                *
 *                                                                    *
 *                                                                    *
 **********************************************************************/

// implementation file for static methods of GenAlgoOptions
// this file contains also the pointer to the static map<algorithm name, options> 

#include "Math/GenAlgoOptions.h"
#include <cassert>

// for toupper
#include <algorithm>
#include <functional>
#include <ctype.h>   // need to use c version of tolower defined here

namespace ROOT { 
namespace Math { 

typedef std::map<std::string, ROOT::Math::GenAlgoOptions > OptionsMap; 

namespace GenAlgoOptUtil {

   // map with the generic options for all ROOT::Math numerical algorithm 
   static OptionsMap gAlgoOptions; 
 

   IOptions * DoFindDefault(std::string & algoname, OptionsMap & gOpts) { 
      // internal function to retrieve the 
      // default extra options for the given algorithm type 
      // return zero if not found
      // store always name in upper case
      std::transform(algoname.begin(), algoname.end(), algoname.begin(), (int(*)(int)) toupper ); 
      
      OptionsMap::iterator pos = gOpts.find(algoname); 
      if (pos !=  gOpts.end() ) { 
         return &(pos->second); 
      }
      return 0; 
   }
}
   
   IOptions * GenAlgoOptions::FindDefault(const char * algo) { 
      // find default options - return 0 if not found
      std::string algoname(algo);
      OptionsMap & gOpts = GenAlgoOptUtil::gAlgoOptions; 
      return GenAlgoOptUtil::DoFindDefault(algoname, gOpts); 
   }

   IOptions & GenAlgoOptions::Default(const char * algo) { 
      // create default extra options for the given algorithm type 
      std::string algoname(algo);
      OptionsMap & gOpts = GenAlgoOptUtil::gAlgoOptions; 
      IOptions * opt = GenAlgoOptUtil::DoFindDefault(algoname, gOpts); 
      if (opt == 0) { 
         // create new extra options for the given type
         std::pair<OptionsMap::iterator,bool> ret = gOpts.insert( OptionsMap::value_type(algoname, ROOT::Math::GenAlgoOptions()) );
         assert(ret.second);
         opt = &((ret.first)->second);
      }
      return *opt;
   }

   void GenAlgoOptions::PrintAllDefault(std::ostream & os) { 
      const OptionsMap & gOpts = GenAlgoOptUtil::gAlgoOptions; 
      for (  OptionsMap::const_iterator pos = gOpts.begin(); 
{'fraction_non_alphanumeric': 0.1530136219443926, 'fraction_numerical': 0.004105243515581265, 'mean_word_length': 2.401015228426396, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '4369175', 'n_tokens_mistral': 1512, 'n_tokens_neox': 1425, 'n_words': 391}