14 #include <gfanlib/gfanlib.h> 15 #include <gfanlib/gfanlib_q.h> 22 gfan::ZMatrix
i=c.getInequalities();
23 gfan::ZMatrix e=c.getEquations();
24 s<<
"AMBIENT_DIM"<<std::endl;
25 s<<c.ambientDimension()-1<<std::endl;
26 s<<
"INEQUALITIES"<<std::endl;
28 s<<
"EQUATIONS"<<std::endl;
35 return (
void*)(
new gfan::ZCone());
45 gfan::ZCone* zd = (gfan::ZCone*)l->
Data();
48 newZc =
new gfan::ZCone();
50 else if (r->
Typ()==l->
Typ())
54 gfan::ZCone* zd = (gfan::ZCone*)l->
Data();
57 gfan::ZCone* zc = (gfan::ZCone*)r->
Data();
58 newZc =
new gfan::ZCone(*zc);
77 Werror(
"assign Type(%d) = Type(%d) not implemented",l->
Typ(),r->
Typ());
87 l->
data=(
void *)newZc;
96 gfan::ZCone* zc = (gfan::ZCone*)d;
106 gfan::ZCone* zc = (gfan::ZCone*) d;
113 gfan::ZCone* zc = (gfan::ZCone*)d;
114 gfan::ZCone* newZc =
new gfan::ZCone(*zc);
134 gfan::ZCone* zc =
new gfan::ZCone();
135 *zc = gfan::ZCone::givenByRays(*zm, gfan::ZMatrix(0, zm->getWidth()));
137 res->
data = (
void*) zc;
164 int k = (int)(
long)v->
Data();
166 if ((k < 0) || (k > 1))
168 WerrorS(
"expected int argument in [0..1]");
173 gfan::ZCone* zc =
new gfan::ZCone();
174 *zc = gfan::ZCone::givenByRays(*zm,gfan::ZMatrix(0, zm->getWidth()));
177 res->
data = (
void*) zc;
187 gfan::initializeCddlibIfRequired();
198 WerrorS(
"polytopeViaPoints: unexpected parameters");
215 gfan::ZCone* zc =
new gfan::ZCone(*zm, gfan::ZMatrix(0, zm->getWidth()));
220 res->
data = (
void*) zc;
249 Werror(
"expected same number of columns but got %d vs. %d",
255 gfan::ZCone* zc =
new gfan::ZCone(*zm1, *zm2);
264 res->
data = (
void*) zc;
295 Werror(
"expected same number of columns but got %d vs. %d",
299 int k = (int)(
long)w->
Data();
300 if ((k < 0) || (k > 3))
302 WerrorS(
"expected int argument in [0..3]");
307 gfan::ZCone* zc =
new gfan::ZCone(*zm1, *zm2, k);
316 res->
data = (
void*) zc;
322 gfan::initializeCddlibIfRequired();
338 WerrorS(
"polytopeViaInequalities: unexpected parameters");
344 gfan::initializeCddlibIfRequired();
348 gfan::ZCone* zc = (gfan::ZCone*)u->
Data();
349 gfan::ZMatrix zmat = zc->extremeRays();
354 WerrorS(
"vertices: unexpected parameters");
360 return zc->ambientDimension()-1;
365 return zc->codimension();
370 return zc->dimension()-1;
375 gfan::ZVector zv(d+1);
377 for(
int j=1;
j<=d;
j++)
387 gfan::ZMatrix zm(0,N+1);
388 int *leadexpv = (
int*)
omAlloc((N+1)*
sizeof(int));
397 gfan::ZCone Delta = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
403 gfan::initializeCddlibIfRequired();
412 WerrorS(
"newtonPolytope: unexpected parameters");
418 gfan::initializeCddlibIfRequired();
425 int s = (int)(
long) u->
Data();
426 gfan::ZCone* zp = (gfan::ZCone*) v->
Data();
427 gfan::ZMatrix zm = zp->extremeRays();
428 for (
int i=0;
i<zm.getHeight();
i++)
429 for (
int j=1;
j<zm.getWidth();
j++)
431 gfan::ZCone* zq =
new gfan::ZCone();
432 *zq = gfan::ZCone::givenByRays(zm,gfan::ZMatrix(0, zm.getWidth()));
434 res->
data = (
void*) zq;
438 WerrorS(
"scalePolytope: unexpected parameters");
444 gfan::initializeCddlibIfRequired();
448 gfan::ZCone* zp = (gfan::ZCone*) u->
Data();
449 gfan::ZCone* zq =
new gfan::ZCone(zp->dualCone());
451 res->
data = (
void*) zq;
454 WerrorS(
"dualPolytope: unexpected parameters");
460 gfan::initializeCddlibIfRequired();
466 std::vector<gfan::IntMatrix>
P(k);
467 for (
int i=0;
i<
k;
i++)
471 gfan::ZCone*
p = (gfan::ZCone*) l->
m[
i].
Data();
472 gfan::ZMatrix pv = p->extremeRays();
473 int r = pv.getHeight();
474 int c = pv.getWidth();
475 gfan::IntMatrix pw(r,c-1);
476 for (
int n=0; n<
r; n++)
477 for (
int m=1;
m<c;
m++)
478 pw[n][
m-1] = pv[n][
m].toInt();
479 P[
i]=pw.transposed();
484 gfan::IntMatrix pw(0,N);
485 int *leadexpv = (
int*)
omAlloc((N+1)*
sizeof(int));
489 gfan::IntVector zv(N);
490 for (
int i=0;
i<
N;
i++)
491 zv[
i] = leadexpv[
i+1];
495 P[
i]=pw.transposed();
500 WerrorS(
"mixedVolume: entries of unsupported type in list");
510 WerrorS(
"mixedVolume: unexpected parameters");
518 blackbox *
b=(blackbox*)
omAlloc0(
sizeof(blackbox));
BOOLEAN mixedVolume(leftv res, leftv args)
const CanonicalForm int s
Class used for (list of) interpreter objects.
BOOLEAN dualPolytope(leftv res, leftv args)
BOOLEAN bbpolytope_Assign(leftv l, leftv r)
BOOLEAN scalePolytope(leftv res, leftv args)
void * bbpolytope_Init(blackbox *)
bigintmat * iv2bim(intvec *b, const coeffs C)
bigintmat * zMatrixToBigintmat(const gfan::ZMatrix &zm)
static void p_GetExpV(poly p, int *ev, const ring r)
#define omFreeSize(addr, size)
static BOOLEAN ppCONENORMALS3(leftv res, leftv u, leftv v, leftv w)
static short rVar(const ring r)
#define rVar(r) (r->N)
static BOOLEAN ppCONERAYS1(leftv res, leftv v)
void WerrorS(const char *s)
gfan::ZVector intStar2ZVectorWithLeadingOne(const int d, const int *i)
int getDimension(gfan::ZCone *zc)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
static BOOLEAN ppCONENORMALS2(leftv res, leftv u, leftv v)
const CanonicalForm CFMap CFMap & N
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
void bbpolytope_destroy(blackbox *, void *d)
BOOLEAN vertices(leftv res, leftv args)
BOOLEAN polytopeViaNormals(leftv res, leftv args)
number integerToNumber(const gfan::Integer &I)
std::string bbpolytopeToString(gfan::ZCone const &c)
const Variable & v
< [in] a sqrfree bivariate poly
BOOLEAN polytopeViaVertices(leftv res, leftv args)
BOOLEAN rays(leftv res, leftv args)
int getCodimension(gfan::ZCone *zc)
int getAmbientDimension(gfan::ZCone *zc)
gfan::ZCone newtonPolytope(poly p, ring r)
static BOOLEAN ppCONENORMALS1(leftv res, leftv v)
std::string toString(const gfan::ZCone *const c)
char * bbpolytope_String(blackbox *, void *d)
int(* iiAddCproc)(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
static BOOLEAN ppCONERAYS3(leftv res, leftv u, leftv v)
void * bbpolytope_Copy(blackbox *, void *d)
void Werror(const char *fmt,...)
void bbpolytope_setup(SModulFunctions *p)