source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/missing-data/whole_invert.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 1.2 KB
Line 
1function [U, stable] = whole_invert(V, W, INC, r)
2%V is the transformation matrix
3%W is the data matrix
4%INC is the incidence matrix of the same size as W.  1 denotes valid
5%    data and 0 denotes missing data
6%r is the desired rank
7
8%to compute each row of U, this function removes the rows of V that
9%correspond to missing data, then pre-multiplies the corresponding data
10%elements from W by the pseudo-inverse of the new transformation
11%matrix.
12
13i = 1;
14n = size(W,1);
15W = W';
16z = zeros(1,r);
17U = zeros(n, r);
18stable = 1;
19
20%for each row column of the original W
21while (i <= n)
22
23  %remove the rows of V that correspond to missing data
24%  sub_mat = V(INC(i,:),:);
25% The above line worked in Matlab IV.  The line below replaces it in V.
26  sub_mat = V(logical(INC(i,:)),:);
27
28  %check that there is some valid data
29%  if (size(sub_mat) > 0)
30  if (rank(sub_mat) >= r)
31
32    %choose the valid entries in W and find the entries of U
33    %by pre-multiplying by the pseudo-inverse of V
34%     t = sub_mat\(W(INC(i,:),i));  % MATLAB IV.
35    t = sub_mat\(W(logical(INC(i,:)),i));
36  else
37    t = z';
38    fprintf(1,'WARNING: Rank deficient in whole_invert.\n');
39    stable = 0;
40%    keyboard
41  end;   
42
43  U(i,:) = t';
44  i = i + 1;
45end;
46
47
Note: See TracBrowser for help on using the repository browser.