|
| ParamView (details::ParamInfoPack *i_pack, size_t rows=1, size_t cols=1, constraint_t c=constraint_t()) noexcept |
|
template<class Func > |
void | traverse (Func &&) const |
|
const var_t & | eval () |
|
void | inv_eval () |
|
template<class TPValPtrType , class TPAdjPtrType > |
auto | ad (const util::PtrPack< value_t *, value_t *, TPValPtrType, TPAdjPtrType, value_t * > &pack) const |
|
template<class TPValPtrType , class TPAdjPtrType > |
auto | logj_ad (const util::PtrPack< value_t *, value_t *, TPValPtrType, TPAdjPtrType, value_t * > &pack) const |
|
template<class GenType , class ContDist > |
void | init (GenType &gen, ContDist &dist) |
|
void | activate (util::OffsetPack &pack) const |
|
void | activate_refcnt () const |
|
template<class PtrPackType > |
void | bind (const PtrPackType &pack) |
|
var_t & | get () |
|
const var_t & | get () const |
|
constexpr size_t | size () const |
|
constexpr size_t | rows () const |
|
constexpr size_t | cols () const |
|
id_t | id () const |
|
auto & | offset () |
|
auto | offset () const |
|
constexpr size_t | size_uc () const |
|
constexpr size_t | size_c () const |
|
ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > & | self () |
|
const ParamView< ValueType, ppl::scl, expr::constraint::Unconstrained > & | self () const |
|
template<class ValueType, class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
struct ppl::ParamView< ValueType, ShapeType, ConstraintType >
ParamView is a class that views or references a parameter entity. It views the internal data of the first parameter object that was created. This is our way of making sure that all references to a parameter object when creating a model expression indeed refers to that first object.
Users will likely not need to create these objects directly. The easier-to-use Param class template will likely be used. When constructing a model expression, both Param and ParamView objects will be converted to a ParamView.
- Template Parameters
-
ValueType | value type to view
|
ShapeType | shape of the object it is viewing. |
ConstraintType | constraint expression type
|
template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
Set the common offsets with pack and resets reference count to 0. Updates pack to contain the next offsets after accounting for current ParamView.
Note: this should only be called exactly once per parameter referenced in a model. Since a model must assign a distribution to every parameter referenced in the model, it suffices to activate parameters in those expressions.
template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
void ppl::ParamView< ValueType, ShapeType, ConstraintType >::activate_refcnt |
( |
| ) |
const |
|
inline |
Increments the reference count to activate the current ParamView. The total number of reference counts for a parameter is defined to be the number of inverse-transforms required for the paarameter during model evaluation. This is identical to the number of ParamView objects referencing the parrameter in the model. In general, constraint expression may need to be activated as well. It requires the current reference count to determine if the activation is needed.
template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
template<class PtrPackType >
void ppl::ParamView< ValueType, ShapeType, ConstraintType >::bind |
( |
const PtrPackType & |
pack | ) |
|
|
inline |
Finds the correct offsetted pointers for the three parameters using the common offsets in info pack and delegates binding to underlying transformer. This only needs to be called if user wishes to call eval(). For AD support only, this does not need to be called.
template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
Evaluates the ParamView expression by first incrementing the visit count. If it is the first to visit such parameter when evaluating the model, it must first transform the unconstrained parameters to constrained parameters. If it is the last to visit such parameter, it must reset the visit count back to 0 for the next time we evaluate the model.
- Returns
- constrained parameter view
template<class ValueType , class ShapeType = ppl::scl, class ConstraintType = expr::constraint::Unconstrained>
template<class GenType , class ContDist >
void ppl::ParamView< ValueType, ShapeType, ConstraintType >::init |
( |
GenType & |
gen, |
|
|
ContDist & |
dist |
|
) |
| |
|
inline |
Initialize unconstrained values by generating constrained values and then transforming to unconstrained values. Undefined behavior if bind has not been called before.