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
#include "polymake_cone.h"
2
3
4
Obj REAL_CREATE_CONE_BY_RAYS( Polymake_Data* data, Obj rays ){
5
6
if( ! IS_PLIST( rays ) ){
7
ErrorMayQuit( "not a plain list", 0, 0);
8
return NULL;
9
}
10
11
int len = LEN_PLIST( rays );
12
Obj akt = ELM_PLIST( rays, 1 );
13
Obj elem;
14
15
#ifdef MORE_TESTS
16
if( !IS_PLIST( akt ) ){
17
ErrorMayQuit( "first ray is not a plain list", 0, 0);
18
return NULL;
19
}
20
#endif
21
22
int len_elem = LEN_PLIST( akt );
23
data->main_polymake_session->set_application("polytope");
24
25
pm::Integer* ratarray = new pm::Integer[(len)*(len_elem)];
26
27
for(int i=0;i<len;i++){
28
akt = ELM_PLIST( rays, i+1 );
29
#ifdef MORE_TESTS
30
if( !IS_PLIST( akt ) ){
31
delete [] ratarray;
32
ErrorMayQuit( "one ray is not a plain list", 0, 0);
33
return NULL;
34
}
35
if( LEN_PLIST( akt ) != len_elem ){
36
delete [] ratarray;
37
ErrorMayQuit( "raygenerators are not of the same lenght", 0, 0);
38
return NULL;
39
}
40
#endif
41
for(int j = 0; j < len_elem; j++){
42
elem = ELM_PLIST( akt, j+1);
43
#ifdef MORE_TESTS
44
if( ! IS_INTOBJ( elem) ){
45
delete [] ratarray;
46
ErrorMayQuit( "some entries are not integers", 0, 0);
47
return NULL;
48
}
49
#endif
50
ratarray[ ( i * len_elem ) + j] = static_cast<pm::Integer>(INT_INTOBJ( elem ));
51
}
52
53
}
54
55
pm::Matrix<pm::Integer>* matr = new pm::Matrix<pm::Integer>(len,len_elem,ratarray);
56
delete [] ratarray;
57
perlobj* p = new perlobj("Cone");
58
p->take("INPUT_RAYS") << *matr;
59
60
delete matr;
61
62
elem = NewPolymakeExternalObject(T_POLYMAKE_EXTERNAL_CONE);
63
64
POLYMAKEOBJ_SET_PERLOBJ(elem, p);
65
66
return elem;
67
}
68
69
70
Obj REAL_CREATE_CONE_BY_RAYS_UNSAVE( Polymake_Data* data, Obj rays ){
71
72
if( ! IS_PLIST( rays ) ){
73
ErrorMayQuit( "not a plain list", 0, 0);
74
return NULL;
75
}
76
77
int len = LEN_PLIST( rays );
78
Obj akt = ELM_PLIST( rays, 1 );
79
Obj elem;
80
81
#ifdef MORE_TESTS
82
if( !IS_PLIST( akt ) ){
83
ErrorMayQuit( "first ray is not a plain list", 0, 0);
84
return NULL;
85
}
86
#endif
87
88
int len_elem = LEN_PLIST( akt );
89
data->main_polymake_session->set_application("polytope");
90
91
pm::Integer* ratarray;
92
ratarray = new pm::Integer[(len)*(len_elem)];
93
94
for(int i=0;i<len;i++){
95
akt = ELM_PLIST( rays, i+1 );
96
#ifdef MORE_TESTS
97
if( !IS_PLIST( akt ) ){
98
delete [] ratarray;
99
ErrorMayQuit( "one ray is not a plain list", 0, 0);
100
return NULL;
101
}
102
if( LEN_PLIST( akt ) != len_elem ){
103
delete [] ratarray;
104
ErrorMayQuit( "raygenerators are not of the same lenght", 0, 0);
105
return NULL;
106
}
107
#endif
108
for(int j = 0; j < len_elem; j++){
109
elem = ELM_PLIST( akt, j+1);
110
#ifdef MORE_TESTS
111
if( ! IS_INTOBJ( elem) ){
112
delete [] ratarray;
113
ErrorMayQuit( "some entries are not integers", 0, 0);
114
return NULL;
115
}
116
#endif
117
ratarray[ ( i * len_elem ) + j] = INT_INTOBJ( elem );
118
}
119
120
}
121
122
pm::Matrix<pm::Integer>* matr = new pm::Matrix<pm::Integer>(len,len_elem,ratarray);
123
delete [] ratarray;
124
perlobj* p = new perlobj("Cone");
125
p->take("RAYS") << *matr;
126
delete matr;
127
elem = NewPolymakeExternalObject(T_POLYMAKE_EXTERNAL_CONE);
128
129
POLYMAKEOBJ_SET_PERLOBJ(elem, p);
130
131
return elem;
132
}
133
134
135
Obj REAL_CREATE_CONE_BY_INEQUALITIES( Polymake_Data* data, Obj rays ){
136
137
if( ! IS_PLIST( rays ) ){
138
ErrorMayQuit( "not a plain list 1", 0, 0);
139
return NULL;
140
}
141
142
int len = LEN_PLIST( rays );
143
Obj akt = ELM_PLIST( rays, 1 );
144
Obj elem;
145
146
#ifdef MORE_TESTS
147
if( !IS_PLIST( akt ) ){
148
ErrorMayQuit( "not a plain list 2", 0, 0);
149
return NULL;
150
}
151
#endif
152
153
int len_elem = LEN_PLIST( akt );
154
data->main_polymake_session->set_application("polytope");
155
156
pm::Integer* ratarray;
157
ratarray = new pm::Integer[(len)*(len_elem)];
158
159
for(int i=0;i<len;i++){
160
akt = ELM_PLIST( rays, i+1 );
161
#ifdef MORE_TESTS
162
if( !IS_PLIST( akt ) ){
163
delete [] ratarray;
164
ErrorMayQuit( "not a plain list 3", 0, 0);
165
return NULL;
166
}
167
if( LEN_PLIST( akt ) != len_elem ){
168
delete [] ratarray;
169
ErrorMayQuit( "raygenerators are not of the same lenght", 0, 0);
170
return NULL;
171
}
172
#endif
173
for(int j = 0; j < len_elem; j++){
174
elem = ELM_PLIST( akt, j+1);
175
#ifdef MORE_TESTS
176
if( ! IS_INTOBJ( elem) ){
177
delete [] ratarray;
178
ErrorMayQuit( "some entries are not integers", 0, 0);
179
return NULL;
180
}
181
#endif
182
ratarray[ ( i * len_elem ) + j] = INT_INTOBJ( elem );
183
}
184
185
}
186
187
pm::Matrix<pm::Integer>* matr = new pm::Matrix<pm::Integer>(len,len_elem,ratarray);
188
delete [] ratarray;
189
perlobj* p = new perlobj("Cone");
190
p->take("INEQUALITIES") << *matr;
191
//this needs to be fixed!!
192
delete matr;
193
elem = NewPolymakeExternalObject(T_POLYMAKE_EXTERNAL_CONE);
194
POLYMAKEOBJ_SET_PERLOBJ(elem, p);
195
return elem;
196
}
197
198
199
Obj REAL_CREATE_DUAL_CONE_OF_CONE( Polymake_Data* data, Obj cone ){
200
201
#ifdef MORE_TESTS
202
if(! IS_POLYMAKE_CONE(cone) ){
203
ErrorMayQuit(" parameter is not an integer.",0,0);
204
return NULL;
205
}
206
#endif
207
208
perlobj* coneobj = PERLOBJ_POLYMAKEOBJ(cone);
209
210
data->main_polymake_session->set_application_of(*coneobj);
211
pm::Matrix<pm::Rational> matr;
212
try
213
{
214
pm::Matrix<pm::Rational> matr_temp = coneobj->give("FACETS"); //That is the ugliest solution
215
matr = matr_temp;
216
}
217
218
POLYMAKE_GAP_CATCH
219
220
perlobj* p;
221
p = new perlobj("Cone<Rational>");
222
pm::Matrix<pm::Rational> matr2;
223
try
224
{
225
pm::Matrix<pm::Rational> matr2_temp = coneobj->give("LINEAR_SPAN");
226
matr2 = matr2_temp;
227
}
228
229
POLYMAKE_GAP_CATCH
230
231
pm::Matrix<pm::Rational>* matr3 = new pm::Matrix<pm::Rational>(matr.rows()+2*matr2.rows(), matr.cols());
232
for(int i = 0; i < matr.rows(); i++)
233
matr3->row(i) = matr.row(i);
234
for(int i = 0; i < matr2.rows(); i++)
235
matr3->row(matr.rows()+i) = matr2.row(i);
236
for(int i = 0; i < matr2.rows(); i++)
237
matr3->row(matr.rows()+matr2.rows()+i) = -(matr2.row(i));
238
p->take("INPUT_RAYS") << *matr3;
239
delete matr3;
240
241
Obj elem = NewPolymakeExternalObject( T_POLYMAKE_EXTERNAL_CONE );
242
243
POLYMAKEOBJ_SET_PERLOBJ( elem, p );
244
245
return elem;
246
247
}
248
249
250
// Obj REAL_GENERATING_RAYS_OF_CONE( Polymake_Data* data, Obj cone){
251
//
252
// #ifdef MORE_TESTS
253
// if( ( ! IS_POLYMAKE_CONE(cone) ) && ( ! IS_POLYMAKE_FAN(cone) ) ){
254
// ErrorMayQuit(" parameter is not a cone or fan.",0,0);
255
// return NULL;
256
// }
257
// #endif
258
//
259
// perlobj* coneobj = PERLOBJ_POLYMAKEOBJ( cone );
260
// data->main_polymake_session->set_application_of(*coneobj);
261
// pm::Matrix<pm::Rational> matr = coneobj->give("RAYS");
262
// Obj RETLI = NEW_PLIST( T_PLIST , matr.rows());
263
// SET_LEN_PLIST( RETLI , matr.rows() );
264
// Obj LIZeil;
265
// pm::Rational nenner;
266
// pm::Rational dentemp;
267
// for(int i = 0;i<matr.rows();i++){
268
// LIZeil = NEW_PLIST( T_PLIST, matr.cols());
269
// SET_LEN_PLIST( LIZeil , matr.cols() );
270
// nenner = 1;
271
// for(int j = 0;j<matr.cols();j++){
272
// CallPolymakeFunction("denominator",matr(i,j)) >> dentemp;
273
// CallPolymakeFunction("lcm",nenner, dentemp ) >> nenner;
274
// }
275
// for(int j = 0;j<matr.cols();j++){
276
// SET_ELM_PLIST(LIZeil,j+1,INTOBJ_INT(matr(i,j)*nenner));
277
// }
278
// SET_ELM_PLIST(RETLI,i+1,LIZeil);
279
// CHANGED_BAG(RETLI);
280
// }
281
// return RETLI;
282
// }
283
284
285
Obj REAL_GENERATING_RAYS_OF_CONE( Polymake_Data* data, Obj cone){
286
287
#ifdef MORE_TESTS
288
if(! IS_POLYMAKE_CONE(cone) ){
289
ErrorMayQuit(" parameter is not an integer.",0,0);
290
return NULL;
291
}
292
#endif
293
perlobj* coneobj = PERLOBJ_POLYMAKEOBJ( cone );
294
data->main_polymake_session->set_application_of(*coneobj);
295
pm::Matrix<pm::Rational> matr;
296
try{
297
pm::Matrix<pm::Rational> matr_temp = coneobj->give("RAYS");
298
matr = matr_temp;
299
}
300
301
POLYMAKE_GAP_CATCH
302
303
pm::Matrix<pm::Rational> matr2;
304
try{
305
pm::Matrix<pm::Rational> matr2_temp = coneobj->give("LINEALITY_SPACE");
306
matr2 = matr2_temp;
307
}
308
309
POLYMAKE_GAP_CATCH
310
311
Obj RETLI = NEW_PLIST( T_PLIST , matr.rows() + 2*matr2.rows());
312
UInt lenght_RETLI = matr.rows() + 2*matr2.rows();
313
SET_LEN_PLIST( RETLI , lenght_RETLI );
314
315
polymake::common::primitive( matr );
316
polymake::common::primitive( matr2 );
317
318
Obj LIZeil;
319
UInt matr_cols = matr.cols();
320
for(int i = 0;i<matr.rows();i++){
321
LIZeil = NEW_PLIST( T_PLIST, matr.cols());
322
SET_LEN_PLIST( LIZeil , matr_cols );
323
for(int j = 0;j<matr.cols();j++){
324
SET_ELM_PLIST(LIZeil,j+1,INTOBJ_INT( (matr(i,j)).to_int() ));
325
}
326
SET_ELM_PLIST(RETLI,i+1,LIZeil);
327
CHANGED_BAG(RETLI);
328
}
329
330
UInt matr2_cols = matr2.cols();
331
332
for(int i = 0;i<matr2.rows();i++){
333
LIZeil = NEW_PLIST( T_PLIST, matr2.cols());
334
SET_LEN_PLIST( LIZeil ,matr2_cols );
335
for(int j = 0;j<matr2.cols();j++){
336
SET_ELM_PLIST(LIZeil,j+1,INTOBJ_INT( (matr2(i,j)).to_int() ));
337
}
338
SET_ELM_PLIST(RETLI,matr.rows() + i +1,LIZeil);
339
CHANGED_BAG(RETLI);
340
}
341
342
for(int i = 0;i<matr2.rows();i++){
343
LIZeil = NEW_PLIST( T_PLIST, matr2.cols());
344
SET_LEN_PLIST( LIZeil ,matr2_cols);
345
for(int j = 0;j<matr2.cols();j++){
346
SET_ELM_PLIST(LIZeil,j+1,INTOBJ_INT( (-matr2(i,j)).to_int() ));
347
}
348
SET_ELM_PLIST(RETLI,matr.rows() + matr2.rows() + i +1,LIZeil);
349
CHANGED_BAG(RETLI);
350
}
351
return RETLI;
352
}
353
354
355
Obj REAL_LINEALITY_SPACE_OF_CONE( Polymake_Data* data, Obj cone){
356
357
#ifdef MORE_TESTS
358
if( ( ! IS_POLYMAKE_CONE(cone) ) ){
359
ErrorMayQuit(" parameter is not a cone or fan.",0,0);
360
return NULL;
361
}
362
#endif
363
364
perlobj* coneobj = PERLOBJ_POLYMAKEOBJ( cone );
365
data->main_polymake_session->set_application_of(*coneobj);
366
pm::Matrix<pm::Rational> matr;
367
try
368
{
369
pm::Matrix<pm::Rational> matr_temp = coneobj->give("LINEALITY_SPACE");
370
matr = matr_temp;
371
}
372
373
POLYMAKE_GAP_CATCH
374
375
376
polymake::common::primitive( matr );
377
378
Obj RETLI = NEW_PLIST( T_PLIST , matr.rows());
379
UInt matr_rows = matr.rows();
380
SET_LEN_PLIST( RETLI , matr_rows );
381
Obj LIZeil;
382
UInt matr_cols = matr.cols();
383
for(int i = 0;i<matr.rows();i++){
384
LIZeil = NEW_PLIST( T_PLIST, matr.cols());
385
SET_LEN_PLIST( LIZeil , matr_cols );
386
for(int j = 0;j<matr.cols();j++){
387
SET_ELM_PLIST(LIZeil,j+1,INTOBJ_INT( (matr(i,j)).to_int() ));
388
}
389
SET_ELM_PLIST(RETLI,i+1,LIZeil);
390
CHANGED_BAG(RETLI);
391
}
392
return RETLI;
393
}
394
395
396
Obj REAL_HILBERT_BASIS_OF_CONE( Polymake_Data* data, Obj cone){
397
398
#ifdef MORE_TESTS
399
if(! IS_POLYMAKE_CONE(cone) ){
400
ErrorMayQuit(" parameter is not a cone.",0,0);
401
return NULL;
402
}
403
#endif
404
405
perlobj* coneobj = PERLOBJ_POLYMAKEOBJ( cone );
406
data->main_polymake_session->set_application_of(*coneobj);
407
pm::Matrix<pm::Rational> matr;
408
try
409
{
410
pm::Array<pm::Matrix<pm::Rational> > matr_temp = coneobj->give("HILBERT_BASIS_GENERATORS");
411
matr = matr_temp[0];
412
}
413
414
POLYMAKE_GAP_CATCH
415
416
Obj RETLI = NEW_PLIST( T_PLIST , matr.rows());
417
UInt matr_rows = matr.rows();
418
SET_LEN_PLIST( RETLI , matr_rows );
419
Obj LIZeil;
420
UInt matr_cols = matr.cols();
421
for(int i = 0;i<matr.rows();i++){
422
LIZeil = NEW_PLIST( T_PLIST, matr.cols());
423
SET_LEN_PLIST( LIZeil ,matr_cols);
424
for(int j = 0;j<matr.cols();j++){
425
SET_ELM_PLIST(LIZeil,j+1,INTOBJ_INT((matr(i,j)).to_int()));
426
}
427
SET_ELM_PLIST(RETLI,i+1,LIZeil);
428
}
429
return RETLI;
430
431
}
432
433
Obj REAL_RAYS_IN_FACETS( Polymake_Data* data, Obj cone){
434
435
#ifdef MORE_TESTS
436
if( ( ! IS_POLYMAKE_CONE(cone) ) and ( ! IS_POLYMAKE_POLYTOPE( cone ) ) ){
437
ErrorMayQuit("parameter is not a cone.",0,0);
438
return NULL;
439
}
440
#endif
441
442
perlobj* coneobj = PERLOBJ_POLYMAKEOBJ( cone );
443
data->main_polymake_session->set_application_of(*coneobj);
444
pm::IncidenceMatrix<pm::NonSymmetric> matr;
445
try
446
{
447
pm::IncidenceMatrix<pm::NonSymmetric> matr_temp = coneobj->give("RAYS_IN_FACETS");
448
matr = matr_temp;
449
}
450
451
POLYMAKE_GAP_CATCH
452
453
Obj RETLI = NEW_PLIST( T_PLIST , matr.rows());
454
UInt matr_rows = matr.rows();
455
SET_LEN_PLIST( RETLI , matr_rows );
456
Obj LIZeil;
457
UInt matr_cols = matr.cols();
458
for(int i = 0;i<matr.rows();i++){
459
LIZeil = NEW_PLIST( T_PLIST, matr.cols());
460
SET_LEN_PLIST( LIZeil , matr_cols );
461
for(int j = 0;j<matr.cols();j++){
462
SET_ELM_PLIST(LIZeil,j+1,INTOBJ_INT(matr(i,j)));
463
}
464
SET_ELM_PLIST(RETLI,i+1,LIZeil);
465
CHANGED_BAG(RETLI);
466
}
467
return RETLI;
468
469
}
470
471
472
Obj REAL_DEFINING_INEQUALITIES_OF_CONE( Polymake_Data* data, Obj cone){
473
474
#ifdef MORE_TESTS
475
if(! IS_POLYMAKE_CONE(cone) ){
476
ErrorMayQuit("parameter is not a polymake cone",0,0);
477
return NULL;
478
}
479
#endif
480
481
perlobj* coneobj = PERLOBJ_POLYMAKEOBJ( cone );
482
data->main_polymake_session->set_application_of(*coneobj);
483
pm::Matrix<pm::Integer> matr;
484
pm::Matrix<pm::Integer> matr2;
485
486
try{
487
coneobj->give("FACETS") >> matr;
488
coneobj->give("LINEAR_SPAN") >> matr2;
489
}
490
491
POLYMAKE_GAP_CATCH
492
493
Obj RETLI = NEW_PLIST( T_PLIST , matr.rows() + 2*matr2.rows());
494
UInt lenght_RETLI = matr.rows() + 2*matr2.rows();
495
SET_LEN_PLIST( RETLI , lenght_RETLI );
496
Obj LIZeil;
497
498
UInt matr_cols = matr.cols();
499
for(int i = 0;i<matr.rows();i++){
500
LIZeil = NEW_PLIST( T_PLIST, matr.cols());
501
SET_LEN_PLIST( LIZeil , matr_cols );
502
for(int j = 0;j<matr.cols();j++){
503
SET_ELM_PLIST(LIZeil, j+1, INTOBJ_INT( matr(i,j).to_int() ) );
504
CHANGED_BAG( LIZeil );
505
}
506
SET_ELM_PLIST(RETLI,i+1,LIZeil);
507
CHANGED_BAG(RETLI);
508
}
509
510
UInt matr2_cols = matr2.cols();
511
512
Obj LIZeil2;
513
514
for(int i = 0;i<matr2.rows();i++){
515
LIZeil = NEW_PLIST( T_PLIST, matr2.cols());
516
LIZeil2 = NEW_PLIST( T_PLIST, matr2.cols() );
517
SET_LEN_PLIST( LIZeil , matr2_cols );
518
SET_LEN_PLIST( LIZeil2, matr2_cols );
519
for(int j = 0;j<matr2.cols();j++){
520
SET_ELM_PLIST( LIZeil, j+1, INTOBJ_INT( matr2(i,j).to_int() ));
521
CHANGED_BAG( LIZeil );
522
SET_ELM_PLIST( LIZeil2, j+1, INTOBJ_INT( -matr2(i,j).to_int() ) );
523
CHANGED_BAG( LIZeil2 );
524
525
}
526
SET_ELM_PLIST(RETLI,matr.rows() + i +1 ,LIZeil);
527
CHANGED_BAG(RETLI);
528
SET_ELM_PLIST(RETLI, matr.rows() + matr2.rows() + i + 1, LIZeil2 );
529
CHANGED_BAG(RETLI);
530
}
531
return RETLI;
532
533
}
534
535
Obj REAL_INTERSECTION_OF_CONES( Polymake_Data* data, Obj cone1, Obj cone2){
536
537
#ifdef MORE_TESTS
538
if(! IS_POLYMAKE_CONE(cone1) || ! IS_POLYMAKE_CONE(cone2) ){
539
ErrorMayQuit(" parameter is not a cone.",0,0);
540
return NULL;
541
}
542
#endif
543
544
perlobj* coneobj1 = PERLOBJ_POLYMAKEOBJ( cone1 );
545
perlobj* coneobj2 = PERLOBJ_POLYMAKEOBJ( cone2 );
546
547
data->main_polymake_session->set_application_of( *coneobj1 );
548
549
perlobj intersec;
550
551
CallPolymakeFunction( "intersection", *coneobj1, *coneobj2 ) >> intersec;
552
553
perlobj* returnobj = new perlobj(intersec);
554
555
Obj elem = NewPolymakeExternalObject(T_POLYMAKE_EXTERNAL_CONE);
556
557
POLYMAKEOBJ_SET_PERLOBJ( elem, returnobj );
558
559
return elem;
560
561
}
562
563
Obj REAL_EQUALITIES_OF_CONE( Polymake_Data* data, Obj cone){
564
565
#ifdef MORE_TESTS
566
if(! IS_POLYMAKE_CONE(cone) ){
567
ErrorMayQuit(" parameter is not an integer.",0,0);
568
return NULL;
569
}
570
#endif
571
perlobj* coneobj = PERLOBJ_POLYMAKEOBJ( cone );
572
data->main_polymake_session->set_application_of(*coneobj);
573
pm::Matrix<pm::Rational> matr = coneobj->give("LINEAR_SPAN");
574
Obj RETLI = NEW_PLIST( T_PLIST , matr.rows() );
575
UInt matr_rows = matr.rows();
576
SET_LEN_PLIST( RETLI ,matr_rows);
577
Obj LIZeil;
578
polymake::common::primitive( matr );
579
UInt matr_cols = matr.cols();
580
for(int i = 0;i<matr.rows();i++){
581
LIZeil = NEW_PLIST( T_PLIST, matr.cols());
582
SET_LEN_PLIST( LIZeil , matr_cols );
583
for(int j = 0;j<matr.cols();j++){
584
SET_ELM_PLIST(LIZeil,j+1,INTOBJ_INT( (matr(i,j)).to_int() ));
585
}
586
SET_ELM_PLIST(RETLI,i+1,LIZeil);
587
CHANGED_BAG(RETLI);
588
}
589
return RETLI;
590
}
591
592
Obj REAL_CREATE_CONE_BY_EQUALITIES_AND_INEQUALITIES( Polymake_Data* data, Obj eqs, Obj ineqs ){
593
594
if( ! IS_PLIST( eqs ) || ! IS_PLIST( ineqs ) ){
595
ErrorMayQuit( "not a plain list", 0, 0);
596
return NULL;
597
}
598
599
int numberofrays = LEN_PLIST( eqs );
600
Obj akt;
601
Obj elem;
602
Obj numb;
603
data->main_polymake_session->set_application("polytope");
604
int dimension = LEN_PLIST( ELM_PLIST( eqs, 1 ) );
605
pm::Integer* ratarray;
606
ratarray = new pm::Integer[ numberofrays*dimension ];
607
for(int i=0;i<numberofrays;i++){
608
akt = ELM_PLIST( eqs, i+1 );
609
#ifdef MORE_TESTS
610
if( !IS_PLIST( akt ) || LEN_PLIST( akt ) != dimension ){
611
delete [] ratarray;
612
ErrorMayQuit( "one ray is not a plain list", 0, 0);
613
return NULL;
614
}
615
#endif
616
for(int j = 0; j<dimension; j++){
617
numb = ELM_PLIST( akt, j+1 );
618
#ifdef MORE_TESTS
619
if( ! IS_INTOBJ( numb ) ){
620
delete [] ratarray;
621
ErrorMayQuit( "some entries are not integers", 0, 0);
622
return NULL;
623
}
624
#endif
625
ratarray[(i*dimension)+j] = INT_INTOBJ( numb );
626
}
627
}
628
int numberofcones = LEN_PLIST( ineqs );
629
pm::Integer* incMatr = new pm::Integer[numberofcones*dimension];
630
for(int i=0;i<numberofcones;i++){
631
akt = ELM_PLIST( ineqs, i+1 );
632
#ifdef MORE_TESTS
633
if( !IS_PLIST( akt ) || LEN_PLIST( akt ) != dimension ){
634
delete [] incMatr;
635
ErrorMayQuit( "one ray is not a plain list", 0, 0);
636
return NULL;
637
}
638
#endif
639
for(int j = 0; j<dimension; j++){
640
numb = ELM_PLIST( akt, j+1 );
641
#ifdef MORE_TESTS
642
if( ! IS_INTOBJ( numb ) ){
643
delete [] incMatr;
644
ErrorMayQuit( "some entries are not integers", 0, 0);
645
return NULL;
646
}
647
#endif
648
incMatr[(i*dimension)+j] = INT_INTOBJ( numb );
649
}
650
}
651
652
pm::Matrix<pm::Integer>* matr = new pm::Matrix<pm::Integer>(numberofrays,dimension,ratarray);
653
pm::Matrix<pm::Integer>* matr2 = new pm::Matrix<pm::Integer>(numberofcones,dimension,incMatr);
654
perlobj* q = new perlobj("Cone<Rational>");
655
q->take("EQUATIONS") << *matr;
656
q->take("INEQUALITIES") << *matr2;
657
elem = NewPolymakeExternalObject( T_POLYMAKE_EXTERNAL_CONE );
658
POLYMAKEOBJ_SET_PERLOBJ( elem, q);
659
delete [] ratarray;
660
delete [] incMatr;
661
delete matr;
662
delete matr2;
663
return elem;
664
}
665
666