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

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

Added original make3d

File size: 1.3 KB
Line 
1function [error, Mapprox, stable1, stable2] = approximate(M, INC, r, NULLSPACE)
2
3stable1 = 0;
4stable2 = 0;
5sumnonzeros = (sum(NULLSPACE' ~= 0)')';
6samprows = find(0 ~= sumnonzeros);
7nonsamprows = find(0 == sumnonzeros);
8
9numcols = size(M,2);
10
11[samp_approx,nonsampcols]=approx_matrix(M(samprows,:), INC(samprows,:), NULLSPACE(samprows,:),r,numcols);
12
13% The rows of NULLSPACE now contain all the nullspaces of the crossproduct spaces. 
14% Use the nullspace to approximate M, taking r least principal components.
15if size(samp_approx,2) < r;
16  error = -2;
17% samp_approx = -2 means that for some reason approximation wasn't possible.
18% or if < r columns, will not be able to extend the matrix correctly.
19else
20  sampcols = setdiff(1:numcols, nonsampcols);
21  [Mapprox, stable1] ...
22     = extend_matrix(M(:,sampcols), INC(:,sampcols), samp_approx, samprows, nonsamprows, r);
23  [Mapprox_transpose, stable2] = extend_matrix(M', INC', Mapprox', sampcols, nonsampcols, r);
24  Mapprox = Mapprox_transpose';
25
26% These extensions are necessary because the nullspace might not allow us to compute
27% every row of the approximating rank r linear space, and then this linear space might
28% not allow us to fill in some columns, if they are missing too much data.
29
30  error = sum(sum((M.*INC - Mapprox.*INC).^2));
31end
32
33
Note: See TracBrowser for help on using the repository browser.