13#include "gfanlib/gfanlib.h"
14#include "gfanlib/gfanlib_q.h"
21 gfan::ZMatrix
i=c.getInequalities();
22 gfan::ZMatrix e=c.getEquations();
23 s<<
"AMBIENT_DIM"<<std::endl;
24 s<<c.ambientDimension()-1<<std::endl;
25 s<<
"INEQUALITIES"<<std::endl;
27 s<<
"EQUATIONS"<<std::endl;
34 return (
void*)(
new gfan::ZCone());
44 gfan::ZCone* zd = (gfan::ZCone*)
l->Data();
47 newZc =
new gfan::ZCone();
49 else if (r->
Typ()==
l->Typ())
53 gfan::ZCone* zd = (gfan::ZCone*)
l->Data();
56 gfan::ZCone* zc = (gfan::ZCone*)r->
Data();
57 newZc =
new gfan::ZCone(*zc);
76 Werror(
"assign Type(%d) = Type(%d) not implemented",
l->Typ(),r->
Typ());
86 l->data=(
void *)newZc;
95 gfan::ZCone* zc = (gfan::ZCone*)d;
105 gfan::ZCone* zc = (gfan::ZCone*) d;
112 gfan::ZCone* zc = (gfan::ZCone*)d;
113 gfan::ZCone* newZc =
new gfan::ZCone(*zc);
133 gfan::ZCone* zc =
new gfan::ZCone();
134 *zc = gfan::ZCone::givenByRays(*zm, gfan::ZMatrix(0, zm->getWidth()));
136 res->data = (
void*) zc;
163 int k = (int)(
long)
v->Data();
165 if ((
k < 0) || (
k > 1))
167 WerrorS(
"expected int argument in [0..1]");
172 gfan::ZCone* zc =
new gfan::ZCone();
173 *zc = gfan::ZCone::givenByRays(*zm,gfan::ZMatrix(0, zm->getWidth()));
176 res->data = (
void*) zc;
191 gfan::initializeCddlibIfRequired();
193 gfan::deinitializeCddlibIfRequired();
201 gfan::initializeCddlibIfRequired();
203 gfan::deinitializeCddlibIfRequired();
208 WerrorS(
"polytopeViaPoints: unexpected parameters");
225 gfan::ZCone* zc =
new gfan::ZCone(*zm, gfan::ZMatrix(0, zm->getWidth()));
230 res->data = (
void*) zc;
259 Werror(
"expected same number of columns but got %d vs. %d",
265 gfan::ZCone* zc =
new gfan::ZCone(*zm1, *zm2);
274 res->data = (
void*) zc;
305 Werror(
"expected same number of columns but got %d vs. %d",
309 int k = (int)(
long)
w->Data();
310 if ((
k < 0) || (
k > 3))
312 WerrorS(
"expected int argument in [0..3]");
317 gfan::ZCone* zc =
new gfan::ZCone(*zm1, *zm2,
k);
326 res->data = (
void*) zc;
337 gfan::initializeCddlibIfRequired();
339 gfan::deinitializeCddlibIfRequired();
348 gfan::initializeCddlibIfRequired();
350 gfan::deinitializeCddlibIfRequired();
359 gfan::initializeCddlibIfRequired();
361 gfan::deinitializeCddlibIfRequired();
365 WerrorS(
"polytopeViaInequalities: unexpected parameters");
374 gfan::initializeCddlibIfRequired();
375 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
376 gfan::ZMatrix zmat = zc->extremeRays();
379 gfan::deinitializeCddlibIfRequired();
382 WerrorS(
"vertices: unexpected parameters");
388 return zc->ambientDimension()-1;
393 return zc->codimension();
398 return zc->dimension()-1;
403 gfan::ZVector zv(d+1);
405 for(
int j=1;
j<=d;
j++)
415 gfan::ZMatrix zm(0,
N+1);
416 int *leadexpv = (
int*)
omAlloc((
N+1)*
sizeof(int));
425 gfan::ZCone Delta = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
434 gfan::initializeCddlibIfRequired();
435 poly
p = (poly)u->
Data();
438 gfan::deinitializeCddlibIfRequired();
441 WerrorS(
"newtonPolytope: unexpected parameters");
453 gfan::initializeCddlibIfRequired();
454 int s = (int)(
long) u->
Data();
455 gfan::ZCone* zp = (gfan::ZCone*)
v->Data();
456 gfan::ZMatrix zm = zp->extremeRays();
457 for (
int i=0;
i<zm.getHeight();
i++)
458 for (
int j=1;
j<zm.getWidth();
j++)
460 gfan::ZCone* zq =
new gfan::ZCone();
461 *zq = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
463 res->data = (
void*) zq;
464 gfan::deinitializeCddlibIfRequired();
468 WerrorS(
"scalePolytope: unexpected parameters");
477 gfan::initializeCddlibIfRequired();
478 gfan::ZCone* zp = (gfan::ZCone*) u->
Data();
479 gfan::ZCone* zq =
new gfan::ZCone(zp->dualCone());
481 res->data = (
void*) zq;
482 gfan::deinitializeCddlibIfRequired();
485 WerrorS(
"dualPolytope: unexpected parameters");
494 gfan::initializeCddlibIfRequired();
497 std::vector<gfan::IntMatrix> P(
k);
498 for (
int i=0;
i<
k;
i++)
502 gfan::ZCone*
p = (gfan::ZCone*)
l->m[
i].Data();
503 gfan::ZMatrix pv =
p->extremeRays();
504 int r = pv.getHeight();
505 int c = pv.getWidth();
506 gfan::IntMatrix pw(r,c-1);
507 for (
int n=0; n<r; n++)
508 for (
int m=1;
m<c;
m++)
509 pw[n][
m-1] = pv[n][
m].toInt();
510 P[
i]=pw.transposed();
513 poly
p = (poly)
l->m[
i].Data();
515 gfan::IntMatrix pw(0,
N);
516 int *leadexpv = (
int*)
omAlloc((
N+1)*
sizeof(int));
520 gfan::IntVector zv(
N);
521 for (
int i=0;
i<
N;
i++)
522 zv[
i] = leadexpv[
i+1];
526 P[
i]=pw.transposed();
531 WerrorS(
"mixedVolume: entries of unsupported type in list");
532 gfan::deinitializeCddlibIfRequired();
536 gfan::Integer mv = gfan::mixedVolume(P);
540 gfan::deinitializeCddlibIfRequired();
543 WerrorS(
"mixedVolume: unexpected parameters");
551 blackbox *
b=(blackbox*)
omAlloc0(
sizeof(blackbox));
BOOLEAN rays(leftv res, leftv args)
std::string toString(const gfan::ZCone *const c)
static BOOLEAN ppCONERAYS1(leftv res, leftv v)
BOOLEAN polytopeViaVertices(leftv res, leftv args)
void bbpolytope_setup(SModulFunctions *p)
void bbpolytope_destroy(blackbox *, void *d)
std::string bbpolytopeToString(gfan::ZCone const &c)
static BOOLEAN ppCONENORMALS2(leftv res, leftv u, leftv v)
int getCodimension(gfan::ZCone *zc)
char * bbpolytope_String(blackbox *, void *d)
BOOLEAN polytopeViaNormals(leftv res, leftv args)
BOOLEAN dualPolytope(leftv res, leftv args)
gfan::ZVector intStar2ZVectorWithLeadingOne(const int d, const int *i)
BOOLEAN scalePolytope(leftv res, leftv args)
static BOOLEAN ppCONENORMALS1(leftv res, leftv v)
int getDimension(gfan::ZCone *zc)
void * bbpolytope_Init(blackbox *)
static BOOLEAN ppCONERAYS3(leftv res, leftv u, leftv v)
int getAmbientDimension(gfan::ZCone *zc)
BOOLEAN bbpolytope_Assign(leftv l, leftv r)
BOOLEAN mixedVolume(leftv res, leftv args)
static BOOLEAN ppCONENORMALS3(leftv res, leftv u, leftv v, leftv w)
gfan::ZCone newtonPolytope(poly p, ring r)
BOOLEAN vertices(leftv res, leftv args)
void * bbpolytope_Copy(blackbox *, void *d)
bigintmat * iv2bim(intvec *b, const coeffs C)
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
number integerToNumber(const gfan::Integer &I)
bigintmat * zMatrixToBigintmat(const gfan::ZMatrix &zm)
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
const CanonicalForm CFMap CFMap & N
Class used for (list of) interpreter objects.
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
#define omFreeSize(addr, size)
static void p_GetExpV(poly p, int *ev, const ring r)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
void Werror(const char *fmt,...)
static short rVar(const ring r)
#define rVar(r) (r->N)