IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
ippl::random::detail::NewtonRaphson< T, Distribution > Struct Template Reference

Functor for solving equations using the Newton-Raphson method. More...

#include <Utility.h>

Collaboration diagram for ippl::random::detail::NewtonRaphson< T, Distribution >:

Public Member Functions

KOKKOS_FUNCTION NewtonRaphson ()=default
KOKKOS_FUNCTION ~NewtonRaphson ()=default
KOKKOS_INLINE_FUNCTION NewtonRaphson (const Distribution &dist_)
KOKKOS_INLINE_FUNCTION void solve (unsigned int d, T &x, T &u)
 Solve an equation using the Newton-Raphson method.

Public Attributes

Distribution dist
double atol = 1e-12
unsigned int max_iter = 20

Detailed Description

template<typename T, class Distribution>
struct ippl::random::detail::NewtonRaphson< T, Distribution >

Functor for solving equations using the Newton-Raphson method.

In particular, find the root x of the equation dist.obj(x, u)= 0 for a given u using Newton-Raphson method.

Template Parameters
TData type for the equation variables.
DistributionClass of target distribution to sample from.
Parameters
distDistribution object providing objective function cdf(x)-u and its derivative.
atolAbsolute tolerance for convergence (default: 1.0e-12).
max_iterMaximum number of iterations (default: 20).

Definition at line 28 of file Utility.h.

Constructor & Destructor Documentation

◆ NewtonRaphson() [1/2]

template<typename T, class Distribution>
KOKKOS_FUNCTION ippl::random::detail::NewtonRaphson< T, Distribution >::NewtonRaphson ( )
default

◆ ~NewtonRaphson()

template<typename T, class Distribution>
KOKKOS_FUNCTION ippl::random::detail::NewtonRaphson< T, Distribution >::~NewtonRaphson ( )
default

◆ NewtonRaphson() [2/2]

template<typename T, class Distribution>
KOKKOS_INLINE_FUNCTION ippl::random::detail::NewtonRaphson< T, Distribution >::NewtonRaphson ( const Distribution & dist_)
inline

Definition at line 39 of file Utility.h.

References dist.

Member Function Documentation

◆ solve()

template<typename T, class Distribution>
KOKKOS_INLINE_FUNCTION void ippl::random::detail::NewtonRaphson< T, Distribution >::solve ( unsigned int d,
T & x,
T & u )
inline

Solve an equation using the Newton-Raphson method.

This function iteratively solves an equation of the form "cdf(x) - u = 0" for a given sample u using the Newton-Raphson method.

Parameters
dDimension index.
xVariable to solve for (initial guess and final solution).
uGiven sample from a uniform distribution [0, 1].

Definition at line 52 of file Utility.h.

References atol, dist, and max_iter.

Referenced by ippl::random::InverseTransformSampling< T, Dim, DeviceType, Distribution >::fill_random< GeneratorPool >::operator()().

Here is the caller graph for this function:

Member Data Documentation

◆ atol

template<typename T, class Distribution>
double ippl::random::detail::NewtonRaphson< T, Distribution >::atol = 1e-12

Definition at line 30 of file Utility.h.

Referenced by solve().

◆ dist

Definition at line 29 of file Utility.h.

Referenced by NewtonRaphson(), and solve().

◆ max_iter

template<typename T, class Distribution>
unsigned int ippl::random::detail::NewtonRaphson< T, Distribution >::max_iter = 20

Definition at line 31 of file Utility.h.

Referenced by solve().


The documentation for this struct was generated from the following file: