-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_cumsum_ord_chain_right.m
45 lines (39 loc) · 1.43 KB
/
get_cumsum_ord_chain_right.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
function C = get_cumsum_ord_chain_right(rel,Wpol)
%ECPN_ordered_chain Calculates ECPN for a (single) ordered chain
% Detailed explanation goes here
n = length(rel);
switch n
case 0
disp('[WARNING] Attemting co call get_cumsum_ord_chain_right with n=0')
% P = 0;
case 1
disp('[WARNING] Attemting co call get_cumsum_ord_chain_right with n=1')
% P = 0;
C(1,:) = ECPN_C_numel2_pol_v2(rel,Wpol);
otherwise
%for i = 2:n-1 %may need optimization
% W(i) = W(i) + V(i-1)*W(i-1); %can't use VW(i-1)
%end
%VVW = V.*circshift(VW,[0,-1]); %VVW(i) = V(i) * VW(i+1);
%VVW(n) = 0;
%P = VVW * W'; %P = sum(VVW(1:n-1) .* W(1:n-1));
%VVW = V.*[VW(2:n) 0]; %VVW(i) = V(i) * VW(i+1);
%P = VVW * W'; %P = sum(VVW(1:n-1) .* W(1:n-1));
%P = (V.*[VW(2:n) 0]) * W'; %P = sum(VVW(1:n-1) .* W(1:n-1));
VWi = VW(n,:);
P = conv2(VW(2,:),VW1);
%cumnrel = cumsum(~rel);
for i = 3:n
if ~rel(i-1)
% VW = padarray(VW, [0,1],'pre');
VW1 = [VW1 0]; %padarray(VWn,[0,1],'post');
% P = [0 0 P]; %padarray(P, [0,2],'pre');
end
%VWn = VW(i-1,:) + VWn;
VW1 = poly_add(VW1,VW(i-1,:));
%P = P + conv2(VW(i,:),VW1);
P = poly_add(P, conv2(VW(i,:),VW1));
end
end
%P = polytrim_fast(P);
end