Automatic Differentiation
 
Loading...
Searching...
No Matches
stan::math::internal Namespace Reference

Detailed Description

A comparator that works for any container type that has the brackets operator.

Returns the natural logarithm of the difference of the inverse logits of the specified arguments and its gradients.

Template Parameters
ascendingtrue if sorting in ascending order
Ccontainer type

\[ \mathrm{log\_inv\_logit\_diff}(x,y) = \ln\left(\frac{1}{1+\exp(-x)}-\frac{1}{1+\exp(-y)}\right) \]

\[ \frac{\partial }{\partial x} = -\frac{e^x}{e^y-e^x}-\frac{e^x}{e^x+1} \]

\[ \frac{\partial }{\partial x} = -\frac{e^y}{e^x-e^y}-\frac{e^y}{e^y+1} \]

Template Parameters
T1Type of x argument
T2Type of y argument
Parameters
aArgument
bArgument
Returns
Result of log difference of inverse logits of arguments and gradients

Classes

class  arena_matrix_cl_impl
 
struct  assignment_op_str
 
struct  assignment_op_str< T, void_t< decltype(T::assignment_op)> >
 
struct  assignment_op_str_impl
 
struct  assignment_op_str_impl< assign_op_cl::divide_equals >
 
struct  assignment_op_str_impl< assign_op_cl::equals >
 
struct  assignment_op_str_impl< assign_op_cl::minus_equals >
 
struct  assignment_op_str_impl< assign_op_cl::multiply_equals >
 
struct  assignment_op_str_impl< assign_op_cl::plus_equals >
 
struct  bounded
 
struct  bounded< T_y, T_low, T_high, true >
 
struct  Box
 Compute the integral of the function to be integrated (integrand) from a to b for more than one dimensions. More...
 
class  broadcast_array
 
struct  callback_vari
 
struct  change_eigen_options_impl
 Change the options of an Eigen matrix or array. More...
 
struct  change_eigen_options_impl< Mat, NewOptions, require_eigen_array_t< Mat > >
 
struct  change_eigen_options_impl< Mat, NewOptions, require_eigen_matrix_base_t< Mat > >
 
struct  change_eigen_options_impl< var_value< Mat >, NewOptions, require_eigen_array_t< Mat > >
 
struct  change_eigen_options_impl< var_value< Mat >, NewOptions, require_eigen_matrix_base_t< Mat > >
 
class  colwise_reduction_base
 
struct  double_d
 
class  empty_broadcast_array
 
class  empty_broadcast_array< ViewElt, T, require_eigen_t< T > >
 
class  fdim_dv_vari
 
class  fdim_vd_vari
 
class  fdim_vv_vari
 
class  fmod_dv_vari
 
class  fmod_vd_vari
 
class  fmod_vv_vari
 
class  gamma_p_dv_vari
 
class  gamma_p_vd_vari
 
class  gamma_p_vv_vari
 
class  gamma_q_dv_vari
 
class  gamma_q_vd_vari
 
class  gamma_q_vv_vari
 
class  inc_beta_vvv_vari
 
class  index_comparator
 
struct  integrate_ode_std_vector_interface_adapter
 Wrap a functor designed for use with integrate_ode_bdf, integrate_ode_rk45, and integrate_ode_adams to use with the new ode_bdf/ode_rk45 interfaces. More...
 
struct  is_colwise_reduction_impl
 
struct  is_colwise_reduction_impl< calc_if_< true, T > >
 
struct  is_reduction_2d_impl
 
struct  is_reduction_2d_impl< calc_if_< true, T > >
 
struct  is_scalar_check_impl
 
struct  is_scalar_check_impl< check_cl_< scalar_< T > > >
 
struct  is_tuple_impl
 
struct  is_tuple_impl< std::tuple< Types... > >
 
struct  is_without_output_impl
 
struct  is_without_output_impl< calc_if_< false, T > >
 
class  Iser
 Apply an error check to a container, signal failure with false. More...
 
struct  lambert_w0_fun
 Structure to wrap lambert_w0() so it can be vectorized. More...
 
struct  lambert_wm1_fun
 Structure to wrap lambert_wm1() so it can be vectorized. More...
 
class  lbeta_dv_vari
 
class  lbeta_vd_vari
 
class  lbeta_vv_vari
 
class  lmgamma_dv_vari
 
class  lmultiply_dv_vari
 
class  lmultiply_vd_vari
 
class  lmultiply_vv_vari
 
class  log_diff_exp_dv_vari
 
class  log_diff_exp_vd_vari
 
class  log_diff_exp_vv_vari
 
class  log_falling_factorial_dv_vari
 
class  log_falling_factorial_vd_vari
 
class  log_falling_factorial_vv_vari
 
class  log_inv_logit_diff_dv_vari
 
class  log_inv_logit_diff_vd_vari
 
class  log_inv_logit_diff_vv_vari
 
class  log_rising_factorial_dv_vari
 
class  log_rising_factorial_vd_vari
 
class  log_rising_factorial_vv_vari
 
class  log_softmax_elt_vari
 
class  log_sum_exp_vd_vari
 
class  log_sum_exp_vv_vari
 
class  map_rect_combine
 
class  map_rect_reduce
 
class  map_rect_reduce< F, double, double >
 
struct  map_rect_reduce< F, double, var >
 
struct  map_rect_reduce< F, var, double >
 
struct  map_rect_reduce< F, var, var >
 
struct  matvec_mul_opt
 Implementation of an optimization for usage of rowwise reduction in matrix-vector multiplication. More...
 
struct  matvec_mul_opt< elt_multiply_< Mat, broadcast_< VecT, true, false > > >
 
class  mdivide_left_spd_alloc
 
class  mdivide_left_spd_dv_vari
 
