-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaln.m
73 lines (67 loc) · 1.87 KB
/
aln.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
66
67
68
69
70
71
72
73
function [dp dm] = aln(polysys,dmax)
% [dp dm] = aln(polysys,dmax)
% ---------------------------
% Analyze Left Nullspace of Macaulay matrix. Calculates the Left Hilbert
% Polynomial for a given polynomial system.
%
% dp = vector, contains degrees that contribute with + terms to
% the Left Hilbert Polynomial
%
% dm = vector, contains degrees that contribute with - terms to
% the Left Hilbert Polynomial
%
% polysys = cell containing coefficients and monomials exponents of the
% set of polynomial equations.
%
% dmax = scalar, desired maximum total degree of matrix M
%
%
% CALLS
% -----
%
% getD0.m, getMDim.m, getM.m, getMex.m
%
% Kim Batselier, 2011-06-09, update 2013-03-25: uses updateN now to
% determine r(d)
d = getD0(polysys);
dp = [];
dm = [];
n = size(polysys{1,2},2);
[p q] = getMDim(polysys,dmax);
[M ] = getM(polysys,0);
for i = 1 : dmax % new algorithm - we always need to start from degree 1
[p q] = getMDim(polysys,i);
temp = M;
[Mex ] = getMex(polysys,i,i-1);
M = zeros( p,q );
M(1:size(temp,1),1:size(temp,2)) = temp;
M(size(temp,1)+1:end,:) = Mex;
% Ms = [Ms zeros(size(Ms,1),size(Mex,2)-size(Ms,2));Mex];
clear Mex
% M = getM(polysys,i);
if ~isempty(M)
lcr = size(M,1)-rank(M);
lcrhat = evalLcr();
e = lcrhat-lcr;
if e > 0
for k = 1 : abs(e)
dm = [dm i];
end
elseif e < 0
for k = 1 : abs(e)
dp = [dp i];
end
end
end
% [length(dp) length(dm) length(dp)-length(dm)]
end
function lcrhat = evalLcr
lcrhat = 0;
for j = 1 : length(dp)
lcrhat = lcrhat + nchoosek(i-dp(j)+n,n);
end
for j = 1 : length(dm)
lcrhat = lcrhat - nchoosek(i-dm(j)+n,n);
end
end
end