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

Go to the source code of this file.

Functions

std::string toString (const gfan::ZCone *const c)
 
voidbbcone_Init (blackbox *)
 
BOOLEAN bbcone_Assign (leftv l, leftv r)
 
charbbcone_String (blackbox *, void *d)
 
void bbcone_destroy (blackbox *, void *d)
 
voidbbcone_Copy (blackbox *, void *d)
 
static BOOLEAN bbcone_Op2 (int op, leftv res, leftv i1, leftv i2)
 
static BOOLEAN jjCONENORMALS1 (leftv res, leftv v)
 
static BOOLEAN jjCONENORMALS2 (leftv res, leftv u, leftv v)
 
static BOOLEAN jjCONENORMALS3 (leftv res, leftv u, leftv v, leftv w)
 
BOOLEAN coneViaNormals (leftv res, leftv args)
 
static BOOLEAN jjCONERAYS1 (leftv res, leftv v)
 
static BOOLEAN jjCONERAYS2 (leftv res, leftv u, leftv v)
 
static BOOLEAN jjCONERAYS3 (leftv res, leftv u, leftv v, leftv w)
 
BOOLEAN coneViaRays (leftv res, leftv args)
 
BOOLEAN inequalities (leftv res, leftv args)
 
BOOLEAN equations (leftv res, leftv args)
 
BOOLEAN facets (leftv res, leftv args)
 
BOOLEAN impliedEquations (leftv res, leftv args)
 
BOOLEAN generatorsOfSpan (leftv res, leftv args)
 
BOOLEAN generatorsOfLinealitySpace (leftv res, leftv args)
 
BOOLEAN rays (leftv res, leftv args)
 
BOOLEAN quotientLatticeBasis (leftv res, leftv args)
 
BOOLEAN getLinearForms (leftv res, leftv args)
 
BOOLEAN ambientDimension (leftv res, leftv args)
 
BOOLEAN dimension (leftv res, leftv args)
 
BOOLEAN codimension (leftv res, leftv args)
 
BOOLEAN linealityDimension (leftv res, leftv args)
 
BOOLEAN getMultiplicity (leftv res, leftv args)
 
BOOLEAN isOrigin (leftv res, leftv args)
 
BOOLEAN isFullSpace (leftv res, leftv args)
 
BOOLEAN isSimplicial (leftv res, leftv args)
 
BOOLEAN containsPositiveVector (leftv res, leftv args)
 
BOOLEAN linealitySpace (leftv res, leftv args)
 
BOOLEAN dualCone (leftv res, leftv args)
 
BOOLEAN negatedCone (leftv res, leftv args)
 
BOOLEAN semigroupGenerator (leftv res, leftv args)
 
BOOLEAN relativeInteriorPoint (leftv res, leftv args)
 
BOOLEAN uniquePoint (leftv res, leftv args)
 
int siRandBound (const int b)
 
gfan::ZVector randomPoint (const gfan::ZCone *zc, const int b)
 
BOOLEAN randomPoint (leftv res, leftv args)
 
BOOLEAN setMultiplicity (leftv res, leftv args)
 
BOOLEAN setLinearForms (leftv res, leftv args)
 
gfan::ZMatrix liftUp (const gfan::ZMatrix &zm)
 
gfan::ZCone liftUp (const gfan::ZCone &zc)
 
BOOLEAN coneToPolytope (leftv res, leftv args)
 
BOOLEAN intersectCones (leftv res, leftv args)
 
BOOLEAN convexHull (leftv res, leftv args)
 
BOOLEAN coneLink (leftv res, leftv args)
 
BOOLEAN containsInSupport (leftv res, leftv args)
 
BOOLEAN containsRelatively (leftv res, leftv args)
 
BOOLEAN hasFace (leftv res, leftv args)
 
BOOLEAN canonicalizeCone (leftv res, leftv args)
 
BOOLEAN containsCone (leftv res, leftv args)
 
BOOLEAN faceContaining (leftv res, leftv args)
 
BOOLEAN onesVector (leftv res, leftv args)
 
gfan::ZMatrix interiorPointsOfFacets (const gfan::ZCone &zc, const std::set< gfan::ZVector > &exceptThese)
 
std::pair< gfan::ZMatrix, gfan::ZMatrixinteriorPointsAndNormalsOfFacets (const gfan::ZCone zc, const std::set< gfan::ZVector > &exceptThesePoints, const bool onlyLowerHalfSpace)
 
static void gfanIntegerWriteFd (gfan::Integer n, ssiInfo *dd)
 
static void gfanZMatrixWriteFd (gfan::ZMatrix M, ssiInfo *dd)
 
BOOLEAN bbcone_serialize (blackbox *b, void *d, si_link f)
 
static gfan::Integer gfanIntegerReadFd (ssiInfo *dd)
 
static gfan::ZMatrix gfanZMatrixReadFd (ssiInfo *dd)
 
BOOLEAN bbcone_deserialize (blackbox **b, void **d, si_link f)
 
BOOLEAN convexIntersectionOld (leftv res, leftv args)
 
void bbcone_setup (SModulFunctions *p)
 

Variables

VAR int coneID
 

Function Documentation

◆ ambientDimension()

BOOLEAN ambientDimension ( leftv res,
leftv args )

Definition at line 723 of file bbcone.cc.

724{
725 leftv u=args;
726 if ((u != NULL) && (u->Typ() == coneID))
727 {
729 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
730 res->rtyp = INT_CMD;
731 res->data = (void*) (long) zc->ambientDimension();
733 return FALSE;
734 }
735 if ((u != NULL) && (u->Typ() == fanID))
736 {
738 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
739 res->rtyp = INT_CMD;
740 res->data = (void*) (long) getAmbientDimension(zf);
742 return FALSE;
743 }
744 if ((u != NULL) && (u->Typ() == polytopeID))
745 {
747 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
748 res->rtyp = INT_CMD;
749 res->data = (void*) (long) getAmbientDimension(zc);
751 return FALSE;
752 }
753 WerrorS("ambientDimension: unexpected parameters");
754 return TRUE;
755}
#define TRUE
Definition auxiliary.h:100
#define FALSE
Definition auxiliary.h:96
VAR int coneID
Definition bbcone.cc:25
VAR int fanID
Definition bbfan.cc:19
int getAmbientDimension(gfan::ZFan *zf)
Definition bbfan.cc:246
VAR int polytopeID
Definition bbpolytope.cc:16
Class used for (list of) interpreter objects.
Definition subexpr.h:83
int Typ()
Definition subexpr.cc:1030
void * Data()
Definition subexpr.cc:1173
CanonicalForm res
Definition facAbsFact.cc:60
void WerrorS(const char *s)
Definition feFopen.cc:24
#define NULL
Definition omList.c:12
@ INT_CMD
Definition tok.h:96

◆ bbcone_Assign()

BOOLEAN bbcone_Assign ( leftv l,
leftv r )

Definition at line 85 of file bbcone.cc.

86{
88 if (r==NULL)
89 {
90 if (l->Data()!=NULL)
91 {
92 gfan::ZCone* zd = (gfan::ZCone*)l->Data();
93 delete zd;
94 }
95 newZc = new gfan::ZCone();
96 }
97 else if (r->Typ()==l->Typ())
98 {
99 if (l->Data()!=NULL)
100 {
101 gfan::ZCone* zd = (gfan::ZCone*)l->Data();
102 delete zd;
103 }
104 newZc = (gfan::ZCone*)r->CopyD();
105 }
106 else if (r->Typ()==INT_CMD)
107 {
108 int ambientDim = (int)(long)r->Data();
109 if (ambientDim < 0)
110 {
111 Werror("expected an int >= 0, but got %d", ambientDim);
112 return TRUE;
113 }
114 if (l->Data()!=NULL)
115 {
116 gfan::ZCone* zd = (gfan::ZCone*)l->Data();
117 delete zd;
118 }
120 }
121 else
122 {
123 Werror("assign Type(%d) = Type(%d) not implemented",l->Typ(),r->Typ());
124 return TRUE;
125 }
126
127 if (l->rtyp==IDHDL)
128 {
129 IDDATA((idhdl)l->data)=(char*) newZc;
130 }
131 else
132 {
133 l->data=(void *)newZc;
134 }
135 return FALSE;
136}
int l
Definition cfEzgcd.cc:100
Definition idrec.h:35
void * CopyD(int t)
Definition subexpr.cc:710
#define IDDATA(a)
Definition ipid.h:126
void Werror(const char *fmt,...)
Definition reporter.cc:189
#define IDHDL
Definition tok.h:31

◆ bbcone_Copy()

void * bbcone_Copy ( blackbox * ,
void * d )

Definition at line 157 of file bbcone.cc.

158{
161 return newZc;
162}

◆ bbcone_deserialize()

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

Definition at line 1993 of file bbcone.cc.

1994{
1995 ssiInfo *dd = (ssiInfo *)f->data;
1996 int preassumptions = s_readint(dd->f_read);
1997
2000
2001 // if (e.getHeight()==0) // why is e sometimes 0x0 and sometimex 0xn???
2002 // e = gfan::ZMatrix(0,i.getWidth());
2003
2005
2006 *d=Z;
2007 return FALSE;
2008}
static gfan::ZMatrix gfanZMatrixReadFd(ssiInfo *dd)
Definition bbcone.cc:1977
int i
Definition cfEzgcd.cc:132
FILE * f
Definition checklibs.c:9
int s_readint(s_buff F)
Definition s_buff.cc:112

◆ bbcone_destroy()

void bbcone_destroy ( blackbox * ,
void * d )

Definition at line 148 of file bbcone.cc.

149{
150 if (d!=NULL)
151 {
152 gfan::ZCone* zc = (gfan::ZCone*) d;
153 delete zc;
154 }
155}

◆ bbcone_Init()

void * bbcone_Init ( blackbox * )

Definition at line 80 of file bbcone.cc.

81{
82 return (void*)(new gfan::ZCone());
83}

◆ bbcone_Op2()

static BOOLEAN bbcone_Op2 ( int op,
leftv res,
leftv i1,
leftv i2 )
static

Definition at line 164 of file bbcone.cc.

