Skip to content

Commit

Permalink
Add GPU support to normal dist
Browse files Browse the repository at this point in the history
Add SYCL testing of normal dist

Add CUDA testing of normal dist

Add NVRTC testing of normal dist

NVRTC fixes

Move headers for NVRTC support

Add GPU support to inverse gaussian dist

Add NVRTC testing of inverse Gaussian dist

Add CUDA testing of inverse gaussian dist

Add SYCL testing of inverse gaussian dist

Add GPU support to lognormal dist

Add SYCL testing of lognormal dist

Add CUDA testing of lognormal dist

Add nvrtc testing of lognormal dist

Add GPU support to negative binomial dist

Avoid float_prior on GPU platform

Add NVRTC testing of negative binomial dist

Fix ambiguous use of nextafter

Add CUDA testing of negative binomial dist

Fix float_prior workaround

Add SYCL testing of negative binomial dist

Add GPU support to non_central_beta dist

Add SYCL testing of nc beta dist

Add CUDA testing of nc beta dist

Enable generic dist handling on GPU

Add GPU support to brent_find_minima

Add NVRTC testing of nc beta dist

Add utility header

Replace non-functional macro with new function

Add GPU support to non central chi squared dist

Add SYCL testing of non central chi squared dist

Add missing macro definition

Markup generic quantile finder

Add CUDA testing of non central chi squared dist

Add NVRTC testing of non central chi squared dist

Add GPU support to the non-central f dist

Add SYCL testing of ncf

Add CUDA testing of ncf dist

Add NVRTC testing of ncf dist

Add GPU support to students_t dist

Add SYCL testing of students_t dist

Add CUDA testing of students_t

Add NVRTC testing of students_t dist

Workaround for header cycle

Add GPU support to pareto dist

Add SYCL testing of pareto dist

Add CUDA testing of pareto dist

Add NVRTC testing of pareto dist

Add missing header

Add GPU support to poisson dist

Add SYCL testing of poisson dist

Add CUDA testing of poisson dist

Add NVRTC testing of poisson dist

Add forward decl for NVRTC platform

Add GPU support to rayleigh dist

Add CUDA testing of rayleigh dist

Add SYCL testing of rayleigh dist

Add NVRTC testing of rayleigh dist

Add GPU support to triangular dist

Add SYCL testing of triangular dist

Add NVRTC testing of triangular dist

Add CUDA testing of triangular dist

Add GPU support to the uniform dist

Add CUDA testing of uniform dist

Add SYCL testing of uniform dist

Add NVRTC testing of uniform dist

Fix missing header

Add markers to docs
  • Loading branch information
mborland committed Sep 6, 2024
1 parent 1e9b2cc commit e9cd6c9
Show file tree
Hide file tree
Showing 211 changed files with 24,666 additions and 701 deletions.
16 changes: 9 additions & 7 deletions doc/distributions/inverse_gaussian.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
typedef RealType value_type;
typedef Policy policy_type;

inverse_gaussian_distribution(RealType mean = 1, RealType scale = 1);
BOOST_MATH_GPU_ENABLED inverse_gaussian_distribution(RealType mean = 1, RealType scale = 1);

RealType mean()const; // mean default 1.
RealType scale()const; // Optional scale, default 1 (unscaled).
RealType shape()const; // Shape = scale/mean.
BOOST_MATH_GPU_ENABLED RealType mean()const; // mean default 1.
BOOST_MATH_GPU_ENABLED RealType scale()const; // Optional scale, default 1 (unscaled).
BOOST_MATH_GPU_ENABLED RealType shape()const; // Shape = scale/mean.
};
typedef inverse_gaussian_distribution<double> inverse_gaussian;

Expand Down Expand Up @@ -90,26 +90,28 @@ Another related parameterisation, the __wald_distrib (where mean [mu] is unity)

[h4 Member Functions]

inverse_gaussian_distribution(RealType df = 1, RealType scale = 1); // optionally scaled.
BOOST_MATH_GPU_ENABLED inverse_gaussian_distribution(RealType df = 1, RealType scale = 1); // optionally scaled.

