Vectorize rows and cols; a bug?
This is not what I would expect for the result of vectorizing rows or cols. Vectorizing last does give me what I would expect though:

This is not what I would expect for the result of vectorizing rows or cols. Vectorizing last does give me what I would expect though:

Honestly what you show is exactly what I would have expected. And I would have expected that vectorising last(V) throws an error as last(2)= would do.
Vectorising looks at all vectors in the expression and feeds the vector elements in the calculation. The results are collected in a new result vector.
So vectorising rows(V) first takes the 1 and feeds in the calculation -> rows(1) gives 0 as result and this result is the first element of the result vector. Same for 2 and 3 which gives us exactly the result vector we see.
On may argue that rows(3) or cols(2) should throw an error (like last(2) does) because the arguments are scalars and not vectors. But we used this behavior of Mathcad to see a scalar as a 0 x 0 matrix often to our advantage, when we used something like V[rows(V) <-- .... in our programs.
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.