A proposal for sparse matrices and GPs in Stan

My understanding (from this thread, but also from discussions with Bob) is that this would be a stunningly large re-do of the way Stan works and would require a very good reason. Basically, we have to eat some inconvenience somewhere along the pipeline, and the way things are makes it much easier to do sampling/autodiff.

I think that would need to happen in the transformed data or transformed parameter block. For the former, it’s possible, but for the latter I can’t see a way to ensure that the order of the values is the same each time (or that the sparsity structure doesn’t change). Again, we can’t access the previous sparsity structure at the current iteration to check it’s the same.

I think the suggested interface is minimal - we need to know the shape of the matrix, where the non-zeros are, and what the values are. (I actually didn’t think through an assignment operation, so suggestions are welcome).

The i_vector and j_vector can be easily accessed from teh sparse matrix format in R (and from most other common interfaces).