Constructs an inverse_gaussian distribution with [mu] mean,
and scale [lambda], with both default values 1.

Requires that both the mean [mu] parameter and scale [lambda] are greater than zero,
otherwise calls __domain_error.

RealType mean()const;
BOOST_MATH_GPU_ENABLED RealType mean()const;

Returns the mean [mu] parameter of this distribution.

RealType scale()const;
BOOST_MATH_GPU_ENABLED RealType scale()const;

Returns the scale [lambda] parameter of this distribution.

[h4 Non-member Accessors]

All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions] that are generic to all
distributions are supported: __usual_accessors.
For this distribution all non-member accessor functions are marked with `BOOST_MATH_GPU_ENABLED` and can
be run on both host and device.

The domain of the random variate is \[0,+[infin]).
[note Unlike some definitions, this implementation supports a random variate
Expand Down
14 changes: 8 additions & 6 deletions doc/distributions/lognormal.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
typedef RealType value_type;
typedef Policy policy_type;
// Construct:
lognormal_distribution(RealType location = 0, RealType scale = 1);
BOOST_MATH_GPU_ENABLED lognormal_distribution(RealType location = 0, RealType scale = 1);
// Accessors:
RealType location()const;
RealType scale()const;
BOOST_MATH_GPU_ENABLED RealType location()const;
BOOST_MATH_GPU_ENABLED RealType scale()const;
};

}} // namespaces
Expand Down Expand Up @@ -51,7 +51,7 @@ The next graph illustrates the effect of the scale parameter on the PDF:

[h4 Member Functions]

lognormal_distribution(RealType location = 0, RealType scale = 1);
BOOST_MATH_GPU_ENABLED lognormal_distribution(RealType location = 0, RealType scale = 1);

Constructs a lognormal distribution with location /location/ and
scale /scale/.
Expand All @@ -65,18 +65,20 @@ logarithm of the random variate.
Requires that the scale parameter is greater than zero, otherwise calls
__domain_error.

RealType location()const;
BOOST_MATH_GPU_ENABLED RealType location()const;

Returns the /location/ parameter of this distribution.

RealType scale()const;
BOOST_MATH_GPU_ENABLED RealType scale()const;

Returns the /scale/ parameter of this distribution.

[h4 Non-member Accessors]

All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions] that are generic to all
distributions are supported: __usual_accessors.
For this distribution all non-member accessor functions are marked with `BOOST_MATH_GPU_ENABLED` and can
be run on both host and device.

The domain of the random variable is \[0,+[infin]\].

Expand Down
18 changes: 10 additions & 8 deletions doc/distributions/nc_beta.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
typedef Policy policy_type;

// Constructor:
non_central_beta_distribution(RealType alpha, RealType beta, RealType lambda);
BOOST_MATH_GPU_ENABLED non_central_beta_distribution(RealType alpha, RealType beta, RealType lambda);

// Accessor to shape parameters:
RealType alpha()const;
RealType beta()const;
BOOST_MATH_GPU_ENABLED RealType alpha()const;
BOOST_MATH_GPU_ENABLED RealType beta()const;

// Accessor to non-centrality parameter lambda:
RealType non_centrality()const;
BOOST_MATH_GPU_ENABLED RealType non_centrality()const;
};

}} // namespaces
Expand Down Expand Up @@ -59,22 +59,22 @@ for different values of [lambda]:

[h4 Member Functions]

non_central_beta_distribution(RealType a, RealType b, RealType lambda);
BOOST_MATH_GPU_ENABLED non_central_beta_distribution(RealType a, RealType b, RealType lambda);

Constructs a noncentral beta distribution with shape parameters /a/ and /b/
and non-centrality parameter /lambda/.

Requires a > 0, b > 0 and lambda >= 0, otherwise calls __domain_error.

RealType alpha()const;
BOOST_MATH_GPU_ENABLED RealType alpha()const;

Returns the parameter /a/ from which this object was constructed.

