@@ -173,17 +173,10 @@ static Obj MatPtrToGapObj(dd_MatrixPtr M)
173173 dd_rowrange nrRows = M -> rowsize ;
174174 dd_colrange nrCols = M -> colsize ;
175175
176- //dd_WriteMatrix(stdout, M);
177176 result = NEW_PLIST (T_PLIST_CYC , 7 );
178177
179- // reading the representation of M
180178 ASS_LIST (result , 1 , INTOBJ_INT (M -> representation ));
181-
182- // reading the number type
183- ASS_LIST (result , 2 , INTOBJ_INT (M -> numbtype ));
184-
185- // entry 3 is left unbound on purpose
186-
179+ // entry 2 & 3 are intentionally left unbound
187180 ASS_LIST (result , 4 , INTOBJ_INT (nrRows ));
188181 ASS_LIST (result , 5 , INTOBJ_INT (nrCols ));
189182 ASS_LIST (result , 6 , ddG_LinearityPtr (M ));
@@ -227,32 +220,29 @@ static dd_MatrixPtr GapInputToMatrixPtr(Obj input)
227220
228221 dd_MatrixPtr M = NULL ;
229222
230- // // creating the matrix with these two dimesnions
223+ // creating the matrix with the given dimensions
231224 M = dd_CreateMatrix (k_rowrange , k_colrange );
232- // controling if the given representation is H or V.
225+
226+ // check whether the given representation is H or V
233227 if (k_rep == 2 )
234228 M -> representation = dd_Generator ;
235229 else if (k_rep == 1 )
236230 M -> representation = dd_Inequality ;
237231 else
238232 M -> representation = dd_Unspecified ;
239233
240- //
241- // controling the numbertype in the matrix
234+ // set the numbertype of the matrix
242235 M -> numbtype = dd_Rational ;
243236
244- //
245- // controling the linearity of the given polygon.
237+ // set the linearity of the given polygon
246238 const Int len = LEN_LIST (k_linearity_array );
247239 for (int i = 1 ; i <= len ; i ++ )
248240 {
249241 Obj val = ELM_LIST (k_linearity_array , i );
250242 set_addelem (M -> linset , INT_INTOBJ (val ));
251243 }
252244
253- //
254- // // filling the matrix with elements scanned from the string k_matrix
255- //
245+ // fill the matrix with elements scanned from the GAP matrix k_matrix
256246 for (int uu = 0 ; uu < k_rowrange ; uu ++ ){
257247 Obj row = ELM_LIST (k_matrix , uu + 1 );
258248 for (int vv = 0 ; vv < k_colrange ; vv ++ ){
@@ -388,48 +378,42 @@ static Obj CddInterface_FourierElimination(Obj self, Obj main)
388378{
389379 dd_MatrixPtr M , A , G ;
390380 dd_PolyhedraPtr poly ;
391- dd_ErrorType err ;
392- err = dd_NoError ;
393- dd_set_global_constants ();
381+ dd_ErrorType err = dd_NoError ;
394382
383+ dd_set_global_constants ();
395384 M = GapInputToMatrixPtr (main );
396385 A = dd_FourierElimination (M , & err );
397386 poly = dd_DDMatrix2Poly (A , & err );
398387 G = dd_CopyInequalities (poly );
388+ dd_free_global_constants ();
399389 return MatPtrToGapObj (G );
400390}
401391
402392static Obj CddInterface_DimAndInteriorPoint (Obj self , Obj main )
403393{
404394 dd_MatrixPtr M ;
405395 Obj result ;
406-
407396 dd_PolyhedraPtr poly ;
408- dd_ErrorType err ;
409- err = dd_NoError ;
410- dd_set_global_constants ();
397+ dd_ErrorType err = dd_NoError ;
411398
399+ dd_set_global_constants ();
412400 M = GapInputToMatrixPtr (main );
413- //dd_WriteMatrix( stdout, M );
414401 poly = dd_DDMatrix2Poly (M , & err );
415402 M = dd_CopyInequalities (poly );
416- //dd_WriteMatrix( stdout, M );
417-
418403 result = ddG_InteriorPoint (M );
419-
420404 dd_free_global_constants ();
421-
422405 return result ;
423406}
424407
425408static Obj CddInterface_Canonicalize (Obj self , Obj main )
426409{
427410 dd_MatrixPtr M ;
428- dd_set_global_constants ();
429- M = GapInputToMatrixPtr (main );
430411 dd_rowset impl_linset , redset ;
431412 dd_rowindex newpos ;
432- dd_ErrorType err ;
413+ dd_ErrorType err = dd_NoError ;
414+
415+ dd_set_global_constants ();
416+ M = GapInputToMatrixPtr (main );
433417 dd_MatrixCanonicalize (& M , & impl_linset , & redset , & newpos , & err );
434418 dd_free_global_constants ();
435419 return MatPtrToGapObj (M );
@@ -439,11 +423,10 @@ static Obj CddInterface_Compute_H_rep(Obj self, Obj main)
439423{
440424 dd_MatrixPtr M , A ;
441425 dd_PolyhedraPtr poly ;
442- dd_ErrorType err ;
443- err = dd_NoError ;
426+ dd_ErrorType err = dd_NoError ;
427+
444428 dd_set_global_constants ();
445429 M = GapInputToMatrixPtr (main );
446-
447430 poly = dd_DDMatrix2Poly (M , & err );
448431 A = dd_CopyInequalities (poly );
449432 dd_free_global_constants ();
@@ -454,37 +437,33 @@ static Obj CddInterface_Compute_V_rep(Obj self, Obj main)
454437{
455438 dd_MatrixPtr M , A ;
456439 dd_PolyhedraPtr poly ;
457- dd_ErrorType err ;
458- err = dd_NoError ;
440+ dd_ErrorType err = dd_NoError ;
441+
459442 dd_set_global_constants ();
460443 M = GapInputToMatrixPtr (main );
461-
462444 poly = dd_DDMatrix2Poly (M , & err );
463445 A = dd_CopyGenerators (poly );
464446 dd_free_global_constants ();
465-
466447 return MatPtrToGapObj (A );
467448}
468449
469450static Obj CddInterface_LpSolution (Obj self , Obj main )
470451{
471452 dd_MatrixPtr M ;
472- dd_ErrorType err ;
453+ dd_ErrorType err = dd_NoError ;
473454 dd_LPPtr lp ;
474455 dd_LPSolutionPtr lps ;
475- dd_LPSolverType solver ;
456+ dd_LPSolverType solver = dd_DualSimplex ;
476457 size_t n ;
477458 dd_colrange j ;
478- dd_set_global_constants ();
479- solver = dd_DualSimplex ;
480- err = dd_NoError ;
481459 Obj current , res ;
482460
461+ dd_set_global_constants ();
483462 M = GapInputToMatrixPtr (main );
484463 lp = dd_Matrix2LP (M , & err );
485-
486464 dd_LPSolve (lp , solver , & err );
487465 lps = dd_CopyLPSolution (lp );
466+ dd_free_global_constants ();
488467
489468 if (lps -> LPS == dd_Optimal )
490469 {
@@ -499,26 +478,27 @@ static Obj CddInterface_LpSolution(Obj self, Obj main)
499478 res = NEW_PLIST (T_PLIST_CYC , 2 );
500479 ASS_LIST (res , 1 , current );
501480 ASS_LIST (res , 2 , MPQ_TO_GAPOBJ (lps -> optvalue ));
502-
503- return res ;
504481 }
505-
506482 else
483+ res = Fail ;
507484
508- return Fail ;
485+
486+ return res ;
509487}
510488
511489static Obj CddInterface_FacesWithDimensionAndInteriorPoints (Obj self , Obj main , Obj mindim )
512490{
513491 dd_MatrixPtr M ;
514492 dd_rowset R , S ;
493+ Obj result ;
515494
495+ dd_set_global_constants ();
516496 M = GapInputToMatrixPtr (main );
517-
518497 set_initialize (& R , M -> rowsize );
519498 set_initialize (& S , M -> rowsize );
520-
521- return FaceWithDimAndInteriorPoint (M , R , S , INT_INTOBJ (mindim ));
499+ result = FaceWithDimAndInteriorPoint (M , R , S , INT_INTOBJ (mindim ));
500+ dd_free_global_constants ();
501+ return result ;
522502}
523503
524504/******************************************************************/
0 commit comments