class  mdivide_left_spd_vd_vari
 
class  mdivide_left_spd_vv_vari
 
class  mdivide_left_tri_dv_vari
 
class  mdivide_left_tri_vd_vari
 
class  mdivide_left_tri_vv_vari
 
class  modified_bessel_first_kind_dv_vari
 
class  modified_bessel_second_kind_dv_vari
 
class  mpi_parallel_call_cache
 Container for locally cached data which is essentially implemented as singleton. More...
 
struct  mrrr_task
 
struct  multi_result_kernel_internal
 
struct  multi_result_kernel_internal<-1, T_results... >
 
class  multiply_log_dv_vari
 
class  multiply_log_vd_vari
 
class  multiply_log_vv_vari
 
class  multiply_vd_vari
 
class  multiply_vv_vari
 
struct  nonexisting_adjoint
 
class  opencl_code_impl
 
class  ops_partials_edge
 An edge holds both the operands and its associated partial derivatives. More...
 
class  ops_partials_edge< double, Op, require_eigen_st< is_var, Op > >
 
class  ops_partials_edge< double, std::vector< Eigen::Matrix< var, R, C > > >
 
class  ops_partials_edge< double, std::vector< std::vector< var > > >
 
class  ops_partials_edge< double, std::vector< var > >
 
class  ops_partials_edge< double, std::vector< var_value< Op > >, require_eigen_t< Op > >
 
class  ops_partials_edge< double, var >
 
class  ops_partials_edge< double, var_value< Op >, require_eigen_t< Op > >
 
class  ops_partials_edge< double, var_value< Op >, require_kernel_expression_lhs_t< Op > >
 
class  ops_partials_edge< Dx, std::vector< Eigen::Matrix< fvar< Dx >, R, C > > >
 
class  ops_partials_edge< Dx, std::vector< std::vector< fvar< Dx > > > >
 
class  ops_partials_edge< Dx, ViewElt, require_eigen_vt< is_fvar, ViewElt > >
 
class  ops_partials_edge< InnerType, T, require_fvar_t< T > >
 
class  ops_partials_edge< InnerType, T, require_std_vector_vt< is_fvar, T > >
 
struct  ops_partials_edge< ViewElt, Op, require_st_arithmetic< Op > >
 Class representing an edge with an inner type of double. More...
 
class  partials_propagator
 
class  partials_propagator< ReturnType, require_arithmetic_t< ReturnType >, Ops... >
 This template builds partial derivatives with respect to a set of operands. More...
 
class  partials_propagator< ReturnType, require_fvar_t< ReturnType >, Ops... >
 This class builds partial derivatives with respect to a set of operands. More...
 
class  partials_propagator< ReturnType, require_var_t< ReturnType >, Ops... >
 This class builds partial derivatives with respect to a set of operands. More...
 
class  quad_form_vari
 
class  quad_form_vari_alloc
 
struct  reduce_sum_impl
 reduce_sum_impl implementation for any autodiff type. More...
 
struct  reduce_sum_impl< ReduceFunction, require_arithmetic_t< ReturnType >, ReturnType, Vec, Args... >
 Specialization of reduce_sum_impl for arithmetic types. More...
 
struct  reduce_sum_impl< ReduceFunction, require_var_t< ReturnType >, ReturnType, Vec, Args... >
 Var specialization of reduce_sum_impl. More...
 
class  reduction_2d_base
 
struct  reverse_pass_callback_vari
 
class  rising_factorial_vd_vari
 
class  squared_distance_vd_vari
 
class  squared_distance_vv_vari
 
class  trace_gen_quad_form_vari
 
class  trace_gen_quad_form_vari_alloc
 
class  trace_quad_form_vari
 
class  trace_quad_form_vari_alloc
 

Typedefs

template<typename T >
using is_scalar_check = is_scalar_check_impl< std::decay_t< T > >
 
using VectorXdd = Eigen::Matrix< double_d, -1, 1 >
 
using MatrixXdd = Eigen::Matrix< double_d, -1, -1 >
 
template<typename T >
using require_matrix_var_value = require_t< bool_constant<(is_eigen< T >::value||is_kernel_expression_and_not_scalar< T >::value) &&std::is_floating_point< value_type_t< T > >::value > >
 

Enumerations

enum  GradientCalc {
  OFF = 0 ,
  ON = 1
}
 

Functions

template<typename FuncTangent , typename InputArg , require_not_st_fvar< InputArg > * = nullptr>
constexpr double aggregate_tangent (const FuncTangent &tangent, const InputArg &arg)
 Helper function for aggregating tangents if the respective input argument was an fvar<T> type.
 
template<typename FuncTangent , typename InputArg , require_st_fvar< InputArg > * = nullptr>
auto aggregate_tangent (const FuncTangent &tangent, const InputArg &arg)
 Helper function for aggregating tangents if the respective input argument was an fvar<T> type.
 
static constexpr auto sum_dx ()
 End of recursion for summing .dx() for fvar<T> ops and partials.
 
template<typename T1 >
auto sum_dx (T1 &a)
 End of recursion for summing .dx() for fvar<T> ops and partials.
 
template<typename T1 , typename T2 , typename... Types>
auto sum_dx (T1 &a, T2 &b, Types &... args)
 Accumulate the .dx() from each of the edges in ops_and_partials_impl.
 
char * eight_byte_aligned_malloc (size_t size)
 
double_d mul_d_d (double a, double b)
 
double_d neg (double_d a)
 
double_d add_dd_dd (double_d a, double_d b)
 
double_d add_dd_d (double_d a, double b)
 
double_d sub_dd_dd (double_d a, double_d b)
 
double_d sub_dd_d (double_d a, double b)
 
double_d sub_d_dd (double a, double_d b)
 
double_d mul_dd_dd (double_d a, double_d b)
 
double_d mul_dd_d (double_d a, double b)
 
double_d div_dd_dd (double_d a, double_d b)
 
double_d div_dd_d (double_d a, double b)
 
double_d div_d_dd (double a, double_d b)
 
double copysign_d_dd (double a, double_d b)
 
double_d abs_dd (double_d a)
 
bool isnan_dd (double_d a)
 
bool isinf_dd (double_d a)
 
bool lt_dd_dd (double_d a, double_d b)
 
bool lt_d_dd (double a, double_d b)
 
bool lt_dd_d (double_d a, double b)
 
bool gt_dd_dd (double_d a, double_d b)
 
bool gt_d_dd (double a, double_d b)
 
bool gt_dd_d (double_d a, double b)
 
bool le_dd_dd (double_d a, double_d b)
 
bool le_d_dd (double a, double_d b)
 
bool le_dd_d (double_d a, double b)
 
bool ge_dd_dd (double_d a, double_d b)
 
bool ge_d_dd (double a, double_d b)
 
bool ge_dd_d (double_d a, double b)
 
double_d operator+ (double_d a, double b)
 
double_d operator+ (double a, double_d b)
 
double_d operator+ (double_d a, double_d b)
 
double_d operator- (double a, double_d b)
 
double_d operator- (double_d a, double b)
 
double_d operator- (double_d a, double_d b)
 
double_d operator* (double_d a, double b)
 
double_d operator* (double a, double_d b)
 
double_d operator* (double_d a, double_d b)
 
double_d operator/ (double_d a, double b)
 
double_d operator/ (double a, double_d b)
 
double_d operator/ (double_d a, double_d b)
 
double_d operator- (double_d a)
 
bool operator< (double_d a, double_d b)
 
bool operator< (double a, double_d b)
 
bool operator< (double_d a, double b)
 
bool operator> (double_d a, double_d b)
 
bool operator> (double a, double_d b)
 
bool operator> (double_d a, double b)
 
bool operator<= (double_d a, double_d b)
 
bool operator<= (double a, double_d b)
 
bool operator<= (double_d a, double b)
 
bool operator>= (double_d a, double_d b)
 
bool operator>= (double a, double_d b)
 
bool operator>= (double_d a, double b)
 
double_d fabs (double_d a)
 
bool isnan (double_d a)
 
bool isinf (double_d a)
 
double copysign (double a, double_d b)
 
int colwise_reduction_wgs_rows (int n_rows, int n_cols)
 Determine number of work groups in rows direction that will be run fro colwise reduction of given size.
 
template<typename T , std::size_t... Is, typename... Args>
auto make_holder_cl_impl_step2 (T &&expr, std::index_sequence< Is... >, const std::tuple< Args *... > &ptrs)
 Second step in implementation of construction holder_cl from a functor.
 
template<typename T , std::size_t... Is, typename... Args>
auto make_holder_cl_impl_step1 (const T &func, std::index_sequence< Is... >, Args &&... args)
 First step in implementation of construction holder_cl from a functor.
 
double_d get_random_perturbation_multiplier ()
 Generates a random number for perturbing a relatively robust representation.
 
void get_gresgorin (const Eigen::Ref< const Eigen::VectorXd > diagonal, const Eigen::Ref< const Eigen::VectorXd > subdiagonal, double &min_eigval, double &max_eigval)
 Calculates bounds on eigenvalues of a symmetric tridiagonal matrix T using Gresgorin discs.
 
double max_nan (double a, double b)
 NaN-favouring max.
 
double get_ldl (const Eigen::Ref< const Eigen::VectorXd > diagonal, const Eigen::Ref< const Eigen::VectorXd > subdiagonal, const double shift, VectorXdd &l, VectorXdd &d_plus)
 Calculates LDL decomposition of a shifted triagonal matrix T.
 
double find_initial_shift (const Eigen::Ref< const Eigen::VectorXd > diagonal, const Eigen::Ref< const Eigen::VectorXd > subdiagonal, VectorXdd &l0, VectorXdd &d0, const double min_eigval, const double max_eigval, const double max_ele_growth)
 Finds a good value for shift of the initial LDL factorization T - shift * I = L * D * L^T.
 
int get_sturm_count_ldl (const VectorXdd &l, const VectorXdd &d, const double_d shift)
 Calculates Sturm count of a LDL decomposition of a tridiagonal matrix - number of eigenvalues larger or equal to shift.
 
void eigenval_bisect_refine (const VectorXdd &l, const VectorXdd &d, double_d &low, double_d &high, const int i)
 Refines bounds on the i-th largest eigenvalue of LDL decomposition using bisection.
 
double get_shifted_ldl (const VectorXdd &l, const VectorXdd &d, const double_d shift, VectorXdd &l_plus, VectorXdd &d_plus)
 Shifts a LDL decomposition.
 
void find_shift (const VectorXdd &l, const VectorXdd &d, const double_d low, const double_d high, const double max_ele_growth, const double_d max_shift, VectorXdd &l2, VectorXdd &d2, double_d &shift, double &min_element_growth)
 Finds good shift and shifts a LDL decomposition so as to keep element growth low.
 
template<bool need_eigenvectors = true>
void mrrr_cl (const Eigen::Ref< const Eigen::VectorXd > diagonal, const Eigen::Ref< const Eigen::VectorXd > subdiagonal, Eigen::Ref< Eigen::VectorXd > eigenvalues, Eigen::Ref< Eigen::MatrixXd > eigenvectors, const double min_rel_sep=1e-4, const double maximum_ele_growth=15)
 Calculates eigenvalues and eigenvectors of a irreducible tridiagonal matrix T using multiple relatively robust representations (MRRR) algorithm.
 
