Problem with Matrix



I am trying to make some student functions for differentiation, such as gradient, Jordan matrix, Hesse matrix. However, I have troubles handling matrices.

1) Is there a way to ask the dimensions of a matrix?

2) Is genmatrix the right way to go, like in

gradient(expr,var) := genmatrix(lambda([i,j],diff(expr,var[j])),1,n)

where n is the length of var?

3) Is there any difference between a vector [x,y] and a 1x2-matrix?

Thanks for any responses.

Ren?