Skip to content

Commit a5feddf

Browse files
committed
feat(grcc): implment qgraf-compatible keywords in FORM
These pass a large number of comparisons with qgraf, using @tueda's "qgraf.frm" comparison procedures.
1 parent ec4a5d2 commit a5feddf

File tree

4 files changed

+121
-75
lines changed

4 files changed

+121
-75
lines changed

sources/diawrap.cc

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ void ProcessDiagram(EGraph *eg, void *ti)
245245
//
246246
// Now get the nodes
247247
//
248-
if ( ( info->flags & NONODES ) == 0 ) {
248+
if ( ( info->flags & WITHOUTNODES ) == 0 ) {
249249
for ( i = 0; i < eg->nNodes; i++ ) {
250250
//
251251
// node_(number,coupling,particle_1(momentum_1),...,particle_n(momentum_n))
@@ -395,7 +395,7 @@ void ProcessDiagram(EGraph *eg, void *ti)
395395
startfill[1] = fill-startfill;
396396
}
397397
}
398-
if ( ( info->flags & WITHONEPI ) == WITHONEPI ) {
398+
if ( ( info->flags & WITHONEPISETS ) == WITHONEPISETS ) {
399399
for ( i = 0; i < eg->econn->nopic; i++ ) {
400400
startfill = fill;
401401
*fill++ = ONEPI;
@@ -452,8 +452,6 @@ void ProcessDiagram(EGraph *eg, void *ti)
452452
*newterm = fill - newterm;
453453
AT.WorkPointer = fill;
454454

455-
// MesPrint("<> %a",newterm[0],newterm);
456-
457455
Generator(BHEAD newterm,info->level);
458456
AT.WorkPointer = oldworkpointer;
459457
}
@@ -664,7 +662,7 @@ Bool ProcessTopology(EGraph *eg, void *ti)
664662
// startfill[1] = fill-startfill;
665663
// }
666664
}
667-
if ( ( info->flags & WITHONEPI ) == WITHONEPI ) {
665+
if ( ( info->flags & WITHONEPISETS ) == WITHONEPISETS ) {
668666
for ( i = 0; i < eg->econn->nopic; i++ ) {
669667
startfill = fill;
670668
*fill++ = ONEPI;
@@ -718,15 +716,35 @@ Bool ProcessTopology(EGraph *eg, void *ti)
718716
*newterm = fill - newterm;
719717
AT.WorkPointer = fill;
720718

721-
//MesPrint("<> %a",*newterm,newterm);
722-
723719
Generator(BHEAD newterm,info->level);
724720
AT.WorkPointer = oldworkpointer;
725721
info->numtopo++;
726722
return False;
727723
}
728724

729725
// #] ProcessTopology :
726+
// #[ SetDualOpts :
727+
void SetDualOpts(int *opt, const WORD num, const int key, const int dual,
728+
const int val, const int dval, const int both) {
729+
730+
if ( ( num & key ) == key ) {
731+
if ( ( num & dual ) == dual ) {
732+
*opt = both;
733+
}
734+
else {
735+
*opt = val;
736+
}
737+
}
738+
else {
739+
if ( ( num & dual ) == dual ) {
740+
*opt = dval;
741+
}
742+
else {
743+
*opt = both;
744+
}
745+
}
746+
}
747+
// #] SetDualOpts :
730748
// #[ GenDiagrams :
731749

732750
int GenDiagrams(PHEAD WORD *term, WORD level)
@@ -780,27 +798,24 @@ int GenDiagrams(PHEAD WORD *term, WORD level)
780798

781799
opt->setOutAG(ProcessDiagram, &info);
782800
opt->setOutMG(ProcessTopology, &info);
783-
// opt->setEndMG(fendMG, &info);
784801

785-
opt->values[GRCC_OPT_1PI] = ( optionnumber & ONEPARTICLEIRREDUCIBLE ) == ONEPARTICLEIRREDUCIBLE;
786-
opt->values[GRCC_OPT_NoTadpole] = ( optionnumber & NOTADPOLES ) == NOTADPOLES;
787-
//
788-
// Next are snails:
789-
//
790-
opt->values[GRCC_OPT_No1PtBlock] = ( optionnumber & NOTADPOLES ) == NOTADPOLES;
791-
//
792-
if ( ( optionnumber & WITHINSERTIONS ) == WITHINSERTIONS ) {
793-
opt->values[GRCC_OPT_No2PtL1PI] = True;
794-
opt->values[GRCC_OPT_NoAdj2PtV] = True;
795-
opt->values[GRCC_OPT_No2PtL1PI] = True;
796-
}
797-
else {
798-
opt->values[GRCC_OPT_NoAdj2PtV] = True;
799-
}
800802
opt->values[GRCC_OPT_SymmInitial] = ( optionnumber & WITHSYMMETRIZE ) == WITHSYMMETRIZE;
801-
opt->values[GRCC_OPT_SymmFinal] = ( optionnumber & WITHSYMMETRIZE ) == WITHSYMMETRIZE;
802-
803+
// TODO decide what to do here
804+
// opt->values[GRCC_OPT_SymmFinal] = ( optionnumber & WITHSYMMETRIZE ) == WITHSYMMETRIZE;
803805
// opt->values[GRCC_OPT_Block] = ( optionnumber & WITHBLOCKS ) == WITHBLOCKS;
806+
// Now the "qgraf-compatible filtering options":
807+
int qgopt[GRCC_QGRAF_OPT_Size];
808+
SetDualOpts(&qgopt[GRCC_QGRAF_OPT_ONEPI], optionnumber, ONEPARTI, ONEPARTR, 1, -1, 0);
809+
SetDualOpts(&qgopt[GRCC_QGRAF_OPT_ONSHELL], optionnumber, ONSHELL, OFFSHELL, 1, -1, 0);
810+
SetDualOpts(&qgopt[GRCC_QGRAF_OPT_NOSIGMA], optionnumber, NOSIGMA, SIGMA, 1, -1, 0);
811+
SetDualOpts(&qgopt[GRCC_QGRAF_OPT_NOSNAIL], optionnumber, NOSNAIL, SNAIL, 1, -1, 0);
812+
SetDualOpts(&qgopt[GRCC_QGRAF_OPT_NOTADPOLE], optionnumber, NOTADPOLE, TADPOLE , 1, -1, 0);
813+
SetDualOpts(&qgopt[GRCC_QGRAF_OPT_SIMPLE], optionnumber, SIMPLE, NOTSIMPLE, 1, -1, 0);
814+
SetDualOpts(&qgopt[GRCC_QGRAF_OPT_BIPART], optionnumber, BIPART, NONBIPART, 1, -1, 0);
815+
SetDualOpts(&qgopt[GRCC_QGRAF_OPT_CYCLI], optionnumber, CYCLI, CYCLR, 1, -1, 0);
816+
qgopt[GRCC_QGRAF_OPT_FLOOP] = ( optionnumber & FLOOP ) == FLOOP;
817+
// Now set the options internally:
818+
opt->setQGrafOpt(qgopt);
804819

805820
opt->setOutputF(False,"");
806821
opt->setOutputP(False,"");
@@ -809,19 +824,18 @@ int GenDiagrams(PHEAD WORD *term, WORD level)
809824
// opt->values[GRCC_OPT_Step] = GRCC_AGraph;
810825

811826
// Load the various arrays.
812-
813-
ninitl = Sets[inset].last - Sets[inset].first;
814-
for ( i = 0; i < ninitl; i++ ) {
815-
x = SetElements[Sets[inset].first+i];
816-
initlPart[i] = ConvertParticle(model,x);
827+
ninitl = Sets[inset].last - Sets[inset].first;
828+
for ( i = 0; i < ninitl; i++ ) {
829+
x = SetElements[Sets[inset].first+i];
830+
initlPart[i] = ConvertParticle(model,x);
817831
info.legcouple[i] = m->vertices[numParticle(m,x)]->couplings;
818-
}
819-
nfinal = Sets[outset].last - Sets[outset].first;
820-
for ( i = 0; i < nfinal; i++ ) {
821-
x = SetElements[Sets[outset].first+i];
822-
finalPart[i] = ConvertParticle(model,x);
832+
}
833+
nfinal = Sets[outset].last - Sets[outset].first;
834+
for ( i = 0; i < nfinal; i++ ) {
835+
x = SetElements[Sets[outset].first+i];
836+
finalPart[i] = ConvertParticle(model,x);
823837
info.legcouple[i+ninitl] = m->vertices[numParticle(m,x)]->couplings;
824-
}
838+
}
825839
info.numextern = ninitl + nfinal;
826840
for ( i = 2; i <= MAXLEGS; i++ ) {
827841
if ( m->legcouple[i] == 1 ) {
@@ -1000,21 +1014,21 @@ int GenTopologies(PHEAD WORD *term, WORD level)
10001014

10011015
info.flags |= TOPOLOGIESONLY; // this is the topologies_ function after all.
10021016
if ( t1 < tstop && t1[0] == -SNUMBER ) {
1003-
if ( ( t1[1] & NONODES ) == NONODES ) info.flags |= NONODES;
1017+
if ( ( t1[1] & WITHOUTNODES ) == WITHOUTNODES ) info.flags |= WITHOUTNODES;
10041018
if ( ( t1[1] & WITHEDGES ) == WITHEDGES ) info.flags |= WITHEDGES;
10051019
if ( ( t1[1] & WITHBLOCKS ) == WITHBLOCKS ) info.flags |= WITHBLOCKS;
1006-
if ( ( t1[1] & WITHONEPI ) == WITHONEPI ) info.flags |= WITHONEPI;
1007-
opt->values[GRCC_OPT_1PI] = ( t1[1] & ONEPARTICLEIRREDUCIBLE ) == ONEPARTICLEIRREDUCIBLE;
1008-
// opt->values[GRCC_OPT_NoTadpole] = ( t1[1] & NOTADPOLES ) == NOTADPOLES;
1009-
opt->values[GRCC_OPT_NoTadpole] = ( t1[1] & NOSNAILS ) == NOSNAILS;
1010-
opt->values[GRCC_OPT_No1PtBlock] = ( t1[1] & NOTADPOLES ) == NOTADPOLES;
1011-
opt->values[GRCC_OPT_NoExtSelf] = ( t1[1] & NOEXTSELF ) == NOEXTSELF;
1012-
1013-
if ( ( t1[1] & WITHINSERTIONS ) == WITHINSERTIONS ) {
1014-
opt->values[GRCC_OPT_No2PtL1PI] = True;
1015-
opt->values[GRCC_OPT_NoAdj2PtV] = True;
1016-
opt->values[GRCC_OPT_No2PtL1PI] = True;
1017-
}
1020+
if ( ( t1[1] & WITHONEPISETS ) == WITHONEPISETS ) info.flags |= WITHONEPISETS;
1021+
opt->values[GRCC_OPT_1PI] = ( t1[1] & ONEPARTI ) == ONEPARTI;
1022+
// opt->values[GRCC_OPT_NoTadpole] = ( t1[1] & NOTADPOLE ) == NOTADPOLE;
1023+
opt->values[GRCC_OPT_NoTadpole] = ( t1[1] & NOSNAIL ) == NOSNAIL;
1024+
opt->values[GRCC_OPT_No1PtBlock] = ( t1[1] & NOTADPOLE ) == NOTADPOLE;
1025+
// opt->values[GRCC_OPT_NoExtSelf] = ( t1[1] & NOEXTSELF ) == NOEXTSELF;
1026+
1027+
// if ( ( t1[1] & WITHINSERTIONS ) == WITHINSERTIONS ) {
1028+
// opt->values[GRCC_OPT_No2PtL1PI] = True;
1029+
// opt->values[GRCC_OPT_NoAdj2PtV] = True;
1030+
// opt->values[GRCC_OPT_No2PtL1PI] = True;
1031+
// }
10181032
opt->values[GRCC_OPT_SymmInitial] = ( t1[1] & WITHSYMMETRIZE ) == WITHSYMMETRIZE;
10191033
}
10201034

sources/ftypes.h

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,16 +1102,33 @@ typedef int (*TFUN1)();
11021102
#define DENSETABLE 1
11031103
#define SPARSETABLE 0
11041104

1105-
#define ONEPARTICLEIRREDUCIBLE 1
1106-
#define WITHINSERTIONS 2
1107-
#define NOTADPOLES 4
1108-
#define WITHSYMMETRIZE 8
1109-
#define TOPOLOGIESONLY 16
1110-
#define NONODES 32
1111-
#define WITHEDGES 64
1112-
#define CHECKEXTERN 128
1113-
#define WITHBLOCKS 256
1114-
#define WITHONEPI 512
1115-
#define NOSNAILS 1024
1116-
#define NOEXTSELF 2048
1105+
// Diagram generator flags. They should be powers of two, since they are added
1106+
// to pass to diagrams and masked in diawrap.cc to check the flags.
1107+
// We use a "stringified" version of these when defining the FORM preprocessor
1108+
// variables, so can't neatly use "1<<10" etc here.
1109+
#define TOPOLOGIESONLY 1
1110+
#define WITHOUTNODES 2
1111+
#define WITHEDGES 4
1112+
#define WITHBLOCKS 8
1113+
#define WITHONEPISETS 16
1114+
#define WITHSYMMETRIZE 32
1115+
#define CHECKEXTERN 64
1116+
// The "qgraf compatible" filtering flags:
1117+
#define ONEPARTI 128
1118+
#define ONEPARTR 256
1119+
#define ONSHELL 512
1120+
#define OFFSHELL 1024
1121+
#define NOSIGMA 2048
1122+
#define SIGMA 4096
1123+
#define NOSNAIL 8192
1124+
#define SNAIL 16384
1125+
#define NOTADPOLE 32768
1126+
#define TADPOLE 65536
1127+
#define SIMPLE 131072
1128+
#define NOTSIMPLE 262144
1129+
#define BIPART 524288
1130+
#define NONBIPART 1048576
1131+
#define CYCLI 2097152
1132+
#define CYCLR 4194304
1133+
#define FLOOP 8388608
11171134

sources/grccparam.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ typedef struct {
129129
#define GRCC_QGRAF_OPT_BIPART 6
130130
#define GRCC_QGRAF_OPT_CYCLI 7
131131
#define GRCC_QGRAF_OPT_FLOOP 8
132-
#define GRCC_QGRAF_OPT_TOPOL 9
132+
//TODO what does this do? Does it work?
133+
//#define GRCC_QGRAF_OPT_TOPOL 9
133134

134135
#ifdef GRCC_QGRAF_OPT_TOPOL
135136
#define GRCC_QGRAF_OPT_Size 10

sources/startup.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,20 +1205,34 @@ void StartVariables(void)
12051205
PutPreVar((UBYTE *)"keepright_",(UBYTE *)("0"),0,0);
12061206
PutPreVar((UBYTE *)"SYSTEMERROR_",(UBYTE *)("0"),0,0);
12071207
/*
1208-
Next are a few 'constants' for diagram generation
1208+
Next are the flags to control diagram generation filters
12091209
*/
1210-
PutPreVar((UBYTE *)"ONEPI_",(UBYTE *)("1"),0,0);
1211-
PutPreVar((UBYTE *)"WITHOUTINSERTIONS_",(UBYTE *)("2"),0,0);
1212-
PutPreVar((UBYTE *)"NOTADPOLES_",(UBYTE *)("4"),0,0);
1213-
PutPreVar((UBYTE *)"SYMMETRIZE_",(UBYTE *)("8"),0,0);
1214-
PutPreVar((UBYTE *)"TOPOLOGIESONLY_",(UBYTE *)("16"),0,0);
1215-
PutPreVar((UBYTE *)"NONODES_",(UBYTE *)("32"),0,0);
1216-
PutPreVar((UBYTE *)"WITHEDGES_",(UBYTE *)("64"),0,0);
1217-
/* Note that CHECKEXTERN is 128 */
1218-
PutPreVar((UBYTE *)"WITHBLOCKS_",(UBYTE *)("256"),0,0);
1219-
PutPreVar((UBYTE *)"WITHONEPISETS_",(UBYTE *)("512"),0,0);
1220-
PutPreVar((UBYTE *)"NOSNAILS_",(UBYTE *)("1024"),0,0);
1221-
PutPreVar((UBYTE *)"NOEXTSELF_",(UBYTE *)("2048"),0,0);
1210+
#define STR2(x) #x
1211+
#define STR(x) STR2(x)
1212+
PutPreVar((UBYTE *)"TOPOLOGIESONLY_",(UBYTE*)(STR(TOPOLOGIESONLY)),0,0);
1213+
PutPreVar((UBYTE *)"WITHOUTNODES_" ,(UBYTE*)(STR(WITHOUTNODES)) ,0,0);
1214+
PutPreVar((UBYTE *)"WITHEDGES_" ,(UBYTE*)(STR(WITHEDGES)) ,0,0);
1215+
PutPreVar((UBYTE *)"WITHBLOCKS_" ,(UBYTE*)(STR(WITHBLOCKS)) ,0,0);
1216+
PutPreVar((UBYTE *)"WITHONEPISETS_" ,(UBYTE*)(STR(WITHONEPISETS)) ,0,0);
1217+
PutPreVar((UBYTE *)"WITHSYMMETRIZE_",(UBYTE*)(STR(WITHSYMMETRIZE)),0,0);
1218+
PutPreVar((UBYTE *)"CHECKEXTERN_" ,(UBYTE*)(STR(CHECKEXTERN)) ,0,0);
1219+
PutPreVar((UBYTE *)"ONEPI_" ,(UBYTE*)(STR(ONEPARTI)) ,0,0);
1220+
PutPreVar((UBYTE *)"ONEPR_" ,(UBYTE*)(STR(ONEPARTR)) ,0,0);
1221+
PutPreVar((UBYTE *)"ONSHELL_" ,(UBYTE*)(STR(ONSHELL)) ,0,0);
1222+
PutPreVar((UBYTE *)"OFFSHELL_" ,(UBYTE*)(STR(OFFSHELL)) ,0,0);
1223+
PutPreVar((UBYTE *)"NOSIGMA_" ,(UBYTE*)(STR(NOSIGMA)) ,0,0);
1224+
PutPreVar((UBYTE *)"SIGMA_" ,(UBYTE*)(STR(SIGMA)) ,0,0);
1225+
PutPreVar((UBYTE *)"NOSNAIL_" ,(UBYTE*)(STR(NOSNAIL)) ,0,0);
1226+
PutPreVar((UBYTE *)"SNAIL_" ,(UBYTE*)(STR(SNAIL)) ,0,0);
1227+
PutPreVar((UBYTE *)"NOTADPOLE_" ,(UBYTE*)(STR(NOTADPOLE)) ,0,0);
1228+
PutPreVar((UBYTE *)"TADPOLE_" ,(UBYTE*)(STR(TADPOLE)) ,0,0);
1229+
PutPreVar((UBYTE *)"SIMPLE_" ,(UBYTE*)(STR(SIMPLE)) ,0,0);
1230+
PutPreVar((UBYTE *)"NOTSIMPLE_" ,(UBYTE*)(STR(NOTSIMPLE)) ,0,0);
1231+
PutPreVar((UBYTE *)"BIPART_" ,(UBYTE*)(STR(BIPART)) ,0,0);
1232+
PutPreVar((UBYTE *)"NONBIPART_" ,(UBYTE*)(STR(NONBIPART)) ,0,0);
1233+
PutPreVar((UBYTE *)"CYCLI_" ,(UBYTE*)(STR(CYCLI)) ,0,0);
1234+
PutPreVar((UBYTE *)"CYCLR_" ,(UBYTE*)(STR(CYCLR)) ,0,0);
1235+
PutPreVar((UBYTE *)"FLOOP_" ,(UBYTE*)(STR(FLOOP)) ,0,0);
12221236

12231237
{
12241238
char buf[41]; /* up to 128-bit */

0 commit comments

Comments
 (0)