source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/zisserman/vgg_numerics/vgg_vech.m @ 37

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
Line 
1function 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
17if 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)); 
24else
25  r = (1:M)'*ones(1,N);
26  c = ones(M,1)*(1:N);
27  h = m(find(c <= r));
28end
29
30return
Note: See TracBrowser for help on using the repository browser.