summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/fact/findG.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/fact/findG.m')
-rwxr-xr-xSD-VBS/common/toolbox/toolbox_basic/fact/findG.m48
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 @@
1function G = find3G(Rhat)
2
3% number of frames
4F = 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
9clear Q
10for 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,:));
16end
17
18% Solve for v
19rhs = [ones(2*F,1); zeros(F,1)];
20v = Q \ rhs;
21
22% C is a symmetric 3x3 matrix such that C = G * transpose(G)
23C(1,1) = v(1);
24C(1,2) = v(2);
25C(1,3) = v(3);
26C(2,2) = v(4);
27C(2,3) = v(5);
28C(3,3) = v(6);
29C(2,1) = C(1,2);
30C(3,1) = C(1,3);
31C(3,2) = C(2,3);
32
33e = eig(C);
34disp(e)
35
36if (any(e<= 0)),
37 G = [];
38else
39 G = sqrtm(C);
40end
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