Skip to content

Commit

Permalink
Merge pull request #46 from niclaurenti/add-tests
Browse files Browse the repository at this point in the history
Add tests
  • Loading branch information
niclaurenti authored Apr 17, 2024
2 parents 4a89481 + 773b88d commit a09d66b
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 125 deletions.
3 changes: 3 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
clang-format -i inc/adani/*.h
clang-format -i src/*.cc
clang-format -i pywrap/pywrap.cc
11 changes: 3 additions & 8 deletions inc/adani/CoefficientFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,10 @@ class CoefficientFunction {
char GetKind() const { return kind_; };
char GetChannel() const { return channel_; };

// set methods
void SetOrder(const int &order);
void SetKind(const char &kind);
void SetChannel(const char &channel);

private:
int order_; // order = 1, 2, or 3
char kind_; // kind_ = '2' for F2 and 'L' for FL
char channel_; // channel_ = 'g' for Cg and 'q' for Cq
const int order_; // order = 1, 2, or 3
const char kind_; // kind_ = '2' for F2 and 'L' for FL
const char channel_; // channel_ = 'g' for Cg and 'q' for Cq
};

#endif
7 changes: 3 additions & 4 deletions inc/adani/Convolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ class AbstractConvolution {
// set methods
void SetAbserr(const double &abserr);
void SetRelerr(const double &relerr);
void SetDim(const int &dim);

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

gsl_integration_workspace *w_;

protected:
Expand Down Expand Up @@ -154,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 @@ -168,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
5 changes: 1 addition & 4 deletions inc/adani/HighEnergyCoefficientFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ class AbstractHighEnergyCoefficientFunction : public CoefficientFunction {
// get methods
bool GetNLL() const { return NLL_; };

// set methods
void SetNLL(const bool &NLL) { NLL_ = NLL; };

private:
bool NLL_;
const bool NLL_;

//==========================================================================================//
// Color factors O(as^3)
Expand Down
17 changes: 11 additions & 6 deletions inc/adani/MatchingCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* Description: Header file for the
* MatchingCondition.cc file.
*
* Author: Vamo!!
* Author: Non credo esista una persona che analizzi il calcio meglio
* di me.
*
* In this file there are the matching conditions.
*
Expand Down Expand Up @@ -34,15 +35,19 @@ class MatchingCondition {
);
~MatchingCondition(){};

int GetOrder() const { return order_; };
char GetEntry1() const { return entry1_; };
char GetEntry2() const { return entry2_; };
string GetVersion() const { return version_; };

Value MuIndependentNfIndependentTerm(double x) const;
vector<double> NotOrdered(double x) const;

private:
int order_;
char entry1_;
char entry2_;

string version_;
const int order_;
const char entry1_;
const char entry2_;
const string version_;

//==========================================================================================//
// Matching conditions O(as)
Expand Down
18 changes: 9 additions & 9 deletions inc/adani/SplittingFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class SplittingFunction : public AbstractSplittingFunction {
char GetEntry2() const { return entry2_; };

private:
int order_;
char entry1_;
char entry2_;
const int order_;
const char entry1_;
const char entry2_;

double (SplittingFunction::*reg_)(double, int) const;
double (SplittingFunction::*sing_)(double, int) const;
Expand Down Expand Up @@ -169,12 +169,12 @@ class ConvolutedSplittingFunctions : public AbstractSplittingFunction {
char GetEntry4() const { return entry4_; };

private:
int order1_;
char entry1_;
char entry2_;
int order2_;
char entry3_;
char entry4_;
const int order1_;
const char entry1_;
const char entry2_;
const int order2_;
const char entry3_;
const char entry4_;

double (ConvolutedSplittingFunctions::*reg_)(double, int) const;

Expand Down
55 changes: 44 additions & 11 deletions pywrap/pywrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ PYBIND11_MODULE(_core, m) {
.def("GetHigher", &Value::GetHigher)
.def("GetLower", &Value::GetLower);

// CoefficientFunction
py::class_<CoefficientFunction>(m, "CoefficientFunction")
.def("GetOrder", &CoefficientFunction::GetOrder)
.def("GetKind", &CoefficientFunction::GetKind)
.def("GetChannel", &CoefficientFunction::GetChannel);

// ApproximateCoefficientFunction
py::class_<ApproximateCoefficientFunction>(
py::class_<ApproximateCoefficientFunction, CoefficientFunction>(
m, "ApproximateCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -87,7 +93,7 @@ PYBIND11_MODULE(_core, m) {
);

// ApproximateCoefficientFunctionKLMV
py::class_<ApproximateCoefficientFunctionKLMV>(
py::class_<ApproximateCoefficientFunctionKLMV, CoefficientFunction>(
m, "ApproximateCoefficientFunctionKLMV"
)
.def(
Expand Down Expand Up @@ -131,7 +137,7 @@ PYBIND11_MODULE(_core, m) {
);

// AsymptoticCoefficientFunction
py::class_<AsymptoticCoefficientFunction>(
py::class_<AsymptoticCoefficientFunction, CoefficientFunction>(
m, "AsymptoticCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -171,7 +177,9 @@ PYBIND11_MODULE(_core, m) {
);

// ExactCoefficientFunction
py::class_<ExactCoefficientFunction>(m, "ExactCoefficientFunction")
py::class_<ExactCoefficientFunction, CoefficientFunction>(
m, "ExactCoefficientFunction"
)
.def(
py::init<
const int &, const char &, const char &, const double &,
Expand Down Expand Up @@ -208,8 +216,15 @@ PYBIND11_MODULE(_core, m) {
py::arg("m2Q2"), py::arg("m2mu2"), py::arg("nf")
);

// AbstractHighEnergyCoefficientFunction
py::class_<AbstractHighEnergyCoefficientFunction, CoefficientFunction>(
m, "AbstractHighEnergyCoefficientFunction"
)
.def("GetNLL", &AbstractHighEnergyCoefficientFunction::GetNLL);

// HighEnergyCoefficientFunction
py::class_<HighEnergyCoefficientFunction>(
py::class_<
HighEnergyCoefficientFunction, AbstractHighEnergyCoefficientFunction>(
m, "HighEnergyCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -247,7 +262,9 @@ PYBIND11_MODULE(_core, m) {
);

// HighEnergyHighScaleCoefficientFunction
py::class_<HighEnergyHighScaleCoefficientFunction>(
py::class_<
HighEnergyHighScaleCoefficientFunction,
AbstractHighEnergyCoefficientFunction>(
m, "HighEnergyHighScaleCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -285,7 +302,8 @@ PYBIND11_MODULE(_core, m) {
);

// PowerTermsCoefficientFunction
py::class_<PowerTermsCoefficientFunction>(
py::class_<
PowerTermsCoefficientFunction, AbstractHighEnergyCoefficientFunction>(
m, "PowerTermsCoefficientFunction"
)
.def(
Expand Down Expand Up @@ -323,7 +341,9 @@ PYBIND11_MODULE(_core, m) {
);

// HighScaleCoefficientFunction
py::class_<HighScaleCoefficientFunction>(m, "HighScaleCoefficientFunction")
py::class_<HighScaleCoefficientFunction, CoefficientFunction>(
m, "HighScaleCoefficientFunction"
)
.def(
py::init<const int &, const char &, const char &, const string &>(),
py::arg("order"), py::arg("kind"), py::arg("channel"),
Expand Down Expand Up @@ -358,7 +378,7 @@ PYBIND11_MODULE(_core, m) {
);

// HighScaleSplitLogs
py::class_<HighScaleSplitLogs>(m, "HighScaleSplitLogs")
py::class_<HighScaleSplitLogs, CoefficientFunction>(m, "HighScaleSplitLogs")
.def(
py::init<const int &, const char &, const char &, const string &>(),
py::arg("order"), py::arg("kind"), py::arg("channel"),
Expand All @@ -382,7 +402,9 @@ PYBIND11_MODULE(_core, m) {
);

// MasslessCoefficientFunction
py::class_<MasslessCoefficientFunction>(m, "MasslessCoefficientFunction")
py::class_<MasslessCoefficientFunction, CoefficientFunction>(
m, "MasslessCoefficientFunction"
)
.def(
py::init<const int &, const char &, const char &>(),
py::arg("order"), py::arg("kind"), py::arg("channel")
Expand All @@ -402,6 +424,9 @@ PYBIND11_MODULE(_core, m) {
py::init<const int &, const char &, const char &>(),
py::arg("order"), py::arg("entry1"), py::arg("entry2")
)
.def("GetOrder", &SplittingFunction::GetOrder)
.def("GetEntry1", &SplittingFunction::GetEntry1)
.def("GetEntry2", &SplittingFunction::GetEntry2)
.def(
"Regular", &SplittingFunction::Regular, py::arg("x"), py::arg("nf")
)
Expand All @@ -424,6 +449,12 @@ PYBIND11_MODULE(_core, m) {
py::arg("order1"), py::arg("entry1"), py::arg("entry2"),
py::arg("order2"), py::arg("entry3"), py::arg("entry4")
)
.def("GetOrder1", &ConvolutedSplittingFunctions::GetOrder1)
.def("GetEntry1", &ConvolutedSplittingFunctions::GetEntry1)
.def("GetEntry2", &ConvolutedSplittingFunctions::GetEntry2)
.def("GetOrder2", &ConvolutedSplittingFunctions::GetOrder2)
.def("GetEntry3", &ConvolutedSplittingFunctions::GetEntry3)
.def("GetEntry4", &ConvolutedSplittingFunctions::GetEntry4)
.def(
"Regular", &ConvolutedSplittingFunctions::Regular, py::arg("x"),
py::arg("nf")
Expand All @@ -440,7 +471,9 @@ PYBIND11_MODULE(_core, m) {
.def("Local", &ConvolutedSplittingFunctions::Local, py::arg("nf"));

// ThresholdCoefficientFunction
py::class_<ThresholdCoefficientFunction>(m, "ThresholdCoefficientFunction")
py::class_<ThresholdCoefficientFunction, CoefficientFunction>(
m, "ThresholdCoefficientFunction"
)
.def(
py::init<const int &, const char &, const char &>(),
py::arg("order"), py::arg("kind"), py::arg("channel")
Expand Down
40 changes: 8 additions & 32 deletions src/CoefficientFunction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,21 @@ using std::endl;

CoefficientFunction::CoefficientFunction(
const int &order, const char &kind, const char &channel
) {
)
: order_(order), kind_(kind), channel_(channel) {

SetOrder(order);
SetKind(kind);
SetChannel(channel);
}

//==========================================================================================//
// CoefficientFunction: destructor
//------------------------------------------------------------------------------------------//

CoefficientFunction::~CoefficientFunction(){};

//==========================================================================================//
// CoefficientFunction: set method for order: order = 1, 2, 3
//------------------------------------------------------------------------------------------//

void CoefficientFunction::SetOrder(const int &order) {
// check order
if (order < 1 || order > 3) {
cout << "Error: order must be 1, 2 or 3. Got: " << order << endl;
exit(-1);
}
order_ = order;
}

//==========================================================================================//
// CoefficientFunction: set method for kind: kind = '2', 'L'
//------------------------------------------------------------------------------------------//

void CoefficientFunction::SetKind(const char &kind) {
// check kind
if (kind != '2' && kind != 'L') {
cout << "Error: kind must be 2 or L. Got: " << kind << endl;
exit(-1);
}
kind_ = kind;
}

//==========================================================================================//
// CoefficientFunction: set method for channel: channel = 'g', 'q'
//------------------------------------------------------------------------------------------//

void CoefficientFunction::SetChannel(const char &channel) {
// check channel
if (channel != 'g' && channel != 'q') {
cout << "Error: channel must be g or q. Got: " << channel << endl;
Expand All @@ -63,9 +34,14 @@ void CoefficientFunction::SetChannel(const char &channel) {
<< endl;
exit(-1);
}
channel_ = channel;
}

//==========================================================================================//
// CoefficientFunction: destructor
//------------------------------------------------------------------------------------------//

CoefficientFunction::~CoefficientFunction(){};

//==========================================================================================//
// CoefficientFunction: central value of fx
//------------------------------------------------------------------------------------------//
Expand Down
Loading

0 comments on commit a09d66b

Please sign in to comment.