diff options
Diffstat (limited to '2048/DEPENDENCIES/indep.sci')
-rwxr-xr-x | 2048/DEPENDENCIES/indep.sci | 38 |
1 files changed, 38 insertions, 0 deletions
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
+
|