My Project
Loading...
Searching...
No Matches
Functions | Variables
bbfan.cc File Reference
#include "kernel/mod2.h"
#include "misc/intvec.h"
#include "coeffs/coeffs.h"
#include "coeffs/bigintmat.h"
#include "Singular/ipid.h"
#include "Singular/ipshell.h"
#include "Singular/blackbox.h"
#include "Singular/links/ssiLink.h"
#include "callgfanlib_conversion.h"
#include "bbfan.h"
#include "gfan.h"

Go to the source code of this file.

Functions

void * bbfan_Init (blackbox *)
 
void bbfan_destroy (blackbox *, void *d)
 
char * bbfan_String (blackbox *, void *d)
 
void * bbfan_Copy (blackbox *, void *d)
 
BOOLEAN bbfan_Assign (leftv l, leftv r)
 
static gfan::IntMatrix permutationIntMatrix (const bigintmat *iv)
 
static BOOLEAN jjFANEMPTY_I (leftv res, leftv v)
 
static BOOLEAN jjFANEMPTY_IM (leftv res, leftv v)
 
BOOLEAN emptyFan (leftv res, leftv args)
 
static BOOLEAN jjFANFULL_I (leftv res, leftv v)
 
static BOOLEAN jjFANFULL_IM (leftv res, leftv v)
 
BOOLEAN fullFan (leftv res, leftv args)
 
int getAmbientDimension (gfan::ZFan *zf)
 
int getCodimension (gfan::ZFan *zf)
 
int getDimension (gfan::ZFan *zf)
 
int getLinealityDimension (gfan::ZFan *zf)
 
BOOLEAN numberOfConesOfDimension (leftv res, leftv args)
 
BOOLEAN ncones (leftv res, leftv args)
 
BOOLEAN nmaxcones (leftv res, leftv args)
 
bool isCompatible (const gfan::ZFan *zf, const gfan::ZCone *zc)
 
BOOLEAN isCompatible (leftv res, leftv args)
 
BOOLEAN insertCone (leftv res, leftv args)
 
bool containsInCollection (gfan::ZFan *zf, gfan::ZCone *zc)
 
BOOLEAN containsInCollection (leftv res, leftv args)
 
BOOLEAN removeCone (leftv res, leftv args)
 
BOOLEAN getCone (leftv res, leftv args)
 
BOOLEAN getCones (leftv res, leftv args)
 
int isSimplicial (gfan::ZFan *zf)
 
BOOLEAN isPure (leftv res, leftv args)
 
BOOLEAN fVector (leftv res, leftv args)
 
gfan::ZMatrix rays (const gfan::ZFan *const zf)
 
int numberOfConesWithVector (gfan::ZFan *zf, gfan::ZVector *v)
 
BOOLEAN numberOfConesWithVector (leftv res, leftv args)
 
BOOLEAN fanFromString (leftv res, leftv args)
 
BOOLEAN fanViaCones (leftv res, leftv args)
 
gfan::ZFan commonRefinement (gfan::ZFan zf, gfan::ZFan zg)
 
BOOLEAN commonRefinement (leftv res, leftv args)
 
BOOLEAN bbfan_serialize (blackbox *b, void *d, si_link f)
 
BOOLEAN bbfan_deserialize (blackbox **b, void **d, si_link f)
 
void bbfan_setup (SModulFunctions *p)
 

Variables

VAR int fanID
 

Function Documentation

◆ bbfan_Assign()

BOOLEAN bbfan_Assign ( leftv  l,
leftv  r 
)

Definition at line 71 of file bbfan.cc.

72{
73 gfan::ZFan* newZf;
74 if (r==NULL)
75 {
76 if (l->Data()!=NULL)
77 {
78 gfan::ZFan* zd = (gfan::ZFan*) l->Data();
79 delete zd;
80 }
81 newZf = new gfan::ZFan(0);
82 }
83 else if (r->Typ()==l->Typ())
84 {
85 if (l->Data()!=NULL)
86 {
87 gfan::ZFan* zd = (gfan::ZFan*) l->Data();
88 delete zd;
89 }
90 newZf = (gfan::ZFan*) r->CopyD();
91 }
92 else if (r->Typ()==INT_CMD)
93 {
94 int ambientDim = (int) (long) r->Data();
95 if (ambientDim < 0)
96 {
97 Werror("expected an int >= 0, but got %d", ambientDim);
98 return TRUE;
99 }
100 if (l->Data()!=NULL)
101 {
102 gfan::ZFan* zd = (gfan::ZFan*) l->Data();
103 delete zd;
104 }
105 newZf = new gfan::ZFan(ambientDim);
106 }
107 else
108 {
109 Werror("assign Type(%d) = Type(%d) not implemented",l->Typ(),r->Typ());
110 return TRUE;
111 }
112
113 if (l->rtyp==IDHDL)
114 {
115 IDDATA((idhdl)l->data) = (char*) newZf;
116 }
117 else
118 {
119 l->data = (void*) newZf;
120 }
121 return FALSE;
122}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int l
Definition: cfEzgcd.cc:100
Definition: idrec.h:35
void * CopyD(int t)
Definition: subexpr.cc:710
int Typ()
Definition: subexpr.cc:1019
void * Data()
Definition: subexpr.cc:1162
#define IDDATA(a)
Definition: ipid.h:126
#define NULL
Definition: omList.c:12
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define IDHDL
Definition: tok.h:31
@ INT_CMD
Definition: tok.h:96

◆ bbfan_Copy()

void * bbfan_Copy ( blackbox *  ,
void *  d 
)

Definition at line 64 of file bbfan.cc.

65{
66 gfan::ZFan* zf = (gfan::ZFan*)d;
67 gfan::ZFan* newZf = new gfan::ZFan(*zf);
68 return newZf;
69}

◆ bbfan_deserialize()

BOOLEAN bbfan_deserialize ( blackbox **  b,
void **  d,
si_link  f 
)

Definition at line 1063 of file bbfan.cc.

1064{
1065 ssiInfo *dd = (ssiInfo *)f->data;
1066
1067 int l = s_readint(dd->f_read);
1068 char* buf = (char*) omAlloc0(l+1);
1069 (void) s_getc(dd->f_read); // skip whitespace
1070 (void) s_readbytes(buf,l,dd->f_read);
1071 buf[l]='\0';
1072
1073 std::istringstream fanInString(std::string(buf,l));
1074 gfan::ZFan* zf = new gfan::ZFan(fanInString);
1075 *d=zf;
1076
1077 omFree(buf);
1078 return FALSE;
1079}
FILE * f
Definition: checklibs.c:9
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int s_getc(s_buff F)
Definition: s_buff.cc:58
int s_readint(s_buff F)
Definition: s_buff.cc:112
int s_readbytes(char *buff, int len, s_buff F)
Definition: s_buff.cc:168
s_buff f_read
Definition: s_buff.h:22
Definition: s_buff.h:21
int status int void * buf
Definition: si_signals.h:59

◆ bbfan_destroy()

void bbfan_destroy ( blackbox *  ,
void *  d 
)

Definition at line 26 of file bbfan.cc.

27{
28 if (d!=NULL)
29 {
30 gfan::ZFan* zf = (gfan::ZFan*) d;
31 delete zf;
32 }
33}

◆ bbfan_Init()

void * bbfan_Init ( blackbox *  )

Definition at line 21 of file bbfan.cc.

22{
23 return (void*) new gfan::ZFan(0);
24}

◆ bbfan_serialize()

BOOLEAN bbfan_serialize ( blackbox *  b,
void *  d,
si_link  f 
)

Definition at line 1044 of file bbfan.cc.

1045{
1046 ssiInfo *dd = (ssiInfo *)f->data;
1047
1048 sleftv l;
1049 memset(&l,0,sizeof(l));
1050 l.rtyp=STRING_CMD;
1051 l.data=(void*)"fan";
1052 f->m->Write(f, &l);
1053
1054 gfan::ZFan* zf = (gfan::ZFan*) d;
1055 std::string s = zf->toString(2+4+8+128);
1056
1057 fprintf(dd->f_write,"%d %s ",(int)s.size(),s.c_str());
1058
1059 return FALSE;
1060}
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
const CanonicalForm int s
Definition: facAbsFact.cc:51
FILE * f_write
Definition: s_buff.h:23
@ STRING_CMD
Definition: tok.h:185

◆ bbfan_setup()

void bbfan_setup ( SModulFunctions p)

Definition at line 1082 of file bbfan.cc.

1083{
1084 blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
1085 // all undefined entries will be set to default in setBlackboxStuff
1086 // the default Print is quite usefule,
1087 // all other are simply error messages
1088 b->blackbox_destroy=bbfan_destroy;
1089 b->blackbox_String=bbfan_String;
1090 //b->blackbox_Print=blackbox_default_Print;
1091 b->blackbox_Init=bbfan_Init;
1092 b->blackbox_Copy=bbfan_Copy;
1093 b->blackbox_Assign=bbfan_Assign;
1094 b->blackbox_serialize=bbfan_serialize;
1095 b->blackbox_deserialize=bbfan_deserialize;
1096 p->iiAddCproc("gfan.lib","emptyFan",FALSE,emptyFan);
1097 p->iiAddCproc("gfan.lib","fullFan",FALSE,fullFan);
1098 /* the following functions are implemented in bbcone.cc */
1099 // iiAddCproc("gfan.lib","containsInSupport",FALSE,containsInSupport);
1100 // iiAddCproc("gfan.lib","getAmbientDimension",FALSE,getAmbientDimension);
1101 // iiAddCproc("gfan.lib","getCodimension",FALSE,getDimension);
1102 // iiAddCproc("gfan.lib","getDimension",FALSE,getDimension);
1103 // iiAddCproc("gfan.lib","getLinealityDimension",FALSE,getLinealityDimension);
1104 // iiAddCproc("gfan.lib","isSimplicial",FALSE,isSimplicial);
1105 /********************************************************/
1106 p->iiAddCproc("gfan.lib","isCompatible",FALSE,isCompatible);
1107 p->iiAddCproc("gfan.lib","numberOfConesOfDimension",FALSE,numberOfConesOfDimension);
1108 p->iiAddCproc("gfan.lib","ncones",FALSE,ncones);
1109 p->iiAddCproc("gfan.lib","nmaxcones",FALSE,nmaxcones);
1110 p->iiAddCproc("gfan.lib","insertCone",FALSE,insertCone);
1111 p->iiAddCproc("gfan.lib","removeCone",FALSE,removeCone);
1112 p->iiAddCproc("gfan.lib","getCone",FALSE,getCone);
1113 p->iiAddCproc("gfan.lib","getCones",FALSE,getCones);
1114 p->iiAddCproc("gfan.lib","isPure",FALSE,isPure);
1115 p->iiAddCproc("gfan.lib","fanFromString",FALSE,fanFromString);
1116 p->iiAddCproc("gfan.lib","fanViaCones",FALSE,fanViaCones);
1117 p->iiAddCproc("gfan.lib","numberOfConesWithVector",FALSE,numberOfConesWithVector);
1118 // iiAddCproc("gfan.lib","isComplete",FALSE,isComplete); not working as expected, should leave this to polymake
1119 p->iiAddCproc("gfan.lib","fVector",FALSE,fVector);
1120 p->iiAddCproc("gfan.lib","containsInCollection",FALSE,containsInCollection);
1121 // p->iiAddCproc("gfan.lib","tropicalVariety",FALSE,tropicalVariety);
1122 p->iiAddCproc("gfan.lib","commonRefinement",FALSE,commonRefinement);
1123 // iiAddCproc("gfan.lib","grFan",FALSE,grFan);
1124 fanID=setBlackboxStuff(b,"fan");
1125 //Print("created type %d (fan)\n",fanID);
1126}
BOOLEAN nmaxcones(leftv res, leftv args)
Definition: bbfan.cc:331
BOOLEAN numberOfConesOfDimension(leftv res, leftv args)
Definition: bbfan.cc:266
BOOLEAN emptyFan(leftv res, leftv args)
Definition: bbfan.cc:176
BOOLEAN fanViaCones(leftv res, leftv args)
Definition: bbfan.cc:814
bool containsInCollection(gfan::ZFan *zf, gfan::ZCone *zc)
Definition: bbfan.cc:433
BOOLEAN fullFan(leftv res, leftv args)
Definition: bbfan.cc:228
BOOLEAN getCones(leftv res, leftv args)
Definition: bbfan.cc:609
char * bbfan_String(blackbox *, void *d)
Definition: bbfan.cc:35
BOOLEAN fanFromString(leftv res, leftv args)
Definition: bbfan.cc:796
BOOLEAN isPure(leftv res, leftv args)
Definition: bbfan.cc:688
void * bbfan_Copy(blackbox *, void *d)
Definition: bbfan.cc:64
int numberOfConesWithVector(gfan::ZFan *zf, gfan::ZVector *v)
Definition: bbfan.cc:748
BOOLEAN ncones(leftv res, leftv args)
Definition: bbfan.cc:309
BOOLEAN bbfan_deserialize(blackbox **b, void **d, si_link f)
Definition: bbfan.cc:1063
BOOLEAN removeCone(leftv res, leftv args)
Definition: bbfan.cc:514
void bbfan_destroy(blackbox *, void *d)
Definition: bbfan.cc:26
VAR int fanID
Definition: bbfan.cc:19
gfan::ZFan commonRefinement(gfan::ZFan zf, gfan::ZFan zg)
Definition: bbfan.cc:948
void * bbfan_Init(blackbox *)
Definition: bbfan.cc:21
BOOLEAN getCone(leftv res, leftv args)
Definition: bbfan.cc:553
BOOLEAN bbfan_Assign(leftv l, leftv r)
Definition: bbfan.cc:71
BOOLEAN bbfan_serialize(blackbox *b, void *d, si_link f)
Definition: bbfan.cc:1044
bool isCompatible(const gfan::ZFan *zf, const gfan::ZCone *zc)
Definition: bbfan.cc:352
BOOLEAN insertCone(leftv res, leftv args)
Definition: bbfan.cc:393
BOOLEAN fVector(leftv res, leftv args)
Definition: bbfan.cc:720
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition: blackbox.cc:142
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103

◆ bbfan_String()

char * bbfan_String ( blackbox *  ,
void *  d 
)

Definition at line 35 of file bbfan.cc.

36{
37 if (d==NULL) return omStrDup("invalid object");
38 else
39 {
40 gfan::initializeCddlibIfRequired();
41 gfan::ZFan* zf = (gfan::ZFan*)d;
42 std::string s = zf->toString(2+4+8+128);
43 gfan::deinitializeCddlibIfRequired();
44 return omStrDup(s.c_str());
45// =======
46// std::stringstream s;
47// std::string raysAndCones = zf->toStringJustRaysAndMaximalCones();
48// s << raysAndCones;
49// if (zf->getDimension() >= 0) // <=> zf is not empty
50// {
51// assert(zf->numberOfConesOfDimension(zf->getDimension()-zf->getLinealityDimension(),0,0));
52// gfan::ZCone zc = zf->getCone(zf->getDimension()-zf->getLinealityDimension(),0,0,0);
53// gfan::ZMatrix genLinSpace = zc.generatorsOfLinealitySpace();
54// char* gens = toString(genLinSpace);
55// s << std::endl << "GENERATORS_LINEALITY_SPACE:" << std::endl;
56// s << gens;
57// }
58// std::string sstring = s.str();
59// return omStrDup(sstring.c_str());
60// >>>>>>> status updated 11.03.
61 }
62}
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ commonRefinement() [1/2]

gfan::ZFan commonRefinement ( gfan::ZFan  zf,
gfan::ZFan  zg 
)

Definition at line 948 of file bbfan.cc.

949{
950 assume(zf.getAmbientDimension() == zg.getAmbientDimension());
951
952 // gather all maximal cones of f and g
953 std::list<gfan::ZCone> maximalConesOfF;
954 for (int d=0; d<=zf.getAmbientDimension(); d++)
955 for (int i=0; i<zf.numberOfConesOfDimension(d,0,1); i++)
956 maximalConesOfF.push_back(zf.getCone(d,i,0,1));
957
958 std::list<gfan::ZCone> maximalConesOfG;
959 for (int d=0; d<=zg.getAmbientDimension(); d++)
960 for (int i=0; i<zg.numberOfConesOfDimension(d,0,1); i++)
961 maximalConesOfG.push_back(zg.getCone(d,i,0,1));
962
963 // construct a new fan out of their intersections
964 gfan::ZFan zr = gfan::ZFan(zf.getAmbientDimension());
965 for (std::list<gfan::ZCone>::iterator itf=maximalConesOfF.begin();
966 itf != maximalConesOfF.end(); itf++)
967 for (std::list<gfan::ZCone>::iterator itg=maximalConesOfG.begin();
968 itg != maximalConesOfG.end(); itg++)
969 zr.insert(intersection(*itf,*itg));
970
971 return zr;
972}
int i
Definition: cfEzgcd.cc:132
#define assume(x)
Definition: mod2.h:389

◆ commonRefinement() [2/2]

BOOLEAN commonRefinement ( leftv  res,
leftv  args 
)

Definition at line 974 of file bbfan.cc.

975{
976 leftv u=args;
977 if ((u != NULL) && (u->Typ() == fanID))
978 {
979 leftv v=u->next;
980 if ((v != NULL) && (v->Typ() == fanID))
981 {
982 gfan::initializeCddlibIfRequired();
983 gfan::ZFan* zf = (gfan::ZFan*) u->Data();
984 gfan::ZFan* zg = (gfan::ZFan*) v->Data();
985 gfan::ZFan* zr = new gfan::ZFan(commonRefinement(*zf,*zg));
986 res->rtyp = fanID;
987 res->data = (void*) zr;
988 gfan::deinitializeCddlibIfRequired();
989 return FALSE;
990 }
991 }
992 WerrorS("commonRefinement: unexpected parameters");
993 return TRUE;
994}
leftv next
Definition: subexpr.h:86
CanonicalForm res
Definition: facAbsFact.cc:60
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ containsInCollection() [1/2]

bool containsInCollection ( gfan::ZFan *  zf,
gfan::ZCone *  zc 
)

Definition at line 433 of file bbfan.cc.

434{
435 gfan::ZVector zv=zc->getRelativeInteriorPoint();
436 for (int d=0; d<=zf->getAmbientDimension(); d++)
437 {
438 for (int i=0; i<zf->numberOfConesOfDimension(d,0,1); i++)
439 {
440 gfan::ZCone zd = zf->getCone(d,i,0,1);
441 zd.canonicalize();
442 if (zd.containsRelatively(zv))
443 {
444 gfan::ZCone temp = *zc;
445 temp.canonicalize();
446 return (!(zd != temp));
447 }
448 }
449 }
450 return 0;
451}

◆ containsInCollection() [2/2]

BOOLEAN containsInCollection ( leftv  res,
leftv  args 
)

Definition at line 453 of file bbfan.cc.

454{
455 leftv u=args;
456 if ((u != NULL) && (u->Typ() == fanID))
457 {
458 leftv v=u->next;
459 if ((v != NULL) && (v->Typ() == coneID))
460 {
461 gfan::initializeCddlibIfRequired();
462 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
463 gfan::ZCone* zc = (gfan::ZCone*)v->Data();
464 if((zf->getAmbientDimension() == zc->ambientDimension()))
465 {
466 res->rtyp = INT_CMD;
467 res->data = (void*) (long) (int) containsInCollection(zf,zc);
468 gfan::deinitializeCddlibIfRequired();
469 return FALSE;
470 }
471 gfan::deinitializeCddlibIfRequired();
472 WerrorS("containsInCollection: mismatching ambient dimensions");
473 return TRUE;
474 }
475 }
476 WerrorS("containsInCollection: unexpected parameters");
477 return TRUE;
478}
VAR int coneID
Definition: bbcone.cc:25

◆ emptyFan()

BOOLEAN emptyFan ( leftv  res,
leftv  args 
)

Definition at line 176 of file bbfan.cc.

177{
178 leftv u = args;
179 if (u == NULL)
180 {
181 res->rtyp = fanID;
182 res->data = (void*) new gfan::ZFan(0);
183 return FALSE;
184 }
185 if ((u != NULL) && (u->Typ() == INT_CMD))
186 {
187 if (u->next == NULL) return jjFANEMPTY_I(res, u);
188 }
189 if ((u != NULL) && (u->Typ() == BIGINTMAT_CMD))
190 {
191 if (u->next == NULL) return jjFANEMPTY_IM(res, u);
192 }
193 WerrorS("emptyFan: unexpected parameters");
194 return TRUE;
195}
static BOOLEAN jjFANEMPTY_I(leftv res, leftv v)
Definition: bbfan.cc:146
static BOOLEAN jjFANEMPTY_IM(leftv res, leftv v)
Definition: bbfan.cc:159
@ BIGINTMAT_CMD
Definition: grammar.cc:278

◆ fanFromString()

BOOLEAN fanFromString ( leftv  res,
leftv  args 
)

Definition at line 796 of file bbfan.cc.

797{
798 leftv u=args;
799 if ((u != NULL) && (u->Typ() == STRING_CMD))
800 {
801 gfan::initializeCddlibIfRequired();
802 std::string fanInString = (char*) u->Data();
803 std::istringstream s(fanInString);
804 gfan::ZFan* zf = new gfan::ZFan(s);
805 res->rtyp = fanID;
806 res->data = (void*) zf;
807 gfan::deinitializeCddlibIfRequired();
808 return FALSE;
809 }
810 WerrorS("fanFromString: unexpected parameters");
811 return TRUE;
812}

◆ fanViaCones()

BOOLEAN fanViaCones ( leftv  res,
leftv  args 
)

Definition at line 814 of file bbfan.cc.

815{
816 leftv u=args;
817 if ((u != NULL) && (u->Typ() == LIST_CMD))
818 {
819 lists L = (lists) u->Data();
820 if (lSize(L)>-1)
821 {
822 gfan::initializeCddlibIfRequired();
823 if (L->m[0].Typ() != coneID)
824 {
825 WerrorS("fanViaCones: list contains entries of wrong type");
826 return TRUE;
827 }
828 gfan::ZCone* zc = (gfan::ZCone*) L->m[0].Data();
829 gfan::ZFan* zf = new gfan::ZFan(zc->ambientDimension());
830 zf->insert(*zc);
831 for (int i=1; i<=lSize(L); i++)
832 {
833 if (L->m[i].Typ() != coneID)
834 {
835 WerrorS("fanViaCones: entries of wrong type in list");
836 gfan::deinitializeCddlibIfRequired();
837 return TRUE;
838 }
839 gfan::ZCone* zc = (gfan::ZCone*) L->m[i].Data();
840 if (zc->ambientDimension() != zf->getAmbientDimension())
841 {
842 WerrorS("fanViaCones: inconsistent ambient dimensions amongst cones in list");
843 gfan::deinitializeCddlibIfRequired();
844 return TRUE;
845 }
846 zf->insert(*zc);
847 }
848 res->rtyp = fanID;
849 res->data = (void*) zf;
850 gfan::deinitializeCddlibIfRequired();
851 return FALSE;
852 }
853 res->rtyp = fanID;
854 res->data = (void*) new gfan::ZFan(0);
855 return FALSE;
856 }
857 if ((u != NULL) && (u->Typ() == coneID))
858 {
859 gfan::initializeCddlibIfRequired();
860 gfan::ZCone* zc = (gfan::ZCone*) u->Data();
861 gfan::ZFan* zf = new gfan::ZFan(zc->ambientDimension());
862 zf->insert(*zc);
863 while (u->next != NULL)
864 {
865 u = u->next;
866 if (u->Typ() != coneID)
867 {
868 WerrorS("fanViaCones: arguments of wrong type");
869 gfan::deinitializeCddlibIfRequired();
870 delete zf;
871 return TRUE;
872 }
873 gfan::ZCone* zc = (gfan::ZCone*) u->Data();
874 if (zc->ambientDimension() != zf->getAmbientDimension())
875 {
876 WerrorS("fanViaCones: inconsistent ambient dimensions amongst input cones");
877 gfan::deinitializeCddlibIfRequired();
878 delete zf;
879 return TRUE;
880 }
881 zf->insert(*zc);
882 }
883 res->rtyp = fanID;
884 res->data = (void*) zf;
885 gfan::deinitializeCddlibIfRequired();
886 return FALSE;
887 }
888 if (u == NULL)
889 {
890 res->rtyp = fanID;
891 res->data = (void*) new gfan::ZFan(0);
892 return FALSE;
893 }
894 WerrorS("fanViaCones: unexpected parameters");
895 return TRUE;
896}
Definition: lists.h:24
sleftv * m
Definition: lists.h:46
int lSize(lists L)
Definition: lists.cc:25
slists * lists
Definition: mpr_numeric.h:146
@ LIST_CMD
Definition: tok.h:118