RealType beta()const;
BOOST_MATH_GPU_ENABLED RealType beta()const;

Returns the parameter /b/ from which this object was constructed.

RealType non_centrality()const;
BOOST_MATH_GPU_ENABLED RealType non_centrality()const;

Returns the parameter /lambda/ from which this object was constructed.

Expand All @@ -83,6 +83,8 @@ Returns the parameter /lambda/ from which this object was constructed.
Most of the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
are supported: __cdf, __pdf, __quantile, __mean, __variance, __sd,
__median, __mode, __hazard, __chf, __range and __support.
For this distribution these functions are marked with `BOOST_MATH_GPU_ENABLED` and can
be run on both host and device.

Mean and variance are implemented using hypergeometric pfq functions and relations given in
[@http://reference.wolfram.com/mathematica/ref/NoncentralBetaDistribution.html Wolfram Noncentral Beta Distribution].
Expand Down
35 changes: 18 additions & 17 deletions doc/distributions/nc_chi_squared.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
typedef Policy policy_type;

// Constructor:
non_central_chi_squared_distribution(RealType v, RealType lambda);
BOOST_MATH_GPU_ENABLED non_central_chi_squared_distribution(RealType v, RealType lambda);

// Accessor to degrees of freedom parameter v:
RealType degrees_of_freedom()const;
BOOST_MATH_GPU_ENABLED RealType degrees_of_freedom()const;

// Accessor to non centrality parameter lambda:
RealType non_centrality()const;
BOOST_MATH_GPU_ENABLED RealType non_centrality()const;

// Parameter finders:
static RealType find_degrees_of_freedom(RealType lambda, RealType x, RealType p);
BOOST_MATH_GPU_ENABLED static RealType find_degrees_of_freedom(RealType lambda, RealType x, RealType p);
template <class A, class B, class C>
static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);
BOOST_MATH_GPU_ENABLED static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);

static RealType find_non_centrality(RealType v, RealType x, RealType p);
BOOST_MATH_GPU_ENABLED static RealType find_non_centrality(RealType v, RealType x, RealType p);
template <class A, class B, class C>
static RealType find_non_centrality(const complemented3_type<A,B,C>& c);
BOOST_MATH_GPU_ENABLED static RealType find_non_centrality(const complemented3_type<A,B,C>& c);
};

}} // namespaces
Expand Down Expand Up @@ -70,43 +70,42 @@ for different values of [lambda]:

[h4 Member Functions]

non_central_chi_squared_distribution(RealType v, RealType lambda);
BOOST_MATH_GPU_ENABLED non_central_chi_squared_distribution(RealType v, RealType lambda);

Constructs a Chi-Squared distribution with [nu] degrees of freedom
and non-centrality parameter /lambda/.

Requires [nu] > 0 and lambda >= 0, otherwise calls __domain_error.

RealType degrees_of_freedom()const;
BOOST_MATH_GPU_ENABLED RealType degrees_of_freedom()const;

Returns the parameter [nu] from which this object was constructed.

RealType non_centrality()const;
BOOST_MATH_GPU_ENABLED RealType non_centrality()const;

Returns the parameter /lambda/ from which this object was constructed.


static RealType find_degrees_of_freedom(RealType lambda, RealType x, RealType p);
BOOST_MATH_GPU_ENABLED static RealType find_degrees_of_freedom(RealType lambda, RealType x, RealType p);

This function returns the number of degrees of freedom [nu] such that:
`cdf(non_central_chi_squared<RealType, Policy>(v, lambda), x) == p`

template <class A, class B, class C>
static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);
template <class A, class B, class C>
BOOST_MATH_GPU_ENABLED static RealType find_degrees_of_freedom(const complemented3_type<A,B,C>& c);

When called with argument `boost::math::complement(lambda, x, q)`
this function returns the number of degrees of freedom [nu] such that:

`cdf(complement(non_central_chi_squared<RealType, Policy>(v, lambda), x)) == q`.

