Skip to content

to_matrix and to_vector to apply to general containers #2666

Open
@mike-lawrence

Description

@mike-lawrence

[edit: generalized for vectors by @bob-carpenter]

Add this signature for to_matrix:

array[N_cols] vector[N_rows] arr_Vec ;
matrix[N_rows,N_cols] mat_from_arr_Vec = to_matrix(arr_Vec) ;//proposed handling of new signature

and general signatures for to_vector for any container:

vector[N] to_vector(some container);

The reason to do this is to make it easy to reshape efficiently for likelihood and prior density increments.

This already works:

array[N_rows] row_vector[N_cols] arr_Rvec ;
matrix[N_rows,N_cols] mat_from_arr_Rvec = to_matrix(arr_Rvec) ;

I've already started a branch of stanc3 exposing this method, but presumably it has to exist in the first place.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions