Stan Math Library  2.20.0
reverse mode automatic differentiation
Public Member Functions | Public Attributes | List of all members
stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p > Class Template Reference

This is a subclass of the vari class for precomputed gradients of gp_periodic_cov. More...

#include <gp_periodic_cov.hpp>

Inheritance diagram for stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >:
stan::math::vari

Public Member Functions

 gp_periodic_cov_vari (const std::vector< T_x > &x, double sigma, const T_l &l, const T_p &p)
 Constructor for gp_periodic_cov. More...
 
virtual void chain ()
 Apply the chain rule to this variable based on the variables on which it depends. More...
 
- Public Member Functions inherited from stan::math::vari
 vari (double x)
 Construct a variable implementation from a value. More...
 
 vari (double x, bool stacked)
 
virtual ~vari ()
 Throw an illegal argument exception. More...
 
void init_dependent ()
 Initialize the adjoint for this (dependent) variable to 1. More...
 
void set_zero_adjoint ()
 Set the adjoint value of this variable to 0. More...
 

Public Attributes

const size_t size_
 
const size_t size_ltri_
 
const double l_d_
 
const double sigma_d_
 
const double p_d_
 
const double sigma_sq_d_
 
double * dist_
 
double * sin_2_dist_
 
double * sin_dist_sq_
 
varil_vari_
 
varip_vari_
 
vari ** cov_lower_
 
vari ** cov_diag_
 
- Public Attributes inherited from stan::math::vari
const double val_
 The value of this variable. More...
 
double adj_
 The adjoint of this variable, which is the partial derivative of this variable with respect to the root variable. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from stan::math::vari
static void * operator new (size_t nbytes)
 Allocate memory from the underlying memory pool. More...
 
static void operator delete (void *)
 Delete a pointer from the underlying memory pool. More...
 

Detailed Description

template<typename T_x, typename T_l, typename T_p>
class stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >

This is a subclass of the vari class for precomputed gradients of gp_periodic_cov.

The class stores the double values for the distance matrix, sine, cosine and sine squared of the latter, pointers to the varis for the covariance matrix, along with a pointer to the vari for sigma, the vari for l and the vari for p.

The elements of periodic covariance matrix $ \mathbf{K} $ using the input $ \mathbf{X} $ are defined as $ \mathbf{K}_{ij} = k(\mathbf{X}_i,\mathbf{X}_j), $ where $ \mathbf{X}_i $ is the $i$-th row of $ \mathbf{X} $ and
$ k(\mathbf{x},\mathbf{x}^\prime) = \sigma^2 \exp\left(-\frac{2\sin^2(\pi |\mathbf{x}-\mathbf{x}^\prime|/p)}{\ell^2}\right), $
where $ \sigma^2 $, $ \ell $ and $ p $ are the signal variance, length-scale and period.

The partial derivatives w.r.t. the parameters are the following:
$ \frac{\partial k}{\partial \sigma} = \frac{2k}{\sigma} $
$ \frac{\partial k}{\partial \ell} = \frac{4k}{\ell^3} \sin^2(\pi|\mathbf{x}-\mathbf{x}^\prime|/p) $
$ \frac{\partial k}{\partial p} = \frac{2k\pi|\mathbf{x}-\mathbf{x}^\prime|}{\ell^2p^2} \sin(2\pi|\mathbf{x}-\mathbf{x}^\prime|/p) $

Template Parameters
T_xtype of std::vector elements of x T_x can be a scalar, an Eigen::Vector, or an Eigen::RowVector.
T_ltype of length-scale
T_ptype of period

Definition at line 189 of file gp_periodic_cov.hpp.

Constructor & Destructor Documentation

◆ gp_periodic_cov_vari()

template<typename T_x , typename T_l , typename T_p >
stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::gp_periodic_cov_vari ( const std::vector< T_x > &  x,
double  sigma,
const T_l &  l,
const T_p &  p 
)
inline

Constructor for gp_periodic_cov.

All memory allocated in ChainableStack's stack_alloc arena.

It is critical for the efficiency of this object that the constructor create new varis that aren't popped onto the var_stack_, but rather are popped onto the var_nochain_stack_. This is controlled by the second argument to vari's constructor.

Parameters
xstd::vector of input elements. Assumes that all elements of x have the same size.
sigmastandard deviation of the signal
llength-scale
pperiod

Definition at line 224 of file gp_periodic_cov.hpp.

Member Function Documentation

◆ chain()

template<typename T_x , typename T_l , typename T_p >
virtual void stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::chain ( )
inlinevirtual

Apply the chain rule to this variable based on the variables on which it depends.

The base implementation in this class is a no-op.

Reimplemented from stan::math::vari.

Definition at line 265 of file gp_periodic_cov.hpp.

Member Data Documentation

◆ cov_diag_

template<typename T_x , typename T_l , typename T_p >
vari** stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::cov_diag_

Definition at line 203 of file gp_periodic_cov.hpp.

◆ cov_lower_

template<typename T_x , typename T_l , typename T_p >
vari** stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::cov_lower_

Definition at line 202 of file gp_periodic_cov.hpp.

◆ dist_

template<typename T_x , typename T_l , typename T_p >
double* stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::dist_

Definition at line 197 of file gp_periodic_cov.hpp.

◆ l_d_

template<typename T_x , typename T_l , typename T_p >
const double stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::l_d_

Definition at line 193 of file gp_periodic_cov.hpp.

◆ l_vari_

template<typename T_x , typename T_l , typename T_p >
vari* stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::l_vari_

Definition at line 200 of file gp_periodic_cov.hpp.

◆ p_d_

template<typename T_x , typename T_l , typename T_p >
const double stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::p_d_

Definition at line 195 of file gp_periodic_cov.hpp.

◆ p_vari_

template<typename T_x , typename T_l , typename T_p >
vari* stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::p_vari_

Definition at line 201 of file gp_periodic_cov.hpp.

◆ sigma_d_

template<typename T_x , typename T_l , typename T_p >
const double stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::sigma_d_

Definition at line 194 of file gp_periodic_cov.hpp.

◆ sigma_sq_d_

template<typename T_x , typename T_l , typename T_p >
const double stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::sigma_sq_d_

Definition at line 196 of file gp_periodic_cov.hpp.

◆ sin_2_dist_

template<typename T_x , typename T_l , typename T_p >
double* stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::sin_2_dist_

Definition at line 198 of file gp_periodic_cov.hpp.

◆ sin_dist_sq_

template<typename T_x , typename T_l , typename T_p >
double* stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::sin_dist_sq_

Definition at line 199 of file gp_periodic_cov.hpp.

◆ size_

template<typename T_x , typename T_l , typename T_p >
const size_t stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::size_

Definition at line 191 of file gp_periodic_cov.hpp.

◆ size_ltri_

template<typename T_x , typename T_l , typename T_p >
const size_t stan::math::gp_periodic_cov_vari< T_x, double, T_l, T_p >::size_ltri_

Definition at line 192 of file gp_periodic_cov.hpp.


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

     [ Stan Home Page ] © 2011–2018, Stan Development Team.