FORM v5.0.0-35-g6318119
grcc.h
1#pragma once
2
3/* #[ License : */
4/*
5 * Copyright (C) 2023-2026 T. Kaneko
6 * When using this file you are requested to refer to the publication
7 * Comput.Phys.Commun. 92 (1995) 127-152
8 *
9 * This file is part of FORM.
10 *
11 * FORM is free software: you can redistribute it and/or modify it under the
12 * terms of the GNU General Public License as published by the Free Software
13 * Foundation, either version 3 of the License, or (at your option) any later
14 * version.
15 *
16 * FORM is distributed in the hope that it will be useful, but WITHOUT ANY
17 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with FORM. If not, see <http://www.gnu.org/licenses/>.
23 */
24/* #] License : */
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29#include <time.h>
30
31#define CHECK
32//==============================================================
33extern "C" {
34#include "grccparam.h"
35}
36
37//==============================================================
38// Name space of this library
39// See 'grccparam.h' for #define
40#ifdef GRCC_NAMESPACE
41namespace Grcc {
42#endif
43
44//==============================================================
45// Common types
46//
47#define True 1
48#define False 0
49typedef int Bool;
50
51//==============================================================
52// Big integer (may be replaced by suitable one)
53
54#define BigInt long
55#define ToBigInt(x) ((BigInt) (x))
56
57//==============================================================
58// Macro functions
59#define Real(x) ((double) (x))
60#define Abs(x) (((x) >= 0)? (x): (-x))
61#define Sign(x) (((x) >= 0)? (1): (-1))
62#define Max(x, y) ((x) > (y) ? (x) : (y))
63#define Min(x, y) ((x) < (y) ? (x) : (y))
64#define Second(t) ((double)(*(t)=(double)(clock()/((double)CLOCKS_PER_SEC))))
65#define isATExternal(x) ((x)==GRCC_AT_Initial||(x)==GRCC_AT_Final||(x)==GRCC_AT_External)
66
67//==============================================================
68// types and classes
69typedef int Edge2n[2]; // pair of nodes expressing an edge
70class Assign;
71class AStack;
72class EEdge;
73class EGraph;
74class ENode;
75class Interaction;
76class MGraph;
77class MNodeClass;
78class MCEdge;
79class MCOpi;
80class MCBridge;
81class MCBlock;
82class MConn;
83class Model;
84class MOrbits;
85class Options;
86class Output;
87class Particle;
88class PNodeClass;
89class Process;
90class SGroup;
91class SProcess;
92class DCGraph;
93
94//==============================================================
95// type of output functions
96typedef Bool OutEGB(EGraph *, void *);
97typedef void OutEG(EGraph *, void *);
98typedef void ErExit(const char *msg, void *);
99
100//==============================================================
101class Options {
102 public:
103
104 Model *model;
105 Process *proc;
106 SProcess *sproc;
107 Output *out; // for output
108 OutEGB *outmg; // call back function of mgraph
109 OutEGB *endmg; // call back function of end of mgraph
110 OutEG *outag; // call back function of agraph
111 void *argmg; // additional argument to outmg
112 void *argemg; // additional argument to endmg
113 void *argag; // additional argument to outag
114
115 //switches for graph generation
116 OptQGRef qgref[2*GRCC_QGRAF_OPT_Size]; // array of reference to QG-options
117 int values[GRCC_OPT_Size]; // array of options
118 int qgopt[GRCC_QGRAF_OPT_Size]; // array of QGRAF options
119
120 int nqgopt; // effective length of qgref
121
122 int DUMMYPADDING;
123
124 // measuring time
125 double time0;
126 double time1;
127
128 //------------------
129 Options(void);
130 ~Options(void);
131 void setDefaultValues(void);
132 void setOldDefaultValues(void);
133
134 void setValue(int ind, int val);
135 int getValue(int ind);
136
137 void setQGrafOpt(int *qgopt);
138
139 void print(void);
140
141 void setOutputF(Bool outgrf, const char *fname);
142 void setOutputP(Bool outgrp, const char *fname);
143 void printLevel(int l);
144
145 void printModel(void);
146 void setOutMG(OutEGB *omg, void *pt);
147 void setOutAG(OutEG *oag, void *pt);
148 void setEndMG(OutEGB *omg, void *pt);
149 void setErExit(ErExit *ere, void *pt);
150 const OptDef *getDef(void);
151 const OptDef *getOldDef(void);
152 const OptQGDef *getQGDef(void);
153
154 void begin(Model *mdl);
155 void end(void);
156 void beginProc(Process *prc);
157 void endProc(void);
158 void beginSubProc(SProcess *sprc);
159 void endSubProc(void);
160 void newMGraph(MGraph *mgr);
161 void newAGraph(EGraph *egr);
162 void outModel(void);
163};
164
165//==============================================================
166class Output {
167 public:
168
169 Options *opt;
170 Model *model;
171 Process *proc;
172 SProcess *sproc;
173 char *outgrf;
174 FILE *outgrfp;
175 char *outgrp;
176 FILE *outgrpp;
177 int procId;
178 Bool outproc;
179
180 Output(Options *optn);
181 ~Output(void);
182
183 void setOutgrf(const char *fname);
184 void setOutgrp(const char *fname);
185 Bool outBeginF(Model *mdl, Bool pr);
186 Bool outBeginP(Model *mdl, Bool pr);
187 void outEndF(void);
188 void outEndP(void);
189 void outProcBeginF(Process *prc);
190 void outProcBeginP(Process *prc);
191 void outProcBegin0(int next, int couple, int loop);
192 void outSProcBeginF(SProcess *sprc);
193 void outSProcBeginP(SProcess *sprc);
194 void outProcEndF(void);
195 void outProcEndP(void);
196 void outEGraphF(EGraph *egraph);
197 void outEGraphP(EGraph *egraph);
198 void outModelF(void);
199 void outModelP(void);
200
201};
202
203//==============================================================
204class Fraction {
205 public:
206 BigInt num, den;
207 double ratio;
208
209 Fraction() { num = 0; den = 1; };
210 Fraction(BigInt n, BigInt d);
211
212 void print(const char *msg);
213 void setValue(BigInt n, BigInt d);
214 void setValue(Fraction &f);
215 void add(BigInt n, BigInt d);
216 void add(Fraction f);
217 void sub(Fraction f);
218 BigInt gcd(BigInt n0, BigInt n1);
219 void normal(void);
220 Bool isEq(Fraction f);
221};
222
223//**************************************************************
224// Model
225//==============================================================
226//--------------------------------------------------------------
227class Particle {
228 public:
229 Model *mdl; // the model
230 char *name; // the name of the particle
231 char *aname; // the name of the anti-particle
232 int id; // id of this particle
233 int ptype; // the type of partice : GRCC_PT_Scalar, etc.
234 int neutral; // True if particle==anti-particle
235 int pcode; // Particle code
236 int acode; // Anti-particle code
237 int cmindeg; // min(leg of connectable interactions)
238 int cmaxdeg; // max(leg of connectable interactions)
239
240 int extonly; // can appear only as external particle
241
242 //-----------------------------
243 Particle(Model *modl, int pid, PInput *pinp);
244 ~Particle(void);
245
246 char *particleName(int p);
247 int particleCode(int p);
248 char *interactionName(int p);
249 char *aparticle(void);
250 void prParticle(void);
251 int isNeutral(void);
252 const char *typeName(void);
253 const char *typeGName(void);
254
255};
256
257//--------------------------------------------------------------
259 public:
260 Model *mdl; // the model
261 char *name; // the name of the interaction
262 int *plist; // the list of particle codes
263 int *clist; // the orders of coupling constants
264 int *slist; // the sorted list of particle codes
265
266 int id; // id of this interaction
267 int csum; // the total orders of coupling constants
268 int nlegs; // the number of legs
269 int loop; // the number of loops
270 int icode; // user defined interaction code
271
272 int nplist; // the list of particle codes
273 int nclist; // the orders of coupling constants
274 int nslist; // the sorted list of particle codes
275
276 //-----------------------------
277 Interaction(Model *modl, int iid, const char* nam, int icode, int *cpl, int nlgs, int *plst, int csm, int lp);
278 ~Interaction(void);
279
280 void prInteraction(void);
281};
282
283//--------------------------------------------------------------
284class Model {
285 public:
286 char *name; // the name of this model
287 char **cnlist; // the list of coupling constant names
288 int ncouple; // the number of coupling consants.
289
290 int nParticles; // the number of particles
291 Particle **particles; // the list of particles
292 int pdef; // the def. of partcls is ended
293
294 // list of particles and anti-p. without Undef.
295 int nallPart;
296 int allPart[GRCC_MAXMPARTICLES2];
297
298 // list of particles and anti-p. without ones of extloop=True
299 int nintPart;
300 int intPart[GRCC_MAXMPARTICLES2];
301
302 int nInteracts; // the number of interactions.
303 Interaction **interacts; // the list of interactions
304 int vdef; // the definition of interaction is ended
305
306 int maxnlegs; // maximum number of legs of an interaction
307 int maxcpl; // maximum number of coupling const.
308 int maxloop; // maximum number of loops inside an intr.
309
310 // classification of interactions
311 int *cplgcp; // coupling constants
312 int *cplglg; // degree
313 int *cplgnvl; // number of vertices
314 int **cplgvl; // list of vertices
315 int ncplgcp; // the number of classes
316
317 int defpart; // GRCC_DEFBYNAME or GRCC_DEFBYCODE
318
319 // methods
320 Model(MInput *minp);
321 ~Model(void);
322
323 void prModel(void);
324 void addParticle(PInput *pinp);
325 void addParticleEnd(void);
326 void addInteraction(IInput *iinp);
327 void addInteractionEnd(void);
328 int findParticleName(const char *name);
329 int findParticleCode(int pcd);
330 int findInteractionName(const char *name);
331 int findInteractionCode(int icd);
332 char *particleName(int p);
333 int particleCode(int p);
334 int normalParticle(int pt);
335 int antiParticle(int pt);
336 int *allParticles(int *len);
337 int findMClass(const int cpl, const int dgr);
338 void prParticleArray(int n, int *a, const char *msg);
339
340 static void printMInput(MInput *min);
341 static void printPInput(PInput *pin);
342 static void printIInput(IInput *iin);
343};
344
345//**************************************************************
346// Process
347//===============================================================
349 public:
350 SProcess *sproc;
351 int *deg; // The degree of each node
352 int *type; // The type of the class : GRCC_AT_xxx
353 int *particle; // The particle code of external node.
354 int *couple; // The orders of coupling constans
355 int *cmindeg; // min(deg of connectable vertex)
356 int *cmaxdeg; // max(deg of connectable vertex)
357 int *count; // The number of nodes in the class
358 int *cl2nd; // cl2nd[class] <= nd < cl2nd[class+1] = set of nodes
359 int *nd2cl; // nd2cl[node] = class
360 int *cl2mcl; // cl2mcl[class] = class defined in the model.
361 int nnodes;
362 int nclass;
363
364 PNodeClass(SProcess *sprc, int nnods, int nclss, NCInput *cls);
365 PNodeClass(SProcess *sprc, int nnods, int nclss, int *dgs, int *typ, int *ptcl, int *cpl, int *cnt, int *cmind, int *cmaxd);
366 ~PNodeClass(void);
367
368 void prPNodeClass(void);
369 void prElem(int e);
370};
371
372//===============================================================
373class SProcess {
374 // In sprocess the number of nodes and edges are fixed.
375 // A node is considered as
376 // (degree, total order of coupling constants),
377 // which pair of data defines a class of nodes.
378
379 public:
380 Model *model; // model
381 Process *proc; // mother process
382 Options *opt; // options
383 PNodeClass *pnclass; // list of classes (cpl and deg is determined)
384 AStack *astack;
385
386 MGraph *mgraph;
387 EGraph *egraph;
388 Assign *agraph;
389
390 int *cl2nd; // (code of nodes in the class[c])
391 // = [cl2nd[c], ..., cl2nd[c+1]-1]
392 int *nd2cl; // node nd is in the class pnclass[nd2cl[nd]]
393 int nclass; // the number of classes
394
395 int ninitl; // the number of initial particles
396 int nfinal; // the number of final particles
397 int nvert; // the number of vertices
398
399 int clist[GRCC_MAXNCPLG]; // coupling constans of the process
400 int id; // sprocess id
401 int loop; // the number of loops
402 int nNodes; // the number of nodes
403 int nEdges; // the number of edges
404 int nExtern; // the number of external particles
405 int ncouple; // the number of coupling constants
406 int tCouple; // the total coupling constants
407
408 int DUMMYPADDING;
409
410 BigInt mgrcount; // count generated mgraph
411 BigInt agrcount; // count generated agraph
412 BigInt extperm; // count generated agraph
413
414 // the results of the graph generation
415 BigInt nMGraphs; // the number of generated M-graphs
416 BigInt nMOPI; // the number of 1PI M-graphs
417 Fraction wMGraphs; // the weighted sum of M-graphs
418 Fraction wMOPI; // the weighted sum of 1PI M-graphs
419
420 BigInt nAGraphs; // the number of generated A-graphs
421 BigInt nAOPI; // the number of 1PI A-graphs
422 Fraction wAGraphs; // the weighted sum of A-graphs
423 Fraction wAOPI; // the weighted sum of 1PI A-graphs
424
425 // methods
426 SProcess(Model *mdl, Process *prc, Options *opts, int sid, int *clst, int ncls, NCInput *cls);
427 SProcess(Model *mdl, Process *prc, Options *opts, int sid, int *clst, int ncls, int *cdeg, int *ctyp, int *ptcl, int *cpl, int *cnum, int *cmind, int *cmaxd);
428
429 ~SProcess(void);
430
431 void prSProcess(void);
432 BigInt generate(void);
433 void assign(MGraph *mgr);
434
435 int toMNodeClass(int *ctyp, int *cldeg, int *clnum, int *cmind, int *cmaxd);
436 PNodeClass *match(MGraph *mgr);
437
438 void endMGraph(MGraph *mgr);
439 void endAGraph(EGraph *egr);
440
441 void resultMGraph(BigInt nmgraphs, Fraction mwsum, BigInt nmopi, Fraction mwopi);
442 void resultAGraph(BigInt nagraphs, Fraction awsum, BigInt naopi, Fraction awopi);
443
444};
445
446//===============================================================
447class Process {
448 public:
449 Model *model; // model used for this process
450 Options *opt; // options
451 BigInt mgrcount; // count generated mgraph
452 BigInt agrcount; // count generated agraph
453 int *initlPart; // list of ids of initial particles
454 int *finalPart; // list of ids of final particles
455
456 int id; // process id
457 int ninitl; // the number of initial particles
458 int nfinal; // the number of final particles
459 int ctotal; // the total number of coupling constants
460 int nExtern; // the number of external particles
461 int loop; // the number of external particles
462 int maxnlegs; // the maximum possible degree of node
463 int clist[GRCC_MAXNCPLG]; // coupling constans of the process
464
465 // table of sprocesses
466 int nSubproc; // the number of sprocesses
467 SProcess *sptbl[GRCC_MAXSUBPROCS]; // the table of sprocesses
468 SProcess *sproc; // the current sprocess
469
470 // stack for the assignment;
471 AStack *astack;
472
473 // the number of graphs
474 BigInt ngraphs;
475 BigInt nopi;
476 BigInt wgraphs;
477 BigInt wopi;
478
479 // the results of the graph generation
480 BigInt nMGraphs; // the number of generated M-graphs
481 BigInt nMOPI; // the number of 1PI M-graphs
482 Fraction wMGraphs; // the weighted sum of M-graphs
483 Fraction wMOPI; // the weighted sum of 1PI M-graphs
484
485 BigInt nAGraphs; // the number of generated A-graphs
486 BigInt nAOPI; // the number of 1PI A-graphs
487 Fraction wAGraphs; // the weighted sum of A-graphs
488 Fraction wAOPI; // the weighted sum of 1PI A-graphs
489
490 double sec;
491
492 Process(int pid, Model *model, Options *opt, int nin, int *initlPart, int nfin, int *finalPart, int *coupling);
493 Process(int pid, Model *model, Options *opt, FGInput *fgi);
494 ~Process(void);
495
496 void prProcess(void);
497 void outProcP(FILE *fp);
498 void prProcessP(const char *fname);
499 void mkSProcess(void);
500
501};
502
503//**************************************************************
504// classes for EGraph
505//==============================================================
506// Constants
507
508#define GRCC_ED_Undef 0
509#define GRCC_ED_Deleted 1
510#define GRCC_ED_Extern 2
511#define GRCC_ED_Back 3
512#define GRCC_ED_Bridge 4
513#define GRCC_ED_Inloop 5
514#define GRCC_ED_Size 6
515#define GRCC_ED_NAMES {"Undef", "Deleted", "Extern", "Back_Edge", "Bridge", "In_Loop"}
516
517#define GRCC_ND_Undef 0
518#define GRCC_ND_Deleted 1
519#define GRCC_ND_Initial 2
520#define GRCC_ND_Final 3
521#define GRCC_ND_CPoint 4
522#define GRCC_ND_VBlock 5
523#define GRCC_ND_Inblock 6
524#define GRCC_ND_Size 7
525#define GRCC_ND_NAMES {"Undef", "Deleted", "Init", "Final", "CPoint", "VBlock", "In_Block"}
526
527//--------------------------------------------------------------
528class ENode {
529 public:
530 EGraph *egraph;
531 int *edges; // list of edges
532 // the value is \pm [(edge index)+1]
533
534 int id; // id of the enode
535 int maxdeg; // maximum degree
536 int deg; // degree
537 int extloop; // loop inside this node or AT_Initial etc.
538 int ndtype; // type of the node
539 int intrct; // assigned interaction/particle (ext.)
540
541 // used in EGraph::biconn()
542 int *klow;
543 int visited;
544
545 int DUMMYPADDING;
546
547 //--------------------------------
548 // functions
549 ENode(void);
550 ENode(EGraph *egrph, int loops, int sdeg);
551 ~ENode(void);
552 void initAss(EGraph *egrph, int nid, int sdg);
553 void setId(EGraph *egrph, const int nid);
554 void copy(ENode *en);
555 void setExtern(int typ, int pt);
556 void setType(int typ);
557 void print(void);
558
559};
560
561//--------------------------------------------------------------
562class EEdge {
563 // momentum is printed like: ("%s%d", (enode.ext)?"Q":"p", enode.momn)
564 public:
565 EGraph *egraph; // egraph
566
567 int id; // id
568 int ext;
569 int ptcl; // assigned particle (agraph)
570 int deleted; // deleted edge, if true
571 int nodes[2]; // nodes of bothsides
572 int nlegs[2]; // nodes of both side (agraph)
573
574 // for biconn
575 int *emom; // external momenta
576 int *lmom; // loop momenta
577 int *extMom; // set of external momenta.
578
579 // momentum obtain in searchME
580 ULong momset; // set of momenta in bit string (leaf --> root)
581 int momdir; // direction (leg=0 --> leg=1)
582
583 Bool cut;
584 int visited;
585 int conid; // connected component
586 int edtype; // type
587 int opicomp; // id of 1PI component
588 int dir; // direction of momentum
589
590 int DUMMYPADDING;
591
592 //--------------------------------
593 // functions
594 EEdge(void);
595 EEdge(EGraph *egrph, int nedges, int nloops);
596 ~EEdge(void);
597 void copy(EEdge *ee);
598 void setId(EGraph *egrph, const int eid);
599 void print(void);
600
601 void setType(int typ);
602 void setLMom(int k, int dir);
603 void setEMom(int nedges, int *extn, int dir);
604};
605
606//--------------------------------------------------------------
607// type of fermion lines
608
609typedef enum {FL_Open, FL_Closed} FLType;
610
611//--------------------------------------------------------------
612class EFLine {
613 public:
614 int elist[GRCC_MAXNODES]; // list of (\pm [(edge index)+1])
615 FLType ftype;
616 int fkind;
617 int nlist;
618
619 EFLine(void);
620 void print(const char *msg);
621};
622
623//--------------------------------------------------------------
624class EGraph {
625 public:
626 Options *opt; // table of options
627 Model *model;
628 Process *proc;
629 SProcess *sproc;
630 MGraph *mgraph;
631 MConn *econn;
632
633 ENode **nodes;
634 EEdge **edges; // edges[nEdges+1]: index starts from 1
635
636 BigInt mId; // id of mgraph
637 BigInt aId; // id of agraph in the same mgraph
638 BigInt sId; // sequential no. of agraph
639 BigInt gSubId; // ???
640 Bool assigned; // mgraph (False) or agraph (True)
641
642 int fsign;
643 BigInt nsym, esym; // symmetry factor with symm. ext.
644 BigInt nsym1; // symmetry factor without symm. ext.
645 BigInt extperm; // the order of group of symm. ext.
646 BigInt multp; // multiplicity of graph in symm. ext.
647
648 int pId;
649
650 int sNodes; // memory size
651 int sEdges; // memory size
652 int sMaxdeg; // memory size
653 int sLoops; // memory size
654
655 int nNodes;
656 int nEdges;
657 int nExtern;
658 int maxdeg; // maximum value of degree of nodes
659 int nLoops;
660 int totalc; // total order of coupling constants
661
662 // biconnect
663 int nopicomp;
664 int opi2plp;
665 int nopi2p;
666 int nadj2ptv; // the no. of edges connecting 2point vertices
667
668 int DUMMYPADDING;
669
670 int *bidef;
671 int *bilow;
672 int *extMom;
673 int bconn;
674 int bicount;
675 int loopm;
676 int opiCount;
677
678 // Fermion lines
679 EFLine *flines[GRCC_MAXFLINES];
680 int nFlines;
681
682 int DUMMYPADDING1;
683
684 //--------------------------
685 // functions
686 EGraph(int nnodes, int nedges, int mxdeg);
687 ~EGraph(void);
688
689 void copy(EGraph *eg);
690 void print(void);
691 void printPy(FILE *fp, long mId);
692 void fromDGraph(DGraph *dg);
693 void fromMGraph(MGraph *mgraph);
694
695 Bool optQGrafM(Options *opt);
696 Bool optQGrafA(Options *opt);
697 Bool isOptE(void);
698
699 ENode *setExtern(int n0, int pt, int ndtp);
700 Bool isExternal(int nd) { return (nodes[nd]->extloop < 0); };
701 Bool isFermion(int nd);
702
703 void setExtLoop(int nd, int val);
704 void endSetExtLoop(void);
705
706 int connComp(void);
707 int connVisit(int nd, int ncc);
708
709 void biconnE(void);
710 void biinitE(void);
711 void bisearchE(int nd, int *extlst, int *intlst, int *opiext, int *opiloop);
712
713 int findRoot(void);
714 int dirEdge(int n, int e);
715 void extMomConsv(void);
716 int cmpMom(int *lm0, int *em0, int *lm1, int *em1);
717 int groupLMom(int *grp, int *ed2gr);
718
719 void chkMomConsv(void);
720
721 void prFLines(void);
722 void getFLines(void);
723 int fltrace(int fk, int nd0, int *fl);
724 void addFLine(const FLType ft, int fk, int nfl, int *fl);
725
726 int legParticle(int ed, int lg);
727};
728
729//**************************************************************
730// Symmetry group of graphs
731//===============================================================
732class SGroup {
733 public:
734 BigInt size; // # of allocated elements
735 BigInt nelem; // # of saved elements
736 int **elem; // saved elements
737 int nnodes; // # of nodes.
738 int neclass; // # of classes
739 int eclass[GRCC_MAXNODES]; // table of classes
740 int cgen; // counter for the generation
741 int csav; // counter for the saved elements
742 int permg[GRCC_MAXNODES]; // resulting permutation
743 int perms[GRCC_MAXNODES]; // curr. elem of saved ones.
744
745 int pgr[GRCC_MAXNODES]; // work
746 int pgq[GRCC_MAXNODES]; // work
747 int psr[GRCC_MAXNODES]; // work
748 int psq[GRCC_MAXNODES]; // work
749
750 //-------------------------------
751 // functions
752
753 SGroup(void);
754 ~SGroup(void);
755
756 void print(void);
757 void newGroup(int nelm, int nclss, int *clss);
758 void clearGroup(void);
759 void delGroup(void);
760 int *genNext(void);
761 void addGroup(int *p);
762 BigInt nElem(void);
763 int *nextElem(void);
764};
765
766//**************************************************************
767// MGraph
768//==============================================================
769// class of nodes for MGraph
770
771class MNode {
772 public:
773 int id; // node id
774 int deg; // degree(node) = the number of legs
775 int clss; // initial class number in which the node belongs
776 int extloop;
777 int cmindeg;
778 int cmaxdeg;
779
780 int freelg; // the number of free legs
781 int visited;
782
783 MNode(int id, int clss, NCInput *mgi);
784 MNode(int id, int deg, int extloop, int clss, int cmind, int cmaxd);
785};
786
787//===============================================================
788// class of scalar graph expressed by matrix form
789//
790// Input : the classified set of nodes.
791// Output : control passed to 'EGraph(self)'
792
793class MGraph {
794
795 public:
796
797 // initial conditions
798 Options *opt; // options
799
800 // symmetry group
801 SGroup *group; // symmetry group
802 MOrbits *orbits; // Orbits of nodes with respect to symmetry group
803
804 MNode **nodes; // table of MNode object
805 BigInt mId; // process/sprocess ID
806 int *clist; // list of initial classes
807 int pId; // process/sprocess ID
808 int nNodes; // the number of nodes
809 int nEdges; // the number of edges
810 int nLoops; // the number of loops
811 int nExtern; // the number of external nodes
812 int nClasses; // the number of initial classes
813 int mindeg; // minimum value of degree of nodes
814 int maxdeg; // maximum value of degree of nodes
815
816 // the current graph
817 int **adjMat; // adjacency matrix
818 MNodeClass *curcl; // the current 'MNodeClass' object
819 EGraph *egraph;
820 BigInt nsym; // symmetry factor from nodes
821 BigInt esym; // symmetry factor from edges
822
823 // generated set of graphs
824 BigInt cDiag; // the total number of generated graphs
825 BigInt c1PI; // the total number of 1PI graphs
826 BigInt cNoTadpole; // the total number of graphs without tadpoles
827 BigInt cNoTadBlock; // the total number of graphs without tad-blocks
828 BigInt c1PINoTadBlock; // the total number of 1PI graphs without tad-blocks
829 Fraction wscon; // weighted sum of graphs
830 Fraction wsopi; // weighted sum of 1PI graphs
831
832 // measures of efficiency
833 BigInt ngen; // generated graph before check
834 BigInt ngconn; // generated connected graph before check
835
836 BigInt nCallRefine;
837 BigInt discardRefine;
838 BigInt discardDisc;
839 BigInt discardIso;
840
841 // for options
842 Bool opi;
843 Bool opiloop;
844 Bool extself;
845 Bool selfloop;
846 Bool multiedge;
847 Bool tadpole;
848 Bool tadblock;
849 Bool block;
850 Bool bipart;
851
852 int DUMMYPADDING1;
853
854 // table of n edge-connected components
855 MConn *mconn;
856
857 // work space for isomorphism
858 int **modmat; // permutated adjacency matrix
859
860 // work space for biconnected component
861 int *bidef;
862 int *bilow;
863 int *bicol;
864 int bicount;
865
866 int DUMMYPADDING2;
867
868 //----------
869 // functions
870 MGraph(int pid, int ncl, NCInput *mgi, Options *opt);
871 MGraph(int pid, int ncl, int *cldeg, int *clnum, int *clexl, int *cmind, int *cmaxd, Options *opt);
872 ~MGraph(void);
873
874 void init(void);
875 BigInt generate(void);
876 Bool isExternal(int nd) { return (nodes[nd]->extloop < 0); };
877 void printAdjMat(MNodeClass *cl);
878 void print(void);
879 void printPy(FILE *fp, long mId);
880
881 Bool isConnected(void);
882 Bool visit(int nd);
883 Bool isIsomorphic(MNodeClass *cl);
884 void permMat(int size, int *perm, int **mat0, int **mat1);
885 int compMat(int size, int **mat0, int **mat1);
886 MNodeClass *refineClass(MNodeClass *cl);
887 void bisearchME(int nd, int pd, int ned, int col, MCOpi *mopi, MCBlock *mblk, ULong *momset, int *next, int *nart);
888 void biconnME(void);
889
890 Bool isOptM(void);
891 void connectClass(MNodeClass *cl);
892 void connectNode(int sc, int ss, MNodeClass *cl);
893 void connectLeg(int sc, int sn, int tc, int ts, MNodeClass *cl);
894 void newGraph(MNodeClass *cl);
895};
896
897//===============================================================
898// class of node-classes for MGraph
899//--------------------------------------------------------------
901 public:
902 int clmat[GRCC_MAXNODES][GRCC_MAXNODES]; // matrix used for classification
903 int clist[GRCC_MAXNODES]; // the number of nodes in each class
904 int ndcl[GRCC_MAXNODES]; // node --> class
905 int flist[GRCC_MAXNODES+1]; // the first node in each class
906 int clord[GRCC_MAXNODES]; // ordering of classes
907 int cmindeg[GRCC_MAXNODES]; // min(deg of connectable node)
908 int cmaxdeg[GRCC_MAXNODES]; // max(deg of connectable node)
909 int nNodes; // the number of nodes
910 int nClasses; // the number of classes
911 int maxdeg; // maximal value of degree(node)
912
913 int flg0;
914 int flg1;
915 int flg2;
916
917 MNodeClass(int nnodes, int nclasses);
918 ~MNodeClass(void);
919
920 void init(int *cl, int mxdeg, int **adjmat);
921 void copy(MNodeClass* mnc);
922 int clCmp(int nd0, int nd1, int cn);
923 void printMat(void);
924
925 void mkFlist(void);
926 void mkNdCl(void);
927 void mkClMat(int **adjmat);
928 void incMat(int nd, int td, int val);
929 int cmpMNCArray(int *a0, int *a1, int ma);
930 void reorder(MGraph *mg);
931};
932
933//===============================================================
934// class of an edge
935//--------------------------------------------------------------
936class MCEdge {
937 public:
938 Edge2n nodes; // nodes at the both size of the edge (leaf --> root)
939 ULong momset; // set of momenta in bit string
940 int momdir; // set of momenta in bit string
941
942 int DUMMYPADDING;
943
944 MCEdge(void);
945 ~MCEdge(void);
946};
947
948//===============================================================
949// class of 1PI component
950//--------------------------------------------------------------
951class MCOpi {
952 public:
953 int *nodes; // array of nodes in
954 int nnodes; // # nodes in the 1PI component
955 int nlegs; // # leg (bridges) of the 1PI component
956 int next; // # external particles of the 1PI comp.
957 int nedges; // # edges in the 1PI comp.
958 int loop; // # loops in the 1PI comp.
959 int ctloop; // # loops in the counter terms in the OP comp.
960 int mom0lg; // # leg (bridges) with 0 momentum
961
962 int DUMMYPADDING;
963
964 MCOpi(void);
965 ~MCOpi(void);
966
967 void init(void);
968};
969
970//===============================================================
971// class of bridge
972//--------------------------------------------------------------
973class MCBridge {
974 public:
975 Edge2n nodes; // nodes at the both size of the bridge
976 int next; // # momenta of ext. particles flowing on the bridge
977
978 MCBridge(void);
979 ~MCBridge(void);
980};
981
982//===============================================================
983// class of block
984//--------------------------------------------------------------
985class MCBlock {
986 public:
987 Edge2n *edges; // array of edges in the block
988 int nmedges; // # edges in the block
989 int nartps; // # articulation points of the block
990 int loop; // # loop in the block
991
992 int DUMMYPADDING;
993
994 MCBlock(void);
995 ~MCBlock(void);
996 void init(void);
997};
998
999//===============================================================
1000// class of table of MConn
1001//--------------------------------------------------------------
1002class MConn {
1003 public:
1004 // 2-edge connected components
1005 MCEdge *cedges; // table of edges
1006 MCOpi *opics; // table of n-edge-connected components
1007 MCBridge *bridges; // table of bridges
1008 MCBlock *blocks; // table of blocks
1009 int *articuls; // buffer for nodes for articulation points
1010
1011 int *opisp; // buffer for nodes in 1PI components
1012 int *opistk; // stack of nodes for 1PI components.
1013 Edge2n *blksp; // buffer for edges in blocks
1014 Edge2n *blkstk; // stack of edges for blocks
1015 int snodes; // # nodes
1016 int sedges; // # edges
1017
1018 // opi components (edge-connected)
1019 int nopic; // # 1PI components (n1PIComps)
1020 int nlpopic; // # looped 1PI components (n1PIComps)
1021 int nctopic; // # 1PI components of one counter term.
1022
1023 // edges
1024 int nbacked; // # back edges
1025
1026 // bridges
1027 int nbridges; // # bridges
1028 int ne0bridges; // # bridges whose next=0
1029 int ne1bridges; // # bridges whose next=1
1030 int nselfloops;
1031 int nmultiedges;
1032
1033 // blocks (node-connected)
1034 int nblocks; // # blocks
1035 int na1blocks; // # bridges whose next=0
1036 int narticuls; // # articulation points
1037 int neblocks; // # effective looped blocks
1038
1039 // indices to work spaces
1040 int nopisp; // # used in opisp
1041 int opistkptr; // # stack pointer of opistk
1042 int nblksp; // # used in blksp
1043 int blkstkptr; // # stack pointer of tlkstk
1044
1045 int DUMMYPADDING;
1046
1047 MConn(int nnod, int nedg);
1048 ~MConn(void);
1049
1050 void init(void);
1051 void initCEdges(MGraph *);
1052 void pushNode(int nd);
1053 void pushEdge(int n0, int n1);
1054 void addCEdge(int n0, int n1, ULong momset);
1055 void addOPIc(MCOpi *mopi, int stp);
1056 void addBridge(int n0, int n1, int nex, int nextot);
1057 void addArtic(int nd, int mul);
1058 void addBlock(MCBlock *eblk, int stp);
1059 void addBlockSelf(int nd, int mul);
1060 void print(void);
1061 void prEdges(void);
1062};
1063
1064//===============================================================
1065// class of orbits of nodes
1066//--------------------------------------------------------------
1067class MOrbits {
1068 // Usage
1069 // 1. node ==> orbit
1070 // (class) = nd2or[(node)]
1071 //
1072 // 2. class ==> nodes
1073 // for (c = 0; c < nClass; c++) {
1074 // for (j = flist[c]; j < flist[c+1]; j++) {
1075 // (node) = or2nd[c];
1076 // }
1077 // }
1078 public:
1079 int nOrbits;
1080 int nNodes;
1081 int nd2or[GRCC_MAXNODES];
1082 int or2nd[GRCC_MAXNODES];
1083 int flist[GRCC_MAXNODES+1];
1084
1085 MOrbits(void);
1086 ~MOrbits(void);
1087
1088 void print(void);
1089
1090 // construction of orbits
1091 void initPerm(int nnodes);
1092 void fromPerm(int *perm);
1093 void toOrbits(void);
1094};
1095
1096//**************************************************************
1097// Particle assignment
1098//===============================================================
1099typedef int CheckPt[2];
1100
1101typedef enum {
1102 AS_UnAssLegs, AS_Assigned, AS_Assigned0, AS_AssExt, AS_Impossible
1103} NCandSt;
1104
1105//===============================================================
1106class NCand {
1107 // List of candidates for the assignment of interactions to a vertex
1108
1109 public:
1110 int deg; // degree of the node
1111 NCandSt st; // status
1112 int nilist; // length of the list
1113 int ilist[GRCC_MAXMINTERACT]; // list of candidates
1114
1115 //========
1116 NCand(const NCandSt sta, const int dega, const int nilst, int *ilst);
1117 ~NCand(void);
1118
1119 // print
1120 void prNCand(const char* msg);
1121};
1122
1123//===============================================================
1124class ECand {
1125 // List of candidates for the assignment of particles to an edge
1126
1127 public:
1128 Bool det; // determined or not
1129 int nplist; // size of the list of candidates
1130 int plist[GRCC_MAXMPARTICLES2]; // list of candidates
1131
1132 ECand(int dt, int nplist, int *plst);
1133 ~ECand(void);
1134
1135 // print
1136 void prECand(const char *msg);
1137};
1138
1139//===============================================================
1140class ANode {
1141 // Connection information of a node to others
1142 //
1143 // (this node) -- (adjacent edge) -- (next node)
1144 // (n0, j) e n1
1145 //
1146 // e = (aedges[j], aelegs[j])
1147 // n1 = anodes[j]
1148
1149 public:
1150 int deg; // degree of the node
1151 int nlegs; // the number of legs already assigned
1152 int *anodes; // anodes[j] = (next node of leg j)
1153 int *aedges; // aedges[j] = (next edge of leg j)
1154 int *aelegs; // aelegs[j] = (leg of the next edge)
1155 NCand *cand; // candidate list
1156
1157 ANode(int dg);
1158 ~ANode(void);
1159
1160 int newleg(void); // get a new leg
1161};
1162
1163//===============================================================
1164class AEdge {
1165// Connection information of an edge
1166// (self) ==> nodes [(nodes[0], nlegs[0]), (nodes[1], nlegs[1])]
1167// particle 'ptcl' flows from leg=0 to 1.
1168
1169 public:
1170
1171 ECand *cand; // candidate
1172 int nodes[2]; // nodes of both sides of the edge
1173 int nlegs[2]; // nodes of both sides of the edge
1174 int ptcl; // particle defined in the model
1175
1176 int DUMMYPADDING;
1177
1178 AEdge(int n0, int l0, int n1, int l1);
1179 ~AEdge(void);
1180};
1181
1182//===============================================================
1183class Assign {
1184// Class for particle/interaction assignment.
1185
1186 public:
1187
1188 EGraph *egraph; // EGraph object
1189 MGraph *mgraph; // MGraph object
1190 SProcess *sproc; // Sub-process object
1191 Process *proc; // Process object
1192 Model *model; // Model object
1193 Options *opt; // Option object
1194 AStack *astack; // Stack for saving candidates
1195 PNodeClass *pnclass; // class of nodes
1196 MOrbits *orbits; // orbits of nodes by symmetry group
1197
1198 int nNodes; // the number of nodes
1199 int nEdges; // the number of edges
1200 int nExtern; // the number of external particles.
1201 int nETotal; // the total number of edges
1202
1203 BigInt nAGraphs; // the number of assigned graphs
1204 Fraction wAGraphs; // the weighted sum of graphs
1205 BigInt nAOPI; // the number of assigned 1PI
1206 Fraction wAOPI; // the weighted sum of 1PI
1207
1208 ANode **nodes; // table of nodes
1209 AEdge **edges; // table of edges
1210
1211 CheckPt checkpoint0; // save stack pointers
1212
1213 int cplleft[GRCC_MAXNCPLG]; // coupling constants left
1214
1215 //===========================================
1216 Assign(SProcess *sprc, MGraph *mgr, PNodeClass *pnc);
1217 ~Assign(void);
1218
1219 //===========================================
1220 // print lists of candidates
1221 void prCand(const char *msg);
1222
1223 // check
1224 void checkAG(const char *msg);
1225
1226 //===========================================
1227 // control of assignment
1228
1229 // entry point of assignment
1230 Bool assignAllVertices(void);
1231
1232 // select a source node for assignment
1233 Bool selectVertex(void);
1234 Bool selectVertexSimp(int lastv);
1235
1236 // select a source leg of the node for assignment
1237 Bool selectLeg(int v, int lastlg);
1238
1239 // assign a vertex a interaction
1240 Bool assignVertex(int v);
1241
1242 // assignment procedure is finished. Needs check.
1243 Bool allAssigned(void);
1244
1245 //===========================================
1246 // Input and output
1247
1248 // Input from mgraph
1249 Bool fromMGraph(void);
1250
1251 // add an edge
1252 void addEdge(int n0, int n1, int nplist, int *plist);
1253
1254 // connect nodes and edges.
1255 void connect(int n0, int l0, int eg, int el, int n1, int l1);
1256
1257 // Output to egraph
1258 Bool fillEGraph(int aid, BigInt nsym, BigInt esym, BigInt nsym1);
1259
1260 // reorder legs in accordance with the interaction definition
1261 int *reordLeg(int n, int *reord, int *plist, int *used);
1262
1263 //===========================================
1264 // direction of particle on an edge and at (node, leg)
1265
1266 // convert particle code
1267 // at node-leg ('n', 'ln') <==> edge at ('n', 'ln')
1268 int getLegParticle(int n, int ln);
1269
1270 // convert particle 'pt' on the edge to ('n', 'ln')
1271 int legEdgeParticle(int n, int ln, int pt);
1272
1273 // convert candidate list at ('v', 'lg') into in-coming direction
1274 int legPart(int v, int lg, int nplst, int *plst, int *rlist, const int size);
1275
1276 // convert candidate list at ('v', 'lg') into in-coming direction
1277 int candPart(int v, int ln, int *plist, const int size);
1278
1279 //===========================================
1280 // assignment
1281
1282 // find a vertex to be assigned
1283 int selUnAssVertex(void);
1284 int selUnAssVertexSimp(int lastv);
1285
1286 // find a leg of the vertex to be assigned
1287 int selUnAssLeg(int v, int lastlg);
1288
1289 // assign the interaction 'ia' to the vertex 'v'.
1290 NCandSt assignIVertex(int v, int ia);
1291
1292 // assign particle 'pt' the the leg 'ln' of the node 'n'.
1293 Bool assignPLeg(int n, int ln, int pt);
1294 Bool isOrdPLeg(int n, int ln, int pt);
1295 Bool detEdge(int e);
1296
1297 //===========================================
1298 // canndidates
1299
1300 // construct lists of assigned / unassigned particles at a node
1301 Bool candPartClassify(int v, int *npdass, int *pdass, int *npuass, int *puass, const int size);
1302
1303 // update candidate list for a vertex 'v'.
1304 Bool updateCandNode(int v);
1305
1306 //===========================================
1307 // filter
1308
1309 Bool checkOrderCpl(void);
1310 Bool isOrdLegs(void);
1311 Bool isIsomorphic(MNodeClass *cl, BigInt *nsym, BigInt *esym, BigInt *nsym1);
1312 int cmpPermGraph(int *p, MNodeClass *cl);
1313 int cmpNodes(int nd0, int nd1, MNodeClass *cn);
1314 BigInt edgeSym(void);
1315
1316 void saveCouple(int *sav);
1317 void restoreCouple(int *sav);
1318 Bool subCouple(int *cpl);
1319
1320#ifdef CHECK
1321 //===========================================
1322 // check
1323 Bool checkCand(const char *msg);
1324
1325 void checkNode(int n, const char *msg);
1326#endif
1327};
1328
1329//**************************************************************
1330// Stack of candidate lists
1331//===============================================================
1332class NStack {
1333// Stack for backtracking method for a node.
1334
1335 public:
1336 int noden;
1337 int deg;
1338 NCandSt st;
1339 int nilist;
1340 int ilist[GRCC_MAXMINTERACT];
1341
1342 NStack() { };
1343 ~NStack() { };
1344
1345 void print(const char *msg);
1346
1347};
1348
1349//===============================================================
1350class EStack {
1351// Stack for backtracking method for an edge.
1352
1353 public:
1354 int edgen;
1355 int det;
1356 int nplist;
1357 int plist[GRCC_MAXMPARTICLES2];
1358
1359 EStack() { };
1360 ~EStack() { };
1361
1362 void print(const char *msg);
1363};
1364
1365
1366//===============================================================
1367class AStack {
1368// Stack for backtracking method for an edge.
1369
1370 public:
1371 Assign *agraph;
1372
1373 NStack **nStack; // stack for nodes
1374 int nStackP; // stack pointer for nodes
1375 int nSize; // stack size
1376
1377 EStack **eStack; // stack for edges
1378 int eStackP; // stack pointer for edges
1379 int eSize; // stack size
1380
1381 AStack(int nSize, int eSize);
1382 ~AStack(void);
1383
1384 void setAGraph(Assign *ag);
1385
1386 void checkPoint(CheckPt sav);
1387 void restore(CheckPt sav);
1388 void restoreMsg(CheckPt sav, const char *msg);
1389 void prStack(void);
1390
1391 void pushNode(int n);
1392 void pushEdge(int e);
1393
1394 private:
1395 void restoreNode(int spr);
1396 void restoreEdge(int spr);
1397};
1398
1399//==============================================================
1400// end of namespace Grcc
1401#ifdef GRCC_NAMESPACE
1402}
1403#endif
Definition grcc.h:1164
Definition grcc.h:1140
Definition grcc.h:1124
Definition grcc.h:562
Definition grcc.h:612
Definition grcc.h:624
Definition grcc.h:528
Definition grcc.h:936
Definition grcc.h:951
Definition grcc.h:1002
Definition grcc.h:793
Definition grcc.h:771
Definition grcc.h:284
Definition grcc.h:1106
Definition grcc.h:166
Definition grcc.h:732