stan-dev / stan-dev/math

single templated implementation of constraints

Open
#2,561 0 comments 0 reactions 2 assignees View on GitHub

@SteveBronder is already working on this.

Since Aug 23, 2021.

code cleanup
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Description

After #2559 is merged, it'd be nice to refactor the implementations.

  • Single Jacobian-templated implementation. Those are going to look as follows.
template <bool Jacobian, typename T>
inline auto XXX_constrain(..., scalar_type_t<T>& lp) {
  value = ...value calculations...
  if (Jacobian)
    lp += ...Jacobian calc...
  return value;
}
  • Deprecate the untemplated XXX_constrain functions.

  • Delegate implementations of untemplated XXX_constrain functions to the Jacobian-templated version.

  • Make sure doc of templated version doesn't point to untemplated version; OK to point to the Stan Reference Manual chapter Constraint Transforms.

Finishing this should remove all the cut-and-paste in the constraining transform code.

What would really be nice is if we could somehow group the constraining and unconstraining transforms together as a unit we can manipulate, but we can save that for a subsequent issue.

Current Version:

v4.1.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.