◆ fullFan()

BOOLEAN fullFan ( leftv  res,
leftv  args 
)

Definition at line 228 of file bbfan.cc.

229{
230 gfan::initializeCddlibIfRequired();
231 leftv u = args;
232 if (u == NULL)
233 {
234 res->rtyp = fanID;
235 res->data = (void*) new gfan::ZFan(0);
236 return FALSE;
237 }
238 if ((u != NULL) && (u->Typ() == INT_CMD))
239 if (u->next == NULL) return jjFANFULL_I(res, u);
240 if ((u != NULL) && (u->Typ() == BIGINTMAT_CMD))
241 if (u->next == NULL) return jjFANFULL_IM(res, u);
242 WerrorS("fullFan: unexpected parameters");
243 return TRUE;
244}
static BOOLEAN jjFANFULL_I(leftv res, leftv v)
Definition: bbfan.cc:197
static BOOLEAN jjFANFULL_IM(leftv res, leftv v)
Definition: bbfan.cc:210

◆ fVector()

BOOLEAN fVector ( leftv  res,
leftv  args 
)

Definition at line 720 of file bbfan.cc.

721{
722 leftv u=args;
723 if ((u != NULL) && (u->Typ() == fanID))
724 {
725 gfan::initializeCddlibIfRequired();
726 gfan::ZFan* zf = (gfan::ZFan*) u->Data();
727 gfan::ZVector zv=zf->getFVector();
728 res->rtyp = BIGINTMAT_CMD;
729 res->data = (void*) zVectorToBigintmat(zv);
730 gfan::deinitializeCddlibIfRequired();
731 return FALSE;
732 }
733 WerrorS("fVector: unexpected parameters");
734 return TRUE;
735}
bigintmat * zVectorToBigintmat(const gfan::ZVector &zv)

◆ getAmbientDimension()

int getAmbientDimension ( gfan::ZFan *  zf)

Definition at line 246 of file bbfan.cc.

247{
248 return zf->getAmbientDimension();
249}

◆ getCodimension()

int getCodimension ( gfan::ZFan *  zf)

Definition at line 251 of file bbfan.cc.

252{
253 return zf->getCodimension();
254}

◆ getCone()

BOOLEAN getCone ( leftv  res,
leftv  args 
)

Definition at line 553 of file bbfan.cc.

554{
555 leftv u=args;
556 if ((u != NULL) && (u->Typ() == fanID))
557 {
558 leftv v=u->next;
559 if ((v != NULL) && (v->Typ() == INT_CMD))
560 {
561 leftv w=v->next;
562 if ((w != NULL) && (w->Typ() == INT_CMD))
563 {
564 gfan::initializeCddlibIfRequired();
565 gfan::ZFan* zf = (gfan::ZFan*) u->Data();
566
567 int d = (int)(long)v->Data();
568 d -= zf->getLinealityDimension(); // shifting by dimension of lineality space
569 // since gfan always regards the lineality space as zero-dimensional
570 int i = (int)(long)w->Data();
571 i -= 1; // shifting by one, since gfan starts counting at 0
572 int m = 0;
573 leftv x=w->next;
574 if ((x != NULL) && (x->Typ() != INT_CMD))
575 {
576 WerrorS("getCone: invalid maximality flag");
577 gfan::deinitializeCddlibIfRequired();
578 return TRUE;
579 }
580 if ((x != NULL) && (x->Typ() == INT_CMD))
581 m = (int)(long) x->Data();
582 bool mm = (bool) m;
583
584 if (d<0 || (d>zf->getAmbientDimension()-zf->getLinealityDimension()))
585 {
586 WerrorS("getCone: invalid dimension");
587 gfan::deinitializeCddlibIfRequired();
588 return TRUE;
589 }
590 if (i<0 || i>=zf->numberOfConesOfDimension(d,0,mm))
591 {
592 WerrorS("getCone: invalid index");
593 gfan::deinitializeCddlibIfRequired();
594 return TRUE;
595 }
596
597 gfan::ZCone zc = zf->getCone(d,i,0,mm);
598 res->rtyp = coneID;
599 res->data = (void*)new gfan::ZCone(zc);
600 gfan::deinitializeCddlibIfRequired();
601 return FALSE;
602 }
603 }
604 }
605 WerrorS("getCone: unexpected parameters");
606 return TRUE;
607}
int m
Definition: cfEzgcd.cc:128
Variable x
Definition: cfModGcd.cc:4082
Variable next() const
Definition: variable.h:52
const CanonicalForm & w
Definition: facAbsFact.cc:51

◆ getCones()

BOOLEAN getCones ( leftv  res,
leftv  args 
)

Definition at line 609 of file bbfan.cc.