template<bool need_eigenvectors = true>
void tridiagonal_eigensolver_cl (const matrix_cl< double > &diagonal_cl, const matrix_cl< double > &subdiagonal_cl, matrix_cl< double > &eigenvalues_cl, matrix_cl< double > &eigenvectors_cl, const double split_threshold=1e-15)
 Calculates eigenvalues and eigenvectors of a tridiagonal matrix T using MRRR algorithm.
 
void block_householder_tridiag_cl (const matrix_cl< double > &A, matrix_cl< double > &packed, const int r=60)
 Tridiagonalize a symmetric matrix using block Housholder algorithm.
 
void block_apply_packed_Q_cl (const matrix_cl< double > &packed_cl, matrix_cl< double > &A, const int r=200)
 Calculates Q*A in-place.
 
int get_num_threads ()
 Get number of threads to use.
 
template<typename U , typename V >
complex_return_t< U, V > complex_add (const U &lhs, const V &rhs)
 Return the sum of the specified arguments.
 
template<typename U , typename V >
complex_return_t< U, V > complex_divide (const U &lhs, const V &rhs)
 Return the quotient of the specified arguments.
 
template<typename U , typename V , require_any_complex_t< U, V > * = nullptr>
complex_return_t< U, V > complex_multiply (const U &lhs, const V &rhs)
 Return the product of the specified arguments.
 
template<typename U , typename V >
complex_return_t< U, V > complex_subtract (const U &lhs, const V &rhs)
 Return the difference between specified arguments.
 
void pipe_in (std::stringstream &ss)
 No-op.
 
template<typename Arg0 , typename... Args>
void pipe_in (std::stringstream &ss, Arg0 arg0, const Args... args)
 Pipes given arguments into a stringstream.
 
template<typename... Args>
void elementwise_throw_domain_error (const Args... args)
 Throws domain error with concatenation of arguments for the error message.
 
constexpr auto construct_idx () noexcept
 
template<typename... Idxs>
auto construct_idx (size_t i, Idxs... idxs)
 
auto make_iter_name (const char *name)
 
template<typename... Idxs>
auto make_iter_name (const char *name, Idxs... idxs)
 Given a name and index, generate a new name with the index attached.
 
template<typename V >
complex_abs (const std::complex< V > &z)
 Return the absolute value of the complex argument.
 
template<typename V >
std::complex< V > complex_acos (const std::complex< V > &x)
 Return the arc cosine of the complex argument.
 
template<typename V >
std::complex< V > complex_acosh (const std::complex< V > &z)
 Return the hyperbolic arc cosine of the complex argument.
 
template<typename V >
complex_arg (const std::complex< V > &z)
 Return the phase angle of the complex argument.
 
template<typename V >
std::complex< V > complex_asin (const std::complex< V > &z)
 Return the arc sine of the complex argument.
 
template<typename V >
std::complex< V > complex_asinh (const std::complex< V > &z)
 Return the hyperbolic arc sine of the complex argument.
 
template<typename V >
std::complex< V > complex_atan (const std::complex< V > &z)
 Return the arc tangent of the complex argument.
 
template<typename V >
std::complex< V > complex_atanh (const std::complex< V > &z)
 Return the hyperbolic arc tangent of the complex argument.
 
size_t fft_next_good_size (size_t N)
 Find the optimal next size for the FFT so that a minimum number of zeros are padded.
 
template<typename V >
std::complex< V > complex_conj (const std::complex< V > &z)
 Return the complex conjugate the complex argument.
 
template<typename T >
std::complex< T > complex_cos (const std::complex< T > &z)
 Return the cosine of the complex argument.
 
template<typename V >
std::complex< V > complex_cosh (const std::complex< V > &z)
 Return the hyperbolic cosine of the complex argument.
 
template<typename V >
std::complex< V > complex_exp (const std::complex< V > &z)
 Return the natural (base e) complex exponentiation of the specified complex argument.
 
template<typename T_x , typename T_sigma , typename T_l >
Eigen::Matrix< return_type_t< T_x, T_sigma, T_l >, Eigen::Dynamic, Eigen::Dynamic > gp_exp_quad_cov (const std::vector< T_x > &x, const T_sigma &sigma_sq, const T_l &neg_half_inv_l_sq)
 Returns a squared exponential kernel.
 
template<typename T_x1 , typename T_x2 , typename T_sigma , typename T_l >
Eigen::Matrix< return_type_t< T_x1, T_x2, T_sigma, T_l >, Eigen::Dynamic, Eigen::Dynamic > gp_exp_quad_cov (const std::vector< T_x1 > &x1, const std::vector< T_x2 > &x2, const T_sigma &sigma_sq, const T_l &neg_half_inv_l_sq)
 Returns a squared exponential kernel.
 
template<bool calc_a1, bool calc_a2, bool calc_b1, typename T1 , typename T2 , typename T3 , typename T_z , typename ScalarT = return_type_t<T1, T2, T3, T_z>, typename TupleT = std::tuple<ScalarT, ScalarT, ScalarT>>
TupleT grad_2F1_impl_ab (const T1 &a1, const T2 &a2, const T3 &b1, const T_z &z, double precision=1e-14, int max_steps=1e6)
 Implementation function to calculate the gradients of the hypergeometric function, 2F1 with respect to the a1, a2, and b2 parameters.
 
template<bool calc_a1, bool calc_a2, bool calc_b1, bool calc_z, typename T1 , typename T2 , typename T3 , typename T_z , typename ScalarT = return_type_t<T1, T2, T3, T_z>, typename TupleT = std::tuple<ScalarT, ScalarT, ScalarT, ScalarT>>
TupleT grad_2F1_impl (const T1 &a1, const T2 &a2, const T3 &b1, const T_z &z, double precision=1e-14, int max_steps=1e6)
 Implementation function to calculate the gradients of the hypergeometric function, 2F1.
 
