IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
Distribution.h
Go to the documentation of this file.
1// Class Distribution
2// This class can be used for creating a distribution object
3// with custom pdf, cdf, and estimate function that is used for
4// the sampling method.
5//
6
7#ifndef IPPL_DISTRIBUTION_H
8#define IPPL_DISTRIBUTION_H
9
10#include "Types/ViewTypes.h"
11
12#include "Random/Utility.h"
13
14namespace ippl {
15 namespace random {
16
21
32 template <typename T, unsigned Dim, unsigned DimP, typename DistributionFunctions>
34 public:
42 T par_m[DimP];
43 typename DistributionFunctions::PDF pdf_m;
44 typename DistributionFunctions::CDF cdf_m;
45 typename DistributionFunctions::Estimate estimate_m;
51 KOKKOS_INLINE_FUNCTION Distribution(const T* par_p) {
52 for (unsigned int i = 0; i < DimP; i++) {
53 par_m[i] = par_p[i];
54 }
55 }
56
61 KOKKOS_INLINE_FUNCTION ~Distribution() {}
62
67 KOKKOS_INLINE_FUNCTION T getPdf(T x, unsigned int d) const {
68 return pdf_m(x, d, par_m);
69 }
70
75 KOKKOS_INLINE_FUNCTION T getCdf(T x, unsigned int d) const {
76 return cdf_m(x, d, par_m);
77 }
78
83 KOKKOS_INLINE_FUNCTION T getEstimate(T x, unsigned int d) const {
84 return estimate_m(x, d, par_m);
85 }
86
92 KOKKOS_INLINE_FUNCTION T getObjFunc(T x, unsigned int d, T u) const {
93 return getCdf(x, d) - u;
94 }
95
100 KOKKOS_INLINE_FUNCTION T getDerObjFunc(T x, unsigned int d) const {
101 return getPdf(x, d);
102 }
103
108 KOKKOS_INLINE_FUNCTION T getFullPdf(ippl::Vector<T, Dim> x) const {
109 T totalPdf = 1.0;
110 for (unsigned int d = 0; d < Dim; d++) {
111 totalPdf *= getPdf(x[d], d);
112 }
113 return totalPdf;
114 }
115 };
116 } // namespace random
117} // namespace ippl
118
119#endif
constexpr unsigned Dim
Definition Archive.h:20
KOKKOS_INLINE_FUNCTION T getObjFunc(T x, unsigned int d, T u) const
DistributionFunctions::Estimate estimate_m
KOKKOS_INLINE_FUNCTION T getDerObjFunc(T x, unsigned int d) const
KOKKOS_INLINE_FUNCTION T getCdf(T x, unsigned int d) const
A wrapper to change the signature arguments of cdf in each dimension d from (x, d,...
KOKKOS_INLINE_FUNCTION ~Distribution()
Destructor for the Distribution class.
KOKKOS_INLINE_FUNCTION Distribution(const T *par_p)
Constructor for the Distribution class.
KOKKOS_INLINE_FUNCTION T getPdf(T x, unsigned int d) const
A wrapper to change the signature arguments of pdf in each dimension d from (x, d,...
KOKKOS_INLINE_FUNCTION T getEstimate(T x, unsigned int d) const
A wrapper to change the signature arguments of estimate in each dimension d from (x,...
DistributionFunctions::CDF cdf_m
KOKKOS_INLINE_FUNCTION T getFullPdf(ippl::Vector< T, Dim > x) const
DistributionFunctions::PDF pdf_m