[37] | 1 | function [error, Mapprox, stable] = rankrsfm_tpose(M,INC,trans) |
---|
| 2 | % Compare to rankrsfm. This will work on the transpose of the matrix. |
---|
| 3 | % trans is a switch that allows the same routine to either allow for |
---|
| 4 | % translation or not. |
---|
| 5 | |
---|
| 6 | if ~ trans |
---|
| 7 | r = 3; |
---|
| 8 | else |
---|
| 9 | r = 4; |
---|
| 10 | end |
---|
| 11 | M = M'; |
---|
| 12 | INC = INC'; |
---|
| 13 | MAXNULLSIZE = 10; |
---|
| 14 | [numrows,numcols] = size(M); |
---|
| 15 | NULLSPACE = []; |
---|
| 16 | frame_pairs = random_frame_pairs(numcols/2); |
---|
| 17 | % gives a 2 x (numframes choose 2) matrix with all pairs of frames, in random order. |
---|
| 18 | |
---|
| 19 | for pair = frame_pairs |
---|
| 20 | if size(NULLSPACE,2) >= numcols*MAXNULLSIZE, break, end |
---|
| 21 | |
---|
| 22 | [submatrix,subrows] = fp_submatrix(pair,M',INC'); |
---|
| 23 | submatrix = submatrix'; |
---|
| 24 | % I have to transpose everything, since this routine is written to work with |
---|
| 25 | % untransposed matrix. |
---|
| 26 | num_subpoints = size(submatrix,1); |
---|
| 27 | if num_subpoints > r |
---|
| 28 | if trans |
---|
| 29 | submatrix = [ones(num_subpoints,1), submatrix]; |
---|
| 30 | end |
---|
| 31 | subnull = nulleps(submatrix,.001,r); |
---|
| 32 | if size(subnull,2) == num_subpoints - r |
---|
| 33 | % Since submatrix has 5+ rows and 5 columns, if it has rank 4, subnull is |
---|
| 34 | % number rows - 4. |
---|
| 35 | % If subnull is bigger, submatrix is rank deficient, and results unstable. |
---|
| 36 | nullTEMP = zeros(numrows, size(subnull,2)); |
---|
| 37 | nullTEMP(subrows,:) = subnull; |
---|
| 38 | NULLSPACE = [NULLSPACE, nullTEMP]; |
---|
| 39 | end |
---|
| 40 | end |
---|
| 41 | end |
---|
| 42 | |
---|
| 43 | if size(NULLSPACE) == [0 0] |
---|
| 44 | error = -2; |
---|
| 45 | Mapprox = []; |
---|
| 46 | else |
---|
| 47 | [error, Mapprox, stable1, stable2] = approximate(M,INC,r,NULLSPACE); |
---|
| 48 | % Now we should be sure that the nullspace of NULLSPACE contains a column with all ones. |
---|
| 49 | if error ~= -2 |
---|
| 50 | error = sum(sum((M.*INC - Mapprox.*INC).^2)); |
---|
| 51 | Mapprox = Mapprox'; |
---|
| 52 | end |
---|
| 53 | stable = stable1 & stable2; |
---|
| 54 | end |
---|
| 55 | |
---|
| 56 | if error == -2 |
---|
| 57 | stable = 0; |
---|
| 58 | end |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | |
---|
| 64 | |
---|