Skip to content

describe how to make sum-to-zero parameters "optional" in User's Guide #909

@bob-carpenter

Description

@bob-carpenter

I liked this suggestion from @WardBrian and think it should be in the User's Guide, because it's a tricky edge case. The context is sum-to-zero vectors, but if there isn't a section on the optionality-with-arrays trick, we should add a whole section.

Note that the fix will just mean your code will be rejected with a nicer error -- you still won't be able to declare a size-0 `sum_to_zero_vector`, since the number of free parameters for this type is one fewer than the declared size, like a simplex.

To make one 'optional', you can either do array[NB] sum_to_zero_vector[S] or declare it as size-1 when it isn't needed, which will make it have no free parameters under the hood: sum_to_zero_vector[NB ? S : 1]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions