-
Notifications
You must be signed in to change notification settings - Fork 5
/
getRad.m
68 lines (54 loc) · 1.7 KB
/
getRad.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
function radsys = getRad(polysys)
% radsys = getRad(polysys)
% ------------------------
% If a polynomial system polysys is not radical then calling this function
% will add polynomials such that the resulting polynomial system radsys is
% radical.
%
% radsys = cell containing coefficients and monomials exponents of the
% set of polynomial equations which are generators of the
% radical ideal of polysys
%
% polysys = cell containing coefficients and monomials exponents of the
% original set of polynomial equations which are not
% generators of a radical ideal.
%
% CALLS
% -----
%
% Kim Batselier, 2011-01-23
warning off all
% number of unknowns
n = size(polysys{1,2},2);
% number of equations
n_eq = size(polysys,1);
radsys = polysys;
israd = 1;
for i = 1 : n
% first need the monic generators
[puni d sintheta tol] = punivar(polysys,i);
puni=puni(1:find(abs(puni)>tol,1,'last')); % prune numerical zero higher order terms
puni(abs(puni)<tol)=0; % set remaining numerical zeros to exact zero
ppuni = prune(diffPoly(puni,1,1),1);
ppuni = ppuni/norm(ppuni);
[lcm h e] = getLCM(vec2polysys(puni,1),vec2polysys(ppuni,1),tol);
h=h/norm(h);
if (length(h)~= length(puni)) || abs(puni*h')-1 > tol
israd = 0;
end
h=h(1:find(abs(h)>tol,1,'last'));
h(abs(h)<tol)=0;
temp = cell(1,2);
coefI = find(h(1,:));
temp{1,1} = h(coefI);
for j = 1 : length(coefI)
temp{1,2} = [temp{1,2} ; [zeros(1,i-1) coefI(j)-1 zeros(1,n-i) ] ];
end
radsys{n_eq+i,1} = temp{1};
radsys{n_eq+i,2} = temp{2};
end
if israd
clear radsys
radsys = polysys;
end
end