template<typename Ta1 , typename Ta2 , typename Tb , typename Tz , typename RtnT = boost::optional<return_type_t<Ta1, Ta1, Tb, Tz>>, require_all_arithmetic_t< Ta1, Ta2, Tb, Tz > * = nullptr>
RtnT hyper_2F1_special_cases (const Ta1 &a1, const Ta2 &a2, const Tb &b, const Tz &z)
 Calculate the Gauss Hypergeometric (2F1) function for special-case combinations of parameters which can be calculated in closed-form.
 
template<typename Ta , typename Tb , typename Tz , typename T_return = return_type_t<Ta, Tb, Tz>, typename ArrayAT = Eigen::Array<scalar_type_t<Ta>, 3, 1>, typename ArrayBT = Eigen::Array<scalar_type_t<Ta>, 3, 1>, require_all_vector_t< Ta, Tb > * = nullptr, require_stan_scalar_t< Tz > * = nullptr>
T_return hypergeometric_3F2_infsum (const Ta &a, const Tb &b, const Tz &z, double precision=1e-6, int max_steps=1e5)
 
double inv_Phi_lambda (double p)
 The inverse of the unit normal cumulative distribution function.
 
template<typename V >
std::complex< V > complex_log (const std::complex< V > &z)
 Return the natural logarithm of the complex argument.
 
template<typename V >
std::complex< V > complex_log10 (const std::complex< V > &z)
 Return the base 10 logarithm of the complex argument.
 
template<typename V >
complex_norm (const std::complex< V > &z)
 Return the squared magnitude of the complex argument.
 
template<typename U , typename V >
complex_return_t< U, V > complex_polar (const U &r, const V &theta)
 Returns complex number with specified magnitude and phase angle.
 
template<typename U , typename V >
complex_return_t< U, V > complex_pow (const U &x, const V &y)
 Return the first argument raised to the power of the second argument.
 
template<typename V >
std::complex< V > complex_proj (const std::complex< V > &z)
 Return the projection of the complex argument onto the Riemann sphere.
 
template<typename T , int R, int C>
void resize (Eigen::Matrix< T, R, C > &x, const std::vector< int > &dims, int pos)
 
template<typename T >
void resize (T, const std::vector< int > &, int)
 
template<typename T >
void resize (std::vector< T > &x, const std::vector< int > &dims, int pos)
 
template<typename V >
std::complex< V > complex_sin (const std::complex< V > &z)
 Return the sine of the complex argument.
 
template<typename V >
std::complex< V > complex_sinh (const std::complex< V > &z)
 Return the hyperbolic sine of the complex argument.
 
template<typename V >
std::complex< V > complex_sqrt (const std::complex< V > &z)
 Return the square root of the complex argument.
 
template<typename V >
std::complex< V > complex_tan (const std::complex< V > &z)
 Return the tangent of the complex argument.
 
template<typename V >
std::complex< V > complex_tanh (const std::complex< V > &z)
 Return the hyperbolic tangent of the complex argument.
 
auto sum_vector_sizes ()
 
template<typename Vec , typename... VecArgs>
auto sum_vector_sizes (const Vec &x, const VecArgs &... args)
 Get the internal sizes of a pack of vectors.
 
template<typename VecInOut >
void append_vectors (VecInOut &x)
 End of recursion for appending to vector.
 
template<typename VecInOut , typename VecIn , typename... VecArgs>
void append_vectors (VecInOut &x, const VecIn &y, const VecArgs &... args)
 Fill a vector with other vectors.
 
template<class F , class Tuple , typename... PreArgs, std::size_t... I>
constexpr decltype(auto) apply_impl (F &&f, Tuple &&t, std::index_sequence< I... > i, PreArgs &&... pre_args)
 
template<typename F , typename T , size_t... Is>
constexpr auto for_each (F &&f, T &&t, std::index_sequence< Is... >)
 Implementation of for_each.
 
template<typename F , typename T1 , typename T2 , size_t... Is>
constexpr auto for_each (F &&f, T1 &&t1, T2 &&t2, std::index_sequence< Is... >)
 Implementation of Binary for_each.
 
template<typename F , typename T1 , typename T2 , typename T3 , size_t... Is>
constexpr auto for_each (F &&f, T1 &&t1, T2 &&t2, T3 &&t3, std::index_sequence< Is... >)
 Implementation of ternary for_each.
 
void combination (Eigen::Matrix< int, Eigen::Dynamic, 1 > &c, const int dim, const int p, const int x)
 Get the [x]-th lexicographically ordered set of [p] elements in [dim] output is in [c], and should be sizeof(int)*[p] "Algorithm 515: Generation of a Vector from the Lexicographical Index"; Buckles, B.
 
template<typename Scalar >
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > combos (const int k, const Scalar lambda, const int dim)
 Compute a matrix [p] of all [dim]-component vectors with [k] components equal to [lambda] and other components equal to zero.
 
template<typename Scalar >
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > signcombos (const int k, const Scalar lambda, const int dim)
 Compute a matrix [p] of all [dim]-component vectors with [k] components equal to [±lambda] and other components equal to zero (with all possible signs).
 
std::tuple< std::array< Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >, 4 >, Eigen::Matrix< double, 5, 1 >, Eigen::Matrix< double, 4, 1 > > make_GenzMalik (const int dim)
 Compute the points and weights corresponding to a [dim]-dimensional Genz-Malik cubature rule.
 
template<typename F , typename T_a , typename T_b , typename ParsPairT >
auto gauss_kronrod (const F &integrand, const T_a a, const T_b b, const ParsPairT &pars_pair)
 Compute the integral of the function to be integrated (integrand) from a to b for one dimension.
 