165{
166 gfan::ZCone* zp = (gfan::ZCone*) i1->Data();
167 switch(op)
168 {
169 case '&':
170 {
171 if (i2->Typ()==coneID)
172 {
173 gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
174 int d1 = zp->ambientDimension();
175 int d2 = zq->ambientDimension();
176 if (d1 != d2)
177 {
178 WerrorS("mismatching ambient dimensions");
179 return TRUE;
180 }
181 gfan::ZCone* zs = new gfan::ZCone();
182 *zs = gfan::intersection(*zp, *zq);
183 zs->canonicalize();
184 res->rtyp = coneID;
185 res->data = (void*) zs;
186 return FALSE;
187 }
188 return blackboxDefaultOp2(op,res,i1,i2);
189 }
190 case '|':
191 {
192 if(i2->Typ()==coneID)
193 {
194 gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
195 int d1 = zp->ambientDimension();
196 int d2 = zq->ambientDimension();
197 if (d1 != d2)
198 {
199 WerrorS("mismatching ambient dimensions");
200 return TRUE;
201 }
202 gfan::ZMatrix rays = zp->extremeRays();
203 rays.append(zq->extremeRays());
204 gfan::ZMatrix lineality = zp->generatorsOfLinealitySpace();
205 lineality.append(zq->generatorsOfLinealitySpace());
206 gfan::ZCone* zs = new gfan::ZCone();
207 *zs = gfan::ZCone::givenByRays(rays,lineality);
208 zs->canonicalize();
209 res->rtyp = coneID;
210 res->data = (void*) zs;
211 return FALSE;
212 }
213 return blackboxDefaultOp2(op,res,i1,i2);
214 }
215 case EQUAL_EQUAL:
216 {
217 if(i2->Typ()==coneID)
218 {
219 gfan::ZCone* zq = (gfan::ZCone*) i2->Data();
220 zp->canonicalize();
221 zq->canonicalize();
222 bool b = !((*zp)!=(*zq));
223 res->rtyp = INT_CMD;
224 res->data = (void*) b;
225 return FALSE;
226 }
227 return blackboxDefaultOp2(op,res,i1,i2);
228 }
229 default:
230 return blackboxDefaultOp2(op,res,i1,i2);
231 }
232 return blackboxDefaultOp2(op,res,i1,i2);
233}
BOOLEAN rays(leftv res, leftv args)
Definition bbcone.cc:662
BOOLEAN blackboxDefaultOp2(int, leftv, leftv, leftv)
default procedure blackboxDefaultOp2, to be called as "default:" branch
Definition blackbox.cc:97
CanonicalForm b
Definition cfModGcd.cc:4102
void append(const T &)
@ EQUAL_EQUAL
Definition grammar.cc:268

◆ bbcone_serialize()

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

Definition at line 1944 of file bbcone.cc.

1945{
1946 ssiInfo *dd = (ssiInfo *)f->data;
1947
1948 sleftv l;
1949 memset(&l,0,sizeof(l));
1950 l.rtyp=STRING_CMD;
1951 l.data=(void*)"cone";
1952 f->m->Write(f, &l);
1953
1954 gfan::ZCone *Z = (gfan::ZCone*) d;
1955 fprintf(dd->f_write,"%d ",Z->areImpliedEquationsKnown()+Z->areFacetsKnown()*2);
1956
1957 gfan::ZMatrix i=Z->getInequalities();
1959
1960 gfan::ZMatrix e=Z->getEquations();
1962
1963 // assert(i.getWidth() == e.getWidth());
1964 return FALSE;
1965}
static void gfanZMatrixWriteFd(gfan::ZMatrix M, ssiInfo *dd)
Definition bbcone.cc:1931
@ STRING_CMD
Definition tok.h:185

◆ bbcone_setup()

void bbcone_setup ( SModulFunctions * p)

Definition at line 2101 of file bbcone.cc.

2102{
2103 blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
2104 // all undefined entries will be set to default in setBlackboxStuff
2105 // the default Print is quite usefull,
2106 // all other are simply error messages
2107 b->blackbox_destroy=bbcone_destroy;
2108 b->blackbox_String=bbcone_String;
2109 // b->blackbox_Print=blackbox_default_Print;
2110 b->blackbox_Init=bbcone_Init;
2111 b->blackbox_Copy=bbcone_Copy;
2112 b->blackbox_Assign=bbcone_Assign;
2113 b->blackbox_Op2=bbcone_Op2;
2114 b->blackbox_serialize=bbcone_serialize;
2115 b->blackbox_deserialize=bbcone_deserialize;
2116 p->iiAddCproc("gfan.lib","coneViaInequalities",FALSE,coneViaNormals);
2117 p->iiAddCproc("gfan.lib","coneViaPoints",FALSE,coneViaRays);
2118 p->iiAddCproc("","listContainsCone",FALSE,containsCone);
2119 // iiAddCproc("gfan.lib","makePolytope",FALSE,coneToPolytope);
2120 p->iiAddCproc("gfan.lib","ambientDimension",FALSE,ambientDimension);
2121 p->iiAddCproc("gfan.lib","canonicalizeCone",FALSE,canonicalizeCone);
2122 p->iiAddCproc("gfan.lib","codimension",FALSE,codimension);
2123 p->iiAddCproc("gfan.lib","coneLink",FALSE,coneLink);
2124 p->iiAddCproc("gfan.lib","containsAsFace",FALSE,hasFace);
2125 p->iiAddCproc("gfan.lib","containsInSupport",FALSE,containsInSupport);
2126 p->iiAddCproc("gfan.lib","containsPositiveVector",FALSE,containsPositiveVector);
2127 p->iiAddCproc("gfan.lib","containsRelatively",FALSE,containsRelatively);
2128 p->iiAddCproc("gfan.lib","convexHull",FALSE,convexHull);
2129 p->iiAddCproc("gfan.lib","convexIntersection",FALSE,intersectCones);
2130 p->iiAddCproc("gfan.lib","dimension",FALSE,dimension);
2131 p->iiAddCproc("gfan.lib","dualCone",FALSE,dualCone);
2132 p->iiAddCproc("gfan.lib","equations",FALSE,equations);
2133 p->iiAddCproc("gfan.lib","facets",FALSE,facets);
2134 p->iiAddCproc("gfan.lib","generatorsOfLinealitySpace",FALSE,generatorsOfLinealitySpace);
2135 p->iiAddCproc("gfan.lib","generatorsOfSpan",FALSE,generatorsOfSpan);
2136 p->iiAddCproc("gfan.lib","getLinearForms",FALSE,getLinearForms);
2137 p->iiAddCproc("gfan.lib","getMultiplicity",FALSE,getMultiplicity);
2138 p->iiAddCproc("gfan.lib","inequalities",FALSE,inequalities);
2139 p->iiAddCproc("gfan.lib","isFullSpace",FALSE,isFullSpace);
2140 p->iiAddCproc("gfan.lib","isOrigin",FALSE,isOrigin);
2141 p->iiAddCproc("gfan.lib","isSimplicial",FALSE,isSimplicial);
2142 p->iiAddCproc("gfan.lib","linealityDimension",FALSE,linealityDimension);
2143 p->iiAddCproc("gfan.lib","linealitySpace",FALSE,linealitySpace);
2144 p->iiAddCproc("gfan.lib","negatedCone",FALSE,negatedCone);
2145 p->iiAddCproc("gfan.lib","quotientLatticeBasis",FALSE,quotientLatticeBasis);
2146 p->iiAddCproc("gfan.lib","randomPoint",FALSE,randomPoint);
2147 p->iiAddCproc("gfan.lib","rays",FALSE,rays);
2148 p->iiAddCproc("gfan.lib","relativeInteriorPoint",FALSE,relativeInteriorPoint);
2149 p->iiAddCproc("gfan.lib","semigroupGenerator",FALSE,semigroupGenerator);
2150 p->iiAddCproc("gfan.lib","setLinearForms",FALSE,setLinearForms);
2151 p->iiAddCproc("gfan.lib","setMultiplicity",FALSE,setMultiplicity);
2152 p->iiAddCproc("gfan.lib","span",FALSE,impliedEquations);
2153 p->iiAddCproc("gfan.lib","uniquePoint",FALSE,uniquePoint);
2154 p->iiAddCproc("gfan.lib","faceContaining",FALSE,faceContaining);
2155 p->iiAddCproc("gfan.lib","onesVector",FALSE,onesVector);
2156 p->iiAddCproc("gfan.lib","convexIntersectionOld",FALSE,convexIntersectionOld);
2157 coneID=setBlackboxStuff(b,"cone");
2158}
BOOLEAN getMultiplicity(leftv res, leftv args)
Definition bbcone.cc:850
BOOLEAN isFullSpace(leftv res, leftv args)
Definition bbcone.cc:884
BOOLEAN canonicalizeCone(leftv res, leftv args)
Definition bbcone.cc:1678
BOOLEAN bbcone_deserialize(blackbox **b, void **d, si_link f)
Definition bbcone.cc:1993
BOOLEAN quotientLatticeBasis(leftv res, leftv args)
Definition bbcone.cc:689
void * bbcone_Init(blackbox *)
Definition bbcone.cc:80
BOOLEAN onesVector(leftv res, leftv args)
Definition bbcone.cc:1776
BOOLEAN convexIntersectionOld(leftv res, leftv args)
Definition bbcone.cc:2010
BOOLEAN getLinearForms(leftv res, leftv args)
Definition bbcone.cc:706
BOOLEAN codimension(leftv res, leftv args)
Definition bbcone.cc:791
void bbcone_destroy(blackbox *, void *d)
Definition bbcone.cc:148
BOOLEAN facets(leftv res, leftv args)
Definition bbcone.cc:594
BOOLEAN impliedEquations(leftv res, leftv args)
Definition bbcone.cc:611
BOOLEAN uniquePoint(leftv res, leftv args)
Definition bbcone.cc:1038
BOOLEAN isSimplicial(leftv res, leftv args)
Definition bbcone.cc:901
BOOLEAN ambientDimension(leftv res, leftv args)
Definition bbcone.cc:723
BOOLEAN bbcone_Assign(leftv l, leftv r)
Definition bbcone.cc:85
BOOLEAN coneLink(leftv res, leftv args)
Definition bbcone.cc:1484
BOOLEAN containsCone(leftv res, leftv args)
Definition bbcone.cc:1696
BOOLEAN negatedCone(leftv res, leftv args)
Definition bbcone.cc:979
BOOLEAN generatorsOfSpan(leftv res, leftv args)
Definition bbcone.cc:628
BOOLEAN equations(leftv res, leftv args)
Definition bbcone.cc:577
char * bbcone_String(blackbox *, void *d)
Definition bbcone.cc:138
BOOLEAN containsRelatively(leftv res, leftv args)
Definition bbcone.cc:1597
BOOLEAN containsPositiveVector(leftv res, leftv args)
Definition bbcone.cc:928
BOOLEAN semigroupGenerator(leftv res, leftv args)
Definition bbcone.cc:996
BOOLEAN dimension(leftv res, leftv args)
Definition bbcone.cc:757
BOOLEAN coneViaNormals(leftv res, leftv args)
Definition bbcone.cc:352
BOOLEAN faceContaining(leftv res, leftv args)
Definition bbcone.cc:1735
BOOLEAN setMultiplicity(leftv res, leftv args)
Definition bbcone.cc:1114
BOOLEAN bbcone_serialize(blackbox *b, void *d, si_link f)
Definition bbcone.cc:1944
BOOLEAN generatorsOfLinealitySpace(leftv res, leftv args)
Definition bbcone.cc:645
BOOLEAN containsInSupport(leftv res, leftv args)
Definition bbcone.cc:1533
void * bbcone_Copy(blackbox *, void *d)
Definition bbcone.cc:157
BOOLEAN dualCone(leftv res, leftv args)
Definition bbcone.cc:962
BOOLEAN isOrigin(leftv res, leftv args)
Definition bbcone.cc:867
gfan::ZVector randomPoint(const gfan::ZCone *zc, const int b)
Definition bbcone.cc:1069
BOOLEAN inequalities(leftv res, leftv args)
Definition bbcone.cc:560
BOOLEAN setLinearForms(leftv res, leftv args)
Definition bbcone.cc:1136
BOOLEAN linealityDimension(leftv res, leftv args)
Definition bbcone.cc:825
BOOLEAN hasFace(leftv res, leftv args)
Definition bbcone.cc:1641
BOOLEAN relativeInteriorPoint(leftv res, leftv args)
Definition bbcone.cc:1021
static BOOLEAN bbcone_Op2(int op, leftv res, leftv i1, leftv i2)
Definition bbcone.cc:164
BOOLEAN linealitySpace(leftv res, leftv args)
Definition bbcone.cc:945
BOOLEAN coneViaRays(leftv res, leftv args)
Definition bbcone.cc:523
BOOLEAN intersectCones(leftv res, leftv args)
Definition bbcone.cc:1209
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition blackbox.cc:143
int p
Definition cfModGcd.cc:4077
#define omAlloc0(size)

◆ bbcone_String()

char * bbcone_String ( blackbox * ,
void * d )

Definition at line 138 of file bbcone.cc.

139{
140 if (d==NULL) return omStrDup("invalid object");
141 else
142 {
143 std::string s=toString((gfan::ZCone*) d);
144 return omStrDup(s.c_str());
145 }
146}
std::string toString(const gfan::ZCone *const c)
Definition bbcone.cc:27
const CanonicalForm int s
Definition facAbsFact.cc:51
#define omStrDup(s)

◆ canonicalizeCone()

BOOLEAN canonicalizeCone ( leftv res,
leftv args )

Definition at line 1678 of file bbcone.cc.

1679{
1680 leftv u=args;
1681 if ((u != NULL) && (u->Typ() == coneID))
1682 {
1684 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1685 gfan::ZCone* zd = new gfan::ZCone(*zc);
1686 zd->canonicalize();
1687 res->rtyp = coneID;
1688 res->data = (void*) zd;
1690 return FALSE;
1691 }
1692 WerrorS("canonicalizeCone: unexpected parameters");
1693 return TRUE;
1694}

◆ codimension()

BOOLEAN codimension ( leftv res,
leftv args )

Definition at line 791 of file bbcone.cc.

792{
793 leftv u=args;
794 if ((u != NULL) && (u->Typ() == coneID))
795 {
797 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
798 res->rtyp = INT_CMD;
799 res->data = (void*) (long) zc->codimension();
801 return FALSE;
802 }
803 if ((u != NULL) && (u->Typ() == fanID))
804 {
806 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
807 res->rtyp = INT_CMD;
808 res->data = (void*) (long) getCodimension(zf);
810 return FALSE;
811 }
812 if ((u != NULL) && (u->Typ() == polytopeID))
813 {
815 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
816 res->rtyp = INT_CMD;
817 res->data = (void*) (long) getCodimension(zc);
819 return FALSE;
820 }
821 WerrorS("getCodimension: unexpected parameters");
822 return TRUE;
823}
int getCodimension(gfan::ZFan *zf)
Definition bbfan.cc:251

◆ coneLink()

BOOLEAN coneLink ( leftv res,
leftv args )

Definition at line 1484 of file bbcone.cc.

1485{
1486 leftv u = args;
1487 if ((u != NULL) && (u->Typ() == coneID))
1488 {
1489 leftv v = u->next;
1490 if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
1491 {
1493 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1494 bigintmat* iv = NULL;
1495 if (v->Typ() == INTVEC_CMD)
1496 {
1497 intvec* iv0 = (intvec*) v->Data();
1499 }
1500 else
1501 iv = (bigintmat*)v->Data();
1503 int d1 = zc->ambientDimension();
1504 int d2 = zv->size();
1505 if (d1 != d2)
1506 {
1507 Werror("expected ambient dim of cone and size of vector\n"
1508 " to be equal but got %d and %d", d1, d2);
1510 return TRUE;
1511 }
1512 if(!zc->contains(*zv))
1513 {
1514 WerrorS("the provided intvec does not lie in the cone");
1516 return TRUE;
1517 }
1518 gfan::ZCone* zd = new gfan::ZCone(zc->link(*zv));
1519 res->rtyp = coneID;
1520 res->data = (void *) zd;
1521
1522 delete zv;
1523 if (v->Typ() == INTVEC_CMD)
1524 delete iv;
1526 return FALSE;
1527 }
1528 }
1529 WerrorS("coneLink: unexpected parameters");
1530 return TRUE;
1531}
bigintmat * iv2bim(intvec *b, const coeffs C)
Definition bigintmat.cc:349
gfan::ZVector * bigintmatToZVector(const bigintmat &bim)
Matrices of numbers.
Definition bigintmat.h:51
bigintmat * transpose()
Definition bigintmat.cc:37
leftv next
Definition subexpr.h:86
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
@ BIGINTMAT_CMD
Definition grammar.cc:278
VAR coeffs coeffs_BIGINT
Definition ipid.cc:50
@ INTVEC_CMD
Definition tok.h:101

◆ coneToPolytope()

BOOLEAN coneToPolytope ( leftv res,
leftv args )

Definition at line 1190 of file bbcone.cc.

1191{
1192 leftv u = args;
1193 if ((u != NULL) && (u->Typ() == coneID))
1194 {
1196 gfan::ZCone* zc = (gfan::ZCone*) u->Data();
1197 gfan::ZMatrix ineq=zc->getInequalities();
1198 gfan::ZMatrix eq=zc->getEquations();
1200 res->rtyp = polytopeID;
1201 res->data = (void*) zd;
1203 return FALSE;
1204 }
1205 WerrorS("makePolytope: unexpected parameters");
1206 return TRUE;
1207}
gfan::ZMatrix liftUp(const gfan::ZMatrix &zm)
Definition bbcone.cc:1170

◆ coneViaNormals()

BOOLEAN coneViaNormals ( leftv res,
leftv args )

Definition at line 352 of file bbcone.cc.

353{
355 leftv u = args;
356 if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
357 {
358 if (u->next == NULL)
359 {
362 return bo;
363 }
364 }
365 leftv v = u->next;
366 if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTMAT_CMD)))
367 {
368 if (v->next == NULL)
369 {
372 return bo;
373 }
374 }
375 leftv w = v->next;
376 if ((w != NULL) && (w->Typ() == INT_CMD))
377 {
378 if (w->next == NULL)
379 {
380 BOOLEAN bo = jjCONENORMALS3(res, u, v, w);
382 return bo;
383 }
384 }
385 WerrorS("coneViaInequalities: unexpected parameters");
386 return TRUE;
387}
int BOOLEAN
Definition auxiliary.h:87
static BOOLEAN jjCONENORMALS1(leftv res, leftv v)
Definition bbcone.cc:237
static BOOLEAN jjCONENORMALS3(leftv res, leftv u, leftv v, leftv w)
Definition bbcone.cc:302
static BOOLEAN jjCONENORMALS2(leftv res, leftv u, leftv v)
Definition bbcone.cc:259
Variable next() const
Definition factory.h:146
const CanonicalForm & w
Definition facAbsFact.cc:51
@ INTMAT_CMD
Definition grammar.cc:279

◆ coneViaRays()

BOOLEAN coneViaRays ( leftv res,
leftv args )

Definition at line 523 of file bbcone.cc.

524{
526 leftv u = args;
527 if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
528 {
529 if (u->next == NULL)
530 {
533 return bo;
534 }
535 leftv v = u->next;
536 if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTMAT_CMD)))
537 {
538 if (v->next == NULL)
539 {
540 BOOLEAN bo = jjCONERAYS2(res, u, v);
542 return bo;
543 }
544 leftv w = v->next;
545 if ((w != NULL) && (w->Typ() == INT_CMD))
546 {
547 if (w->next == NULL)
548 {
549 BOOLEAN bo = jjCONERAYS3(res, u, v, w);
551 return bo;
552 }
553 }
554 }
555 }
556 WerrorS("coneViaPoints: unexpected parameters");
557 return TRUE;
558}
static BOOLEAN jjCONERAYS3(leftv res, leftv u, leftv v, leftv w)
Definition bbcone.cc:464
static BOOLEAN jjCONERAYS1(leftv res, leftv v)
Definition bbcone.cc:389
static BOOLEAN jjCONERAYS2(leftv res, leftv u, leftv v)
Definition bbcone.cc:416

◆ containsCone()

BOOLEAN containsCone ( leftv res,
leftv args )

Definition at line 1696 of file bbcone.cc.

1697{
1698 leftv u=args;
1699 if ((u != NULL) && (u->Typ() == LIST_CMD))
1700 {
1701 leftv v=u->next;
1702 if ((v != NULL) && (v->Typ() == coneID))
1703 {
1705 lists l = (lists) u->Data();
1706 gfan::ZCone* zc = (gfan::ZCone*) v->Data();
1707 zc->canonicalize();
1708 int b = 0;
1709 for (int i=0; i<=lSize(l); i++)
1710 {
1711 if (l->m[i].Typ() != coneID)
1712 {
1713 WerrorS("containsCone: entries of wrong type in list");
1715 return TRUE;
1716 }
1717 gfan::ZCone* ll = (gfan::ZCone*) l->m[i].Data();
1718 ll->canonicalize();
1719 if (!((*ll) != (*zc)))
1720 {
1721 b = 1;
1722 break;
1723 }
1724 }
1725 res->rtyp = INT_CMD;
1726 res->data = (char*) (long) b;
1728 return FALSE;
1729 }
1730 }
1731 WerrorS("containsCone: unexpected parameters");
1732 return TRUE;
1733}
Definition lists.h:24
int lSize(lists L)
Definition lists.cc:25
slists * lists
@ LIST_CMD
Definition tok.h:118

◆ containsInSupport()

BOOLEAN containsInSupport ( leftv res,
leftv args )

Definition at line 1533 of file bbcone.cc.

