stan-dev / stan

Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
2.55k stars 365 forks source link

FR: `model_base` methods - use `Eigen::Ref<Eigen::VectorXd>` #3289

Open andrjohns opened 1 month ago

andrjohns commented 1 month ago

Summary:

The Eigen overloads for model base methods like log_prob and unconstrain_array only accept Eigen::VectorXd inputs, which can require some data-reshaping/copying for downstream interfaces.

If these could be changed to Eigen::Ref<Eigen::VectorXd> (or overloads for these added), then the current Stan behaviour would be unchanged but interfaces could then pass Eigen::Map<Eigen::VectorXd> types and avoid extra copies

Current Version:

v2.35.0