-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgetRowSelect.m
62 lines (55 loc) · 1.64 KB
/
getRowSelect.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
function [Sa Sb] = getRowSelect(d,n,a,b)
% [Sa Sb] = getRowSelect(d,n,a,b)
% -------------------------------
% Returns row selection matrices for shifts a,b of homogeneous n-variate Vandermonde vectors of degree d.
%
% Sa = vector, contains indices of left-hand side row selection, multiplication with x_a
%
% Sb = vector, contains indices of right-hand side row selection, multiplication with x_b
%
% d = scalar, degree at which homogeneous Vandermonde vector is made
%
% n = scalar, number of variables
%
% a = scalar, index of multiplication monomial on left-hand side, 0 <= a <=n
%
% b = scalar, index of multiplication monomial on right-hand side, 0 <= b <=n
%
% CALLS
% -----
%
% getMonBase.m
%
% Kim Batselier, 2013-09
if a<0 | a > n
error(['Error: shift variable should be scalar between ' num2str(0) ' and ' num2str(n)])
end
if b<0 | b > n
error(['Error: shift variable should be scalar between ' num2str(0) ' and ' num2str(n)])
end
% monomial basis
mons=getMonBase(d,n+1);
% left-hand side row selection matrix depends on right-hand side shift
% monomial b
sa=find(mons(:,b+1)>0);
Sa = zeros(length(sa),nchoosek(d+n,n));
for i=1:length(sa)
Sa(i,sa(i))=1;
end
% right-hand side row selection matrix depends on left-hand side shift
% monomial b
Sa=find(mons(:,b+1)>0)';
Sb=zeros(1,length(Sa));
for i=1:length(Sa)
indexfound=0;
index=1;
while ~indexfound
if sum(mons(index,:)==mons(sa(i),:)+[zeros(1,a) 1 zeros(1,n-a)]-[zeros(1,b) 1 zeros(1,n-b)])==n+1
Sb(i)=index;
indexfound=1;
else
index=index+1;
end
end
end
end