diff options
Diffstat (limited to '2048/DEPENDENCIES/cindep.sci')
-rwxr-xr-x | 2048/DEPENDENCIES/cindep.sci | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/2048/DEPENDENCIES/cindep.sci b/2048/DEPENDENCIES/cindep.sci new file mode 100755 index 000000000..3ffd243d4 --- /dev/null +++ b/2048/DEPENDENCIES/cindep.sci @@ -0,0 +1,35 @@ +// function b = cindep( S,gap)
+// Used in XD + YN = C. All rows except the last of are assumed to
+// be independent. The aim is to check if the last row is dependent on the
+// rest and if so how. The coefficients of dependence are sent in b.
+function b = cindep( S,gap)
+
+if argn(2) == 1
+ gap = 1.0e8;
+end
+eps = 2.2204e-016;
+[rows,cols] = size(S);
+if rows > cols
+ ind = 0;
+else
+ sigma = svd(S);
+ len = length(sigma);
+ if (sigma(len)/sigma(1) <= (eps*max(i,cols)))
+ ind = 0; //not independent
+ else
+ if or(sigma(1:len-1) ./sigma(2:len)>=gap)
+ ind = 0; // not dependent
+ else
+ ind = 1; //independent
+ end
+ end
+end
+if ind
+ b = [];
+else
+ b = S(rows,:)/S(1:rows-1,:);
+ b = makezero(b,gap);
+end
+endfunction
+
+
|