Last change
on this file since 37 was
37,
checked in by (none), 14 years ago
|
Added original make3d
|
-
Property svn:executable set to
*
|
File size:
768 bytes
|
Rev | Line | |
---|
[37] | 1 | function h = vgg_vech(m)
|
---|
| 2 | % VGG_VECH Vectorization ("flattening") of symmetric matrix.
|
---|
| 3 | %
|
---|
| 4 | % For square matrix X, vgg_vech(X) is the column vector of elements on or
|
---|
| 5 | % below the main diagonal of m.
|
---|
| 6 | %
|
---|
| 7 | % Also works inversely: for a N*(N+1)/2-vector x, it returns symmetric
|
---|
| 8 | % N-by-N matrix X = vgg_vech(x) such that vgg_vech(X) = x.
|
---|
| 9 | %
|
---|
| 10 | % Useful for solving linear matrix equations, see Magnus and Neudecker.
|
---|
| 11 | %
|
---|
| 12 | % See vgg_matrix_test, vgg_duplic_matrix, and also vgg_vech_swap,
|
---|
| 13 | % vgg_commut_matrix.
|
---|
| 14 |
|
---|
| 15 | [M N] = size(m);
|
---|
| 16 |
|
---|
| 17 | if M==1 | N==1
|
---|
| 18 | N = (sqrt(8*M*N+1)-1)/2;
|
---|
| 19 | r = (1:N)'*ones(1,N);
|
---|
| 20 | c = r';
|
---|
| 21 | h = zeros(N);
|
---|
| 22 | h(find(c <= r)) = m;
|
---|
| 23 | h = h+h'-diag(diag(h));
|
---|
| 24 | else
|
---|
| 25 | r = (1:M)'*ones(1,N);
|
---|
| 26 | c = ones(M,1)*(1:N);
|
---|
| 27 | h = m(find(c <= r));
|
---|
| 28 | end
|
---|
| 29 |
|
---|
| 30 | return |
---|
Note: See
TracBrowser
for help on using the repository browser.