19#include "gfanlib/gfanlib.h"
20#include "gfanlib/gfanlib_q.h"
27std::string
toString(
const gfan::ZCone*
const c)
30 s<<
"AMBIENT_DIM"<<std::endl;
31 s<<c->ambientDimension()<<std::endl;
33 gfan::ZMatrix
i=c->getInequalities();
35 if (c->areFacetsKnown())
36 s<<
"FACETS"<<std::endl;
38 s<<
"INEQUALITIES"<<std::endl;
45 gfan::ZMatrix e=c->getEquations();
47 if (c->areImpliedEquationsKnown())
48 s<<
"LINEAR_SPAN"<<std::endl;
50 s<<
"EQUATIONS"<<std::endl;
57 if (c->areExtremeRaysKnown())
59 gfan::ZMatrix r=c->extremeRays();
67 gfan::ZMatrix
l=c->generatorsOfLinealitySpace();
69 s<<
"LINEALITY_SPACE"<<std::endl;
82 return (
void*)(
new gfan::ZCone());
92 gfan::ZCone* zd = (gfan::ZCone*)
l->Data();
95 newZc =
new gfan::ZCone();
97 else if (r->
Typ()==
l->Typ())
101 gfan::ZCone* zd = (gfan::ZCone*)
l->Data();
104 newZc = (gfan::ZCone*)r->
CopyD();
108 int ambientDim = (int)(
long)r->
Data();
111 Werror(
"expected an int >= 0, but got %d", ambientDim);
116 gfan::ZCone* zd = (gfan::ZCone*)
l->Data();
119 newZc =
new gfan::ZCone(ambientDim);
123 Werror(
"assign Type(%d) = Type(%d) not implemented",
l->Typ(),r->
Typ());
133 l->data=(
void *)newZc;
143 std::string
s=
toString((gfan::ZCone*) d);
152 gfan::ZCone* zc = (gfan::ZCone*) d;
159 gfan::ZCone* zc = (gfan::ZCone*)d;
160 gfan::ZCone* newZc =
new gfan::ZCone(*zc);
166 gfan::ZCone* zp = (gfan::ZCone*) i1->
Data();
173 gfan::ZCone* zq = (gfan::ZCone*) i2->
Data();
174 int d1 = zp->ambientDimension();
175 int d2 = zq->ambientDimension();
178 WerrorS(
"mismatching ambient dimensions");
181 gfan::ZCone* zs =
new gfan::ZCone();
182 *zs = gfan::intersection(*zp, *zq);
185 res->data = (
void*) zs;
194 gfan::ZCone* zq = (gfan::ZCone*) i2->
Data();
195 int d1 = zp->ambientDimension();
196 int d2 = zq->ambientDimension();
199 WerrorS(
"mismatching ambient dimensions");
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);
210 res->data = (
void*) zs;
219 gfan::ZCone* zq = (gfan::ZCone*) i2->
Data();
222 bool b = !((*zp)!=(*zq));
224 res->data = (
void*)
b;
250 gfan::ZCone* zc =
new gfan::ZCone(*zm, gfan::ZMatrix(0, zm->getWidth()));
255 res->data = (
void*) zc;
284 Werror(
"expected same number of columns but got %d vs. %d",
290 gfan::ZCone* zc =
new gfan::ZCone(*zm1, *zm2);
298 res->data = (
void*) zc;
328 Werror(
"expected same number of columns but got %d vs. %d",
332 int k = (int)(
long)
w->Data();
333 if ((
k < 0) || (
k > 3))
335 WerrorS(
"expected int argument in [0..3]");
340 gfan::ZCone* zc =
new gfan::ZCone(*zm1, *zm2,
k);
348 res->data = (
void*) zc;
354 gfan::initializeCddlibIfRequired();
361 gfan::deinitializeCddlibIfRequired();
371 gfan::deinitializeCddlibIfRequired();
381 gfan::deinitializeCddlibIfRequired();
385 WerrorS(
"coneViaInequalities: unexpected parameters");
405 gfan::ZCone* zc =
new gfan::ZCone();
406 *zc = gfan::ZCone::givenByRays(*zm, gfan::ZMatrix(0, zm->getWidth()));
408 res->data = (
void*) zc;
442 if (
rays->cols() != linSpace->
cols())
444 Werror(
"expected same number of columns but got %d vs. %d",
450 gfan::ZCone* zc =
new gfan::ZCone();
451 *zc = gfan::ZCone::givenByRays(*zm1, *zm2);
453 res->data = (
void*) zc;
494 if (
rays->cols() != linSpace->
cols())
496 Werror(
"expected same number of columns but got %d vs. %d",
500 int k = (int)(
long)
w->Data();
501 if ((
k < 0) || (
k > 3))
503 WerrorS(
"expected int argument in [0..3]");
508 gfan::ZCone* zc =
new gfan::ZCone();
509 *zc = gfan::ZCone::givenByRays(*zm1, *zm2);
512 res->data = (
void*) zc;
525 gfan::initializeCddlibIfRequired();
532 gfan::deinitializeCddlibIfRequired();
541 gfan::deinitializeCddlibIfRequired();
550 gfan::deinitializeCddlibIfRequired();
556 WerrorS(
"coneViaPoints: unexpected parameters");
565 gfan::initializeCddlibIfRequired();
566 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
567 gfan::ZMatrix zmat = zc->getInequalities();
570 gfan::deinitializeCddlibIfRequired();
573 WerrorS(
"inequalities: unexpected parameters");
582 gfan::initializeCddlibIfRequired();
583 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
584 gfan::ZMatrix zmat = zc->getEquations();
587 gfan::deinitializeCddlibIfRequired();
590 WerrorS(
"equations: unexpected parameters");
599 gfan::initializeCddlibIfRequired();
600 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
601 gfan::ZMatrix zm = zc->getFacets();
604 gfan::deinitializeCddlibIfRequired();
607 WerrorS(
"facets: unexpected parameters");
616 gfan::initializeCddlibIfRequired();
617 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
618 gfan::ZMatrix zmat = zc->getImpliedEquations();
621 gfan::deinitializeCddlibIfRequired();
624 WerrorS(
"span: unexpected parameters");
633 gfan::initializeCddlibIfRequired();
634 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
635 gfan::ZMatrix zmat = zc->generatorsOfSpan();
638 gfan::deinitializeCddlibIfRequired();
641 WerrorS(
"generatorsOfSpan: unexpected parameters");
650 gfan::initializeCddlibIfRequired();
651 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
652 gfan::ZMatrix zmat = zc->generatorsOfLinealitySpace();
655 gfan::deinitializeCddlibIfRequired();
658 WerrorS(
"generatorsOfLinealitySpace: unexpected parameters");
667 gfan::initializeCddlibIfRequired();
668 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
669 gfan::ZMatrix zm = zc->extremeRays();
672 gfan::deinitializeCddlibIfRequired();
677 gfan::initializeCddlibIfRequired();
678 gfan::ZFan* zf = (gfan::ZFan*)u->
Data();
679 gfan::ZMatrix zmat =
rays(zf);
682 gfan::deinitializeCddlibIfRequired();
685 WerrorS(
"rays: unexpected parameters");
694 gfan::initializeCddlibIfRequired();
695 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
696 gfan::ZMatrix zmat = zc->quotientLatticeBasis();
699 gfan::deinitializeCddlibIfRequired();
702 WerrorS(
"quotientLatticeBasis: unexpected parameters");
711 gfan::initializeCddlibIfRequired();
712 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
713 gfan::ZMatrix zmat = zc->getLinearForms();
716 gfan::deinitializeCddlibIfRequired();
719 WerrorS(
"getLinearForms: unexpected parameters");
728 gfan::initializeCddlibIfRequired();
729 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
731 res->data = (
void*) (
long) zc->ambientDimension();
732 gfan::deinitializeCddlibIfRequired();
737 gfan::initializeCddlibIfRequired();
738 gfan::ZFan* zf = (gfan::ZFan*)u->
Data();
741 gfan::deinitializeCddlibIfRequired();
746 gfan::initializeCddlibIfRequired();
747 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
750 gfan::deinitializeCddlibIfRequired();
753 WerrorS(
"ambientDimension: unexpected parameters");
762 gfan::initializeCddlibIfRequired();
763 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
765 res->data = (
void*) (
long) zc->dimension();
766 gfan::deinitializeCddlibIfRequired();
771 gfan::initializeCddlibIfRequired();
772 gfan::ZFan* zf = (gfan::ZFan*)u->
Data();
775 gfan::deinitializeCddlibIfRequired();
780 gfan::initializeCddlibIfRequired();
781 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
784 gfan::deinitializeCddlibIfRequired();
787 WerrorS(
"dimension: unexpected parameters");
796 gfan::initializeCddlibIfRequired();
797 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
799 res->data = (
void*) (
long) zc->codimension();
800 gfan::deinitializeCddlibIfRequired();
805 gfan::initializeCddlibIfRequired();
806 gfan::ZFan* zf = (gfan::ZFan*)u->
Data();
809 gfan::deinitializeCddlibIfRequired();
814 gfan::initializeCddlibIfRequired();
815 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
818 gfan::deinitializeCddlibIfRequired();
821 WerrorS(
"getCodimension: unexpected parameters");
830 gfan::initializeCddlibIfRequired();
831 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
833 res->data = (
void*) (
long) zc->dimensionOfLinealitySpace();
834 gfan::deinitializeCddlibIfRequired();
839 gfan::initializeCddlibIfRequired();
840 gfan::ZFan* zf = (gfan::ZFan*)u->
Data();
843 gfan::deinitializeCddlibIfRequired();
846 WerrorS(
"linealityDimension: unexpected parameters");
855 gfan::initializeCddlibIfRequired();
856 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
859 res->data = (
void*)
i;
860 gfan::deinitializeCddlibIfRequired();
863 WerrorS(
"getMultiplicity: unexpected parameters");
872 gfan::initializeCddlibIfRequired();
873 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
874 int i = zc->isOrigin();
876 res->data = (
void*) (
long)
i;
877 gfan::deinitializeCddlibIfRequired();
880 WerrorS(
"isOrigin: unexpected parameters");
889 gfan::initializeCddlibIfRequired();
890 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
891 int i = zc->isFullSpace();
893 res->data = (
void*) (
long)
i;
894 gfan::deinitializeCddlibIfRequired();
897 WerrorS(
"isFullSpace: unexpected parameters");
906 gfan::initializeCddlibIfRequired();
907 gfan::ZCone* zc = (gfan::ZCone*) u->
Data();
908 int b = zc->isSimplicial();
910 res->data = (
void*) (
long)
b;
911 gfan::deinitializeCddlibIfRequired();
916 gfan::initializeCddlibIfRequired();
917 gfan::ZFan* zf = (gfan::ZFan*) u->
Data();
920 res->data = (
void*) (
long)
b;
921 gfan::deinitializeCddlibIfRequired();
924 WerrorS(
"isSimplicial: unexpected parameters");
933 gfan::initializeCddlibIfRequired();
934 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
935 int i = zc->containsPositiveVector();
937 res->data = (
void*) (
long)
i;
938 gfan::deinitializeCddlibIfRequired();
941 WerrorS(
"containsPositiveVector: unexpected parameters");
950 gfan::initializeCddlibIfRequired();
951 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
952 gfan::ZCone* zd =
new gfan::ZCone(zc->linealitySpace());
954 res->data = (
void*) zd;
955 gfan::deinitializeCddlibIfRequired();
958 WerrorS(
"linealitySpace: unexpected parameters");
967 gfan::initializeCddlibIfRequired();
968 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
969 gfan::ZCone* zd =
new gfan::ZCone(zc->dualCone());
971 res->data = (
void*) zd;
972 gfan::deinitializeCddlibIfRequired();
975 WerrorS(
"dual: unexpected parameters");
984 gfan::initializeCddlibIfRequired();
985 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
986 gfan::ZCone* zd =
new gfan::ZCone(zc->negated());
988 res->data = (
void*) zd;
989 gfan::deinitializeCddlibIfRequired();
992 WerrorS(
"negatedCone: unexpected parameters");
1001 gfan::initializeCddlibIfRequired();
1002 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1003 int d = zc->dimension();
1004 int dLS = zc->dimensionOfLinealitySpace();
1007 gfan::ZVector zv = zc->semiGroupGeneratorOfRay();
1010 gfan::deinitializeCddlibIfRequired();
1013 gfan::deinitializeCddlibIfRequired();
1014 Werror(
"expected dim of cone one larger than dim of lin space\n"
1015 "but got dimensions %d and %d", d, dLS);
1017 WerrorS(
"semigroupGenerator: unexpected parameters");
1026 gfan::initializeCddlibIfRequired();
1027 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1028 gfan::ZVector zv = zc->getRelativeInteriorPoint();
1031 gfan::deinitializeCddlibIfRequired();
1034 WerrorS(
"relativeInteriorPoint: unexpected parameters");
1043 gfan::initializeCddlibIfRequired();
1044 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1045 gfan::ZVector zv = zc->getUniquePoint();
1048 gfan::deinitializeCddlibIfRequired();
1051 WerrorS(
"uniquePoint: unexpected parameters");
1071 gfan::ZVector rp = gfan::ZVector(zc->ambientDimension());
1073 gfan::ZMatrix
rays = zc->extremeRays();
1074 for (
int i=0;
i<
rays.getHeight();
i++)
1092 gfan::initializeCddlibIfRequired();
1098 b = (int) (
long)
v->Data();
1102 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1107 gfan::deinitializeCddlibIfRequired();
1110 WerrorS(
"randomPoint: unexpected parameters");
1119 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1123 gfan::initializeCddlibIfRequired();
1124 int val = (int)(
long)
v->Data();
1125 zc->setMultiplicity(gfan::Integer(val));
1128 gfan::deinitializeCddlibIfRequired();
1132 WerrorS(
"setMultiplicity: unexpected parameters");
1141 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1145 gfan::initializeCddlibIfRequired();
1155 zc->setLinearForms(*zm);
1162 gfan::deinitializeCddlibIfRequired();
1166 WerrorS(
"setLinearForms: unexpected parameters");
1172 int r=zm.getHeight();
1173 int c=zm.getWidth();
1174 gfan::ZMatrix zn(r+1,c+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];
1184 gfan::ZMatrix ineq=zc.getInequalities();
1185 gfan::ZMatrix eq=zc.getEquations();
1195 gfan::initializeCddlibIfRequired();
1196 gfan::ZCone* zc = (gfan::ZCone*) u->
Data();
1197 gfan::ZMatrix ineq=zc->getInequalities();
1198 gfan::ZMatrix eq=zc->getEquations();
1199 gfan::ZCone* zd =
new gfan::ZCone(
liftUp(ineq),
liftUp(eq));
1201 res->data = (
void*) zd;
1202 gfan::deinitializeCddlibIfRequired();
1205 WerrorS(
"makePolytope: unexpected parameters");
1217 gfan::initializeCddlibIfRequired();
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();
1224 Werror(
"expected ambient dims of both cones to coincide\n"
1225 "but got %d and %d", d1, d2);
1226 gfan::deinitializeCddlibIfRequired();
1229 gfan::ZCone zc3 = gfan::intersection(*zc1, *zc2);
1232 res->data = (
void *)
new gfan::ZCone(zc3);
1233 gfan::deinitializeCddlibIfRequired();
1238 gfan::initializeCddlibIfRequired();
1239 gfan::ZCone* zc11 = (gfan::ZCone*)u->
Data();
1240 gfan::ZCone zc1 =
liftUp(*zc11);
1241 gfan::ZCone* zc2 = (gfan::ZCone*)
v->Data();
1242 int d1 = zc1.ambientDimension();
1243 int d2 = zc2->ambientDimension();
1246 Werror(
"expected ambient dims of both cones to coincide\n"
1247 "but got %d and %d", d1, d2);
1248 gfan::deinitializeCddlibIfRequired();
1251 gfan::ZCone zc3 = gfan::intersection(zc1, *zc2);
1254 res->data = (
void *)
new gfan::ZCone(zc3);
1255 gfan::deinitializeCddlibIfRequired();
1273 WerrorS(
"convexIntersection: entries of wrong type in list");
1276 gfan::ZCone* ll = (gfan::ZCone*)
l->m[
i].Data();
1277 r1 = r1 + ll->getInequalities().getHeight();
1278 r2 = r2 + ll->getEquations().getHeight();
1282 gfan::ZCone* ll = (gfan::ZCone*)
l->m[0].Data();
1283 c = ll->getInequalities().getWidth();
1285 gfan::ZMatrix totalIneqs(r1,c);
1286 gfan::ZMatrix totalEqs(r2,c);
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++)
1297 totalIneqs[r1]=ineqs[
j];
1300 gfan::ZMatrix eqs = ll->getEquations();
1301 for (
int j=0;
j<eqs.getHeight();
j++)
1303 totalEqs[r2]=eqs[
j];
1308 gfan::ZCone* zc =
new gfan::ZCone(totalIneqs,totalEqs);
1311 res->data = (
void *) zc;
1320 gfan::initializeCddlibIfRequired();
1321 gfan::ZCone* zc1 = (gfan::ZCone*)u->
Data();
1322 gfan::ZCone* zc22 = (gfan::ZCone*)
v->Data();
1323 gfan::ZCone zc2 =
liftUp(*zc22);
1324 int d1 = zc1->ambientDimension();
1325 int d2 = zc2.ambientDimension();
1328 Werror(
"expected ambient dims of both cones to coincide\n"
1329 "but got %d and %d", d1, d2);
1330 gfan::deinitializeCddlibIfRequired();
1333 gfan::ZCone zc3 = gfan::intersection(*zc1, zc2);
1336 res->data = (
void *)
new gfan::ZCone(zc3);
1337 gfan::deinitializeCddlibIfRequired();
1342 gfan::initializeCddlibIfRequired();
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();
1349 Werror(
"expected ambient dims of both cones to coincide\n"
1350 "but got %d and %d", d1, d2);
1351 gfan::deinitializeCddlibIfRequired();
1354 gfan::ZCone zc3 = gfan::intersection(*zc1, *zc2);
1357 res->data = (
void *)
new gfan::ZCone(zc3);
1358 gfan::deinitializeCddlibIfRequired();
1362 WerrorS(
"convexIntersection: unexpected parameters");
1374 gfan::initializeCddlibIfRequired();
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();
1381 Werror(
"expected ambient dims of both cones to coincide\n"
1382 "but got %d and %d", d1, d2);
1383 gfan::deinitializeCddlibIfRequired();
1386 gfan::ZMatrix zm1 = zc1->extremeRays();
1387 gfan::ZMatrix zm2 = zc2->extremeRays();
1388 gfan::ZMatrix zn1 = zc1->generatorsOfLinealitySpace();
1389 gfan::ZMatrix zn2 = zc2->generatorsOfLinealitySpace();
1390 gfan::ZMatrix zm = combineOnTop(zm1,zm2);
1391 gfan::ZMatrix zn = combineOnTop(zn1,zn2);
1392 gfan::ZCone* zc =
new gfan::ZCone();
1393 *zc = gfan::ZCone::givenByRays(zm, zn);
1395 res->data = (
void*) zc;
1396 gfan::deinitializeCddlibIfRequired();
1401 gfan::initializeCddlibIfRequired();
1402 gfan::ZCone* zc11 = (gfan::ZCone*)u->
Data();
1403 gfan::ZCone zc1 =
liftUp(*zc11);
1404 gfan::ZCone* zc2 = (gfan::ZCone*)
v->Data();
1405 int d1 = zc1.ambientDimension()-1;
1406 int d2 = zc2->ambientDimension()-1;
1409 Werror(
"expected ambient dims of both cones to coincide\n"
1410 "but got %d and %d", d1, d2);
1411 gfan::deinitializeCddlibIfRequired();
1414 gfan::ZMatrix zm1 = zc1.extremeRays();
1415 gfan::ZMatrix zm2 = zc2->extremeRays();
1416 gfan::ZMatrix zn = zc1.generatorsOfLinealitySpace();
1417 gfan::ZMatrix zm = combineOnTop(zm1,zm2);
1418 gfan::ZCone* zc =
new gfan::ZCone();
1419 *zc = gfan::ZCone::givenByRays(zm, zn);
1421 res->data = (
void*) zc;
1422 gfan::deinitializeCddlibIfRequired();
1431 gfan::initializeCddlibIfRequired();
1432 gfan::ZCone* zc1 = (gfan::ZCone*)u->
Data();
1433 gfan::ZCone* zc22 = (gfan::ZCone*)
v->Data();
1434 gfan::ZCone zc2 =
liftUp(*zc22);
1435 int d1 = zc1->ambientDimension()-1;
1436 int d2 = zc2.ambientDimension()-1;
1439 Werror(
"expected ambient dims of both cones to coincide\n"
1440 "but got %d and %d", d1, d2);
1441 gfan::deinitializeCddlibIfRequired();
1444 gfan::ZMatrix zm1 = zc1->extremeRays();
1445 gfan::ZMatrix zm2 = zc2.extremeRays();
1446 gfan::ZMatrix zn = zc2.generatorsOfLinealitySpace();
1447 gfan::ZMatrix zm = combineOnTop(zm1,zm2);
1448 gfan::ZCone* zc =
new gfan::ZCone();
1449 *zc = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
1451 res->data = (
void*) zc;
1452 gfan::deinitializeCddlibIfRequired();
1457 gfan::initializeCddlibIfRequired();
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;
1464 Werror(
"expected ambient dims of both cones to coincide\n"
1465 "but got %d and %d", d1, d2);
1466 gfan::deinitializeCddlibIfRequired();
1469 gfan::ZMatrix zm1 = zc1->extremeRays();
1470 gfan::ZMatrix zm2 = zc2->extremeRays();
1471 gfan::ZMatrix zm = combineOnTop(zm1,zm2);
1472 gfan::ZCone* zc =
new gfan::ZCone();
1473 *zc = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
1475 res->data = (
void*) zc;
1476 gfan::deinitializeCddlibIfRequired();
1480 WerrorS(
"convexHull: unexpected parameters");
1492 gfan::initializeCddlibIfRequired();
1493 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1503 int d1 = zc->ambientDimension();
1504 int d2 = zv->size();
1507 Werror(
"expected ambient dim of cone and size of vector\n"
1508 " to be equal but got %d and %d", d1, d2);
1509 gfan::deinitializeCddlibIfRequired();
1512 if(!zc->contains(*zv))
1514 WerrorS(
"the provided intvec does not lie in the cone");
1515 gfan::deinitializeCddlibIfRequired();
1518 gfan::ZCone* zd =
new gfan::ZCone(zc->link(*zv));
1520 res->data = (
void *) zd;
1525 gfan::deinitializeCddlibIfRequired();
1529 WerrorS(
"coneLink: unexpected parameters");
1541 gfan::initializeCddlibIfRequired();
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();
1548 Werror(
"expected cones with same ambient dimensions\n but got"
1549 " dimensions %d and %d", d1, d2);
1550 gfan::deinitializeCddlibIfRequired();
1553 bool b = (zc->contains(*zd) ? 1 : 0);
1555 res->data = (
void*) (
long)
b;
1556 gfan::deinitializeCddlibIfRequired();
1561 gfan::initializeCddlibIfRequired();
1562 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1573 int d1 = zc->ambientDimension();
1574 int d2 = zv->size();
1577 Werror(
"expected cones with same ambient dimensions\n but got"
1578 " dimensions %d and %d", d1, d2);
1579 gfan::deinitializeCddlibIfRequired();
1582 int b = zc->contains(*zv);
1584 res->data = (
void*) (
long)
b;
1589 gfan::deinitializeCddlibIfRequired();
1593 WerrorS(
"containsInSupport: unexpected parameters");
1605 gfan::initializeCddlibIfRequired();
1606 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1616 int d1 = zc->ambientDimension();
1617 int d2 = zv->size();
1620 bool b = (zc->containsRelatively(*zv) ? 1 : 0);
1622 res->data = (
void *)
b;
1626 gfan::deinitializeCddlibIfRequired();
1632 gfan::deinitializeCddlibIfRequired();
1633 Werror(
"expected ambient dim of cone and size of vector\n"
1634 "to be equal but got %d and %d", d1, d2);
1637 WerrorS(
"containsRelatively: unexpected parameters");
1649 gfan::initializeCddlibIfRequired();
1650 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1651 gfan::ZCone* zd = (gfan::ZCone*)
v->Data();
1652 bool b = zc->hasFace(*zd);
1654 res->data = (
void*) (
long)
b;
1655 gfan::deinitializeCddlibIfRequired();
1664 gfan::initializeCddlibIfRequired();
1665 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1666 gfan::ZCone* zd = (gfan::ZCone*)
v->Data();
1667 bool b = zc->hasFace(*zd);
1669 res->data = (
void*) (
long)
b;
1670 gfan::deinitializeCddlibIfRequired();
1674 WerrorS(
"containsAsFace: unexpected parameters");
1683 gfan::initializeCddlibIfRequired();
1684 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
1685 gfan::ZCone* zd =
new gfan::ZCone(*zc);
1688 res->data = (
void*) zd;
1689 gfan::deinitializeCddlibIfRequired();
1692 WerrorS(
"canonicalizeCone: unexpected parameters");
1704 gfan::initializeCddlibIfRequired();
1706 gfan::ZCone* zc = (gfan::ZCone*)
v->Data();
1713 WerrorS(
"containsCone: entries of wrong type in list");
1714 gfan::deinitializeCddlibIfRequired();
1717 gfan::ZCone* ll = (gfan::ZCone*)
l->m[
i].Data();
1719 if (!((*ll) != (*zc)))
1726 res->data = (
char*) (
long)
b;
1727 gfan::deinitializeCddlibIfRequired();
1731 WerrorS(
"containsCone: unexpected parameters");
1743 gfan::initializeCddlibIfRequired();
1744 gfan::ZCone* zc = (gfan::ZCone*) u->
Data();
1756 if (!zc->contains(*point))
1758 WerrorS(
"faceContaining: point not in cone");
1762 res->data = (
void*)
new gfan::ZCone(zc->faceContaining(*point));
1767 gfan::deinitializeCddlibIfRequired();
1771 WerrorS(
"faceContaining: unexpected parameters");
1781 int n = (int) (
long) u->
Data();
1785 for (
int i=0;
i<n;
i++)
1788 res->data = (
void*)
v;
1792 WerrorS(
"onesVector: unexpected parameters");
1802 gfan::ZMatrix
equations = zc.getImpliedEquations();
1807 gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);
1808 if (r==0)
return relativeInteriorPoints;
1813 gfan::ZMatrix newInequalities =
inequalities.submatrix(1,0,r,c);
1816 gfan::ZCone
facet = gfan::ZCone(newInequalities,newEquations);
1817 facet.canonicalize();
1818 gfan::ZVector interiorPoint =
facet.getRelativeInteriorPoint();
1819 if (exceptThese.count(interiorPoint)==0)
1820 relativeInteriorPoints.appendRow(interiorPoint);
1823 for (
int i=1;
i<r-1;
i++)
1829 facet = gfan::ZCone(newInequalities,newEquations);
1830 facet.canonicalize();
1831 interiorPoint =
facet.getRelativeInteriorPoint();
1832 if (exceptThese.count(interiorPoint)==0)
1833 relativeInteriorPoints.appendRow(interiorPoint);
1840 facet = gfan::ZCone(newInequalities,newEquations);
1841 facet.canonicalize();
1842 interiorPoint =
facet.getRelativeInteriorPoint();
1843 if (exceptThese.count(interiorPoint)==0)
1844 relativeInteriorPoints.appendRow(interiorPoint);
1846 return relativeInteriorPoints;
1856 gfan::ZMatrix
equations = zc.getImpliedEquations();
1861 gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);
1862 gfan::ZMatrix outerFacetNormals = gfan::ZMatrix(0,c);
1864 return std::make_pair(relativeInteriorPoints,outerFacetNormals);
1869 gfan::ZMatrix newInequalities =
inequalities.submatrix(1,0,r,c);
1872 gfan::ZCone
facet = gfan::ZCone(newInequalities,newEquations);
1873 gfan::ZVector interiorPoint =
facet.getRelativeInteriorPoint();
1874 if (onlyLowerHalfSpace==
false || interiorPoint[0].
sign()<0)
1876 if (exceptThesePoints.count(interiorPoint)==0)
1878 relativeInteriorPoints.appendRow(interiorPoint);
1879 outerFacetNormals.appendRow(-
inequalities[0].toVector());
1884 for (
int i=1;
i<r-1;
i++)
1890 facet = gfan::ZCone(newInequalities,newEquations);
1891 interiorPoint =
facet.getRelativeInteriorPoint();
1892 if (onlyLowerHalfSpace==
false || interiorPoint[0].
sign()<0)
1894 if (exceptThesePoints.count(interiorPoint)==0)
1896 relativeInteriorPoints.appendRow(interiorPoint);
1906 facet = gfan::ZCone(newInequalities,newEquations);
1907 interiorPoint =
facet.getRelativeInteriorPoint();
1908 if (onlyLowerHalfSpace==
false || interiorPoint[0].
sign()<0)
1910 if (exceptThesePoints.count(interiorPoint)==0)
1912 relativeInteriorPoints.appendRow(interiorPoint);
1913 outerFacetNormals.appendRow(-
inequalities[r-1].toVector());
1917 return std::make_pair(relativeInteriorPoints,outerFacetNormals);
1933 fprintf(dd->
f_write,
"%d %d ",
M.getHeight(),
M.getWidth());
1935 for (
int i=0;
i<
M.getHeight();
i++)
1937 for (
int j=0;
j<
M.getWidth();
j++)
1949 memset(&
l,0,
sizeof(
l));
1951 l.data=(
void*)
"cone";
1954 gfan::ZCone *Z = (gfan::ZCone*) d;
1955 fprintf(dd->
f_write,
"%d ",Z->areImpliedEquationsKnown()+Z->areFacetsKnown()*2);
1957 gfan::ZMatrix
i=Z->getInequalities();
1960 gfan::ZMatrix e=Z->getEquations();
1972 gfan::Integer n(tmp);
1982 gfan::ZMatrix
M(r,c);
1983 for (
int i=0;
i<r;
i++)
1985 for (
int j=0;
j<c;
j++)
2004 gfan::ZCone* Z =
new gfan::ZCone(
i,e,preassumptions);
2012 gfan::initializeCddlibIfRequired();
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();
2025 Werror(
"expected ambient dims of both cones to coincide\n"
2026 "but got %d and %d", d1, d2);
2029 gfan::ZCone zc3 = gfan::intersection(*zc1, *zc2);
2032 res->data = (
void *)
new gfan::ZCone(zc3);
2037 gfan::ZCone* zc11 = (gfan::ZCone*)u->
Data();
2038 gfan::ZCone zc1 =
liftUp(*zc11);
2039 gfan::ZCone* zc2 = (gfan::ZCone*)
v->Data();
2040 int d1 = zc1.ambientDimension();
2041 int d2 = zc2->ambientDimension();
2044 Werror(
"expected ambient dims of both cones to coincide\n"
2045 "but got %d and %d", d1, d2);
2048 gfan::ZCone zc3 = gfan::intersection(zc1, *zc2);
2051 res->data = (
void *)
new gfan::ZCone(zc3);
2060 gfan::ZCone* zc1 = (gfan::ZCone*)u->
Data();
2061 gfan::ZCone* zc22 = (gfan::ZCone*)
v->Data();
2062 gfan::ZCone zc2 =
liftUp(*zc22);
2063 int d1 = zc1->ambientDimension();
2064 int d2 = zc2.ambientDimension();
2067 Werror(
"expected ambient dims of both cones to coincide\n"
2068 "but got %d and %d", d1, d2);
2071 gfan::ZCone zc3 = gfan::intersection(*zc1, zc2);
2074 res->data = (
void *)
new gfan::ZCone(zc3);
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();
2085 Werror(
"expected ambient dims of both cones to coincide\n"
2086 "but got %d and %d", d1, d2);
2089 gfan::ZCone zc3 = gfan::intersection(*zc1, *zc2);
2092 res->data = (
void *)
new gfan::ZCone(zc3);
2096 WerrorS(
"convexIntersectionOld: unexpected parameters");
2103 blackbox *
b=(blackbox*)
omAlloc0(
sizeof(blackbox));
BOOLEAN getMultiplicity(leftv res, leftv args)
BOOLEAN isFullSpace(leftv res, leftv args)
BOOLEAN canonicalizeCone(leftv res, leftv args)
BOOLEAN bbcone_deserialize(blackbox **b, void **d, si_link f)
BOOLEAN quotientLatticeBasis(leftv res, leftv args)
void * bbcone_Init(blackbox *)
std::pair< gfan::ZMatrix, gfan::ZMatrix > interiorPointsAndNormalsOfFacets(const gfan::ZCone zc, const std::set< gfan::ZVector > &exceptThesePoints, const bool onlyLowerHalfSpace)
BOOLEAN onesVector(leftv res, leftv args)
BOOLEAN convexIntersectionOld(leftv res, leftv args)
BOOLEAN getLinearForms(leftv res, leftv args)
BOOLEAN codimension(leftv res, leftv args)
int siRandBound(const int b)
void bbcone_destroy(blackbox *, void *d)
BOOLEAN facets(leftv res, leftv args)
BOOLEAN impliedEquations(leftv res, leftv args)
BOOLEAN uniquePoint(leftv res, leftv args)
BOOLEAN isSimplicial(leftv res, leftv args)
static BOOLEAN jjCONENORMALS1(leftv res, leftv v)
BOOLEAN ambientDimension(leftv res, leftv args)
static gfan::ZMatrix gfanZMatrixReadFd(ssiInfo *dd)
BOOLEAN bbcone_Assign(leftv l, leftv r)
BOOLEAN coneLink(leftv res, leftv args)
BOOLEAN containsCone(leftv res, leftv args)
void bbcone_setup(SModulFunctions *p)
BOOLEAN negatedCone(leftv res, leftv args)
BOOLEAN generatorsOfSpan(leftv res, leftv args)
gfan::ZMatrix interiorPointsOfFacets(const gfan::ZCone &zc, const std::set< gfan::ZVector > &exceptThese)
static void gfanZMatrixWriteFd(gfan::ZMatrix M, ssiInfo *dd)
BOOLEAN equations(leftv res, leftv args)
char * bbcone_String(blackbox *, void *d)
static gfan::Integer gfanIntegerReadFd(ssiInfo *dd)
BOOLEAN containsRelatively(leftv res, leftv args)
static BOOLEAN jjCONERAYS3(leftv res, leftv u, leftv v, leftv w)
BOOLEAN containsPositiveVector(leftv res, leftv args)
static BOOLEAN jjCONERAYS1(leftv res, leftv v)
BOOLEAN semigroupGenerator(leftv res, leftv args)
BOOLEAN dimension(leftv res, leftv args)
BOOLEAN coneViaNormals(leftv res, leftv args)
BOOLEAN faceContaining(leftv res, leftv args)
BOOLEAN setMultiplicity(leftv res, leftv args)
BOOLEAN bbcone_serialize(blackbox *b, void *d, si_link f)
static BOOLEAN jjCONENORMALS3(leftv res, leftv u, leftv v, leftv w)
BOOLEAN generatorsOfLinealitySpace(leftv res, leftv args)
BOOLEAN containsInSupport(leftv res, leftv args)
BOOLEAN coneToPolytope(leftv res, leftv args)
void * bbcone_Copy(blackbox *, void *d)
BOOLEAN dualCone(leftv res, leftv args)
BOOLEAN isOrigin(leftv res, leftv args)
gfan::ZVector randomPoint(const gfan::ZCone *zc, const int b)
BOOLEAN inequalities(leftv res, leftv args)
BOOLEAN setLinearForms(leftv res, leftv args)
BOOLEAN linealityDimension(leftv res, leftv args)
gfan::ZMatrix liftUp(const gfan::ZMatrix &zm)
BOOLEAN hasFace(leftv res, leftv args)
BOOLEAN relativeInteriorPoint(leftv res, leftv args)
static void gfanIntegerWriteFd(gfan::Integer n, ssiInfo *dd)
static BOOLEAN bbcone_Op2(int op, leftv res, leftv i1, leftv i2)
static BOOLEAN jjCONENORMALS2(leftv res, leftv u, leftv v)
BOOLEAN rays(leftv res, leftv args)
BOOLEAN linealitySpace(leftv res, leftv args)
BOOLEAN coneViaRays(leftv res, leftv args)
static BOOLEAN jjCONERAYS2(leftv res, leftv u, leftv v)
BOOLEAN intersectCones(leftv res, leftv args)
std::string toString(const gfan::ZCone *const c)
int getDimension(gfan::ZFan *zf)
int getCodimension(gfan::ZFan *zf)
int getLinealityDimension(gfan::ZFan *zf)
int getAmbientDimension(gfan::ZFan *zf)
bigintmat * iv2bim(intvec *b, const coeffs C)
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
BOOLEAN blackboxDefaultOp2(int, leftv, leftv, leftv)
default procedure blackboxDefaultOp2, to be called as "default:" branch
number integerToNumber(const gfan::Integer &I)
bigintmat * zMatrixToBigintmat(const gfan::ZMatrix &zm)
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
bigintmat * zVectorToBigintmat(const gfan::ZVector &zv)
gfan::ZVector * bigintmatToZVector(const bigintmat &bim)
Class used for (list of) interpreter objects.
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
void Werror(const char *fmt,...)
void s_readmpz_base(s_buff F, mpz_ptr a, int base)