summaryrefslogtreecommitdiff
path: root/2048/DEPENDENCIES/recursion.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/recursion.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/recursion.sci')
-rw-r--r--2048/DEPENDENCIES/recursion.sci35
1 files changed, 35 insertions, 0 deletions
diff --git a/2048/DEPENDENCIES/recursion.sci b/2048/DEPENDENCIES/recursion.sci
new file mode 100644
index 000000000..ead807bfb
--- /dev/null
+++ b/2048/DEPENDENCIES/recursion.sci
@@ -0,0 +1,35 @@
+// Recursive computation of Ej and Fj
+// 11.1
+
+function [Fj,dFj,Ej,dEj] = recursion(A,dA,C,dC,j)
+Fo = C; dFo = dC;
+Eo = 1; dEo = 0;
+A_z = A(2:dA+1); dA_z = dA-1;
+zi = 1; dzi = 0;
+for i = 1:j-1
+ if (dFo == 0)
+ Fn1 = 0;
+ else
+ Fn1 = Fo(2:(dFo+1));
+ end
+ dFn1 = max(dFo-1,0);
+ Fn2 = -Fo(1)*A_z; dFn2 = dA-1;
+ [Fn,dFn] = poladd(Fn1,dFn1,Fn2,dFn2);
+ zi = convol(zi,[0,1]); dzi = dzi + 1;
+ En2 = Fn(1)*zi; dEn2 = dzi;
+ [En,dEn] = poladd(Eo,dEo,En2,dEn2);
+ Eo = En; Fo = Fn;
+ dEo = dEn; dFo = dFn;
+end
+if (dFo == 0)
+ Fn1 = 0;
+else
+Fn1 = Fo(2:(dFo+1));
+end;
+dFn1 = max(dFo-1,0);
+Fn2 = -Fo(1)*A_z; dFn2 = dA-1;
+[Fn,dFn] = poladd(Fn1,dFn1,Fn2,dFn2);
+Fj = Fn; dFj = dFn;
+Ej = Eo; dEj = dEo;
+endfunction;
+