stan
stan copied to clipboard
Add var_value<Matrix> rvalue accessors
Summary:
Once #2024 goes into math we'll be able to have cheap views into var_value<Matrix> types. One Q is whether we should spend extra time when someone writes something like
matrix[10, 10] A = // fill in A;
matrix[2, 2] B = A[1:2, 1:2];
To look at the indices when calling rvalue(...) and deduce if the user is asking for linear access like the above we could just call A.block(1, 1, 2, 2) and not have to make a copy of the underlying data. For non-linear access like
matrix[10, 10] A = // fill in A;
vector[5] B = A[{1, 5, 2, 4 ,3}, 1];
idt it's possible to not make a copy.
Current Version:
v2.24.0
To look at the indices when calling rvalue(...) and deduce if the user is asking for linear access like the above we could just call A.block(1, 1, 2, 2) and not have to make a copy of the underlying data.
Agreed.
idt it's possible to not make a copy.
We could probably implement some custom views, but I don't think it is worth it.