Skip to content

Commit

Permalink
boh
Browse files Browse the repository at this point in the history
  • Loading branch information
niclaurenti committed Apr 17, 2024
1 parent 2c29ec6 commit a079fe7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
10 changes: 7 additions & 3 deletions inc/adani/Convolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ class AbstractConvolution {
CoefficientFunction *GetCoeffFunc() const { return coefffunc_; };
AbstractSplittingFunction *GetSplitFunc() const { return splitfunc_; };

// set methods
void SetAbserr(const double &abserr);
void SetRelerr(const double &relerr);

private:
double abserr_;
double relerr_;
int dim_;
const int dim_;

gsl_integration_workspace *w_;

protected:
Expand Down Expand Up @@ -149,7 +154,6 @@ class DoubleConvolution : public AbstractConvolution {
int GetMCcalls() const { return MCcalls_; };

// set methods
void SetMCintegral(const bool &MCintegral);
void SetMCcalls(const int &MCcalls);

// support function for the integral. it is static in order to be passed
Expand All @@ -163,7 +167,7 @@ class DoubleConvolution : public AbstractConvolution {
static double singular3_integrand(double z, void *p);

private:
bool MCintegral_;
const bool MCintegral_;
int MCcalls_;
gsl_monte_vegas_state *s_;
gsl_rng *r_;
Expand Down
56 changes: 30 additions & 26 deletions src/Convolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,16 @@ using std::endl;
AbstractConvolution::AbstractConvolution(
CoefficientFunction *coefffunc, AbstractSplittingFunction *splitfunc,
const double &abserr, const double &relerr, const int &dim
) {
) : dim_(dim) {

// check abserr
if (abserr <= 0) {
cout << "Error: abserr must be positive. Got " << abserr << endl;
exit(-1);
}
abserr_ = abserr;

// check relerr
if (relerr <= 0) {
cout << "Error: relerr must be positive. Got " << relerr << endl;
exit(-1);
}
relerr_ = relerr;
SetAbserr(abserr);
SetRelerr(relerr);

// check dim
if (dim <= 0) {
cout << "Error: dim must be positive. Got " << dim << endl;
exit(-1);
}
dim_ = dim;

w_ = gsl_integration_workspace_alloc(dim);

Expand All @@ -54,6 +42,32 @@ AbstractConvolution::~AbstractConvolution() {
gsl_integration_workspace_free(w_);
};

//==========================================================================================//
// AbstractConvolution: set method for abserr
//------------------------------------------------------------------------------------------//

void AbstractConvolution::SetAbserr(const double &abserr) {
// check abserr
if (abserr <= 0) {
cout << "Error: abserr must be positive. Got " << abserr << endl;
exit(-1);
}
abserr_ = abserr;
}

//==========================================================================================//
// AbstractConvolution: set method for relerr
//------------------------------------------------------------------------------------------//

void AbstractConvolution::SetRelerr(const double &relerr) {
// check relerr
if (relerr <= 0) {
cout << "Error: relerr must be positive. Got " << relerr << endl;
exit(-1);
}
relerr_ = relerr;
}

//==========================================================================================//
// AbstractConvolution: convolute splitting function with coefficient function
//------------------------------------------------------------------------------------------//
Expand Down Expand Up @@ -253,9 +267,8 @@ DoubleConvolution::DoubleConvolution(
const double &abserr, const double &relerr, const int &dim,
const bool &MCintegral, const int &MCcalls
)
: AbstractConvolution(coefffunc, splitfunc, abserr, relerr, dim) {
: AbstractConvolution(coefffunc, splitfunc, abserr, relerr, dim), MCintegral_(MCintegral) {

SetMCintegral(MCintegral);
SetMCcalls(MCcalls);

if (MCintegral) {
Expand Down Expand Up @@ -291,15 +304,6 @@ DoubleConvolution::~DoubleConvolution() {
delete conv_coeff_;
}

//==========================================================================================//
// DoubleConvolution: set method for method_flag
//------------------------------------------------------------------------------------------//

void DoubleConvolution::SetMCintegral(const bool &MCintegral) {

MCintegral_ = MCintegral;
}

//==========================================================================================//
// DoubleConvolution: set method for MCcalls
//------------------------------------------------------------------------------------------//
Expand Down

0 comments on commit a079fe7

Please sign in to comment.