summaryrefslogtreecommitdiff
path: root/2048/DEPENDENCIES/spec1.sci
diff options
context:
space:
mode:
authorprashantsinalkar2018-02-03 11:01:52 +0530
committerprashantsinalkar2018-02-03 11:01:52 +0530
commit7bc77cb1ed33745c720952c92b3b2747c5cbf2df (patch)
tree449d555969bfd7befe906877abab098c6e63a0e8 /2048/DEPENDENCIES/spec1.sci
parentd1e070fe2d77c8e7f6ba4b0c57b1b42e26349059 (diff)
downloadScilab-TBC-Uploads-master.tar.gz
Scilab-TBC-Uploads-master.tar.bz2
Scilab-TBC-Uploads-master.zip
Added new codeHEADmaster
Diffstat (limited to '2048/DEPENDENCIES/spec1.sci')
-rw-r--r--2048/DEPENDENCIES/spec1.sci23
1 files changed, 23 insertions, 0 deletions
diff --git a/2048/DEPENDENCIES/spec1.sci b/2048/DEPENDENCIES/spec1.sci
new file mode 100644
index 000000000..c749f9695
--- /dev/null
+++ b/2048/DEPENDENCIES/spec1.sci
@@ -0,0 +1,23 @@
+// Function to implement spectral factorization, as discussed in sec. 13.1.
+// 13.2
+
+function [r,b,rbbr] = spec1(A,dA,B,dB,rho)
+AA = rho * convol(A,flip(A));
+BB = convol(B,flip(B));
+diff1 = dA - dB;
+dBB = 2*dB;
+for i = 1:diff1
+ [BB,dBB] = polmul(BB,dBB,[0 1],1);
+end
+[rbbr,drbbr] = poladd(AA,2*dA,BB,dBB);
+rts = roots(rbbr); // roots in descending order of magnitude
+rts = flip(rts);
+rtsin = rts(dA+1:2*dA);
+b = 1;
+for i = 1:dA,
+ b = convol(b,[1 -rtsin(i)]);
+end
+br = flip(b);
+bbr = convol(b,br);
+r = rbbr(1) / bbr(1);
+endfunction;