From d17b33131c14864bd1eae275f49a3f148e21cf29 Mon Sep 17 00:00:00 2001 From: Leo Chan Date: Thu, 22 Oct 2020 01:53:21 -0400 Subject: Squashed commit of the sb-vbs branch. Includes the SD-VBS benchmarks modified to: - Use libextra to loop as realtime jobs - Preallocate memory before starting their main computation - Accept input via stdin instead of via argc Does not include the SD-VBS matlab code. Fixes libextra execution in LITMUS^RT. --- SD-VBS/common/toolbox/toolbox_basic/fact/findG.m | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 SD-VBS/common/toolbox/toolbox_basic/fact/findG.m (limited to 'SD-VBS/common/toolbox/toolbox_basic/fact/findG.m') 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 @@ +function G = find3G(Rhat) + +% number of frames +F = size(Rhat,1)/2; + +% Build matrix Q such that Q * v = [1,...,1,0,...,0] where v is a six +% element vector containg all six distinct elements of the Matrix C + +clear Q +for f = 1:F, + g = f + F; + h = g + F; + Q(f,:) = zt(Rhat(f,:), Rhat(f,:)); + Q(g,:) = zt(Rhat(g,:), Rhat(g,:)); + Q(h,:) = zt(Rhat(f,:), Rhat(g,:)); +end + +% Solve for v +rhs = [ones(2*F,1); zeros(F,1)]; +v = Q \ rhs; + +% C is a symmetric 3x3 matrix such that C = G * transpose(G) +C(1,1) = v(1); +C(1,2) = v(2); +C(1,3) = v(3); +C(2,2) = v(4); +C(2,3) = v(5); +C(3,3) = v(6); +C(2,1) = C(1,2); +C(3,1) = C(1,3); +C(3,2) = C(2,3); + +e = eig(C); +disp(e) + +if (any(e<= 0)), + G = []; +else + G = sqrtm(C); +end + +%neg = 0; +%if e(1) <= 0, neg = 1; end +%if e(2) <= 0, neg = 1; end +%if e(3) <= 0, neg = 1; end +%if neg == 1, G = []; +%else G = sqrtm(C); +%end -- cgit v1.2.2