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 29<br />
sort<br />
If A is a matrix, A.sort() sorts each column of A in an ascending order.<br />
If A is a vector, A.sort() sorts the vector in an ascending order.<br />
If you want to sort it in descending order, the following will do the job:<br />
> a = Vector(3,2,4);<br />
> b = a.sort()<br />
i = 1 i = 2 i = 3<br />
2 3 4<br />
> b(3:1:-1) # sort it in descending order<br />
i = 1 i = 2 i = 3<br />
4 3 2<br />
std<br />
A.std() returns a vector containing the standard deviations for each column of A.<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 = [3,2,1;4,5,6;9,8,7];<br />
> A.std()<br />
sum<br />
i = 1 i = 2 i = 3<br />
3.21455 3 3.21455<br />
A.sum() returns a vector containing sum values for each column of A. If A is a one-row or one-column matrix,<br />
then the returned value would be a scalar.<br />
sumsq<br />
A.sumsq() returns a vector containing sum square values for each column of A. If A is a one-row or one-column<br />
matrix, then the returned value would be a scalar.<br />
svd<br />
The singular value decomposition of an m-by-n matrix A is a decomposition<br />
A = U*W*V’<br />
where U is m-by-n with U’*U = I, W is an n-by-n diagonal matrix and V is an n-by-n orthogonal matrix.<br />
Both A.svd() and A.svd(U,V) returns a vector containing diagonals in W, but the latter has U and V<br />
which must be declared as matrix objects before calling.<br />
If A is a scalar, then it will be treated as a 1-by-1 matrix.<br />
For example,<br />
> a=[1,2,3;2,9,4;2,1,8];<br />
> u=[]; v=[];<br />
> a.svd(u,v)<br />
i = 1 i = 2 i = 3<br />
12.0953 0.0538603 6.14008