610{
611 leftv u=args;
612 if ((u != NULL) && (u->Typ() == fanID))
613 {
614 leftv v=u->next;
615 if ((v != NULL) && (v->Typ() == INT_CMD))
616 {
617 gfan::initializeCddlibIfRequired();
618 gfan::ZFan* zf = (gfan::ZFan*) u->Data();
619 int d = (int)(long)v->Data();
620 int o = -1;
621 int m = -1;
622 leftv w=v->next;
623 if ((w != NULL) && (w->Typ() == INT_CMD))
624 {
625 o = (int)(long)w->Data();
626 leftv x=w->next;
627 if ((x != NULL) && (x->Typ() == INT_CMD))
628 {
629 m = (int)(long)x->Data();
630 }
631 }
632 if (o == -1) o = 0;
633 if (m == -1) m = 0;
634 if (((o == 0) || (o == 1)) && ((m == 0) || (m == 1)))
635 {
636 bool oo = (bool) o;
637 bool mm = (bool) m;
638 if (0<=d && d<=zf->getAmbientDimension())
639 {
640 int ld = zf->getLinealityDimension();
641 if (d-ld>=0)
642 {
644 int n = zf->numberOfConesOfDimension(d-ld,oo,mm);
645 L->Init(n);
646 for (int i=0; i<n; i++)
647 {
648 gfan::ZCone zc = zf->getCone(d-ld,i,oo,mm);
649 L->m[i].rtyp = coneID; L->m[i].data=(void*) new gfan::ZCone(zc);
650 }
651 res->rtyp = LIST_CMD;
652 res->data = (void*) L;
653 gfan::deinitializeCddlibIfRequired();
654 return FALSE;
655 }
656 else
657 {
658 WerrorS("getCones: invalid dimension; no cones in this dimension");
659 gfan::deinitializeCddlibIfRequired();
660 return TRUE;
661 }
662 }
663 else
664 {
665 WerrorS("getCones: invalid dimension");
666 gfan::deinitializeCddlibIfRequired();
667 return TRUE;
668 }
669 }
670 else
671 {
672 WerrorS("getCones: invalid specifier for orbit or maximal");
673 gfan::deinitializeCddlibIfRequired();
674 return TRUE;
675 }
676 }
677 }
678 WerrorS("getCones: unexpected parameters");
679 return TRUE;
680}
int getAmbientDimension(gfan::ZFan *zf)
Definition: bbfan.cc:246
int rtyp
Definition: subexpr.h:91
void * data
Definition: subexpr.h:88
INLINE_THIS void Init(int l=0)
VAR omBin slists_bin
Definition: lists.cc:23
#define omAllocBin(bin)
Definition: omAllocDecl.h:205

◆ getDimension()

int getDimension ( gfan::ZFan *  zf)

Definition at line 256 of file bbfan.cc.

257{
258 return zf->getDimension();
259}

◆ getLinealityDimension()

int getLinealityDimension ( gfan::ZFan *  zf)

Definition at line 261 of file bbfan.cc.

262{
263 return zf->getLinealityDimension();
264}

◆ insertCone()

BOOLEAN insertCone ( leftv  res,
leftv  args 
)

Definition at line 393 of file bbfan.cc.

394{
395 leftv u=args;
396 if ((u != NULL) && (u->rtyp==IDHDL) && (u->e==NULL) && (u->Typ() == fanID))
397 {
398 leftv v=u->next;
399 if ((v != NULL) && (v->Typ() == coneID))
400 {
401 gfan::initializeCddlibIfRequired();
402 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
403 gfan::ZCone* zc = (gfan::ZCone*)v->Data();
404 zc->canonicalize();
405
406 leftv w=v->next;
407 int n=1;
408 if ((w != NULL) && (w->Typ() == INT_CMD))
409 n = (int)(long) w->Data();
410
411 if (n != 0)
412 {
413 if (!isCompatible(zf,zc))
414 {
415 WerrorS("insertCone: cone and fan not compatible");
416 gfan::deinitializeCddlibIfRequired();
417 return TRUE;
418 }
419 }
420
421 zf->insert(*zc);
422 res->rtyp = NONE;
423 res->data = NULL;
424 IDDATA((idhdl)u->data) = (char*) zf;
425 gfan::deinitializeCddlibIfRequired();
426 return FALSE;
427 }
428 }
429 WerrorS("insertCone: unexpected parameters");
430 return TRUE;
431}
Subexpr e
Definition: subexpr.h:105
#define NONE
Definition: tok.h:221

◆ isCompatible() [1/2]

bool isCompatible ( const gfan::ZFan *  zf,
const gfan::ZCone *  zc 
)

Definition at line 352 of file bbfan.cc.

353{
354 bool b = (zf->getAmbientDimension() == zc->ambientDimension());
355 if(b)
356 {
357 for (int d=0; d<=zf->getAmbientDimension(); d++)
358 {
359 for (int i=0; i<zf->numberOfConesOfDimension(d,0,1); i++)
360 {
361 gfan::ZCone zd = zf->getCone(d,i,0,1);
362 gfan::ZCone zt = gfan::intersection(*zc,zd);
363 zt.canonicalize();
364 b = b && zd.hasFace(zt);
365 }
366 }
367 }
368 return b;
369}

◆ isCompatible() [2/2]

BOOLEAN isCompatible ( leftv  res,
leftv  args 
)

Definition at line 371 of file bbfan.cc.

372{
373 leftv u=args;
374 if ((u != NULL) && (u->Typ() == fanID))
375 {
376 leftv v=u->next;
377 if ((v != NULL) && (v->Typ() == coneID))
378 {
379 gfan::initializeCddlibIfRequired();
380 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
381 gfan::ZCone* zc = (gfan::ZCone*)v->Data();
382 int b = isCompatible(zf,zc);
383 res->rtyp = INT_CMD;
384 res->data = (void*) (long) b;
385 gfan::deinitializeCddlibIfRequired();
386 return FALSE;
387 }
388 }
389 WerrorS("isCompatible: unexpected parameters");
390 return TRUE;
391}

◆ isPure()

BOOLEAN isPure ( leftv  res,
leftv  args 
)

Definition at line 688 of file bbfan.cc.

