Matvec Users’ Guide
Matvec Users' Guide
Matvec Users' Guide
- No tags were found...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
3.4. COMPUTATION 27<br />
reshape<br />
A.reshape(m,n) returns a new matrix of m rows and n columns, whose elements are taken from the matrix A<br />
row-by-row. If the matrix A doesn’t have enough elements, then the operation cycles back to the beginning<br />
of A to get enough values for the new matrix. For example,<br />
> A = [1,0,0,0];<br />
> B = A.reshape(3,3)<br />
Col 1 Col 2 Col 3<br />
Row 1 1 0 0<br />
Row 2 0 1 0<br />
Row 3 0 0 1<br />
> C = A.reshape(3,4)<br />
Col 1 Col 2 Col 3 Col 4<br />
Row 1 1 0 0 0<br />
Row 2 1 0 0 0<br />
Row 3 1 0 0 0<br />
resize<br />
A.resize(m, n), Matrix A is resized to be m-by-n. The contents in A could be garbage.<br />
rot90<br />
A.rot90(k) rotate the matrix A counterclockwise k*90 degrees.<br />
This member function is a user-defined function, it’s loaded automatically into memory whenever you<br />
launch <strong>Matvec</strong>.<br />
For example,<br />
> A = [1,2,3;4,5,6;7,8,9]<br />
Col 1 Col 2 Col 3<br />
Row 1 1 2 3<br />
Row 2 4 5 6<br />
Row 3 7 8 9<br />
> A.rot90()<br />
Col 1 Col 2 Col 3<br />
Row 1 3 6 9<br />
Row 2 2 5 8<br />
Row 3 1 4 7<br />
> A.rot90(1)<br />
Col 1 Col 2 Col 3<br />
Row 1 3 6 9<br />
Row 2 2 5 8<br />
Row 3 1 4 7<br />
sample<br />
A.sample() replaces its elements with random numbers from UniformDist(0.0,1.0). A.sample(m,n) first<br />
resizes matrix A to m by n, then replaces its elements with random numbers from UniformDist(0.0,1.0).