Skip to content

relax type identity between constrained variable and target log density #1733

Open
@bob-carpenter

Description

@bob-carpenter

Description

In the constrain_XXX functions applied to map unconstrained parameters to parameters in Stan, the value being constrained is required to be the same type as the log density target being incremented. These functions should allow the two types to vary independently. The target will always be at least double, whereas the variable being constrained might be int when used in the language.

Example

template <typename T, typename L, typename U>
inline return_type_t<T, L, U> lub_constrain(const T& x, const L& lb,
                                            const U& ub, T& lp) {

Expected Output

For all of the XXX_constrain functions with an lp argument, the types should be generalized to look like this:

template <typename T, typename L, typename U, typename L>
inline return_type_t<T, L, U> lub_constrain(const T& x, const L& lb,
                                            const U& ub, L& lp)

On the identity constrain version, that means the lp argument needs to be uncommented to support type inference.

Current Version:

v3.1.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions