File indexing completed on 2025-01-30 10:22:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef ROOT_Math_IntegratorOptions
0012 #define ROOT_Math_IntegratorOptions
0013
0014 #include "Math/AllIntegrationTypes.h"
0015
0016 #include <string>
0017 #include <iostream>
0018
0019 namespace ROOT {
0020
0021
0022 namespace Math {
0023
0024 class IOptions;
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class BaseIntegratorOptions {
0036
0037 protected:
0038
0039
0040 BaseIntegratorOptions();
0041
0042 public:
0043
0044
0045 BaseIntegratorOptions(const BaseIntegratorOptions & opt);
0046
0047
0048 BaseIntegratorOptions & operator=(const BaseIntegratorOptions & opt);
0049
0050
0051
0052 virtual ~BaseIntegratorOptions() { ClearExtra(); }
0053
0054
0055
0056 virtual std::string Integrator() const = 0;
0057
0058
0059
0060
0061 double AbsTolerance() const { return fAbsTolerance; }
0062
0063
0064 double RelTolerance() const { return fRelTolerance; }
0065
0066
0067 unsigned int WKSize() const { return fWKSize; }
0068
0069
0070
0071 IOptions * ExtraOptions() const { return fExtraOptions; }
0072
0073
0074
0075
0076
0077 void SetAbsTolerance(double tol) { fAbsTolerance = tol; }
0078
0079
0080 void SetRelTolerance(double tol) { fRelTolerance = tol; }
0081
0082
0083 void SetWKSize(unsigned int size) { fWKSize = size; }
0084
0085
0086 void SetExtraOptions(const IOptions & opt);
0087
0088
0089 protected:
0090
0091 void ClearExtra();
0092
0093 int fIntegType;
0094
0095 unsigned int fWKSize;
0096 unsigned int fNCalls;
0097 double fAbsTolerance;
0098 double fRelTolerance;
0099
0100
0101
0102 ROOT::Math::IOptions * fExtraOptions;
0103
0104 };
0105
0106
0107
0108
0109
0110
0111
0112
0113 class IntegratorOneDimOptions : public BaseIntegratorOptions {
0114
0115 public:
0116
0117
0118
0119
0120 IntegratorOneDimOptions(IOptions * extraOpts = nullptr);
0121
0122 ~IntegratorOneDimOptions() override {}
0123
0124
0125 IntegratorOneDimOptions(const IntegratorOneDimOptions & rhs) :
0126 BaseIntegratorOptions(rhs)
0127 {}
0128
0129
0130 IntegratorOneDimOptions & operator=(const IntegratorOneDimOptions & rhs) {
0131 if (this == &rhs) return *this;
0132 static_cast<BaseIntegratorOptions &>(*this) = rhs;
0133 return *this;
0134 }
0135
0136
0137
0138
0139
0140 void SetNPoints(unsigned int n) { fNCalls = n; }
0141
0142
0143 unsigned int NPoints() const { return fNCalls; }
0144
0145
0146 std::string Integrator() const override;
0147
0148
0149 IntegrationOneDim::Type IntegratorType() const { return (IntegrationOneDim::Type) fIntegType; }
0150
0151
0152 void SetIntegrator(const char * name);
0153
0154
0155 void Print(std::ostream & os = std::cout) const;
0156
0157
0158
0159 static void SetDefaultIntegrator(const char * name);
0160 static void SetDefaultAbsTolerance(double tol);
0161 static void SetDefaultRelTolerance(double tol);
0162 static void SetDefaultWKSize(unsigned int size);
0163 static void SetDefaultNPoints(unsigned int n);
0164
0165 static std::string DefaultIntegrator();
0166 static IntegrationOneDim::Type DefaultIntegratorType();
0167 static double DefaultAbsTolerance();
0168 static double DefaultRelTolerance();
0169 static unsigned int DefaultWKSize();
0170 static unsigned int DefaultNPoints();
0171
0172
0173 static ROOT::Math::IOptions & Default(const char * name);
0174
0175
0176 static ROOT::Math::IOptions * FindDefault(const char * name);
0177
0178
0179 static void PrintDefault(const char * name = nullptr, std::ostream & os = std::cout);
0180
0181
0182 private:
0183
0184
0185 };
0186
0187
0188
0189
0190
0191
0192
0193
0194 class IntegratorMultiDimOptions : public BaseIntegratorOptions {
0195
0196 public:
0197
0198
0199
0200
0201 IntegratorMultiDimOptions(IOptions * extraOpts = nullptr);
0202
0203 ~IntegratorMultiDimOptions() override {}
0204
0205
0206 IntegratorMultiDimOptions(const IntegratorMultiDimOptions & rhs) :
0207 BaseIntegratorOptions(rhs)
0208 {}
0209
0210
0211 IntegratorMultiDimOptions & operator=(const IntegratorMultiDimOptions & rhs) {
0212 if (this == &rhs) return *this;
0213 static_cast<BaseIntegratorOptions &>(*this) = rhs;
0214 return *this;
0215 }
0216
0217
0218
0219 void SetNCalls(unsigned int calls) { fNCalls = calls; }
0220
0221
0222 unsigned int NCalls() const { return fNCalls; }
0223
0224
0225 std::string Integrator() const override;
0226
0227
0228 IntegrationMultiDim::Type IntegratorType() const { return (IntegrationMultiDim::Type) fIntegType; }
0229
0230
0231 void SetIntegrator(const char * name);
0232
0233
0234 void Print(std::ostream & os = std::cout) const;
0235
0236
0237
0238 static void SetDefaultIntegrator(const char * name);
0239 static void SetDefaultAbsTolerance(double tol);
0240 static void SetDefaultRelTolerance(double tol);
0241 static void SetDefaultWKSize(unsigned int size);
0242 static void SetDefaultNCalls(unsigned int ncall);
0243
0244 static std::string DefaultIntegrator();
0245 static IntegrationMultiDim::Type DefaultIntegratorType();
0246 static double DefaultAbsTolerance();
0247 static double DefaultRelTolerance();
0248 static unsigned int DefaultWKSize();
0249 static unsigned int DefaultNCalls();
0250
0251
0252 static ROOT::Math::IOptions & Default(const char * name);
0253
0254
0255 static ROOT::Math::IOptions * FindDefault(const char * name);
0256
0257
0258 static void PrintDefault(const char *name = nullptr, std::ostream & os = std::cout);
0259
0260
0261 private:
0262
0263
0264 };
0265
0266
0267 }
0268
0269 }
0270
0271 #endif