1 #include <goofit/Error.h>
2 #include <goofit/PDFs/basic/ExpPdf.h>
6 __device__ fptype device_Exp(fptype *evt, fptype *p, unsigned int *indices) {
7 fptype x = evt[indices[2 + indices[0]]];
8 fptype alpha = p[indices[1]];
10 fptype ret = exp(alpha * x);
14 __device__ fptype device_ExpOffset(fptype *evt, fptype *p, unsigned int *indices) {
15 fptype x = evt[indices[2 + indices[0]]];
17 fptype alpha = p[indices[2]];
19 fptype ret = exp(alpha * x);
23 __device__ fptype device_ExpPoly(fptype *evt, fptype *p, unsigned int *indices) {
24 fptype x = evt[indices[2 + indices[0]]];
28 for(int i = 0; i <= indices[0]; ++i) {
29 exparg += pow(x, i) * p[indices[i + 1]];
32 fptype ret = exp(exparg);
36 __device__ fptype device_ExpPolyOffset(fptype *evt, fptype *p, unsigned int *indices) {
37 fptype x = evt[indices[2 + indices[0]]];
42 for(int i = 0; i <= indices[0]; ++i) {
43 exparg += pow(x, i) * p[indices[i + 2]];
46 fptype ret = exp(exparg);
50 __device__ device_function_ptr ptr_to_Exp = device_Exp;
51 __device__ device_function_ptr ptr_to_ExpPoly = device_ExpPoly;
52 __device__ device_function_ptr ptr_to_ExpOffset = device_ExpOffset;
53 __device__ device_function_ptr ptr_to_ExpPolyOffset = device_ExpPolyOffset;
55 __host__ ExpPdf::ExpPdf(std::string n, Observable _x, Variable alpha)
57 std::vector<unsigned int> pindices;
59 pindices.push_back(registerParameter(alpha));
60 GET_FUNCTION_ADDR(ptr_to_Exp);
64 __host__ ExpPdf::ExpPdf(std::string n, Observable _x, Variable alpha, Variable offset)
66 std::vector<unsigned int> pindices;
68 pindices.push_back(registerParameter(offset));
69 pindices.push_back(registerParameter(alpha));
70 GET_FUNCTION_ADDR(ptr_to_ExpOffset);
74 __host__ ExpPdf::ExpPdf(std::string n, Observable _x, std::vector<Variable> &weights)
76 std::vector<unsigned int> pindices;
79 throw GooFit::GeneralError("Weights are empty!");
81 for(Variable &w : weights)
82 pindices.push_back(registerParameter(w));
84 GET_FUNCTION_ADDR(ptr_to_ExpPoly);
89 __host__ ExpPdf::ExpPdf(std::string n, Observable _x, std::vector<Variable> &weights, Variable offset)
91 std::vector<unsigned int> pindices;
93 pindices.push_back(registerParameter(offset));
96 throw GooFit::GeneralError("Weights are empty!");
98 for(Variable &w : weights)
99 pindices.push_back(registerParameter(w));
101 GET_FUNCTION_ADDR(ptr_to_ExpPolyOffset);
103 initialize(pindices);
106 __host__ fptype ExpPdf::integrate(fptype lo, fptype hi) const {
107 fptype alpha = host_params[host_indices[parameters + 1]];
110 // This gives a constant 1 all across the range
114 fptype ret = exp(alpha * hi) - exp(alpha * lo);
119 } // namespace GooFit