static RealType find_non_centrality(RealType v, RealType x, RealType p);
BOOST_MATH_GPU_ENABLED static RealType find_non_centrality(RealType v, RealType x, RealType p);

This function returns the non centrality parameter /lambda/ such that:

`cdf(non_central_chi_squared<RealType, Policy>(v, lambda), x) == p`

template <class A, class B, class C>
static RealType find_non_centrality(const complemented3_type<A,B,C>& c);
template <class A, class B, class C>
BOOST_MATH_GPU_ENABLED static RealType find_non_centrality(const complemented3_type<A,B,C>& c);

When called with argument `boost::math::complement(v, x, q)`
this function returns the non centrality parameter /lambda/ such that:
Expand All @@ -117,6 +116,8 @@ this function returns the non centrality parameter /lambda/ such that:

All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
that are generic to all distributions are supported: __usual_accessors.
For this distribution all non-member accessor functions are marked with `BOOST_MATH_GPU_ENABLED` and can
be run on both host and device.

The domain of the random variable is \[0, +[infin]\].

Expand Down
18 changes: 10 additions & 8 deletions doc/distributions/nc_f.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
typedef Policy policy_type;

// Constructor:
non_central_f_distribution(RealType v1, RealType v2, RealType lambda);
BOOST_MATH_GPU_ENABLED non_central_f_distribution(RealType v1, RealType v2, RealType lambda);

// Accessor to degrees_of_freedom parameters v1 & v2:
RealType degrees_of_freedom1()const;
RealType degrees_of_freedom2()const;
BOOST_MATH_GPU_ENABLED RealType degrees_of_freedom1()const;
BOOST_MATH_GPU_ENABLED RealType degrees_of_freedom2()const;

// Accessor to non-centrality parameter lambda:
RealType non_centrality()const;
BOOST_MATH_GPU_ENABLED RealType non_centrality()const;
};

}} // namespaces
Expand Down Expand Up @@ -55,29 +55,31 @@ for different values of [lambda]:

[h4 Member Functions]

non_central_f_distribution(RealType v1, RealType v2, RealType lambda);
BOOST_MATH_GPU_ENABLED non_central_f_distribution(RealType v1, RealType v2, RealType lambda);

Constructs a non-central beta distribution with parameters /v1/ and /v2/
and non-centrality parameter /lambda/.

Requires /v1/ > 0, /v2/ > 0 and lambda >= 0, otherwise calls __domain_error.

RealType degrees_of_freedom1()const;
BOOST_MATH_GPU_ENABLED RealType degrees_of_freedom1()const;

Returns the parameter /v1/ from which this object was constructed.

RealType degrees_of_freedom2()const;
BOOST_MATH_GPU_ENABLED RealType degrees_of_freedom2()const;

Returns the parameter /v2/ from which this object was constructed.

RealType non_centrality()const;
BOOST_MATH_GPU_ENABLED RealType non_centrality()const;

Returns the non-centrality parameter /lambda/ from which this object was constructed.

[h4 Non-member Accessors]

All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
that are generic to all distributions are supported: __usual_accessors.
For this distribution all non-member accessor functions are marked with `BOOST_MATH_GPU_ENABLED` and can
be run on both host and device.

The domain of the random variable is \[0, +[infin]\].

Expand Down
30 changes: 16 additions & 14 deletions doc/distributions/negative_binomial.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@
typedef RealType value_type;
typedef Policy policy_type;
// Constructor from successes and success_fraction:
negative_binomial_distribution(RealType r, RealType p);
BOOST_MATH_GPU_ENABLED negative_binomial_distribution(RealType r, RealType p);

// Parameter accessors:
RealType success_fraction() const;
RealType successes() const;
BOOST_MATH_GPU_ENABLED RealType success_fraction() const;
BOOST_MATH_GPU_ENABLED RealType successes() const;