1534{
1535 leftv u=args;
1536 if ((u != NULL) && (u->Typ() == coneID))
1537 {
1538 leftv v=u->next;
1539 if ((v != NULL) && (v->Typ() == coneID))
1540 {
1542 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1543 gfan::ZCone* zd = (gfan::ZCone*)v->Data();
1544 int d1 = zc->ambientDimension();
1545 int d2 = zd->ambientDimension();
1546 if (d1 != d2)
1547 {
1548 Werror("expected cones with same ambient dimensions\n but got"
1549 " dimensions %d and %d", d1, d2);
1551 return TRUE;
1552 }
1553 bool b = (zc->contains(*zd) ? 1 : 0);
1554 res->rtyp = INT_CMD;
1555 res->data = (void*) (long) b;
1557 return FALSE;
1558 }
1559 if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
1560 {
1562 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1563 bigintmat* iv = NULL;
1564 if (v->Typ() == INTVEC_CMD)
1565 {
1566 intvec* iv0 = (intvec*) v->Data();
1568 }
1569 else
1570 iv = (bigintmat*)v->Data();
1571
1573 int d1 = zc->ambientDimension();
1574 int d2 = zv->size();
1575 if (d1 != d2)
1576 {
1577 Werror("expected cones with same ambient dimensions\n but got"
1578 " dimensions %d and %d", d1, d2);
1580 return TRUE;
1581 }
1582 int b = zc->contains(*zv);
1583 res->rtyp = INT_CMD;
1584 res->data = (void*) (long) b;
1585
1586 delete zv;
1587 if (v->Typ() == INTVEC_CMD)
1588 delete iv;
1590 return FALSE;
1591 }
1592 }
1593 WerrorS("containsInSupport: unexpected parameters");
1594 return TRUE;
1595}

◆ containsPositiveVector()

BOOLEAN containsPositiveVector ( leftv res,
leftv args )

Definition at line 928 of file bbcone.cc.

929{
930 leftv u = args;
931 if ((u != NULL) && (u->Typ() == coneID))
932 {
934 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
935 int i = zc->containsPositiveVector();
936 res->rtyp = INT_CMD;
937 res->data = (void*) (long) i;
939 return FALSE;
940 }
941 WerrorS("containsPositiveVector: unexpected parameters");
942 return TRUE;
943}

◆ containsRelatively()

BOOLEAN containsRelatively ( leftv res,
leftv args )

Definition at line 1597 of file bbcone.cc.

1598{
1599 leftv u = args;
1600 if ((u != NULL) && (u->Typ() == coneID))
1601 {
1602 leftv v = u->next;
1603 if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
1604 {
1606 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1607 bigintmat* iv = NULL;
1608 if (v->Typ() == INTVEC_CMD)
1609 {
1610 intvec* iv0 = (intvec*) v->Data();
1612 }
1613 else
1614 iv = (bigintmat*)v->Data();
1616 int d1 = zc->ambientDimension();
1617 int d2 = zv->size();
1618 if (d1 == d2)
1619 {
1620 bool b = (zc->containsRelatively(*zv) ? 1 : 0);
1621 res->rtyp = INT_CMD;
1622 res->data = (void *) b;
1623 delete zv;
1624 if (v->Typ() == INTVEC_CMD)
1625 delete iv;
1627 return FALSE;
1628 }
1629 delete zv;
1630 if (v->Typ() == INTVEC_CMD)
1631 delete iv;
1633 Werror("expected ambient dim of cone and size of vector\n"
1634 "to be equal but got %d and %d", d1, d2);
1635 }
1636 }
1637 WerrorS("containsRelatively: unexpected parameters");
1638 return TRUE;
1639}

◆ convexHull()

BOOLEAN convexHull ( leftv res,
leftv args )

Definition at line 1366 of file bbcone.cc.

1367{
1368 leftv u = args;
1369 if ((u != NULL) && (u->Typ() == coneID))
1370 {
1371 leftv v = u->next;
1372 if ((v != NULL) && (v->Typ() == coneID))
1373 {
1375 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
1376 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
1377 int d1 = zc1->ambientDimension();
1378 int d2 = zc2->ambientDimension();
1379 if (d1 != d2)
1380 {
1381 Werror("expected ambient dims of both cones to coincide\n"
1382 "but got %d and %d", d1, d2);
1384 return TRUE;
1385 }
1386 gfan::ZMatrix zm1 = zc1->extremeRays();
1387 gfan::ZMatrix zm2 = zc2->extremeRays();
1388 gfan::ZMatrix zn1 = zc1->generatorsOfLinealitySpace();
1389 gfan::ZMatrix zn2 = zc2->generatorsOfLinealitySpace();
1392 gfan::ZCone* zc = new gfan::ZCone();
1393 *zc = gfan::ZCone::givenByRays(zm, zn);
1394 res->rtyp = coneID;
1395 res->data = (void*) zc;
1397 return FALSE;
1398 }
1399 if ((v != NULL) && (v->Typ() == polytopeID))
1400 {
1402 gfan::ZCone* zc11 = (gfan::ZCone*)u->Data();
1404 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
1405 int d1 = zc1.ambientDimension()-1;
1406 int d2 = zc2->ambientDimension()-1;
1407 if (d1 != d2)
1408 {
1409 Werror("expected ambient dims of both cones to coincide\n"
1410 "but got %d and %d", d1, d2);
1412 return TRUE;
1413 }
1414 gfan::ZMatrix zm1 = zc1.extremeRays();
1415 gfan::ZMatrix zm2 = zc2->extremeRays();
1416 gfan::ZMatrix zn = zc1.generatorsOfLinealitySpace();
1418 gfan::ZCone* zc = new gfan::ZCone();
1419 *zc = gfan::ZCone::givenByRays(zm, zn);
1420 res->rtyp = polytopeID;
1421 res->data = (void*) zc;
1423 return FALSE;
1424 }
1425 }
1426 if ((u != NULL) && (u->Typ() == polytopeID))
1427 {
1428 leftv v = u->next;
1429 if ((v != NULL) && (v->Typ() == coneID))
1430 {
1432 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
1433 gfan::ZCone* zc22 = (gfan::ZCone*)v->Data();
1435 int d1 = zc1->ambientDimension()-1;
1436 int d2 = zc2.ambientDimension()-1;
1437 if (d1 != d2)
1438 {
1439 Werror("expected ambient dims of both cones to coincide\n"
1440 "but got %d and %d", d1, d2);
1442 return TRUE;
1443 }
1444 gfan::ZMatrix zm1 = zc1->extremeRays();
1445 gfan::ZMatrix zm2 = zc2.extremeRays();
1446 gfan::ZMatrix zn = zc2.generatorsOfLinealitySpace();
1448 gfan::ZCone* zc = new gfan::ZCone();
1449 *zc = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
1450 res->rtyp = polytopeID;
1451 res->data = (void*) zc;
1453 return FALSE;
1454 }
1455 if ((v != NULL) && (v->Typ() == polytopeID))
1456 {
1458 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
1459 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
1460 int d1 = zc1->ambientDimension()-1;
1461 int d2 = zc2->ambientDimension()-1;
1462 if (d1 != d2)
1463 {
1464 Werror("expected ambient dims of both cones to coincide\n"
1465 "but got %d and %d", d1, d2);
1467 return TRUE;
1468 }
1469 gfan::ZMatrix zm1 = zc1->extremeRays();
1470 gfan::ZMatrix zm2 = zc2->extremeRays();
1472 gfan::ZCone* zc = new gfan::ZCone();
1473 *zc = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
1474 res->rtyp = polytopeID;
1475 res->data = (void*) zc;
1477 return FALSE;
1478 }
1479 }
1480 WerrorS("convexHull: unexpected parameters");
1481 return TRUE;
1482}

◆ convexIntersectionOld()

BOOLEAN convexIntersectionOld ( leftv res,
leftv args )

Definition at line 2010 of file bbcone.cc.

2011{
2013 leftv u = args;
2014 if ((u != NULL) && (u->Typ() == coneID))
2015 {
2016 leftv v = u->next;
2017 if ((v != NULL) && (v->Typ() == coneID))
2018 {
2019 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
2020 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
2021 int d1 = zc1->ambientDimension();
2022 int d2 = zc2->ambientDimension();
2023 if (d1 != d2)
2024 {
2025 Werror("expected ambient dims of both cones to coincide\n"
2026 "but got %d and %d", d1, d2);
2027 return TRUE;
2028 }
2030 zc3.canonicalize();
2031 res->rtyp = coneID;
2032 res->data = (void *)new gfan::ZCone(zc3);
2033 return FALSE;
2034 }
2035 if ((v != NULL) && (v->Typ() == polytopeID))
2036 {
2037 gfan::ZCone* zc11 = (gfan::ZCone*)u->Data();
2039 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
2040 int d1 = zc1.ambientDimension();
2041 int d2 = zc2->ambientDimension();
2042 if (d1 != d2)
2043 {
2044 Werror("expected ambient dims of both cones to coincide\n"
2045 "but got %d and %d", d1, d2);
2046 return TRUE;
2047 }
2049 zc3.canonicalize();
2050 res->rtyp = polytopeID;
2051 res->data = (void *)new gfan::ZCone(zc3);
2052 return FALSE;
2053 }
2054 }
2055 if ((u != NULL) && (u->Typ() == polytopeID))
2056 {
2057 leftv v = u->next;
2058 if ((v != NULL) && (v->Typ() == coneID))
2059 {
2060 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
2061 gfan::ZCone* zc22 = (gfan::ZCone*)v->Data();
2063 int d1 = zc1->ambientDimension();
2064 int d2 = zc2.ambientDimension();
2065 if (d1 != d2)
2066 {
2067 Werror("expected ambient dims of both cones to coincide\n"
2068 "but got %d and %d", d1, d2);
2069 return TRUE;
2070 }
2072 zc3.canonicalize();
2073 res->rtyp = polytopeID;
2074 res->data = (void *)new gfan::ZCone(zc3);
2075 return FALSE;
2076 }
2077 if ((v != NULL) && (v->Typ() == polytopeID))
2078 {
2079 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
2080 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
2081 int d1 = zc1->ambientDimension();
2082 int d2 = zc2->ambientDimension();
2083 if (d1 != d2)
2084 {
2085 Werror("expected ambient dims of both cones to coincide\n"
2086 "but got %d and %d", d1, d2);
2087 return TRUE;
2088 }
2090 zc3.canonicalize();
2091 res->rtyp = polytopeID;
2092 res->data = (void *)new gfan::ZCone(zc3);
2093 return FALSE;
2094 }
2095 }
2096 WerrorS("convexIntersectionOld: unexpected parameters");
2097 return TRUE;
2098}

◆ dimension()

BOOLEAN dimension ( leftv res,
leftv args )

Definition at line 757 of file bbcone.cc.

