stan-dev / stan-dev/math

Matrix comprehensions (`build_matrix` function)

Open
#3,282 6 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This would be a variadic function with signature:
matrix build_matrix(int I, int J, Fn f, T1 arg1,...TN argN) (name up for debate)

where Fn is a function (int, int, T1, ..., TN) => real

It returns a matrix M such that M[i,j] = f(i,j, arg1, ... argN)

The real advantage to this function is that it can do local autodiff, which will improve memory usage/locality and allow us to have the returned matrix be a SoA matrix (cf https://github.com/stan-dev/math/issues/2344#issuecomment-770418908).

Once implemented, build_[row]_vector is the obvious extension.

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

The issue defines a variadic build_matrix signature and the required matrix relationship M[i,j] = f(i,j,args). No files or tests are named, so begin by locating the existing matrix construction and automatic-differentiation entry points. Done means agreeing on the function name and supporting local autodiff and SoA matrix results; build_[row]_vector is a later extension.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.