689{
690 leftv u=args;
691 if ((u != NULL) && (u->Typ() == fanID))
692 {
693 gfan::initializeCddlibIfRequired();
694 gfan::ZFan* zf = (gfan::ZFan*) u->Data();
695 int b = zf->isPure();
696 res->rtyp = INT_CMD;
697 res->data = (void*) (long) b;
698 gfan::deinitializeCddlibIfRequired();
699 return FALSE;
700 }
701 WerrorS("isPure: unexpected parameters");
702 return TRUE;
703}

◆ isSimplicial()

int isSimplicial ( gfan::ZFan *  zf)

Definition at line 682 of file bbfan.cc.

683{
684 int i = zf->isSimplicial() ? 1 : 0;
685 return i;
686}

◆ jjFANEMPTY_I()

static BOOLEAN jjFANEMPTY_I ( leftv  res,
leftv  v 
)
static

Definition at line 146 of file bbfan.cc.

147{
148 int ambientDim = (int)(long)v->Data();
149 if (ambientDim < 0)
150 {
151 Werror("expected non-negative ambient dim but got %d", ambientDim);
152 return TRUE;
153 }
154 res->rtyp = fanID;
155 res->data = (void*)(new gfan::ZFan(ambientDim));
156 return FALSE;
157}

◆ jjFANEMPTY_IM()

static BOOLEAN jjFANEMPTY_IM ( leftv  res,
leftv  v 
)
static

Definition at line 159 of file bbfan.cc.

160{
161 bigintmat* permutations = (bigintmat*)v->Data();
162 int ambientDim = permutations->cols();
163 gfan::IntMatrix im = permutationIntMatrix(permutations);
164 if (!gfan::Permutation::arePermutations(im))
165 {
166 Werror("provided bigintmat contains invalid permutations of {1, ..., %d}", ambientDim);
167 return TRUE;
168 }
169 gfan::SymmetryGroup sg = gfan::SymmetryGroup(ambientDim);
170 sg.computeClosure(im);
171 res->rtyp = fanID;
172 res->data = (void*)(new gfan::ZFan(sg));
173 return FALSE;
174}
static gfan::IntMatrix permutationIntMatrix(const bigintmat *iv)
Definition: bbfan.cc:127
Matrices of numbers.
Definition: bigintmat.h:51
int cols() const
Definition: bigintmat.h:144

◆ jjFANFULL_I()

static BOOLEAN jjFANFULL_I ( leftv  res,
leftv  v 
)
static

Definition at line 197 of file bbfan.cc.

198{
199 int ambientDim = (int)(long)v->Data();
200 if (ambientDim < 0)
201 {
202 Werror("expected non-negative ambient dim but got %d", ambientDim);
203 return TRUE;
204 }
205 gfan::ZFan* zf = new gfan::ZFan(gfan::ZFan::fullFan(ambientDim));
206 res->rtyp = fanID;
207 res->data = (void*) zf;
208 return FALSE;
209}

◆ jjFANFULL_IM()

static BOOLEAN jjFANFULL_IM ( leftv  res,
leftv  v 
)
static

Definition at line 210 of file bbfan.cc.

211{
212 bigintmat* permutations = (bigintmat*)v->Data();
213 int ambientDim = permutations->cols();
214 gfan::IntMatrix im = permutationIntMatrix(permutations);
215 if (!gfan::Permutation::arePermutations(im))
216 {
217 Werror("provided bigintmat contains invalid permutations of {1, ..., %d}", ambientDim);
218 return TRUE;
219 }
220 gfan::SymmetryGroup sg = gfan::SymmetryGroup(ambientDim);
221 sg.computeClosure(im);
222 gfan::ZFan* zf = new gfan::ZFan(gfan::ZFan::fullFan(sg));
223 res->rtyp = fanID;
224 res->data = (void*) zf;
225 return FALSE;
226}

◆ ncones()

BOOLEAN ncones ( leftv  res,
leftv  args 
)

Definition at line 309 of file bbfan.cc.

310{
311 leftv u=args;
312 if ((u != NULL) && (u->Typ() == fanID))
313 {
314 gfan::initializeCddlibIfRequired();
315 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
316 int d = zf->getAmbientDimension();
317 int n = 0;
318
319 for (int i=0; i<=d; i++)
320 n = n + zf->numberOfConesOfDimension(i,0,0);
321
322 res->rtyp = INT_CMD;
323 res->data = (void*) (long) n;
324 gfan::deinitializeCddlibIfRequired();
325 return FALSE;
326 }
327 WerrorS("ncones: unexpected parameters");
328 return TRUE;
329}

◆ nmaxcones()

BOOLEAN nmaxcones ( leftv  res,
leftv  args 
)

Definition at line 331 of file bbfan.cc.

332{
333 leftv u=args;
334 if ((u != NULL) && (u->Typ() == fanID))
335 {
336 gfan::initializeCddlibIfRequired();
337 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
338
339 int n = 0;
340 for (int d=0; d<=zf->getAmbientDimension(); d++)
341 n = n + zf->numberOfConesOfDimension(d,0,1);
342
343 res->rtyp = INT_CMD;
344 res->data = (void*) (long) n;
345 gfan::deinitializeCddlibIfRequired();
346 return FALSE;
347 }
348 WerrorS("nmaxcones: unexpected parameters");
349 return TRUE;
350}

◆ numberOfConesOfDimension()

BOOLEAN numberOfConesOfDimension ( leftv  res,
leftv  args 
)

Definition at line 266 of file bbfan.cc.

267{
268 leftv u=args;
269 if ((u != NULL) && (u->Typ() == fanID))
270 {
271 leftv v=u->next;
272 if ((v != NULL) && (v->Typ() == INT_CMD))
273 {
274 gfan::initializeCddlibIfRequired();
275 gfan::ZFan* zf = (gfan::ZFan*) u->Data();
276 int d = (int)(long)v->Data();
277 d -= zf->getLinealityDimension(); // shifting by dimension of lineality space
278 // since gfan always regards the lineality space as zero-dimensional
279 int m = 0;
280 leftv w=v->next;
281 if ((w != NULL) && (w->Typ() != INT_CMD))
282 {
283 WerrorS("numberOfConesOfDimension: invalid maximality flag");
284 gfan::deinitializeCddlibIfRequired();
285 return TRUE;
286 }
287 if ((w != NULL) && (w->Typ() == INT_CMD))
288 m = (int)(long) w->Data();
289 bool mm = (bool) m;
290
291 if (d<0 || (d>zf->getAmbientDimension()-zf->getLinealityDimension()))
292 {
293 WerrorS("numberOfConesOfDimension: invalid dimension");
294 gfan::deinitializeCddlibIfRequired();
295 return TRUE;
296 }
297
298 int n = zf->numberOfConesOfDimension(d,0,mm);
299 res->rtyp = INT_CMD;
300 res->data = (void*) (long) n;
301 gfan::deinitializeCddlibIfRequired();
302 return FALSE;
303 }
304 }
305 WerrorS("numberOfConesOfDimension: unexpected parameters");
306 return TRUE;
307}

