Sparse matrix roadmap

I don’t think this requires the TWG, but yes, it’s good to get it involved. What this actually requires is a discussion / proposal about the points you mentioned. I don’t think we got far enough before.

what a stan type looks like

We currently have things like simplex and cov_matrix. What would an ideal sparse type look like? How would it be constructed? Putting down something we can look at and build off of would be very useful. Perhaps start with what’s natural, then we can talk about what technical challenges we have to implementing it that way.

Does this look like…

sparse_matrix[N, M, idx_r, idx_c, vals] A;

or something else?

how heavy our data types can be in the math library

The heaviness shouldn’t matter much. Right now, our containers are either std::vector<T> or Eigen::Matrix<T, R, C>. The only concrete proposal for something heavier was std::complex<T>. There’s no reason we can’t have anything heavier other than it’s work. That leads right to your next point…

what it’s supposed to do

That’s what we need to decide. Let’s say we could declare:

sparse_matrix[N, M] A;

then are we allowed to do stuff like matrix multiplication? What’s the output type? We’d need the checks to be extended to sparse_matrix, etc. It’s just a matter of what operations / functions are allowed for this new type.

We don’t have to roll it all out at once. Maybe it’s just one operation that works now with a list of others to implement.

how we can declare structure to be constant (or if we should?)

Wouldn’t it be the same way we deal with everything else? If it’s a type of primitive, it’s constant, if it’s of stan::math::var, it’s not?