template<typename F , typename GenzMalik , typename T_a , typename T_b , typename ParsTupleT >
auto integrate_GenzMalik (const F &integrand, const GenzMalik &genz_malik, const int dim, const Eigen::Matrix< T_a, Eigen::Dynamic, 1 > &a, const Eigen::Matrix< T_b, Eigen::Dynamic, 1 > &b, const ParsTupleT &pars_tuple)
 Compute the integral of the function to be integrated (integrand) from a to b for more than one dimensions.
 
template<int call_id, typename F , typename T_shared_param , typename T_job_param , require_eigen_col_vector_t< T_shared_param > * = nullptr>
Eigen::Matrix< return_type_t< T_shared_param, T_job_param >, Eigen::Dynamic, 1 > map_rect_concurrent (const T_shared_param &shared_params, const std::vector< Eigen::Matrix< T_job_param, Eigen::Dynamic, 1 > > &job_params, const std::vector< std::vector< double > > &x_r, const std::vector< std::vector< int > > &x_i, std::ostream *msgs=nullptr)
 
template<int call_id, typename F , typename T_shared_param , typename T_job_param >
Eigen::Matrix< return_type_t< T_shared_param, T_job_param >, Eigen::Dynamic, 1 > map_rect_mpi (const T_shared_param &shared_params, const std::vector< Eigen::Matrix< T_job_param, Eigen::Dynamic, 1 > > &job_params, const std::vector< std::vector< double > > &x_r, const std::vector< std::vector< int > > &x_i, std::ostream *msgs=nullptr)
 
template<typename T1 , typename T2 >
constexpr bool eigen_static_size_match (T1 desired, T2 actual)
 
template<typename T >
auto holder_handle_element (T &a, T *&res)
 Handles single element (moving rvalue non-expressions to heap) for construction of holder or holder_cl from a functor.
 
template<typename T , std::enable_if_t<!(Eigen::internal::traits< std::decay_t< T > >::Flags &Eigen::NestByRefBit)> * = nullptr>
auto holder_handle_element (T &&a, std::remove_reference_t< T > *&res)
 
template<typename T , require_t< std::is_rvalue_reference< T && > > * = nullptr, std::enable_if_t< static_cast< bool >(Eigen::internal::traits< std::decay_t< T > >::Flags &Eigen::NestByRefBit)> * = nullptr>
auto holder_handle_element (T &&a, T *&res)
 Handles single element (moving rvalue non-expressions to heap) for construction of holder or holder_cl from a functor.
 
template<typename T , std::size_t... Is, typename... Args>
auto make_holder_impl_construct_object (T &&expr, std::index_sequence< Is... >, const std::tuple< Args *... > &ptrs)
 Second step in implementation of construction holder from a functor.
 
template<typename F , std::size_t... Is, typename... Args>
auto make_holder_impl (const F &func, std::index_sequence< Is... >, Args &&... args)
 Implementation of construction holder from a functor.
 
template<class F , std::size_t... Is>
constexpr auto index_apply_impl (F &&f, std::index_sequence< Is... >)
 
template<class RNG >
Eigen::VectorXd multi_normal_semidefinite_rng (const Eigen::VectorXd &mu, const Eigen::LDLT< Eigen::MatrixXd > &S_ldlt, RNG &rng)
 Return a multivariate normal random variate with the given location and covariance using the specified random number generator.
 
template<typename T_x , typename T_k >
return_type_t< T_x, T_k > von_mises_cdf_series (const T_x &x, const T_k &k)
 This implementation of the von Mises cdf is a copy of scipy's.
 
template<typename T_x , typename T_k >
return_type_t< T_x, T_k > von_mises_cdf_normalapprox (const T_x &x, const T_k &k)
 conv_mises_cdf_normapprox(x, k) is used to approximate the von Mises cdf for k > 50.
 
template<typename T_x , typename T_k >
return_type_t< T_x, T_k > von_mises_cdf_centered (const T_x &x, const T_k &k)
 This function calculates the cdf of the von Mises distribution in the case where the distribution has support on (-pi, pi) and has mean 0.
 
template<typename T_y , typename T_a , typename T_v , typename T_w , typename T_sv >
auto wiener5_compute_error_term (T_y &&y, T_a &&a, T_v &&v_value, T_w &&w_value, T_sv &&sv) noexcept
 Calculate the 'error_term' term for a wiener5 density or gradient.
 
template<bool Density, GradientCalc GradW, typename T_y , typename T_a , typename T_w_value , typename T_err >
auto wiener5_n_terms_small_t (T_y &&y, T_a &&a, T_w_value &&w_value, T_err &&error) noexcept
 Calculate the 'n_terms_small_t' term for a wiener5 density or gradient.
 
template<typename T_y , typename T_a , typename T_w_value , typename T_err >
auto wiener5_density_large_reaction_time_terms (T_y &&y, T_a &&a, T_w_value &&w_value, T_err &&error) noexcept
 Calculate the 'n_terms_large_t' term for a wiener5 density.
 
template<GradientCalc GradW, typename T_y , typename T_a , typename T_w_value , typename T_err >
auto wiener5_gradient_large_reaction_time_terms (T_y &&y, T_a &&a, T_w_value &&w_value, T_err &&error) noexcept
 Calculate the 'n_terms_large_t' term for a wiener5 gradient.
 
template<bool Density, GradientCalc GradW, typename T_y , typename T_a , typename T_w , typename T_nsmall , typename T_nlarge >
auto wiener5_log_sum_exp (T_y &&y, T_a &&a, T_w &&w_value, T_nsmall &&n_terms_small_t, T_nlarge &&n_terms_large_t) noexcept
 Calculate the 'result' term and its sign for a wiener5 density or gradient.
 
