24 static std::string gDefaultSampler =
"Unuran";
25 static std::string gDefaultAlgorithm1D =
"auto";
26 static std::string gDefaultAlgorithmND =
"vnrou";
27 static int gDefaultPrintLevel = 0;
31 void DistSamplerOptions::SetDefaultSampler(
const char * type ) {
33 if (type) Sampler::gDefaultSampler = std::string(type);
35 void DistSamplerOptions::SetDefaultAlgorithm1D(
const char * algo ) {
37 if (algo) Sampler::gDefaultAlgorithm1D = std::string(algo);
39 void DistSamplerOptions::SetDefaultAlgorithmND(
const char * algo ) {
41 if (algo) Sampler::gDefaultAlgorithmND = std::string(algo);
43 void DistSamplerOptions::SetDefaultPrintLevel(
int level) {
45 Sampler::gDefaultPrintLevel = level;
48 const std::string & DistSamplerOptions::DefaultAlgorithm1D() {
return Sampler::gDefaultAlgorithm1D; }
49 const std::string & DistSamplerOptions::DefaultAlgorithmND() {
return Sampler::gDefaultAlgorithmND; }
50 int DistSamplerOptions::DefaultPrintLevel() {
return Sampler::gDefaultPrintLevel; }
52 const std::string & DistSamplerOptions::DefaultSampler()
58 return Sampler::gDefaultSampler;
62 DistSamplerOptions::DistSamplerOptions(
int dim):
63 fLevel( Sampler::gDefaultPrintLevel),
68 fSamplerType = DistSamplerOptions::DefaultSampler();
71 fAlgoType = DistSamplerOptions::DefaultAlgorithm1D();
73 fAlgoType = DistSamplerOptions::DefaultAlgorithmND();
76 fAlgoType = std::string();
80 IOptions * gopts = FindDefault( fSamplerType.c_str() );
81 if (gopts) fExtraOptions = gopts->Clone();
86 DistSamplerOptions::DistSamplerOptions(
const DistSamplerOptions & opt) : fExtraOptions(0) {
91 DistSamplerOptions & DistSamplerOptions::operator=(
const DistSamplerOptions & opt) {
93 if (
this == &opt)
return *
this;
95 fSamplerType = opt.fSamplerType;
96 fAlgoType = opt.fAlgoType;
98 if (fExtraOptions)
delete fExtraOptions;
100 if (opt.fExtraOptions) fExtraOptions = (opt.fExtraOptions)->Clone();
104 DistSamplerOptions::~DistSamplerOptions() {
105 if (fExtraOptions)
delete fExtraOptions;
108 void DistSamplerOptions::SetExtraOptions(
const IOptions & opt) {
110 if (fExtraOptions)
delete fExtraOptions;
111 fExtraOptions = opt.Clone();
114 void DistSamplerOptions::Print(std::ostream & os)
const {
116 os << std::setw(25) <<
"DistSampler Type" <<
" : " << std::setw(15) << fSamplerType << std::endl;
117 os << std::setw(25) <<
"DistSampler Algorithm" <<
" : " << std::setw(15) << fAlgoType << std::endl;
118 os << std::setw(25) <<
"Print Level" <<
" : " << std::setw(15) << fLevel << std::endl;
120 if (ExtraOptions()) {
121 os << fSamplerType <<
" specific options :" << std::endl;
122 ExtraOptions()->Print(os);
126 IOptions & DistSamplerOptions::Default(
const char * name) {
128 return GenAlgoOptions::Default(name);
131 IOptions * DistSamplerOptions::FindDefault(
const char * name) {
133 return GenAlgoOptions::FindDefault(name);
136 void DistSamplerOptions::PrintDefault(
const char * name, std::ostream & os) {
138 os <<
"Default DistSampler options " << std::endl;
139 os << std::setw(25) <<
"Default Type" <<
" : " << std::setw(15) << DistSamplerOptions::DefaultSampler() << std::endl;
140 os << std::setw(25) <<
"Default Algorithm 1D" <<
" : " << std::setw(15) << DistSamplerOptions::DefaultAlgorithm1D() << std::endl;
141 os << std::setw(25) <<
"Default Algorithm ND" <<
" : " << std::setw(15) << DistSamplerOptions::DefaultAlgorithmND() << std::endl;
142 os << std::setw(25) <<
"Default Print Level" <<
" : " << std::setw(15) << DistSamplerOptions::DefaultPrintLevel() << std::endl;
143 IOptions * opt = FindDefault(name);
145 os <<
"Specific default options for " << name << std::endl;