CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
#ifndef POLYMAKEDATA
2
#define POLYMAKEDATA 1
3
4
#include "loadgap.h"
5
6
#include <polymake/Main.h>
7
#include <polymake/Matrix.h>
8
#include <polymake/IncidenceMatrix.h>
9
#include <polymake/Rational.h>
10
#include <polymake/common/lattice_tools.h>
11
12
#include <iostream>
13
#include <map>
14
#include <utility>
15
16
using std::cerr;
17
using std::endl;
18
using std::string;
19
using std::map;
20
using std::pair;
21
22
extern Obj TheTypeExternalPolymakeCone;
23
extern Obj TheTypeExternalPolymakeFan;
24
extern Obj TheTypeExternalPolymakePolytope;
25
extern Obj TheTypeExternalPolymakeTropicalHypersurface;
26
extern Obj TheTypeExternalPolymakeTropicalPolytope;
27
28
typedef pair<int, pm::perl::Object*> object_pair;
29
typedef pm::perl::Object perlobj;
30
typedef map<int, pm::perl::Object*>::iterator iterator;
31
32
struct Polymake_Data {
33
bool initialized;
34
polymake::Main *main_polymake_session;
35
polymake::perl::Scope *main_polymake_scope;
36
map<int, pm::perl::Object*> *polymake_objects;
37
int new_polymake_object_number;
38
};
39
40
#define POLYMAKEOBJ_SET_PERLOBJ(o, p) (ADDR_OBJ(o)[1] = reinterpret_cast<Obj>(p))
41
#define PERLOBJ_POLYMAKEOBJ(o) (reinterpret_cast<perlobj*>(ADDR_OBJ(o)[1]))
42
43
#define IS_POLYMAKE_CONE(o) ((UInt)(ADDR_OBJ(o)[0])==(UInt)TheTypeExternalPolymakeCone)
44
#define IS_POLYMAKE_POLYTOPE(o) ((UInt)(ADDR_OBJ(o)[0])==(UInt)TheTypeExternalPolymakePolytope)
45
#define IS_POLYMAKE_FAN(o) ((UInt)(ADDR_OBJ(o)[0])==(UInt)TheTypeExternalPolymakeFan)
46
#define IS_POLYMAKE_TROPICAL_HYPERSURFACE(o) ((UInt)(ADDR_OBJ(o)[0])==(UInt)TheTypeExternalPolymakeTropicalHypersurface)
47
#define IS_POLYMAKE_TROPICAL_POLYTOPE(o) ((UInt)(ADDR_OBJ(o)[0])==(UInt)TheTypeExternalPolymakeTropicalPolytope)
48
#define IS_POLYMAKE_OBJECT(o) ((IS_POLYMAKE_CONE(o))||(IS_POLYMAKE_POLYTOPE(o))||(IS_POLYMAKE_FAN(o))||(IS_POLYMAKE_TROPICAL_HYPERSURFACE(o))||(IS_POLYMAKE_TROPICAL_POLYTOPE(o)))
49
50
enum polymake_object_type {
51
T_POLYMAKE_EXTERNAL_CONE,
52
T_POLYMAKE_EXTERNAL_FAN,
53
T_POLYMAKE_EXTERNAL_POLYTOPE,
54
T_POLYMAKE_EXTERNAL_TROPICAL_HYPERSURFACE,
55
T_POLYMAKE_EXTERNAL_TROPICAL_POLYTOPE
56
};
57
Obj NewPolymakeExternalObject(enum polymake_object_type t);
58
void ExternalPolymakeObjectFreeFunc(Obj o);
59
Obj ExternalPolymakeObjectTypeFunc(Obj o);
60
61
void polymake_start( Polymake_Data* );
62
63
64
// Obj x = NewPolymakeExternalObject(T_POLYMAKE_EXTERNAL_CONE);
65
// POLYMAKEOBJ_SET_PERLOBJ(x, p);
66
67
#define POLYMAKE_GAP_CATCH \
68
catch( std::exception& err ){ \
69
cerr << "Polymake error: " << endl << err.what( ) << endl; \
70
ErrorMayQuit("during polymake computation.",0,0); \
71
}
72
73
#endif
74
75