template<bool NaturalScale = false, typename T_y , typename T_a , typename T_w , typename T_v , typename T_sv , typename T_err >
auto wiener5_density (const T_y &y, const T_a &a, const T_v &v_value, const T_w &w_value, const T_sv &sv, T_err &&err=log(1e-12)) noexcept
 Calculate the wiener5 density.
 
template<bool WrtLog = false, typename T_y , typename T_a , typename T_w , typename T_v , typename T_sv , typename T_err >
auto wiener5_grad_t (const T_y &y, const T_a &a, const T_v &v_value, const T_w &w_value, const T_sv &sv, T_err &&err=log(1e-12)) noexcept
 Calculate the derivative of the wiener5 density w.r.t.
 
template<bool WrtLog = false, typename T_y , typename T_a , typename T_w , typename T_v , typename T_sv , typename T_err >
auto wiener5_grad_a (const T_y &y, const T_a &a, const T_v &v_value, const T_w &w_value, const T_sv &sv, T_err &&err=log(1e-12)) noexcept
 Calculate the derivative of the wiener5 density w.r.t.
 
template<bool WrtLog = false, typename T_y , typename T_a , typename T_w , typename T_v , typename T_sv , typename T_err >
auto wiener5_grad_v (const T_y &y, const T_a &a, const T_v &v_value, const T_w &w_value, const T_sv &sv, T_err &&err=log(1e-12)) noexcept
 Calculate the derivative of the wiener5 density w.r.t.
 
template<bool WrtLog = false, typename T_y , typename T_a , typename T_w , typename T_v , typename T_sv , typename T_err >
auto wiener5_grad_w (const T_y &y, const T_a &a, const T_v &v_value, const T_w &w_value, const T_sv &sv, T_err &&err=log(1e-12)) noexcept
 Calculate the derivative of the wiener5 density w.r.t.
 
template<bool WrtLog = false, typename T_y , typename T_a , typename T_w , typename T_v , typename T_sv , typename T_err >
auto wiener5_grad_sv (const T_y &y, const T_a &a, const T_v &v_value, const T_w &w_value, const T_sv &sv, T_err &&err=log(1e-12)) noexcept
 Calculate the derivative of the wiener5 density w.r.t.
 
template<size_t NestedIndex, typename Scalar1 , typename Scalar2 >
void assign_err (Scalar1 arg, Scalar2 err)
 Utility function for replacing a value with a specified error value.
 
template<size_t NestedIndex, typename Scalar , typename... TArgs>
void assign_err (std::tuple< TArgs... > &args_tuple, Scalar err)
 Utility function for replacing a value with a specified error value, overload for use when the value is stored within a tuple.
 
template<size_t ErrIndex, size_t NestedIndex = 0, GradientCalc GradW7 = GradientCalc::OFF, bool LogResult = true, typename F , typename T_err , typename... ArgsTupleT>
auto estimate_with_err_check (F &&functor, T_err &&err, ArgsTupleT &&... args_tuple)
 Utility function for estimating a function with a given set of arguments, checking the result against a provided error tolerance, and re-estimating the function with the increased error if it fails.
 
template<typename T_y , typename T_a , typename T_v , typename T_w , typename T_sv , typename T_sw , typename T_err >
auto wiener7_grad_sw (const T_y &y, const T_a &a, const T_v &v, const T_w &w, const T_sv &sv, const T_sw &sw, T_err log_error)
 Calculate the derivative of the wiener7 density w.r.t.
 
template<GradientCalc GradSW, typename F , typename T_y , typename T_a , typename T_v , typename T_w , typename T_sv , typename T_sw , typename T_err , std::enable_if_t<!GradSW > * = nullptr>
auto conditionally_grad_sw (F &&functor, T_y &&y_diff, T_a &&a, T_v &&v, T_w &&w, T_sv &&sv, T_sw &&sw, T_err &&log_error)
 Helper function for agnostically calling wiener5 functions (to be integrated over) or directly calling wiener7 functions, accounting for the different number of arguments.
 
template<GradientCalc GradSW, GradientCalc GradW7 = GradientCalc::OFF, typename Wiener7FunctorT , typename T_err , typename... TArgs>
auto wiener7_integrate (const Wiener7FunctorT &wiener7_functor, T_err &&hcubature_err, TArgs &&... args)
 Implementation function for preparing arguments and functor to be passed to the hcubature() function for calculating wiener7 parameters via integration.
 
template<typename VecVar , require_std_vector_vt< is_var, VecVar > * = nullptr, typename... Pargs>
size_t count_vars_impl (size_t count, VecVar &&x, Pargs &&... args)
 Count the number of vars in x (a std::vector of vars), add it to the running total, count the number of vars in the remaining arguments and return the result.
 
template<typename VecContainer , require_std_vector_st< is_var, VecContainer > * = nullptr, require_std_vector_vt< is_container, VecContainer > * = nullptr, typename... Pargs>
size_t count_vars_impl (size_t count, VecContainer &&x, Pargs &&... args)
 Count the number of vars in x (a std::vector holding other containers), add it to the running total, count the number of vars in the remaining arguments and return the result.
 
template<typename EigT , require_eigen_vt< is_var, EigT > * = nullptr, typename... Pargs>
size_t count_vars_impl (size_t count, EigT &&x, Pargs &&... args)
 Count the number of vars in x (an eigen container), add it to the running total, count the number of vars in the remaining arguments and return the result.
 
template<typename... Pargs>
size_t count_vars_impl (size_t count, const var &x, Pargs &&... args)
 Add one to the running total number of vars, count the number of vars in the remaining arguments and return the result.
 
template<typename Arith , require_arithmetic_t< scalar_type_t< Arith > > * = nullptr, typename... Pargs>
size_t count_vars_impl (size_t count, Arith &x, Pargs &&... args)
 Arguments without vars contribute zero to the total number of vars.
 
