diff options
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/fact/findG.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/fact/findG.m | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/fact/findG.m b/SD-VBS/common/toolbox/toolbox_basic/fact/findG.m new file mode 100755 index 0000000..9a6bd73 --- /dev/null +++ b/SD-VBS/common/toolbox/toolbox_basic/fact/findG.m | |||
@@ -0,0 +1,48 @@ | |||
1 | function G = find3G(Rhat) | ||
2 | |||
3 | % number of frames | ||
4 | F = size(Rhat,1)/2; | ||
5 | |||
6 | % Build matrix Q such that Q * v = [1,...,1,0,...,0] where v is a six | ||
7 | % element vector containg all six distinct elements of the Matrix C | ||
8 | |||
9 | clear Q | ||
10 | for f = 1:F, | ||
11 | g = f + F; | ||
12 | h = g + F; | ||
13 | Q(f,:) = zt(Rhat(f,:), Rhat(f,:)); | ||
14 | Q(g,:) = zt(Rhat(g,:), Rhat(g,:)); | ||
15 | Q(h,:) = zt(Rhat(f,:), Rhat(g,:)); | ||
16 | end | ||
17 | |||
18 | % Solve for v | ||
19 | rhs = [ones(2*F,1); zeros(F,1)]; | ||
20 | v = Q \ rhs; | ||
21 | |||
22 | % C is a symmetric 3x3 matrix such that C = G * transpose(G) | ||
23 | C(1,1) = v(1); | ||
24 | C(1,2) = v(2); | ||
25 | C(1,3) = v(3); | ||
26 | C(2,2) = v(4); | ||
27 | C(2,3) = v(5); | ||
28 | C(3,3) = v(6); | ||
29 | C(2,1) = C(1,2); | ||
30 | C(3,1) = C(1,3); | ||
31 | C(3,2) = C(2,3); | ||
32 | |||
33 | e = eig(C); | ||
34 | disp(e) | ||
35 | |||
36 | if (any(e<= 0)), | ||
37 | G = []; | ||
38 | else | ||
39 | G = sqrtm(C); | ||
40 | end | ||
41 | |||
42 | %neg = 0; | ||
43 | %if e(1) <= 0, neg = 1; end | ||
44 | %if e(2) <= 0, neg = 1; end | ||
45 | %if e(3) <= 0, neg = 1; end | ||
46 | %if neg == 1, G = []; | ||
47 | %else G = sqrtm(C); | ||
48 | %end | ||