My Project
Loading...
Searching...
No Matches
Functions | Variables
bbcone.h File Reference
#include "kernel/mod2.h"
#include "misc/intvec.h"
#include "coeffs/bigintmat.h"
#include "Singular/ipid.h"
#include "gfanlib/gfanlib.h"

Go to the source code of this file.

Functions

void bbcone_setup (SModulFunctions *p)
 
std::string toString (const gfan::ZCone *const c)
 
gfan::ZVector randomPoint (const gfan::ZCone *zc, const int b=0)
 
gfan::ZCone liftUp (const gfan::ZCone &zc)
 
gfan::ZMatrix interiorPointsOfFacets (const gfan::ZCone &zc, const std::set< gfan::ZVector > &exceptThese=std::set< gfan::ZVector >())
 
std::pair< gfan::ZMatrix, gfan::ZMatrix > interiorPointsAndNormalsOfFacets (const gfan::ZCone zc, const std::set< gfan::ZVector > &exceptThesePoints=std::set< gfan::ZVector >(), const bool onlyLowerHalfSpace=false)
 

Variables

EXTERN_VAR int coneID
 

Function Documentation

◆ 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}
#define FALSE
Definition: auxiliary.h:96
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
VAR int coneID
Definition: bbcone.cc:25
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 rays(leftv res, leftv args)
Definition: bbcone.cc:662
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:142
int p
Definition: cfModGcd.cc:4078
CanonicalForm b
Definition: cfModGcd.cc:4103
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ interiorPointsAndNormalsOfFacets()

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

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 */
1861 gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);
1862 gfan::ZMatrix outerFacetNormals = gfan::ZMatrix(0,c);
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);
1870 gfan::ZMatrix newEquations = equations;
1871 newEquations.appendRow(inequalities[0]);
1872 gfan::ZCone facet = gfan::ZCone(newInequalities,newEquations);
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));
1888 newEquations = equations;
1889 newEquations.appendRow(inequalities[i]);
1890 facet = gfan::ZCone(newInequalities,newEquations);
1891 interiorPoint = facet.getRelativeInteriorPoint();
1892 if (onlyLowerHalfSpace==false || interiorPoint[0].sign()<0)
1893 {
1894 if (exceptThesePoints.count(interiorPoint)==0)
1895 {
1896 relativeInteriorPoints.appendRow(interiorPoint);
1897 outerFacetNormals.appendRow(-inequalities[i].toVector());
1898 }
1899 }
1900 }
1901
1902 /* this is the i=r-1 case */
1903 newInequalities = inequalities.submatrix(0,0,r-1,c);
1904 newEquations = equations;
1905 newEquations.appendRow(inequalities[r-1]);
1906 facet = gfan::ZCone(newInequalities,newEquations);
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}
int i
Definition: cfEzgcd.cc:132
Definition: gfan.h:47
static int sign(int x)
Definition: ring.cc:3427

◆ interiorPointsOfFacets()

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

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 */
1807 gfan::ZMatrix relativeInteriorPoints = gfan::ZMatrix(0,c);
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);
1814 gfan::ZMatrix newEquations = equations;
1815 newEquations.appendRow(inequalities[0]);
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);
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));
1827 newEquations = equations;
1828 newEquations.appendRow(inequalities[i]);
1829 facet = gfan::ZCone(newInequalities,newEquations);
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);
1838 newEquations = equations;
1839 newEquations.appendRow(inequalities[r-1]);
1840 facet = gfan::ZCone(newInequalities,newEquations);
1841 facet.canonicalize();
1842 interiorPoint = facet.getRelativeInteriorPoint();
1843 if (exceptThese.count(interiorPoint)==0)
1844 relativeInteriorPoints.appendRow(interiorPoint);
1845
1846 return relativeInteriorPoints;
1847}

◆ liftUp()

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();
1186 gfan::ZCone zd(liftUp(ineq),liftUp(eq));
1187 return zd;
1188}
gfan::ZMatrix liftUp(const gfan::ZMatrix &zm)
Definition: bbcone.cc:1170

◆ randomPoint()

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

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

◆ 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;
42 omFree(ineqs);
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}
std::string toString(const gfan::ZCone *const c)
Definition: bbcone.cc:27
int l
Definition: cfEzgcd.cc:100
const CanonicalForm int s
Definition: facAbsFact.cc:51
#define omFree(addr)
Definition: omAllocDecl.h:261
#define NULL
Definition: omList.c:12

Variable Documentation

◆ coneID

EXTERN_VAR int coneID

Definition at line 14 of file bbcone.h.