◆ numberOfConesWithVector() [1/2]

int numberOfConesWithVector ( gfan::ZFan *  zf,
gfan::ZVector *  v 
)

Definition at line 748 of file bbfan.cc.

749{
750 int count = 0;
751 int ambientDim = zf->getAmbientDimension();
752 for (int i=0; i<zf->numberOfConesOfDimension(ambientDim, 0, 0); i++)
753 {
754 gfan::ZCone zc = zf->getCone(ambientDim, i, 0, 0);
755 if (zc.contains(*v))
756 {
757 count = count +1;
758 if (count > 1)
759 return count;
760 }
761 }
762 return count;
763}
int status int void size_t count
Definition: si_signals.h:59

◆ numberOfConesWithVector() [2/2]

BOOLEAN numberOfConesWithVector ( leftv  res,
leftv  args 
)

Definition at line 765 of file bbfan.cc.

766{
767 leftv u=args;
768 if ((u != NULL) && (u->Typ() == fanID))
769 {
770 leftv v=u->next;
771 if ((v != NULL) && (v->Typ() == BIGINTMAT_CMD))
772 {
773 gfan::initializeCddlibIfRequired();
774 gfan::ZFan* zf = (gfan::ZFan*) u->Data();
775 bigintmat* v0 = (bigintmat*) v->Data();
776 int ambientDim = zf->getAmbientDimension();
777 if (ambientDim != v0->cols())
778 {
779 WerrorS("numberOfConesWithVector: mismatching dimensions");
780 gfan::deinitializeCddlibIfRequired();
781 return TRUE;
782 }
783 gfan::ZVector* v1 = bigintmatToZVector(*v0);
784 int count = numberOfConesWithVector(zf, v1);
785 delete v1;
786 res->rtyp = INT_CMD;
787 res->data = (void*) (long) count;
788 gfan::deinitializeCddlibIfRequired();
789 return FALSE;
790 }
791 }
792 WerrorS("numberOfConesWithVector: unexpected parameters");
793 return TRUE;
794}
gfan::ZVector * bigintmatToZVector(const bigintmat &bim)

◆ permutationIntMatrix()

static gfan::IntMatrix permutationIntMatrix ( const bigintmat iv)
static

Definition at line 127 of file bbfan.cc.

128{
129 int cc = iv->cols();
130 int rr = iv->rows();
131 bigintmat* ivCopy = new bigintmat(rr, cc, coeffs_BIGINT);
132 number temp1 = n_Init(1,coeffs_BIGINT);
133 for (int r = 1; r <= rr; r++)
134 for (int c = 1; c <= cc; c++)
135 {
136 number temp2 = n_Sub(IMATELEM(*iv, r, c),temp1,coeffs_BIGINT);
137 ivCopy->set(r,c,temp2);
138 n_Delete(&temp2,coeffs_BIGINT);
139 }
140 n_Delete(&temp1,coeffs_BIGINT);
141 gfan::ZMatrix* zm = bigintmatToZMatrix(ivCopy);
142 gfan::IntMatrix im = gfan::IntMatrix(gfan::ZToIntMatrix(*zm));
143 delete zm;
144 return im;
145}
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
int rows() const
Definition: bigintmat.h:145
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition: coeffs.h:652
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:535
intvec * ivCopy(const intvec *o)
Definition: intvec.h:145
#define IMATELEM(M, I, J)
Definition: intvec.h:85
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50

◆ rays()

gfan::ZMatrix rays ( const gfan::ZFan *const  zf)

Definition at line 737 of file bbfan.cc.

738{
739 gfan::ZMatrix rays(0,zf->getAmbientDimension());
740 for (int i=0; i<zf->numberOfConesOfDimension(1,0,0); i++)
741 {
742 gfan::ZCone zc = zf->getCone(1, i, 0, 0);
743 rays.append(zc.extremeRays());
744 }
745 return rays;
746}
gfan::ZMatrix rays(const gfan::ZFan *const zf)
Definition: bbfan.cc:737

◆ removeCone()

BOOLEAN removeCone ( leftv  res,
leftv  args 
)

Definition at line 514 of file bbfan.cc.

515{
516 leftv u=args;
517 if ((u != NULL) && (u->Typ() == fanID))
518 {
519 leftv v=u->next;
520 if ((v != NULL) && (v->Typ() == coneID))
521 {
522 gfan::initializeCddlibIfRequired();
523 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
524 gfan::ZCone* zc = (gfan::ZCone*)v->Data();
525 zc->canonicalize();
526
527 leftv w=v->next; int n = 1;
528 if ((w != NULL) && (w->Typ() == INT_CMD))
529 n = (int)(long) w;
530
531 if (n != 0)
532 {
533 if (!containsInCollection(zf,zc))
534 {
535 WerrorS("removeCone: cone not contained in fan");
536 gfan::deinitializeCddlibIfRequired();
537 return TRUE;
538 }
539 }
540
541 zf->remove(*zc);
542 res->rtyp = NONE;
543 res->data = NULL;
544 IDDATA((idhdl)u->data) = (char*) zf;
545 gfan::deinitializeCddlibIfRequired();
546 return FALSE;
547 }
548 }
549 WerrorS("removeCone: unexpected parameters");
550 return TRUE;
551}

Variable Documentation

◆ fanID

VAR int fanID

Definition at line 19 of file bbfan.cc.