autoppl  v0.8
A C++ template library for probabilistic programming
ppl::expr::constraint::Transformer< ValueType, mat, PosDef > Struct Template Reference

#include <pos_def.hpp>

Public Types

using value_t = ValueType
 
using shape_t = mat
 
using var_t = util::var_t< value_t, shape_t >
 
using constraint_t = PosDef
 
using uc_view_t = ad::util::shape_to_raw_view_t< value_t, vec >
 
using view_t = ad::util::shape_to_raw_view_t< value_t, shape_t >
 

Public Member Functions

 Transformer (size_t rows, size_t, constraint_t=constraint_t())
 
void transform ()
 
void inv_transform (size_t refcnt)
 
template<class CurrPtrPack , class PtrPack >
auto inv_transform_ad (const CurrPtrPack &curr_pack, const PtrPack &, size_t refcnt) const
 
template<class CurrPtrPack , class PtrPack >
auto logj_inv_transform_ad (const CurrPtrPack &curr_pack, const PtrPack &) const
 
template<class GenType , class ContDist >
void init (GenType &, ContDist &)
 
void activate_refcnt (size_t) const
 
var_tget_c ()
 
const var_tget_c () const
 
constexpr size_t size_uc () const
 
constexpr size_t rows_uc () const
 
constexpr size_t cols_uc () const
 
constexpr size_t size_c () const
 
constexpr size_t rows_c () const
 
constexpr size_t cols_c () const
 
constexpr size_t bind_size_uc () const
 
constexpr size_t bind_size_c () const
 
constexpr size_t bind_size_v () const
 
template<class CurrPtrPack , class PtrPack >
void bind (const CurrPtrPack &curr_pack, const PtrPack &)
 

Member Typedef Documentation

◆ constraint_t

template<class ValueType >
using ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::constraint_t = PosDef

◆ shape_t

template<class ValueType >
using ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::shape_t = mat

◆ uc_view_t

template<class ValueType >
using ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::uc_view_t = ad::util::shape_to_raw_view_t<value_t, vec>

◆ value_t

template<class ValueType >
using ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::value_t = ValueType

◆ var_t

template<class ValueType >
using ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::var_t = util::var_t<value_t, shape_t>

◆ view_t

template<class ValueType >
using ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::view_t = ad::util::shape_to_raw_view_t<value_t, shape_t>

Constructor & Destructor Documentation

◆ Transformer()

template<class ValueType >
ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::Transformer ( size_t  rows,
size_t  ,
constraint_t  = constraint_t() 
)
inline

Constructs a Transformer object. It represents a positive-definite matrix, and hence ignores cols (second parameter) and treats rows as both rows and cols.

Parameters
rowsnumber of constrained rows (and cols)

Member Function Documentation

◆ activate_refcnt()

template<class ValueType >
void ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::activate_refcnt ( size_t  ) const
inline

◆ bind()

template<class ValueType >
template<class CurrPtrPack , class PtrPack >
void ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::bind ( const CurrPtrPack &  curr_pack,
const PtrPack &   
)
inline

Binds unconstrained viewer to unconstrained region (viewed as a vector), constrained viewer to constrained region (viewed as a matrix), and internal visit count to visit count region.

◆ bind_size_c()

template<class ValueType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::bind_size_c ( ) const
inlineconstexpr

◆ bind_size_uc()

template<class ValueType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::bind_size_uc ( ) const
inlineconstexpr

Returns the number of elements required to bind and compute unconstrained, constrained parameters and visit count.

◆ bind_size_v()

template<class ValueType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::bind_size_v ( ) const
inlineconstexpr

◆ cols_c()

template<class ValueType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::cols_c ( ) const
inlineconstexpr

◆ cols_uc()

template<class ValueType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::cols_uc ( ) const
inlineconstexpr

◆ get_c() [1/2]

template<class ValueType >
var_t& ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::get_c ( )
inline

◆ get_c() [2/2]

template<class ValueType >
const var_t& ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::get_c ( ) const
inline

◆ init()

template<class ValueType >
template<class GenType , class ContDist >
void ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::init ( GenType &  ,
ContDist &   
)
inline

Initializes unconstrained values such that constrained (pos-def) matrix is identity. This is equivalent to simply setting the unconstrained values to 0, since diagonal is first exponentiated and the Cholesky decomposition of identity is identity.

◆ inv_transform()

template<class ValueType >
void ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::inv_transform ( size_t  refcnt)
inline

Inverse transforms from unconstrained parameters to constrained parameters. Only the first visitor of the visit count will invoke the actual transformation. The reference count is used to reset the visit count if the visit count has reached refcnt.

Returns
viewer of constrained parameters

◆ inv_transform_ad()

template<class ValueType >
template<class CurrPtrPack , class PtrPack >
auto ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::inv_transform_ad ( const CurrPtrPack &  curr_pack,
const PtrPack &  ,
size_t  refcnt 
) const
inline

Inverse transform from unconstrained parameters to constrained parameters. This should not have any memory dependency through calling bind. It is expected that uc and c are vector-like in the sense that either row or column is 1. In debug mode, we check that uc and c have correct sizes.

Parameters
ucvector of unconstrained parameters to transform
cvector of constrained parameters to populate Creates an AD expression representing the inverse transform. User must ensure that this gets called exactly refcnt number of times.
uc_valbeginning of unconstrained parameter values
uc_adjbeginning of unconstrained parameter adjoints
c_valbeginning of constrained value region. The first size_c() elements will be used as temporary region to compute a lower-triangular matrix.
v_valbeginning of visit count
refcnttotal reference count to determine when to loop visit count back to 0

◆ logj_inv_transform_ad()

template<class ValueType >
template<class CurrPtrPack , class PtrPack >
auto ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::logj_inv_transform_ad ( const CurrPtrPack &  curr_pack,
const PtrPack &   
) const
inline

Creates an AD expression representing the log-jacobian of inverse transform. In general, this may need to reuse computed values from inverse transform. User must guarantee that inverse transform AD expression that is bound to the same resources as the return value of this function is evaluated before.

◆ rows_c()

template<class ValueType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::rows_c ( ) const
inlineconstexpr

◆ rows_uc()

template<class ValueType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::rows_uc ( ) const
inlineconstexpr

◆ size_c()

template<class ValueType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::size_c ( ) const
inlineconstexpr

◆ size_uc()

template<class ValueType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::size_uc ( ) const
inlineconstexpr

Returns the dimension information for the viewers of unconstrained and constrained parameters.

◆ transform()

template<class ValueType >
void ppl::expr::constraint::Transformer< ValueType, mat, PosDef >::transform ( )
inline

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