size_t count_vars_impl (size_t count)
 End count_vars_impl recursion and return total number of counted vars.
 
template<typename LMat , typename LAMat >
void initialize_return (LMat &L, const LAMat &L_A, vari *&dummy)
 
template<typename T1 , typename T2 , typename T3 >
auto unblocked_cholesky_lambda (T1 &L_A, T2 &L, T3 &A)
 Reverse mode differentiation algorithm reference:
 
template<typename T1 , typename T2 , typename T3 >
auto cholesky_lambda (T1 &L_A, T2 &L, T3 &A)
 Reverse mode differentiation algorithm reference:
 
template<typename T1 , typename T2 , typename T3 , typename T4 , require_all_matrix_t< T1, T2, T3 > * = nullptr>
auto fma_reverse_pass (T1 &arena_x, T2 &arena_y, T3 &arena_z, T4 &ret)
 Overload for matrix, matrix, matrix.
 
template<typename T1 , typename T2 , typename T3 , typename T4 , require_all_matrix_t< T2, T3 > * = nullptr, require_stan_scalar_t< T1 > * = nullptr>
auto fma_reverse_pass (T1 &arena_x, T2 &arena_y, T3 &arena_z, T4 &ret)
 Overload for scalar, matrix, matrix.
 
template<typename T1 , typename T2 >
auto generalized_inverse_lambda (T1 &G_arena, T2 &inv_G)
 
template<typename Mat1 , typename Mat2 , require_all_matrix_t< Mat1, Mat2 > * = nullptr, require_any_var_matrix_t< Mat1, Mat2 > * = nullptr>
auto quad_form_impl (const Mat1 &A, const Mat2 &B, bool symmetric)
 Return the quadratic form \( B^T A B \).
 
var calc_variance (size_t size, const var *dtrs)
 
template<typename F >
void finite_diff_hessian_auto (const F &f, const Eigen::VectorXd &x, double &fx, Eigen::VectorXd &grad_fx, Eigen::MatrixXd &hess_fx)
 Calculate the value and the Hessian of the specified function at the specified argument using first-order finite difference of gradients, automatically setting the stepsize between the function evaluations along a dimension.
 
template<typename F >
void finite_diff_hessian_times_vector_auto (const F &f, const Eigen::VectorXd &x, const Eigen::VectorXd &v, double &fx, Eigen::VectorXd &hvp)
 Calculate the value and the product of the Hessian and the specified vector of the specified function at the specified argument using central finite difference of gradients, automatically setting the stepsize between the function evaluations along a dimension.
 
template<typename T1 , typename T2 , require_all_kernel_expressions_and_none_scalar_t< T1, T2 > * = nullptr>
void update_adjoints (var_value< T1 > &x, const T2 &y, const vari &z)
 
template<typename T1 , typename T2 , require_all_kernel_expressions_and_none_scalar_t< T1, T2 > * = nullptr>
void update_adjoints (var_value< T1 > &x, const T2 &y, const var &z)
 
template<typename Scalar1 , typename Scalar2 , require_var_t< Scalar1 > * = nullptr, require_not_var_matrix_t< Scalar1 > * = nullptr, require_arithmetic_t< Scalar2 > * = nullptr>
void update_adjoints (Scalar1 x, Scalar2 y, const vari &z) noexcept
 
template<typename Scalar1 , typename Scalar2 , require_var_t< Scalar1 > * = nullptr, require_not_var_matrix_t< Scalar1 > * = nullptr, require_arithmetic_t< Scalar2 > * = nullptr>
void update_adjoints (Scalar1 x, Scalar2 y, const var &z) noexcept
 
template<typename Matrix1 , typename Matrix2 , require_rev_matrix_t< Matrix1 > * = nullptr, require_st_arithmetic< Matrix2 > * = nullptr>
void update_adjoints (Matrix1 &x, const Matrix2 &y, const vari &z)
 
template<typename Matrix1 , typename Matrix2 , require_rev_matrix_t< Matrix1 > * = nullptr, require_st_arithmetic< Matrix2 > * = nullptr>
void update_adjoints (Matrix1 &x, const Matrix2 &y, const var &z)
 
template<typename Arith , typename Alt , require_st_arithmetic< Arith > * = nullptr>
constexpr void update_adjoints (Arith &&, Alt &&, const vari &) noexcept
 
template<typename Arith , typename Alt , require_st_arithmetic< Arith > * = nullptr>
constexpr void update_adjoints (Arith &&, Alt &&, const var &) noexcept
 
template<typename StdVec1 , typename Vec2 , require_std_vector_t< StdVec1 > * = nullptr, require_st_arithmetic< Vec2 > * = nullptr>
void update_adjoints (StdVec1 &x, const Vec2 &y, const vari &z)
 
template<typename StdVec1 , typename Vec2 , require_std_vector_t< StdVec1 > * = nullptr, require_st_arithmetic< Vec2 > * = nullptr>
void update_adjoints (StdVec1 &x, const Vec2 &y, const var &z)
 

Variables

const size_t DEFAULT_INITIAL_NBYTES = 1 << 16
 
static const double_d perturbation_range = 1e-20
 
const char opencl_normal_lcdf_impl []
 
const char opencl_normal_lcdf_ldncdf_impl []
 
const char opencl_std_normal_lcdf_impl []
 
const char opencl_std_normal_lcdf_dnlcdf []
 
const int BIGINT = 2000000000
 The largest integer that protects against floating point errors for the inv_Phi function.
 
static constexpr std::array< double, 8 > xd7
 
static constexpr std::array< double, 8 > wd7
 
static constexpr std::array< double, 4 > gwd7
 
constexpr double neg_binomial_alpha_cutoff = 1e10