To_matrix function

Hi,

Could someone give me a few specific examples on how the to_matrix function works with respect to the following features? Thanks.

matrix to_matrix (matrix m, int m, int n)
Convert a matrix m to a matrix with m rows and n columns filled in column-major order.

matrix to_matrix (vector v, int m, int n)
Convert a vector v to a matrix with m rows and n columns filled in column-major order.

matrix to_matrix (matrix m, int m, int n, int col_major)
Convert a matrix m to a matrix with m rows and n columns filled in row-major order if col_major equals 0 (otherwise, they get filled in column-major order).

matrix to_matrix (vector v, int m, int n, int col_major)
Convert a vector v to a matrix with m rows and n columns filled in row-major order if col_major equals 0 (otherwise, they get filled in column-major order).

The first reshapes a matrix to have m rows and n columns. The third is the same except you can specify 0 for the last argument in order to use row major order.

The second and fourth reshape a vector to be a matrix with m rows and n columns.

Is this correct?

my vector, v, is = [1,2,3,4,5,6].

to_matrix(v,3,2) gives

[1,2;
3,4;
5,6]

???

to_matrix(v, 3, 2, 0) yields that, whereas to_matrix(v, 3, 2) yields

[1, 4;
 2, 5;
 3, 6;]

with the default column-major ordering.