clProbDist
An OpenCL library for probability distributions
continuous.h
1 /*
2  * Authors:
3  *
4  * Nabil Kemerchou <kemerchn@iro.umontreal.ca> (2015)
5  * David Munger <mungerd@iro.umontreal.ca> (2015)
6  * Pierre L'Ecuyer <lecuyer@iro.umontreal.ca> (2015)
7  *
8  */
9 
10 #pragma once
11 #ifndef CLPROBDIST_CONTINUOUSDIST_H
12 #define CLPROBDIST_CONTINUOUSDIST_H
13 
14 #if defined(__APPLE__) || defined(__MACOSX)
15 #include <OpenCL/cl.h>
16 #else
17 #include <CL/cl.h>
18 #endif
19 
37 typedef struct _clprobdistContinuousDist{
38  int decPrec; //Decimal degits of precision
39  // [supportA, supportB] is the support of the pdf(x)
40  cl_double supportA; //NEGATIVE INFINITY
41  cl_double supportB; //POSITIVE INFINITY
42 } clprobdistContinuous;
43 
44 // None of these functions are currently used by the library, but they could be
45 // used in the future when more distributions are implemented.
46 
47 #if 0
48 /***********************************
49 * Constructor & destructor
50 ***********************************/
51 cl_int clprobdistContinuousGetDecPrec(clprobdistContinuous* distObj, clprobdistStatus* err);
52 
53 cl_double clprobdistContinuousGetXinf(clprobdistContinuous* distObj, clprobdistStatus* err);
54 
55 cl_double clprobdistContinuousGetXsup(clprobdistContinuous* distObj, clprobdistStatus* err);
56 
57 clprobdistStatus clprobdistContinuousSetXinf(cl_double xa, clprobdistContinuous* distObj);
58 
59 clprobdistStatus clprobdistContinuousSetXsup(cl_double xb, clprobdistContinuous* distObj);
60 
61 
62 
63 /***********************************
64 * Abstract functions
65 ***********************************/
66 cl_double clprobdistContinuousCDF(cl_double x, clprobdistStatus* err);
67 
68 clprobdistStatus findInterval(cl_double u, cl_double* iv, clprobdistContinuous* distObj, clprobdistStatus* err);
69 
70 cl_double clprobdistContinuousDensity(cl_double x, clprobdistStatus* err);
71 
72 cl_double clprobdistContinuousGetMean(clprobdistStatus* err);
73 
74 cl_double clprobdistContinuousGetVariance(clprobdistStatus* err);
75 
76 cl_double clprobdistContinuousGetStdDeviation(clprobdistStatus* err);
77 
78 /***********************************
79 * Default implementations of functions
80 ***********************************/
81 cl_double clprobdistContinuousComplCDF(cl_double x, clprobdistStatus* err);
82 
83 cl_double clprobdistContinuousInverseBrent(cl_double a, cl_double b, cl_double u, cl_double tol, clprobdistContinuous* distObj, clprobdistStatus* err);
84 
85 cl_double clprobdistContinuousInverseBisection(cl_double u, clprobdistContinuous* distObj, clprobdistStatus* err);
86 
87 cl_double clprobdistContinuousInverseCDF(cl_double u, clprobdistContinuous* distObj, clprobdistStatus* err);
88 #endif
89 
90 #endif /* CONTINUOUSDIST_H */
91