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

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

Added original make3d

File size: 1.7 KB
Line 
1function [error, Mapprox, stable] = rankr(M,INC,r,n, iter)
2% Fit a rank r matrix to a matrix with missing data.  This uses my
3% algorithm of taking the most orthogonal space to the null space generated
4% by r-tuples of the columns of M.  In principle, it would be nice
5% to use all r-tuples, but instead we'll pick n random ones.
6
7
8%global NULLSPACEexternal
9
10NULLSPACE = create_nullspace(M,INC,r,n);
11
12if size(NULLSPACE) == [0 0]
13  error = -2;
14  Mapprox = [];
15else
16  [error, Mapprox, stable1, stable2] = approximate(M,INC,r,NULLSPACE);
17  stable = stable1 & stable2;
18
19% NOTE:  needed to comment out this next re-running step for intensity
20% simulations because matrix was too large, so matlab ran out of memory.
21
22%  if (~ stable2) | (error == -2)
23%    fprintf(1, 'Repeating procedure....\n');
24%    NULLSPACE = create_nullspace(M',INC',r,n);
25%    if size(NULLSPACE) == [0 0]
26%      error2 = -2;
27%    else
28%      [error2, Mapprox2, stable1, stable2] = approximate(M',INC',r,NULLSPACE);
29%
30%     if ((error2 < error) & (error2 ~= -2)) | (error == -2)
31%        fprintf(1,'Using new results.\n');
32%        error = error2;
33%        Mapprox = Mapprox2';
34%        stable = stable1 & stable2;
35%      end   
36%    end
37%  end
38
39end
40%save data if error.
41%if ((error > 3) & stable)
42%  fname = sprintf('error%d.bin',iter);
43%  fid = fopen(fname, 'W');
44%  count = fwrite(fid,[size(M)], 'float');
45%  count = fwrite(fid,[M], 'float');
46%  count = fwrite(fid,[INC], 'float');
47%  count = fwrite(fid,[size(NULLSPACE)], 'float');
48%  count = fwrite(fid,[NULLSPACE], 'float');
49%  fclose(fid);
50%end
51%NULLSPACEexternal = NULLSPACE;
52
53if error == -2
54  stable = 0;
55end
Note: See TracBrowser for help on using the repository browser.