-
Notifications
You must be signed in to change notification settings - Fork 3
/
Q_save.m
46 lines (46 loc) · 2.34 KB
/
Q_save.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
function [res, resDagger] = Q(Y, P1, P2, P3, Pdagger1, Pdagger2, Pdagger3, Ni, Ne, Nf, NNB)
% Q computes both Q and Q_dagger
% both are of size Nf x Nf
res=zeros(Nf); resDagger=zeros(Nf);
for pp=7:Ni
ee=1;
res = res+Y(NNB(pp, 2*ee))*cell2mat(P2(pp, ee)) ...
+ Y(NNB(pp, 2*ee+1))*cell2mat(P3(pp, ee));
resDagger = resDagger +Y(NNB(pp, 2*ee))*cell2mat(Pdagger2(pp, ee)) ...
+ Y(NNB(pp, 2*ee+1))*cell2mat(Pdagger3(pp, ee));
for ee = 2:Ne
res = res + Y(NNB(pp, 2*ee-1))*cell2mat(P1(pp, ee)) ...
+ Y(NNB(pp, 2*ee))*cell2mat(P2(pp, ee)) ...
+ Y(NNB(pp, 2*ee+1))*cell2mat(P3(pp, ee));
resDagger = resDagger + Y(NNB(pp, 2*ee-1))*cell2mat(Pdagger1(pp, ee)) ...
+ Y(NNB(pp, 2*ee))*cell2mat(Pdagger2(pp, ee)) ...
+ Y(NNB(pp, 2*ee+1))*cell2mat(Pdagger3(pp, ee));
end
end
%%% erreur ici ???
% % for pp=1:6
% % for ee=1:Ne-1
% % res = res + Y(NNB(pp, 2*ee-1))*cell2mat(P1(pp, ee)) ...
% % + Y(NNB(pp, 2*ee))*cell2mat(P2(pp, ee)) ...
% % + Y(NNB(pp, 2*ee+1))*cell2mat(P3(pp, ee));
% % resDagger = resDagger + Y(NNB(pp, 2*ee-1))*cell2mat(Pdagger1(pp, ee)) ...
% % + Y(NNB(pp, 2*ee))*cell2mat(Pdagger2(pp, ee)) ...
% % + Y(NNB(pp, 2*ee+1))*cell2mat(Pdagger3(pp, ee));
% % end
% % ee = Ne;
% % res = res + Y(NNB(pp, 2*ee-1))*cell2mat(P1(pp, ee)) ...
% % + Y(NNB(pp, 2*ee))*cell2mat(P2(pp, ee));
% % resDagger = resDagger + Y(NNB(pp, 2*ee-1))*cell2mat(Pdagger1(pp, ee)) ...
% % + Y(NNB(pp, 2*ee))*cell2mat(Pdagger2(pp, ee));
% % end
for pp=1:6
for ee=1:Ne
res = res + Y(NNB(pp, 2*ee-1))*cell2mat(P1(pp, ee)) ...
+ Y(NNB(pp, 2*ee))*cell2mat(P2(pp, ee)) ...
+ Y(NNB(pp, 2*ee+1))*cell2mat(P3(pp, ee));
resDagger = resDagger + Y(NNB(pp, 2*ee-1))*cell2mat(Pdagger1(pp, ee)) ...
+ Y(NNB(pp, 2*ee))*cell2mat(Pdagger2(pp, ee)) ...
+ Y(NNB(pp, 2*ee+1))*cell2mat(Pdagger3(pp, ee));
end
end
end