stan-dev / stan-dev/math

to_matrix and to_vector to apply to general containers

Open
#2,666 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature good first issue
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

[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.

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.

Research direction

Start by reviewing the existing to_matrix handling for array row_vectors and the generalized vector work described in the issue. Then inspect the referenced stanc3 branch to understand the expected signatures and container coverage. Done means the requested to_matrix and to_vector conversions are supported consistently and the issue's example cases work.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.