The motivation is to allow transition matrices in Stan’s hmm functions which vary over time. So instead of passing a single matrix, the user would pass an array of matrices. We would then have two signatures. See Allowing changing transition matrix for hmm suites · Issue #2678 · stan-dev/math · GitHub.
Under the hood, this means rewriting the code using an std::vector<Eigen::Matrix>
type for Gamma
. I can then write a wrapper which takes in Gamma
as an Eigen::Matrix
and converts it to an std::vector<Eigen::Matrix>
by duplicating the original matrix. This is of course memory intensive. Is there a way to do this without actually duplicating the matrix, i.e. have an std::vector
of pointers, with pointers potentially pointing to the same matrix in the case where the users only passes a single matrix? I’m not sure how to do this with std
but it seems Eigen
has some features supporting this.