758{
759 leftv u=args;
760 if ((u != NULL) && (u->Typ() == coneID))
761 {
763 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
764 res->rtyp = INT_CMD;
765 res->data = (void*) (long) zc->dimension();
767 return FALSE;
768 }
769 if ((u != NULL) && (u->Typ() == fanID))
770 {
772 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
773 res->rtyp = INT_CMD;
774 res->data = (void*) (long) getDimension(zf);
776 return FALSE;
777 }
778 if ((u != NULL) && (u->Typ() == polytopeID))
779 {
781 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
782 res->rtyp = INT_CMD;
783 res->data = (void*) (long) getDimension(zc);
785 return FALSE;
786 }
787 WerrorS("dimension: unexpected parameters");
788 return TRUE;
789}
int getDimension(gfan::ZFan *zf)
Definition bbfan.cc:256

◆ dualCone()

BOOLEAN dualCone ( leftv res,
leftv args )

Definition at line 962 of file bbcone.cc.

963{
964 leftv u = args;
965 if ((u != NULL) && (u->Typ() == coneID))
966 {
968 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
969 gfan::ZCone* zd = new gfan::ZCone(zc->dualCone());
970 res->rtyp = coneID;
971 res->data = (void*) zd;
973 return FALSE;
974 }
975 WerrorS("dual: unexpected parameters");
976 return TRUE;
977}

◆ equations()

BOOLEAN equations ( leftv res,
leftv args )

Definition at line 577 of file bbcone.cc.

578{
579 leftv u = args;
580 if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
581 {
583 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
584 gfan::ZMatrix zmat = zc->getEquations();
585 res->rtyp = BIGINTMAT_CMD;
586 res->data = (void*) zMatrixToBigintmat(zmat);
588 return FALSE;
589 }
590 WerrorS("equations: unexpected parameters");
591 return TRUE;
592}
bigintmat * zMatrixToBigintmat(const gfan::ZMatrix &zm)

◆ faceContaining()

BOOLEAN faceContaining ( leftv res,
leftv args )

Definition at line 1735 of file bbcone.cc.

1736{
1737 leftv u = args;
1738 if ((u != NULL) && (u->Typ() == coneID))
1739 {
1740 leftv v = u->next;
1741 if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
1742 {
1744 gfan::ZCone* zc = (gfan::ZCone*) u->Data();
1745
1747 if (v->Typ() == INTVEC_CMD)
1748 {
1749 intvec* point0 = (intvec*) v->Data();
1751 }
1752 else
1753 point1 = (bigintmat*) v->Data();
1755
1756 if (!zc->contains(*point))
1757 {
1758 WerrorS("faceContaining: point not in cone");
1759 return TRUE;
1760 }
1761 res->rtyp = coneID;
1762 res->data = (void*) new gfan::ZCone(zc->faceContaining(*point));
1763
1764 delete point;
1765 if (v->Typ() == INTVEC_CMD)
1766 delete point1;
1768 return FALSE;
1769 }
1770 }
1771 WerrorS("faceContaining: unexpected parameters");
1772 return TRUE;
1773}

◆ facets()

BOOLEAN facets ( leftv res,
leftv args )

Definition at line 594 of file bbcone.cc.

595{
596 leftv u = args;
597 if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
598 {
600 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
601 gfan::ZMatrix zm = zc->getFacets();
602 res->rtyp = BIGINTMAT_CMD;
603 res->data = (void*) zMatrixToBigintmat(zm);
605 return FALSE;
606 }
607 WerrorS("facets: unexpected parameters");
608 return TRUE;
609}

◆ generatorsOfLinealitySpace()

BOOLEAN generatorsOfLinealitySpace ( leftv res,
leftv args )

Definition at line 645 of file bbcone.cc.

646{
647 leftv u = args;
648 if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
649 {
651 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
652 gfan::ZMatrix zmat = zc->generatorsOfLinealitySpace();
653 res->rtyp = BIGINTMAT_CMD;
654 res->data = (void*) zMatrixToBigintmat(zmat);
656 return FALSE;
657 }
658 WerrorS("generatorsOfLinealitySpace: unexpected parameters");
659 return TRUE;
660}

◆ generatorsOfSpan()

BOOLEAN generatorsOfSpan ( leftv res,
leftv args )

Definition at line 628 of file bbcone.cc.

629{
630 leftv u = args;
631 if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
632 {
634 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
635 gfan::ZMatrix zmat = zc->generatorsOfSpan();
636 res->rtyp = BIGINTMAT_CMD;
637 res->data = (void*) zMatrixToBigintmat(zmat);
639 return FALSE;
640 }
641 WerrorS("generatorsOfSpan: unexpected parameters");
642 return TRUE;
643}

◆ getLinearForms()

BOOLEAN getLinearForms ( leftv res,
leftv args )

Definition at line 706 of file bbcone.cc.

707{
708 leftv u = args;
709 if ((u != NULL) && (u->Typ() == coneID))
710 {
712 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
713 gfan::ZMatrix zmat = zc->getLinearForms();
714 res->rtyp = BIGINTMAT_CMD;
715 res->data = (void*) zMatrixToBigintmat(zmat);
717 return FALSE;
718 }
719 WerrorS("getLinearForms: unexpected parameters");
720 return TRUE;
721}

◆ getMultiplicity()

BOOLEAN getMultiplicity ( leftv res,
leftv args )

Definition at line 850 of file bbcone.cc.

851{
852 leftv u = args;
853 if ((u != NULL) && (u->Typ() == coneID))
854 {
856 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
857 number i = integerToNumber(zc->getMultiplicity());
858 res->rtyp = BIGINT_CMD;
859 res->data = (void*) i;
861 return FALSE;
862 }
863 WerrorS("getMultiplicity: unexpected parameters");
864 return TRUE;
865}
number integerToNumber(const gfan::Integer &I)
@ BIGINT_CMD
Definition tok.h:38

◆ gfanIntegerReadFd()

static gfan::Integer gfanIntegerReadFd ( ssiInfo * dd)
static

Definition at line 1967 of file bbcone.cc.

1968{
1969 mpz_t tmp;
1970 mpz_init(tmp);
1971 s_readmpz_base(dd->f_read,tmp,SSI_BASE);
1972 gfan::Integer n(tmp);
1973 mpz_clear(tmp);
1974 return n;
1975}
#define SSI_BASE
Definition auxiliary.h:135
void s_readmpz_base(s_buff F, mpz_ptr a, int base)
Definition s_buff.cc:209

◆ gfanIntegerWriteFd()

static void gfanIntegerWriteFd ( gfan::Integer n,
ssiInfo * dd )
static

Definition at line 1921 of file bbcone.cc.

1922{
1923 mpz_t tmp;
1924 mpz_init(tmp);
1925 n.setGmp(tmp);
1926 mpz_out_str (dd->f_write,SSI_BASE, tmp);
1927 mpz_clear(tmp);
1928 fputc(' ',dd->f_write);
1929}

◆ gfanZMatrixReadFd()

static gfan::ZMatrix gfanZMatrixReadFd ( ssiInfo * dd)
static

Definition at line 1977 of file bbcone.cc.

1978{
1979 int r=s_readint(dd->f_read);
1980 int c=s_readint(dd->f_read);
1981
1982 gfan::ZMatrix M(r,c);
1983 for (int i=0; i<r; i++)
1984 {
1985 for (int j=0; j<c; j++)
1986 {
1987 M[i][j] = gfanIntegerReadFd(dd);
1988 }
1989 }
1990 return M;
1991}
static gfan::Integer gfanIntegerReadFd(ssiInfo *dd)
Definition bbcone.cc:1967
int j
Definition facHensel.cc:110
#define M
Definition sirandom.c:25

◆ gfanZMatrixWriteFd()

static void gfanZMatrixWriteFd ( gfan::ZMatrix M,
ssiInfo * dd )
static

Definition at line 1931 of file bbcone.cc.

1932{
1933 fprintf(dd->f_write,"%d %d ",M.getHeight(),M.getWidth());
1934
1935 for (int i=0; i<M.getHeight(); i++)
1936 {
1937 for (int j=0; j<M.getWidth(); j++)
1938 {
1940 }
1941 }
1942}
static void gfanIntegerWriteFd(gfan::Integer n, ssiInfo *dd)
Definition bbcone.cc:1921

◆ hasFace()

BOOLEAN hasFace ( leftv res,
leftv args )

Definition at line 1641 of file bbcone.cc.

1642{
1643 leftv u=args;
1644 if ((u != NULL) && (u->Typ() == coneID))
1645 {
1646 leftv v=u->next;
1647 if ((v != NULL) && (v->Typ() == coneID))
1648 {
1650 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1651 gfan::ZCone* zd = (gfan::ZCone*)v->Data();
1652 bool b = zc->hasFace(*zd);
1653 res->rtyp = INT_CMD;
1654 res->data = (void*) (long) b;
1656 return FALSE;
1657 }
1658 }
1659 if ((u != NULL) && (u->Typ() == polytopeID))
1660 {
1661 leftv v=u->next;
1662 if ((v != NULL) && (v->Typ() == polytopeID))
1663 {
1665 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1666 gfan::ZCone* zd = (gfan::ZCone*)v->Data();
1667 bool b = zc->hasFace(*zd);
1668 res->rtyp = INT_CMD;
1669 res->data = (void*) (long) b;
1671 return FALSE;
1672 }
1673 }
1674 WerrorS("containsAsFace: unexpected parameters");
1675 return TRUE;
1676}

◆ impliedEquations()

BOOLEAN impliedEquations ( leftv res,
leftv args )

Definition at line 611 of file bbcone.cc.

612{
613 leftv u = args;
614 if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
615 {
617 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
618 gfan::ZMatrix zmat = zc->getImpliedEquations();
619 res->rtyp = BIGINTMAT_CMD;
620 res->data = (void*) zMatrixToBigintmat(zmat);
622 return FALSE;
623 }
624 WerrorS("span: unexpected parameters");
625 return TRUE;
626}

◆ inequalities()

BOOLEAN inequalities ( leftv res,
leftv args )

Definition at line 560 of file bbcone.cc.

561{
562 leftv u = args;
563 if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
564 {
566 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
567 gfan::ZMatrix zmat = zc->getInequalities();
568 res->rtyp = BIGINTMAT_CMD;
569 res->data = (void*) zMatrixToBigintmat(zmat);
571 return FALSE;
572 }
573 WerrorS("inequalities: unexpected parameters");
574 return TRUE;
575}

◆ interiorPointsAndNormalsOfFacets()

std::pair< gfan::ZMatrix, gfan::ZMatrix > interiorPointsAndNormalsOfFacets ( const gfan::ZCone zc,
const std::set< gfan::ZVector > & exceptThesePoints,
const bool onlyLowerHalfSpace )

