Perhaps I should explain how the analytical definitions from the paper match up with the code? Sure, might as well. But I believe it is already explained in the paper. Here is the current version of the quaternion version of the code.
https://www.wolframcloud.com/obj/fredif ... -forum3.nbEPRsims/newCS-15-S3quat-prodcalc-forum3.pdfAnd a link to the paper.
http://dx.doi.org/10.13140/RG.2.2.28311.91047/2So, in the paper we have the main equations (13) and (20) which may be a little confusing at first until you go thru the other definitions. Think of just one event. Then A and B will just be equal to 1 of the 3 possibilities. The other 2 possibilities at that time will be "no result". This in the code here,
outA=Sort[Catenate[{listA4,outA2,listA6}],#1[[3]]<#2[[3]]&]; (*Combine lists and sort*)
outB=Sort[Catenate[{listB4,outB2,listB6}],#1[[3]]<#2[[3]]&]; (*Combine lists and sort*)
Next we have the definitions that correspond to the code. For A1, A2, B1 and B2. The code is this,
outA1=Select[outAa,MemberQ[#,g1]&]; (*Split outAa into outA1 and outA2*)
outA2=Select[outAa,MemberQ[#,f1]&];
outB1=Select[outBb,MemberQ[#,g2]&]; (*Split outBb into outB1 and outB2*)
outB2=Select[outBb,MemberQ[#,f2]&];
What they do is separate the events for pre-result outAa and outBb into A1 and B1 events that are greater than the HV process and for A2 and B2, events that are less than the HV process. Exactly like it says in the paper for eqs. (14), (15), (21) and (22). Next in the paper we have A3 and B3 eqs. (16) and (23). The code for that is,
listA3=Select[outA1,Intersection[{#[[3]]},listad3]!={#[[3]]}&];
listB3=Select[outB1,Intersection[{#[[3]]},listbd3]!={#[[3]]}&];
And easy to see that it is for events from outA1 and outB1 that don't match via trial numbers via outA4 and outB4. Then of course we have A4 and B4 from eqs. (17) and (24) for which the code is,
listA4=Select[outA1,Intersection[{#[[3]]},list23]=={#[[3]]}&];
listB4=Select[outB1,Intersection[{#[[3]]},list13]=={#[[3]]}&];
Also easy to see that it is for events from outA1 and outB1 where the trial numbers do match. Perhaps we should reverse n3 and n4 to make the flow better in the paper. Then we have A5 and B5 in the paper eqs. (18) and (25) for which the code is,
I should mention here that A5 and B5 are recorded as the 5th element for every event in the tables for the A and B sides. And these are for use in A6 and B6 eqs. (19) and (26). Which in the code are,
Do[If[listA3[[i]][[2]]==listA3[[i]][[5]],qaaq[[i]]=1,qaaq[[i]]=Re[listA36[[i]]**listA37[[i]]]];
listA6[[i]]={listA3[[i]][[1]],qaaq[[i]]*listA3[[i]][[2]],listA3[[i]][[3]],listA3[[i]][[4]],listA3[[i]][[5]],listA3[[i]][[6]],listA3[[i]][[7]]}, {i, M}]
Do[If[listB3[[i]][[2]]==listB3[[i]][[5]],qbbq[[i]]=1,qbbq[[i]]=Re[listB36[[i]]**listB37[[i]]]];
listB6[[i]]={listB3[[i]][[1]],qbbq[[i]]*listB3[[i]][[2]],listB3[[i]][[3]],listB3[[i]][[4]],listB3[[i]][[5]],listB3[[i]][[6]],listB3[[i]][[7]]}, {i, M2}]
Yep, those two are doozies but you can see the spinorial sign changes here qaaq[[i]]*listA3[[i]][[2]] and here qbbq[[i]]*listB3[[i]][[2]]. So, "emulates" comes out of the paper description. Ok, I think that is it.
.