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

#include <bounded.hpp>

Public Types

using value_t = ValueType
 
using shape_t = ShapeType
 
using var_t = util::var_t< value_t, shape_t >
 
using constraint_t = Bounded< LowerType, UpperType >
 
using uc_view_t = ad::util::shape_to_raw_view_t< value_t, shape_t >
 
using view_t = uc_view_t
 

Public Member Functions

 Transformer (size_t rows, size_t cols, constraint_t c)
 
void transform ()
 
void inv_transform (size_t refcnt)
 
template<class CurrPtrPack , class PtrPack >
auto inv_transform_ad (const CurrPtrPack &curr_pack, const PtrPack &pack, size_t refcnt) const
 
template<class CurrPtrPack , class PtrPack >
auto logj_inv_transform_ad (const CurrPtrPack &curr_pack, const PtrPack &pack) const
 
template<class GenType , class ContDist >
void init (GenType &gen, ContDist &dist)
 
void activate_refcnt (size_t curr_refcnt) 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 &pack)
 

Member Typedef Documentation

◆ constraint_t

template<class ValueType , class ShapeType , class LowerType , class UpperType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::constraint_t = Bounded<LowerType, UpperType>

◆ shape_t

template<class ValueType , class ShapeType , class LowerType , class UpperType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::shape_t = ShapeType

◆ uc_view_t

template<class ValueType , class ShapeType , class LowerType , class UpperType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::uc_view_t = ad::util::shape_to_raw_view_t<value_t, shape_t>

◆ value_t

template<class ValueType , class ShapeType , class LowerType , class UpperType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::value_t = ValueType

◆ var_t

template<class ValueType , class ShapeType , class LowerType , class UpperType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::var_t = util::var_t<value_t, shape_t>

◆ view_t

template<class ValueType , class ShapeType , class LowerType , class UpperType >
using ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::view_t = uc_view_t

Constructor & Destructor Documentation

◆ Transformer()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::Transformer ( size_t  rows,
size_t  cols,
constraint_t  c 
)
inline

Constructs a Transformer object. It represents a lower and upper bounded scalar.

Parameters
cconstraint object must be provided since it cannot be default-constructed

Member Function Documentation

◆ activate_refcnt()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::activate_refcnt ( size_t  curr_refcnt) const
inline

◆ bind()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
template<class CurrPtrPack , class PtrPack >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::bind ( const CurrPtrPack &  curr_pack,
const PtrPack &  pack 
)
inline

Binds unconstrained viewer to unconstrained region, constrained viewer to constrained region, and internal visit count to visit count region.

◆ bind_size_c()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::bind_size_c ( ) const
inlineconstexpr

◆ bind_size_uc()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::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 , class ShapeType , class LowerType , class UpperType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::bind_size_v ( ) const
inlineconstexpr

◆ cols_c()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::cols_c ( ) const
inlineconstexpr

◆ cols_uc()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::cols_uc ( ) const
inlineconstexpr

◆ get_c() [1/2]

template<class ValueType , class ShapeType , class LowerType , class UpperType >
var_t& ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::get_c ( )
inline

◆ get_c() [2/2]

template<class ValueType , class ShapeType , class LowerType , class UpperType >
const var_t& ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::get_c ( ) const
inline

◆ init()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
template<class GenType , class ContDist >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::init ( GenType &  gen,
ContDist &  dist 
)
inline

Initializes unconstrained values such that unconstrained value is randomly generated determined by dist.

◆ inv_transform()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::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.

◆ inv_transform_ad()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
template<class CurrPtrPack , class PtrPack >
auto ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::inv_transform_ad ( const CurrPtrPack &  curr_pack,
const PtrPack &  pack,
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 1x1 block of Eigen matrix acting as scalar.

Parameters
ucunconstrained parameter to transform
cconstrained parameter 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.
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 , class ShapeType , class LowerType , class UpperType >
template<class CurrPtrPack , class PtrPack >
auto ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::logj_inv_transform_ad ( const CurrPtrPack &  curr_pack,
const PtrPack &  pack 
) 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 , class ShapeType , class LowerType , class UpperType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::rows_c ( ) const
inlineconstexpr

◆ rows_uc()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::rows_uc ( ) const
inlineconstexpr

◆ size_c()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::size_c ( ) const
inlineconstexpr

◆ size_uc()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
constexpr size_t ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::size_uc ( ) const
inlineconstexpr

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

◆ transform()

template<class ValueType , class ShapeType , class LowerType , class UpperType >
void ppl::expr::constraint::Transformer< ValueType, ShapeType, Bounded< LowerType, UpperType > >::transform ( )
inline

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