From 7bc77cb1ed33745c720952c92b3b2747c5cbf2df Mon Sep 17 00:00:00 2001 From: prashantsinalkar Date: Sat, 3 Feb 2018 11:01:52 +0530 Subject: Added new code --- 2048/DEPENDENCIES/recursion.sci | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 2048/DEPENDENCIES/recursion.sci (limited to '2048/DEPENDENCIES/recursion.sci') 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; + -- cgit