-
Notifications
You must be signed in to change notification settings - Fork 5
/
idealMember.m
65 lines (58 loc) · 1.48 KB
/
idealMember.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function [ang p] = idealMember(psys,polysys,d,varargin)
% [ang p] = idealMember(psys,polysys,d,tol)
% -----------------------------------------
% Ideal membership checking via principal angles. Returns principal angle
% between M(d) and monomial basis for given polynomial psys. Computes sines
% of principal angles instead of cosines.
%
% ang = scalar, principal angle between row space M(d) and given
% polynomial
%
% p = vector, coefficient vector of polynomial that lies in row(M(d))
%
% psys = cell, polysys cell for polynomial you want to check
%
% polysys = cell, polysys cell for generators of ideal
%
% d = scalar, degree of row(M(d))
%
% tol = scalar, tolerance: optional. Default =
% max(size(M))*eps(sigma1) with sigma1 = largest singular value
%
% CALLS
% -----
%
% getM.m, feti.m
%
% Kim Batselier, 2012-05-28
M = getM(polysys,d);
[A S V] = svd(M,'econ');
sig=diag(S);
if nargin == 3
tol = max(size(M))*eps(sig(1));
else
tol = varargin{1};
end
% need monomial basis for psys
indices = zeros(1,length(psys{1,1}));
for i = 1:length(psys{1,1})
indices(i) = feti(psys{1,2}(i,:));
end
%E = speye(fetr(LT),size(M,2));
indices = sort(indices);
p=zeros(1,size(M,2));
r = sum(sig>tol);
U = V(:,1:r);
clear A S V
test=-U*U(indices,:)';
for j=1:length(indices)
test(indices(j),j) = 1+test(indices(j),j);
end
% compute the sines
[Y S Z] = svd(test);
s=diag(S);
ang = asin(s(end));
if ang < tol
p(1,indices)=Z(:,end)';
end
end