Definition at line 1853 of file bbcone.cc.

1854{
1855 gfan::ZMatrix inequalities = zc.getFacets();
1856 gfan::ZMatrix equations = zc.getImpliedEquations();
1857 int r = inequalities.getHeight();
1858 int c = inequalities.getWidth();
1859
1860 /* our cone has r facets, if r==0 return empty matrices */
1863 if (r==0)
1864 return std::make_pair(relativeInteriorPoints,outerFacetNormals);
1865
1866 /* next we iterate over each of the r facets,
1867 * build the respective cone and add it to the list
1868 * this is the i=0 case */
1869 gfan::ZMatrix newInequalities = inequalities.submatrix(1,0,r,c);
1871 newEquations.appendRow(inequalities[0]);
1873 gfan::ZVector interiorPoint = facet.getRelativeInteriorPoint();
1874 if (onlyLowerHalfSpace==false || interiorPoint[0].sign()<0)
1875 {
1876 if (exceptThesePoints.count(interiorPoint)==0)
1877 {
1878 relativeInteriorPoints.appendRow(interiorPoint);
1879 outerFacetNormals.appendRow(-inequalities[0].toVector());
1880 }
1881 }
1882
1883 /* these are the cases i=1,...,r-2 */
1884 for (int i=1; i<r-1; i++)
1885 {
1886 newInequalities = inequalities.submatrix(0,0,i,c);
1887 newInequalities.append(inequalities.submatrix(i+1,0,r,c));
1889 newEquations.appendRow(inequalities[i]);
1891 interiorPoint = facet.getRelativeInteriorPoint();
1892 if (onlyLowerHalfSpace==false || interiorPoint[0].sign()<0)
1893 {
1894 if (exceptThesePoints.count(interiorPoint)==0)
1895 {
1896 relativeInteriorPoints.appendRow(interiorPoint);
1898 }
1899 }
1900 }
1901
1902 /* this is the i=r-1 case */
1903 newInequalities = inequalities.submatrix(0,0,r-1,c);
1905 newEquations.appendRow(inequalities[r-1]);
1907 interiorPoint = facet.getRelativeInteriorPoint();
1908 if (onlyLowerHalfSpace==false || interiorPoint[0].sign()<0)
1909 {
1910 if (exceptThesePoints.count(interiorPoint)==0)
1911 {
1912 relativeInteriorPoints.appendRow(interiorPoint);
1913 outerFacetNormals.appendRow(-inequalities[r-1].toVector());
1914 }
1915 }
1916
1917 return std::make_pair(relativeInteriorPoints,outerFacetNormals);
1918}
Definition gfan.h:47
static int sign(int x)
Definition ring.cc:3436

◆ interiorPointsOfFacets()

gfan::ZMatrix interiorPointsOfFacets ( const gfan::ZCone & zc,
const std::set< gfan::ZVector > & exceptThese )

Definition at line 1799 of file bbcone.cc.

1800{
1801 gfan::ZMatrix inequalities = zc.getFacets();
1802 gfan::ZMatrix equations = zc.getImpliedEquations();
1803 int r = inequalities.getHeight();
1804 int c = inequalities.getWidth();
1805
1806 /* our cone has r facets, if r==0 return empty matrices */
1808 if (r==0) return relativeInteriorPoints;
1809
1810 /* next we iterate over each of the r facets,
1811 * build the respective cone and add it to the list
1812 * this is the i=0 case */
1813 gfan::ZMatrix newInequalities = inequalities.submatrix(1,0,r,c);
1815 newEquations.appendRow(inequalities[0]);
1817 facet.canonicalize();
1818 gfan::ZVector interiorPoint = facet.getRelativeInteriorPoint();
1819 if (exceptThese.count(interiorPoint)==0)
1820 relativeInteriorPoints.appendRow(interiorPoint);
1821
1822 /* these are the cases i=1,...,r-2 */
1823 for (int i=1; i<r-1; i++)
1824 {
1825 newInequalities = inequalities.submatrix(0,0,i,c);
1826 newInequalities.append(inequalities.submatrix(i+1,0,r,c));
1828 newEquations.appendRow(inequalities[i]);
1830 facet.canonicalize();
1831 interiorPoint = facet.getRelativeInteriorPoint();
1832 if (exceptThese.count(interiorPoint)==0)
1833 relativeInteriorPoints.appendRow(interiorPoint);
1834 }
1835
1836 /* this is the i=r-1 case */
1837 newInequalities = inequalities.submatrix(0,0,r-1,c);
1839 newEquations.appendRow(inequalities[r-1]);
1841 facet.canonicalize();
1842 interiorPoint = facet.getRelativeInteriorPoint();
1843 if (exceptThese.count(interiorPoint)==0)
1844 relativeInteriorPoints.appendRow(interiorPoint);
1845
1847}

◆ intersectCones()

BOOLEAN intersectCones ( leftv res,
leftv args )

Definition at line 1209 of file bbcone.cc.

1210{
1211 leftv u = args;
1212 if ((u != NULL) && (u->Typ() == coneID))
1213 {
1214 leftv v = u->next;
1215 if ((v != NULL) && (v->Typ() == coneID))
1216 {
1218 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
1219 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
1220 int d1 = zc1->ambientDimension();
1221 int d2 = zc2->ambientDimension();
1222 if (d1 != d2)
1223 {
1224 Werror("expected ambient dims of both cones to coincide\n"
1225 "but got %d and %d", d1, d2);
1227 return TRUE;
1228 }
1230 zc3.canonicalize();
1231 res->rtyp = coneID;
1232 res->data = (void *)new gfan::ZCone(zc3);
1234 return FALSE;
1235 }
1236 if ((v != NULL) && (v->Typ() == polytopeID))
1237 {
1239 gfan::ZCone* zc11 = (gfan::ZCone*)u->Data();
1241 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
1242 int d1 = zc1.ambientDimension();
1243 int d2 = zc2->ambientDimension();
1244 if (d1 != d2)
1245 {
1246 Werror("expected ambient dims of both cones to coincide\n"
1247 "but got %d and %d", d1, d2);
1249 return TRUE;
1250 }
1252 zc3.canonicalize();
1253 res->rtyp = polytopeID;
1254 res->data = (void *)new gfan::ZCone(zc3);
1256 return FALSE;
1257 }
1258 }
1259 if ((u != NULL) && (u->Typ() == LIST_CMD))
1260 {
1261 if (u->next == NULL)
1262 {
1263 lists l = (lists) u->Data();
1264
1265 // find the total number of inequalities and equations
1266 int r1=0; // total number of inequalities
1267 int r2=0; // total number of equations
1268 int c=0; // ambient dimension
1269 for (int i=0; i<=lSize(l); i++)
1270 {
1271 if (l->m[i].Typ() != coneID)
1272 {
1273 WerrorS("convexIntersection: entries of wrong type in list");
1274 return TRUE;
1275 }
1276 gfan::ZCone* ll = (gfan::ZCone*) l->m[i].Data();
1277 r1 = r1 + ll->getInequalities().getHeight();
1278 r2 = r2 + ll->getEquations().getHeight();
1279 }
1280 if (lSize(l)>=0)
1281 {
1282 gfan::ZCone* ll = (gfan::ZCone*) l->m[0].Data();
1283 c = ll->getInequalities().getWidth();
1284 }
1287
1288 // concat all inequalities and equations
1289 r1=0; // counter for inequalities
1290 r2=0; // counter for equations
1291 for (int i=0; i<=lSize(l); i++)
1292 {
1293 gfan::ZCone* ll = (gfan::ZCone*) l->m[i].Data();
1294 gfan::ZMatrix ineqs = ll->getInequalities();
1295 for (int j=0; j<ineqs.getHeight(); j++)
1296 {
1297 totalIneqs[r1]=ineqs[j];
1298 r1 = r1+1;
1299 }
1300 gfan::ZMatrix eqs = ll->getEquations();
1301 for (int j=0; j<eqs.getHeight(); j++)
1302 {
1303 totalEqs[r2]=eqs[j];
1304 r2 = r2+1;
1305 }
1306 }
1307
1309 zc->canonicalize();
1310 res->rtyp = coneID;
1311 res->data = (void *) zc;
1312 return FALSE;
1313 }
1314 }
1315 if ((u != NULL) && (u->Typ() == polytopeID))
1316 {
1317 leftv v = u->next;
1318 if ((v != NULL) && (v->Typ() == coneID))
1319 {
1321 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
1322 gfan::ZCone* zc22 = (gfan::ZCone*)v->Data();
1324 int d1 = zc1->ambientDimension();
1325 int d2 = zc2.ambientDimension();
1326 if (d1 != d2)
1327 {
1328 Werror("expected ambient dims of both cones to coincide\n"
1329 "but got %d and %d", d1, d2);
1331 return TRUE;
1332 }
1334 zc3.canonicalize();
1335 res->rtyp = polytopeID;
1336 res->data = (void *)new gfan::ZCone(zc3);
1338 return FALSE;
1339 }
1340 if ((v != NULL) && (v->Typ() == polytopeID))
1341 {
1343 gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
1344 gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
1345 int d1 = zc1->ambientDimension();
1346 int d2 = zc2->ambientDimension();
1347 if (d1 != d2)
1348 {
1349 Werror("expected ambient dims of both cones to coincide\n"
1350 "but got %d and %d", d1, d2);
1352 return TRUE;
1353 }
1355 zc3.canonicalize();
1356 res->rtyp = polytopeID;
1357 res->data = (void *)new gfan::ZCone(zc3);
1359 return FALSE;
1360 }
1361 }
1362 WerrorS("convexIntersection: unexpected parameters");
1363 return TRUE;
1364}

◆ isFullSpace()

BOOLEAN isFullSpace ( leftv res,
leftv args )

Definition at line 884 of file bbcone.cc.

885{
886 leftv u = args;
887 if ((u != NULL) && (u->Typ() == coneID))
888 {
890 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
891 int i = zc->isFullSpace();
892 res->rtyp = INT_CMD;
893 res->data = (void*) (long) i;
895 return FALSE;
896 }
897 WerrorS("isFullSpace: unexpected parameters");
898 return TRUE;
899}

◆ isOrigin()

BOOLEAN isOrigin ( leftv res,
leftv args )

Definition at line 867 of file bbcone.cc.

868{
869 leftv u = args;
870 if ((u != NULL) && (u->Typ() == coneID))
871 {
873 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
874 int i = zc->isOrigin();
875 res->rtyp = INT_CMD;
876 res->data = (void*) (long) i;
878 return FALSE;
879 }
880 WerrorS("isOrigin: unexpected parameters");
881 return TRUE;
882}

◆ isSimplicial()

BOOLEAN isSimplicial ( leftv res,
leftv args )

