Hi Mitzi,
Thanks for your answer. I spent some extra time looking at the examples to make sure, but I still don’t quite see how they’re supposed to work.
Specifically, in the User’s guide, the declarations are these:
matrix[3, 4] m[5, 7];
matrix[3, 4] a[2];
And the examples that draw from it are the following:
vector[2] b;
b = a[1, 3, 2:3, 2];
row_vector[3] c[2];
c = a[4:5, 3, 1, 2: ];
As I currently understand it, commas separate the indices for different dimensions, so both of these definition statements (try to) access 4 different dimensions in the source array. That’s why I wondered if they were actually meant to refer to array m instead of a. In that case, I could read the first call as taking element [1,3] out of the array, yielding a matrix, and then elements [2,2] and [3,2] out of that matrix, yielding the desired 2-element column vector (and similar for c). If the calls actually do refer to array a, I don’t really know how to interpret them at all. In that case, could you give me some clue how to proceed, please?
For the Reference manual, my comment was didactic much more than syntactic. The given list is introduced as legal definitions, and that much is clear.
matrix[6, 5] d[3, 4];
matrix[6, 5] e[4];
matrix[6, 5] f;
row_vector[5] g;
real x;
e = d[1]; // result is array of matrices
f = d[1,3]; // result is matrix
f = e[3]; // same result as above
g = d[1,3,2]; // result is row vector
g = e[3,2]; // same result as above
g = f[2]; // same result as above
x = d[1,3,5,2]; // result is scalar
x = e[3,5,2]; // same result as above
x = f[5,2]; // same result as above
x = g[2]; // same result as above
However, it seems like the intent is to show how working down through the layers of dimensions one by one is synonymous to punching through with all desired indices in a single line. Assuming that is the case (and assuming I understand these indices correctly, of course), the three lines for g each point to the matrix in position d[1,3] and then the 2nd row out of that matrix. The first three lines for x, however, point to the 5th row (of the same matrix). I was simply wondering if the lines for g here were actually meant to read:
g = d[1,3,5];
g = e[3,5];
g = f[5];
That way the definitions for x would all be synonymous, which they currently are not (again, assuming I have not completely misunderstood indexing).
My apologies that this got so lengthy, by the way. I’ve erred on the side of precision. Hopefully it all makes at least some sense.