Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
DistSamplerOptions.cxx
Go to the documentation of this file.
1// @(#)root/mathcore:$Id$
2// Author: L. Moneta Fri Aug 15 2008
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2008 LCG ROOT Math Team, CERN/PH-SFT *
7 * *
8 * *
9 **********************************************************************/
10
12
13#include "Math/GenAlgoOptions.h"
14
15
16#include <iomanip>
17
18namespace ROOT {
19
20
21namespace Math {
22
23 namespace Sampler {
24 static std::string gDefaultSampler = "Unuran";
25 static std::string gDefaultAlgorithm1D = "auto";
26 static std::string gDefaultAlgorithmND = "vnrou";
27 static int gDefaultPrintLevel = 0;
28 }
29
30
32 // set the default minimizer type and algorithm
33 if (type) Sampler::gDefaultSampler = std::string(type);
34}
36 // set the default minimizer type and algorithm
37 if (algo) Sampler::gDefaultAlgorithm1D = std::string(algo);
38}
40 // set the default minimizer type and algorithm
41 if (algo) Sampler::gDefaultAlgorithmND = std::string(algo);
42}
44 // set the default printing level
46}
47
51
53{
54 // return default minimizer
55 // if is "" (no default is set) read from etc/system.rootrc
56 // use form /etc/ ??
57
59}
60
61
63 fLevel( Sampler::gDefaultPrintLevel),
64 fExtraOptions(nullptr)
65{
66 // constructor using the default options
67
69
70 if (dim == 1)
72 else if (dim >1)
74 else
75 // not specified - keep null string
76 fAlgoType = std::string();
77
78 // check if extra options exists (copy them if needed)
79 if (!fExtraOptions) {
80 IOptions * gopts = FindDefault( fSamplerType.c_str() );
81 if (gopts) fExtraOptions = gopts->Clone();
82 }
83}
84
85
86DistSamplerOptions::DistSamplerOptions(const DistSamplerOptions & opt) : fExtraOptions(nullptr) {
87 // copy constructor
88 (*this) = opt;
89}
90
92 // assignment operator
93 if (this == &opt) return *this; // self assignment
94 fLevel = opt.fLevel;
96 fAlgoType = opt.fAlgoType;
97
98 if (fExtraOptions) delete fExtraOptions;
99 fExtraOptions = nullptr;
100 if (opt.fExtraOptions) fExtraOptions = (opt.fExtraOptions)->Clone();
101 return *this;
102}
103
105 if (fExtraOptions) delete fExtraOptions;
106}
107
109 // set extra options (clone the passed one)
110 if (fExtraOptions) delete fExtraOptions;
111 fExtraOptions = opt.Clone();
112}
113
115 if (fExtraOptions) return;
117}
118
119void DistSamplerOptions::Print(std::ostream & os) const {
120 //print all the options
121 os << std::setw(25) << "DistSampler Type" << " : " << std::setw(15) << fSamplerType << std::endl;
122 os << std::setw(25) << "DistSampler Algorithm" << " : " << std::setw(15) << fAlgoType << std::endl;
123 os << std::setw(25) << "Print Level" << " : " << std::setw(15) << fLevel << std::endl;
124
125 if (ExtraOptions()) {
126 os << fSamplerType << " specific options :" << std::endl;
127 ExtraOptions()->Print(os);
128 }
129}
130
132 // create default extra options for the given algorithm type
134}
135
137 // find extra options for the given algorithm type
139}
140
141void DistSamplerOptions::PrintDefault(const char * name, std::ostream & os) {
142 //print default options
143 os << "Default DistSampler options " << std::endl;
144 os << std::setw(25) << "Default Type" << " : " << std::setw(15) << DistSamplerOptions::DefaultSampler() << std::endl;
145 os << std::setw(25) << "Default Algorithm 1D" << " : " << std::setw(15) << DistSamplerOptions::DefaultAlgorithm1D() << std::endl;
146 os << std::setw(25) << "Default Algorithm ND" << " : " << std::setw(15) << DistSamplerOptions::DefaultAlgorithmND() << std::endl;
147 os << std::setw(25) << "Default Print Level" << " : " << std::setw(15) << DistSamplerOptions::DefaultPrintLevel() << std::endl;
148 IOptions * opt = FindDefault(name);
149 if (opt) {
150 os << "Specific default options for " << name << std::endl;
151 opt->Print(os);
152 }
153}
154
155
156
157
158} // end namespace Math
159
160} // end namespace ROOT
161
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
DistSampler options class.
DistSamplerOptions & operator=(const DistSamplerOptions &opt)
assignment operators
static void SetDefaultSampler(const char *type)
void SetExtraOptions(const IOptions &opt)
set extra options (in this case pointer is cloned)
std::string fSamplerType
DistSampler type (Unuran, Foam, etc...)xs.
static void SetDefaultPrintLevel(int level)
static void PrintDefault(const char *name, std::ostream &os=std::cout)
print all the default options for the name given
ROOT::Math::IOptions * fExtraOptions
extra options
static const std::string & DefaultSampler()
std::string fAlgoType
DistSampler algorithmic specification (for Unuran only)
static void SetDefaultAlgorithmND(const char *algo)
IOptions * ExtraOptions() const
return extra options (NULL pointer if they are not present)
static const std::string & DefaultAlgorithmND()
static const std::string & DefaultAlgorithm1D()
static void SetDefaultAlgorithm1D(const char *algo)
static ROOT::Math::IOptions & Default(const char *name)
retrieve extra options - if not existing create a IOptions
static ROOT::Math::IOptions * FindDefault(const char *name)
void Print(std::ostream &os=std::cout) const
print all the options
class implementing generic options for a numerical algorithm Just store the options in a map of strin...
static IOptions & Default(const char *algoname)
static IOptions * FindDefault(const char *algoname)
Generic interface for defining configuration options of a numerical algorithm.
Definition IOptions.h:28
virtual IOptions * Clone() const =0
virtual void Print(std::ostream &=std::cout) const
print options
Definition IOptions.cxx:56
Namespace for new Math classes and functions.
static std::string gDefaultAlgorithm1D
static std::string gDefaultAlgorithmND
static std::string gDefaultSampler
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.