Definition at line 901 of file bbcone.cc.

902{
903 leftv u=args;
904 if ((u != NULL) && (u->Typ() == coneID))
905 {
907 gfan::ZCone* zc = (gfan::ZCone*) u->Data();
908 int b = zc->isSimplicial();
909 res->rtyp = INT_CMD;
910 res->data = (void*) (long) b;
912 return FALSE;
913 }
914 if ((u != NULL) && (u->Typ() == fanID))
915 {
917 gfan::ZFan* zf = (gfan::ZFan*) u->Data();
918 bool b = isSimplicial(zf);
919 res->rtyp = INT_CMD;
920 res->data = (void*) (long) b;
922 return FALSE;
923 }
924 WerrorS("isSimplicial: unexpected parameters");
925 return TRUE;
926}

◆ jjCONENORMALS1()

static BOOLEAN jjCONENORMALS1 ( leftv res,
leftv v )
static

Definition at line 237 of file bbcone.cc.

238{
239 /* method for generating a cone object from inequalities;
240 valid parametrizations: (intmat) */
242 if (v->Typ() == INTMAT_CMD)
243 {
244 intvec* ineq0 = (intvec*) v->Data();
246 }
247 else
248 ineq = (bigintmat*) v->Data();
250 gfan::ZCone* zc = new gfan::ZCone(*zm, gfan::ZMatrix(0, zm->getWidth()));
251 delete zm;
252 if (v->Typ() == INTMAT_CMD)
253 delete ineq;
254 res->rtyp = coneID;
255 res->data = (void*) zc;
256 return FALSE;
257}
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)

◆ jjCONENORMALS2()

static BOOLEAN jjCONENORMALS2 ( leftv res,
leftv u,
leftv v )
static

Definition at line 259 of file bbcone.cc.

260{
261 /* method for generating a cone object from iequalities,
262 and equations (...)
263 valid parametrizations: (intmat, intmat)
264 Errors will be invoked in the following cases:
265 - u and v have different numbers of columns */
267 if (u->Typ() == INTMAT_CMD)
268 {
269 intvec* ineq0 = (intvec*) u->Data();
271 }
272 else
273 ineq = (bigintmat*) u->Data();
274 if (v->Typ() == INTMAT_CMD)
275 {
276 intvec* eq0 = (intvec*) v->Data();
278 }
279 else
280 eq = (bigintmat*) v->Data();
281
282 if (ineq->cols() != eq->cols())
283 {
284 Werror("expected same number of columns but got %d vs. %d",
285 ineq->cols(), eq->cols());
286 return TRUE;
287 }
290 gfan::ZCone* zc = new gfan::ZCone(*zm1, *zm2);
291 delete zm1;
292 delete zm2;
293 if (u->Typ() == INTMAT_CMD)
294 delete ineq;
295 if (v->Typ() == INTMAT_CMD)
296 delete eq;
297 res->rtyp = coneID;
298 res->data = (void*) zc;
299 return FALSE;
300}

◆ jjCONENORMALS3()

static BOOLEAN jjCONENORMALS3 ( leftv res,
leftv u,
leftv v,
leftv w )
static

Definition at line 302 of file bbcone.cc.

303{
304 /* method for generating a cone object from inequalities, equations,
305 and an integer k;
306 valid parametrizations: (intmat, intmat, int);
307 Errors will be invoked in the following cases:
308 - u and v have different numbers of columns,
309 - k not in [0..3];
310 if the 2^0-bit of k is set, then ... */
312 if (u->Typ() == INTMAT_CMD)
313 {
314 intvec* ineq0 = (intvec*) u->Data();
316 }
317 else
318 ineq = (bigintmat*) u->Data();
319 if (v->Typ() == INTMAT_CMD)
320 {
321 intvec* eq0 = (intvec*) v->Data();
323 }
324 else
325 eq = (bigintmat*) v->Data();
326 if (ineq->cols() != eq->cols())
327 {
328 Werror("expected same number of columns but got %d vs. %d",
329 ineq->cols(), eq->cols());
330 return TRUE;
331 }
332 int k = (int)(long)w->Data();
333 if ((k < 0) || (k > 3))
334 {
335 WerrorS("expected int argument in [0..3]");
336 return TRUE;
337 }
340 gfan::ZCone* zc = new gfan::ZCone(*zm1, *zm2, k);
341 delete zm1;
342 delete zm2;
343 if (u->Typ() == INTMAT_CMD)
344 delete ineq;
345 if (v->Typ() == INTMAT_CMD)
346 delete eq;
347 res->rtyp = coneID;
348 res->data = (void*) zc;
349 return FALSE;
350}
int k
Definition cfEzgcd.cc:99

◆ jjCONERAYS1()

static BOOLEAN jjCONERAYS1 ( leftv res,
leftv v )
static

Definition at line 389 of file bbcone.cc.

390{
391 /* method for generating a cone object from half-lines
392 (cone = convex hull of the half-lines; note: there may be
393 entire lines in the cone);
394 valid parametrizations: (intmat) */
396 if (v->Typ() == INTMAT_CMD)
397 {
398 intvec* rays0 = (intvec*) v->Data();
400 }
401 else
402 rays = (bigintmat*) v->Data();
403
405 gfan::ZCone* zc = new gfan::ZCone();
406 *zc = gfan::ZCone::givenByRays(*zm, gfan::ZMatrix(0, zm->getWidth()));
407 res->rtyp = coneID;
408 res->data = (void*) zc;
409
410 delete zm;
411 if (v->Typ() == INTMAT_CMD)
412 delete rays;
413 return FALSE;
414}

◆ jjCONERAYS2()

static BOOLEAN jjCONERAYS2 ( leftv res,
leftv u,
leftv v )
static

Definition at line 416 of file bbcone.cc.

417{
418 /* method for generating a cone object from half-lines,
419 and lines (any point in the cone being the sum of a point
420 in the convex hull of the half-lines and a point in the span
421 of the lines; the second argument may contain or entirely consist
422 of zero rows);
423 valid parametrizations: (intmat, intmat)
424 Errors will be invoked in the following cases:
425 - u and v have different numbers of columns */
427 if (u->Typ() == INTMAT_CMD)
428 {
429 intvec* rays0 = (intvec*) u->Data();
431 }
432 else
433 rays = (bigintmat*) u->Data();
434 if (v->Typ() == INTMAT_CMD)
435 {
436 intvec* linSpace0 = (intvec*) v->Data();
438 }
439 else
440 linSpace = (bigintmat*) v->Data();
441
442 if (rays->cols() != linSpace->cols())
443 {
444 Werror("expected same number of columns but got %d vs. %d",
445 rays->cols(), linSpace->cols());
446 return TRUE;
447 }
450 gfan::ZCone* zc = new gfan::ZCone();
451 *zc = gfan::ZCone::givenByRays(*zm1, *zm2);
452 res->rtyp = coneID;
453 res->data = (void*) zc;
454
455 delete zm1;
456 delete zm2;
457 if (u->Typ() == INTMAT_CMD)
458 delete rays;
459 if (v->Typ() == INTMAT_CMD)
460 delete linSpace;
461 return FALSE;
462}

◆ jjCONERAYS3()

static BOOLEAN jjCONERAYS3 ( leftv res,
leftv u,
leftv v,
leftv w )
static

Definition at line 464 of file bbcone.cc.

465{
466 /* method for generating a cone object from half-lines,
467 and lines (any point in the cone being the sum of a point
468 in the convex hull of the half-lines and a point in the span
469 of the lines), and an integer k;
470 valid parametrizations: (intmat, intmat, int);
471 Errors will be invoked in the following cases:
472 - u and v have different numbers of columns,
473 - k not in [0..3];
474 if the 2^0-bit of k is set, then the lineality space is known
475 to be the span of the provided lines;
476 if the 2^1-bit of k is set, then the extreme rays are known:
477 each half-line spans a (different) extreme ray */
479 if (u->Typ() == INTMAT_CMD)
480 {
481 intvec* rays0 = (intvec*) u->Data();
483 }
484 else
485 rays = (bigintmat*) u->Data();
486 if (v->Typ() == INTMAT_CMD)
487 {
488 intvec* linSpace0 = (intvec*) v->Data();
490 }
491 else
492 linSpace = (bigintmat*) v->Data();
493
494 if (rays->cols() != linSpace->cols())
495 {
496 Werror("expected same number of columns but got %d vs. %d",
497 rays->cols(), linSpace->cols());
498 return TRUE;
499 }
500 int k = (int)(long)w->Data();
501 if ((k < 0) || (k > 3))
502 {
503 WerrorS("expected int argument in [0..3]");
504 return TRUE;
505 }
508 gfan::ZCone* zc = new gfan::ZCone();
509 *zc = gfan::ZCone::givenByRays(*zm1, *zm2);
510 //k should be passed on to zc; not available yet
511 res->rtyp = coneID;
512 res->data = (void*) zc;
513
514 delete zm1;
515 delete zm2;
516 if (u->Typ() == INTMAT_CMD)
517 delete rays;
518 if (v->Typ() == INTMAT_CMD)
519 delete linSpace;
520 return FALSE;
521}

◆ liftUp() [1/2]

gfan::ZCone liftUp ( const gfan::ZCone & zc)

Definition at line 1182 of file bbcone.cc.

1183{
1184 gfan::ZMatrix ineq=zc.getInequalities();
1185 gfan::ZMatrix eq=zc.getEquations();
1187 return zd;
1188}

◆ liftUp() [2/2]

Definition at line 1170 of file bbcone.cc.

1171{
1172 int r=zm.getHeight();
1173 int c=zm.getWidth();
1174 gfan::ZMatrix zn(r+1,c+1);
1175 zn[1][1]=1;
1176 for (int i=0; i<r; i++)
1177 for (int j=0; j<c; j++)
1178 zn[i+1][j+1]=zm[i][j];
1179 return zn;
1180}

◆ linealityDimension()

BOOLEAN linealityDimension ( leftv res,
leftv args )

Definition at line 825 of file bbcone.cc.

826{
827 leftv u=args;
828 if ((u != NULL) && (u->Typ() == coneID))
829 {
831 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
832 res->rtyp = INT_CMD;
833 res->data = (void*) (long) zc->dimensionOfLinealitySpace();
835 return FALSE;
836 }
837 if ((u != NULL) && (u->Typ() == fanID))
838 {
840 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
841 res->rtyp = INT_CMD;
842 res->data = (void*) (long) getLinealityDimension(zf);
844 return FALSE;
845 }
846 WerrorS("linealityDimension: unexpected parameters");
847 return TRUE;
848}
int getLinealityDimension(gfan::ZFan *zf)
Definition bbfan.cc:261

◆ linealitySpace()

BOOLEAN linealitySpace ( leftv res,
leftv args )