// Bounds on success fraction:
static RealType find_lower_bound_on_p(
BOOST_MATH_GPU_ENABLED static RealType find_lower_bound_on_p(
RealType trials,
RealType successes,
RealType probability); // alpha
static RealType find_upper_bound_on_p(
BOOST_MATH_GPU_ENABLED static RealType find_upper_bound_on_p(
RealType trials,
RealType successes,
RealType probability); // alpha

// Estimate min/max number of trials:
static RealType find_minimum_number_of_trials(
BOOST_MATH_GPU_ENABLED static RealType find_minimum_number_of_trials(
RealType k, // Number of failures.
RealType p, // Success fraction.
RealType probability); // Probability threshold alpha.
static RealType find_maximum_number_of_trials(
BOOST_MATH_GPU_ENABLED static RealType find_maximum_number_of_trials(
RealType k, // Number of failures.
RealType p, // Success fraction.
RealType probability); // Probability threshold alpha.
Expand Down Expand Up @@ -112,7 +112,7 @@ poisson([lambda]) = lim [sub r [rarr] [infin]] negative_binomial(r, r / ([lambda

[h5 Construct]

negative_binomial_distribution(RealType r, RealType p);
BOOST_MATH_GPU_ENABLED negative_binomial_distribution(RealType r, RealType p);

Constructor: /r/ is the total number of successes, /p/ is the
probability of success of a single trial.
Expand All @@ -121,11 +121,11 @@ Requires: `r > 0` and `0 <= p <= 1`.

[h5 Accessors]

RealType success_fraction() const; // successes / trials (0 <= p <= 1)
BOOST_MATH_GPU_ENABLED RealType success_fraction() const; // successes / trials (0 <= p <= 1)

Returns the parameter /p/ from which this distribution was constructed.

RealType successes() const; // required successes (r > 0)
BOOST_MATH_GPU_ENABLED RealType successes() const; // required successes (r > 0)

Returns the parameter /r/ from which this distribution was constructed.

Expand All @@ -134,7 +134,7 @@ see __binomial_distrib for more discussion.

[h5 Lower Bound on Parameter p]

static RealType find_lower_bound_on_p(
BOOST_MATH_GPU_ENABLED static RealType find_lower_bound_on_p(
RealType failures,
RealType successes,
RealType probability) // (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.
Expand Down Expand Up @@ -170,7 +170,7 @@ Computational statistics and data analysis, 2005, vol. 48, no3, 605-621].

[h5 Upper Bound on Parameter p]

static RealType find_upper_bound_on_p(
BOOST_MATH_GPU_ENABLED static RealType find_upper_bound_on_p(
RealType trials,
RealType successes,
RealType alpha); // (0 <= alpha <= 1), 0.05 equivalent to 95% confidence.
Expand Down Expand Up @@ -206,7 +206,7 @@ Computational statistics and data analysis, 2005, vol. 48, no3, 605-621].

[h5 Estimating Number of Trials to Ensure at Least a Certain Number of Failures]

static RealType find_minimum_number_of_trials(
BOOST_MATH_GPU_ENABLED static RealType find_minimum_number_of_trials(
RealType k, // number of failures.
RealType p, // success fraction.
RealType alpha); // probability threshold (0.05 equivalent to 95%).
Expand Down Expand Up @@ -236,7 +236,7 @@ of observing k failures or fewer.

[h5 Estimating Number of Trials to Ensure a Maximum Number of Failures or Less]

static RealType find_maximum_number_of_trials(
BOOST_MATH_GPU_ENABLED static RealType find_maximum_number_of_trials(
RealType k, // number of failures.
RealType p, // success fraction.
RealType alpha); // probability threshold (0.05 equivalent to 95%).
Expand Down Expand Up @@ -266,6 +266,8 @@ of observing more than k failures.

All the [link math_toolkit.dist_ref.nmp usual non-member accessor functions]
that are generic to all distributions are supported: __usual_accessors.
For this distribution all non-member accessor functions are marked with `BOOST_MATH_GPU_ENABLED` and can
be run on both host and device.

However it's worth taking a moment to define what these actually mean in
the context of this distribution:
Expand Down
Loading

0 comments on commit e9cd6c9

Please sign in to comment.