From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 2048/DEPENDENCIES/indep.sci | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 2048/DEPENDENCIES/indep.sci (limited to '2048/DEPENDENCIES/indep.sci') diff --git a/2048/DEPENDENCIES/indep.sci b/2048/DEPENDENCIES/indep.sci new file mode 100755 index 000000000..860abae31 --- /dev/null +++ b/2048/DEPENDENCIES/indep.sci @@ -0,0 +1,38 @@ +// function b = indep(S,gap) +// determines the first row that is dependent on the previous rows of S. +// The coefficients of dependence is returned in b +function b = indep( S,gap) + +if argn(2) == 1 + gap = 1.0e8; + end +[rows,cols] = size(S); +ind = 1; +i = 2; +eps = 2.2204e-016; +while ind & i <= rows + sigma = svd(S(1:i,:)); + len = length(sigma); + if(sigma(len)/sigma(1) < (eps*max(i,cols))) + ind =0; + else + shsig = [sigma(2:len);sigma(len)]; + if or( (sigma ./shsig) > gap) + ind = 0; + else + ind = 1; + i = i+1; + end + end + +end +if ind + b =[]; + +else + c = S(i,:)/S(1:i-1,:); + c = makezero(c,gap); + b = [-c 1]; +end +endfunction + -- cgit