Definition at line 945 of file bbcone.cc.

946{
947 leftv u = args;
948 if ((u != NULL) && (u->Typ() == coneID))
949 {
951 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
952 gfan::ZCone* zd = new gfan::ZCone(zc->linealitySpace());
953 res->rtyp = coneID;
954 res->data = (void*) zd;
956 return FALSE;
957 }
958 WerrorS("linealitySpace: unexpected parameters");
959 return TRUE;
960}

◆ negatedCone()

BOOLEAN negatedCone ( leftv res,
leftv args )

Definition at line 979 of file bbcone.cc.

980{
981 leftv u = args;
982 if ((u != NULL) && (u->Typ() == coneID))
983 {
985 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
986 gfan::ZCone* zd = new gfan::ZCone(zc->negated());
987 res->rtyp = coneID;
988 res->data = (void*) zd;
990 return FALSE;
991 }
992 WerrorS("negatedCone: unexpected parameters");
993 return TRUE;
994}

◆ onesVector()

BOOLEAN onesVector ( leftv res,
leftv args )

Definition at line 1776 of file bbcone.cc.

1777{
1778 leftv u=args;
1779 if ((u != NULL) && (u->Typ() == INT_CMD))
1780 {
1781 int n = (int) (long) u->Data();
1782 if (n>0)
1783 {
1784 intvec* v = new intvec(n);
1785 for (int i=0; i<n; i++)
1786 (*v)[i]=1;
1787 res->rtyp = INTVEC_CMD;
1788 res->data = (void*) v;
1789 return FALSE;
1790 }
1791 }
1792 WerrorS("onesVector: unexpected parameters");
1793 return TRUE;
1794}

◆ quotientLatticeBasis()

BOOLEAN quotientLatticeBasis ( leftv res,
leftv args )

Definition at line 689 of file bbcone.cc.

690{
691 leftv u = args;
692 if ((u != NULL) && (u->Typ() == coneID))
693 {
695 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
696 gfan::ZMatrix zmat = zc->quotientLatticeBasis();
697 res->rtyp = BIGINTMAT_CMD;
698 res->data = (void*) zMatrixToBigintmat(zmat);
700 return FALSE;
701 }
702 WerrorS("quotientLatticeBasis: unexpected parameters");
703 return TRUE;
704}

◆ randomPoint() [1/2]

gfan::ZVector randomPoint ( const gfan::ZCone * zc,
const int b )

Definition at line 1069 of file bbcone.cc.

1070{
1071 gfan::ZVector rp = gfan::ZVector(zc->ambientDimension());
1072
1073 gfan::ZMatrix rays = zc->extremeRays();
1074 for (int i=0; i<rays.getHeight(); i++)
1075 rp += siRandBound(b) * rays[i].toVector();
1076
1077 // gfan::ZMatrix lins = zc->generatorsOfLinealitySpace();
1078 // for (int i=0; i<lins.getHeight(); i++)
1079 // {
1080 // int n = siRandBound(b);
1081 // rp = rp + n * lins[i].toVector();
1082 // }
1083
1084 return rp;
1085}
int siRandBound(const int b)
Definition bbcone.cc:1055

◆ randomPoint() [2/2]

BOOLEAN randomPoint ( leftv res,
leftv args )

Definition at line 1087 of file bbcone.cc.

1088{
1089 leftv u = args;
1090 if ((u != NULL) && (u->Typ() == coneID))
1091 {
1093
1094 int b = 0;
1095 leftv v = u->next;
1096 if ((v != NULL) && (v->Typ() == INT_CMD))
1097 {
1098 b = (int) (long) v->Data();
1099 b = b+1;
1100 }
1101
1102 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1104
1105 res->rtyp = BIGINTMAT_CMD;
1106 res->data = (void*) zVectorToBigintmat(zv);
1108 return FALSE;
1109 }
1110 WerrorS("randomPoint: unexpected parameters");
1111 return TRUE;
1112}
bigintmat * zVectorToBigintmat(const gfan::ZVector &zv)

◆ rays()

BOOLEAN rays ( leftv res,
leftv args )

Definition at line 662 of file bbcone.cc.

663{
664 leftv u = args;
665 if ((u != NULL) && (u->Typ() == coneID))
666 {
668 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
669 gfan::ZMatrix zm = zc->extremeRays();
670 res->rtyp = BIGINTMAT_CMD;
671 res->data = (void*)zMatrixToBigintmat(zm);
673 return FALSE;
674 }
675 if ((u != NULL) && (u->Typ() == fanID))
676 {
678 gfan::ZFan* zf = (gfan::ZFan*)u->Data();
680 res->rtyp = BIGINTMAT_CMD;
681 res->data = (void*) zMatrixToBigintmat(zmat);
683 return FALSE;
684 }
685 WerrorS("rays: unexpected parameters");
686 return TRUE;
687}

◆ relativeInteriorPoint()

BOOLEAN relativeInteriorPoint ( leftv res,
leftv args )

Definition at line 1021 of file bbcone.cc.

1022{
1023 leftv u = args;
1024 if ((u != NULL) && (u->Typ() == coneID))
1025 {
1027 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1028 gfan::ZVector zv = zc->getRelativeInteriorPoint();
1029 res->rtyp = BIGINTMAT_CMD;
1030 res->data = (void*) zVectorToBigintmat(zv);
1032 return FALSE;
1033 }
1034 WerrorS("relativeInteriorPoint: unexpected parameters");
1035 return TRUE;
1036}

◆ semigroupGenerator()

BOOLEAN semigroupGenerator ( leftv res,
leftv args )

Definition at line 996 of file bbcone.cc.

997{
998 leftv u = args;
999 if ((u != NULL) && (u->Typ() == coneID))
1000 {
1002 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1003 int d = zc->dimension();
1004 int dLS = zc->dimensionOfLinealitySpace();
1005 if (d == dLS + 1)
1006 {
1007 gfan::ZVector zv = zc->semiGroupGeneratorOfRay();
1008 res->rtyp = BIGINTMAT_CMD;
1009 res->data = (void*) zVectorToBigintmat(zv);
1011 return FALSE;
1012 }
1014 Werror("expected dim of cone one larger than dim of lin space\n"
1015 "but got dimensions %d and %d", d, dLS);
1016 }
1017 WerrorS("semigroupGenerator: unexpected parameters");
1018 return TRUE;
1019}

◆ setLinearForms()

BOOLEAN setLinearForms ( leftv res,
leftv args )

Definition at line 1136 of file bbcone.cc.

1137{
1138 leftv u = args;
1139 if ((u != NULL) && (u->Typ() == coneID))
1140 {
1141 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1142 leftv v = u->next;
1143 if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
1144 {
1147 if (v->Typ() == INTVEC_CMD)
1148 {
1149 intvec* mat0 = (intvec*) v->Data();
1151 }
1152 else
1153 mat = (bigintmat*) v->Data();
1155 zc->setLinearForms(*zm);
1156 res->rtyp = NONE;
1157 res->data = NULL;
1158
1159 delete zm;
1160 if (v->Typ() == INTVEC_CMD)
1161 delete mat;
1163 return FALSE;
1164 }
1165 }
1166 WerrorS("setLinearForms: unexpected parameters");
1167 return TRUE;
1168}
#define NONE
Definition tok.h:221

◆ setMultiplicity()

BOOLEAN setMultiplicity ( leftv res,
leftv args )

Definition at line 1114 of file bbcone.cc.

1115{
1116 leftv u = args;
1117 if ((u != NULL) && (u->Typ() == coneID))
1118 {
1119 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1120 leftv v = u->next;
1121 if ((v != NULL) && (v->Typ() == INT_CMD))
1122 {
1124 int val = (int)(long)v->Data();
1125 zc->setMultiplicity(gfan::Integer(val));
1126 res->rtyp = NONE;
1127 res->data = NULL;
1129 return FALSE;
1130 }
1131 }
1132 WerrorS("setMultiplicity: unexpected parameters");
1133 return TRUE;
1134}

◆ siRandBound()

int siRandBound ( const int b)

Definition at line 1055 of file bbcone.cc.

1056{
1057 int n = 0;
1058 while (n==0)
1059 {
1060 n = siRand();
1061 if (b>1)
1062 {
1063 n = n % b;
1064 }
1065 }
1066 return n;
1067}
int siRand()
Definition sirandom.c:42

◆ toString()

std::string toString ( const gfan::ZCone *const c)

Definition at line 27 of file bbcone.cc.

28{
29 std::stringstream s;
30 s<<"AMBIENT_DIM"<<std::endl;
31 s<<c->ambientDimension()<<std::endl;
32
33 gfan::ZMatrix i=c->getInequalities();
34 char* ineqs = toString(i);
35 if (c->areFacetsKnown())
36 s<<"FACETS"<<std::endl;
37 else
38 s<<"INEQUALITIES"<<std::endl;
39 if (ineqs!=NULL)
40 {
41 s<<ineqs<<std::endl;
43 }
44
45 gfan::ZMatrix e=c->getEquations();
46 char* eqs = toString(e);
47 if (c->areImpliedEquationsKnown())
48 s<<"LINEAR_SPAN"<<std::endl;
49 else
50 s<<"EQUATIONS"<<std::endl;
51 if (eqs!=NULL)
52 {
53 s<<eqs<<std::endl;
54 omFree(eqs);
55 }
56
57 if (c->areExtremeRaysKnown())
58 {
59 gfan::ZMatrix r=c->extremeRays();
60 char* rs = toString(r);
61 s<<"RAYS"<<std::endl;
62 if (rs!=NULL)
63 {
64 s<<rs<<std::endl;
65 omFree(rs);
66 }
67 gfan::ZMatrix l=c->generatorsOfLinealitySpace();
68 char* ls = toString(l);
69 s<<"LINEALITY_SPACE"<<std::endl;
70 if (ls!=NULL)
71 {
72 s<<ls<<std::endl;
73 omFree(ls);
74 }
75 }
76
77 return s.str();
78}
#define omFree(addr)

◆ uniquePoint()

BOOLEAN uniquePoint ( leftv res,
leftv args )

Definition at line 1038 of file bbcone.cc.

1039{
1040 leftv u = args;
1041 if ((u != NULL) && (u->Typ() == coneID))
1042 {
1044 gfan::ZCone* zc = (gfan::ZCone*)u->Data();
1045 gfan::ZVector zv = zc->getUniquePoint();
1046 res->rtyp = BIGINTMAT_CMD;
1047 res->data = (void*) zVectorToBigintmat(zv);
1049 return FALSE;
1050 }
1051 WerrorS("uniquePoint: unexpected parameters");
1052 return TRUE;
1053}

Variable Documentation

◆ coneID

VAR int coneID

Definition at line 25 of file bbcone.cc.