Changeset 5a1c78 in git


Ignore:
Timestamp:
Jan 15, 2017, 3:36:48 PM (6 years ago)
Author:
Yue <ren@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '5bec8f88c9ee2573d328cf7c3aff2bcb301d2395')
Children:
8ed7dc85f8531614409ce9273f8b59ae49fce769
Parents:
e85feda0c40361dfe1754b7c0fa791e33c600e71
Message:
fix: proper deinitialization of cddlib global variables
Location:
Singular/dyn_modules/gfanlib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/gfanlib/bbcone.cc

    re85fed r5a1c78  
    357357  if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
    358358  {
    359     if (u->next == NULL) return jjCONENORMALS1(res, u);
     359    if (u->next == NULL)
     360    {
     361      BOOLEAN bo = jjCONENORMALS1(res, u);
     362      gfan::deinitializeCddlibIfRequired();
     363      return bo;
     364    }
    360365  }
    361366  leftv v = u->next;
    362367  if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTMAT_CMD)))
    363368  {
    364     if (v->next == NULL) return jjCONENORMALS2(res, u, v);
     369    if (v->next == NULL)
     370    {
     371      BOOLEAN bo = jjCONENORMALS2(res, u, v);
     372      gfan::deinitializeCddlibIfRequired();
     373      return bo;
     374    }
    365375  }
    366376  leftv w = v->next;
    367377  if ((w != NULL) && (w->Typ() == INT_CMD))
    368378  {
    369     if (w->next == NULL) return jjCONENORMALS3(res, u, v, w);
     379    if (w->next == NULL)
     380    {
     381      BOOLEAN bo = jjCONENORMALS3(res, u, v, w);
     382      gfan::deinitializeCddlibIfRequired();
     383      return bo;
     384    }
    370385  }
    371386  WerrorS("coneViaInequalities: unexpected parameters");
     
    513528  if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
    514529  {
    515     if (u->next == NULL) return jjCONERAYS1(res, u);
     530    if (u->next == NULL)
     531    {
     532      BOOLEAN bo = jjCONERAYS1(res, u);
     533      gfan::deinitializeCddlibIfRequired();
     534      return bo;
     535    }
    516536    leftv v = u->next;
    517537    if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTMAT_CMD)))
    518538    {
    519       if (v->next == NULL) return jjCONERAYS2(res, u, v);
     539      if (v->next == NULL)
     540      {
     541        BOOLEAN bo = jjCONERAYS2(res, u, v);
     542        gfan::deinitializeCddlibIfRequired();
     543        return bo;
     544      }
    520545      leftv w = v->next;
    521546      if ((w != NULL) && (w->Typ() == INT_CMD))
    522547      {
    523         if (w->next == NULL) return jjCONERAYS3(res, u, v, w);
     548        if (w->next == NULL)
     549        {
     550          BOOLEAN bo = jjCONERAYS3(res, u, v, w);
     551          gfan::deinitializeCddlibIfRequired();
     552          return bo;
     553        }
    524554      }
    525555    }
     
    531561BOOLEAN inequalities(leftv res, leftv args)
    532562{
    533   gfan::initializeCddlibIfRequired();
    534563  leftv u = args;
    535564  if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
    536565  {
    537     gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    538 
     566    gfan::initializeCddlibIfRequired();
     567    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    539568    gfan::ZMatrix zmat = zc->getInequalities();
    540569    res->rtyp = BIGINTMAT_CMD;
    541570    res->data = (void*) zMatrixToBigintmat(zmat);
     571    gfan::deinitializeCddlibIfRequired();
    542572    return FALSE;
    543573  }
     
    548578BOOLEAN equations(leftv res, leftv args)
    549579{
    550   gfan::initializeCddlibIfRequired();
    551580  leftv u = args;
    552581  if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
    553582  {
     583    gfan::initializeCddlibIfRequired();
    554584    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    555585    gfan::ZMatrix zmat = zc->getEquations();
    556586    res->rtyp = BIGINTMAT_CMD;
    557587    res->data = (void*) zMatrixToBigintmat(zmat);
     588    gfan::deinitializeCddlibIfRequired();
    558589    return FALSE;
    559590  }
     
    564595BOOLEAN facets(leftv res, leftv args)
    565596{
    566   gfan::initializeCddlibIfRequired();
    567597  leftv u = args;
    568598  if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
    569599  {
     600    gfan::initializeCddlibIfRequired();
    570601    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    571602    gfan::ZMatrix zm = zc->getFacets();
    572603    res->rtyp = BIGINTMAT_CMD;
    573604    res->data = (void*) zMatrixToBigintmat(zm);
     605    gfan::deinitializeCddlibIfRequired();
    574606    return FALSE;
    575607  }
     
    580612BOOLEAN impliedEquations(leftv res, leftv args)
    581613{
    582   gfan::initializeCddlibIfRequired();
    583614  leftv u = args;
    584615  if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
    585616  {
     617    gfan::initializeCddlibIfRequired();
    586618    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    587619    gfan::ZMatrix zmat = zc->getImpliedEquations();
    588620    res->rtyp = BIGINTMAT_CMD;
    589621    res->data = (void*) zMatrixToBigintmat(zmat);
     622    gfan::deinitializeCddlibIfRequired();
    590623    return FALSE;
    591624  }
     
    596629BOOLEAN generatorsOfSpan(leftv res, leftv args)
    597630{
    598   gfan::initializeCddlibIfRequired();
    599631  leftv u = args;
    600632  if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
    601633  {
     634    gfan::initializeCddlibIfRequired();
    602635    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    603636    gfan::ZMatrix zmat = zc->generatorsOfSpan();
    604637    res->rtyp = BIGINTMAT_CMD;
    605638    res->data = (void*) zMatrixToBigintmat(zmat);
     639    gfan::deinitializeCddlibIfRequired();
    606640    return FALSE;
    607641  }
     
    612646BOOLEAN generatorsOfLinealitySpace(leftv res, leftv args)
    613647{
    614   gfan::initializeCddlibIfRequired();
    615648  leftv u = args;
    616649  if ((u != NULL) && (u->Typ() == coneID || u->Typ() == polytopeID))
    617650  {
     651    gfan::initializeCddlibIfRequired();
    618652    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    619653    gfan::ZMatrix zmat = zc->generatorsOfLinealitySpace();
    620654    res->rtyp = BIGINTMAT_CMD;
    621655    res->data = (void*) zMatrixToBigintmat(zmat);
     656    gfan::deinitializeCddlibIfRequired();
    622657    return FALSE;
    623658  }
     
    628663BOOLEAN rays(leftv res, leftv args)
    629664{
    630   gfan::initializeCddlibIfRequired();
    631   leftv u = args;
    632   if ((u != NULL) && (u->Typ() == coneID))
    633   {
     665  leftv u = args;
     666  if ((u != NULL) && (u->Typ() == coneID))
     667  {
     668    gfan::initializeCddlibIfRequired();
    634669    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    635670    gfan::ZMatrix zm = zc->extremeRays();
    636671    res->rtyp = BIGINTMAT_CMD;
    637672    res->data = (void*)zMatrixToBigintmat(zm);
     673    gfan::deinitializeCddlibIfRequired();
    638674    return FALSE;
    639675  }
    640676  if ((u != NULL) && (u->Typ() == fanID))
    641677  {
     678    gfan::initializeCddlibIfRequired();
    642679    gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    643680    gfan::ZMatrix zmat = rays(zf);
    644681    res->rtyp = BIGINTMAT_CMD;
    645682    res->data = (void*) zMatrixToBigintmat(zmat);
     683    gfan::deinitializeCddlibIfRequired();
    646684    return FALSE;
    647685  }
     
    652690BOOLEAN quotientLatticeBasis(leftv res, leftv args)
    653691{
    654   gfan::initializeCddlibIfRequired();
    655   leftv u = args;
    656   if ((u != NULL) && (u->Typ() == coneID))
    657   {
     692  leftv u = args;
     693  if ((u != NULL) && (u->Typ() == coneID))
     694  {
     695    gfan::initializeCddlibIfRequired();
    658696    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    659697    gfan::ZMatrix zmat = zc->quotientLatticeBasis();
    660698    res->rtyp = BIGINTMAT_CMD;
    661699    res->data = (void*) zMatrixToBigintmat(zmat);
     700    gfan::deinitializeCddlibIfRequired();
    662701    return FALSE;
    663702  }
     
    668707BOOLEAN getLinearForms(leftv res, leftv args)
    669708{
    670   gfan::initializeCddlibIfRequired();
    671   leftv u = args;
    672   if ((u != NULL) && (u->Typ() == coneID))
    673   {
     709  leftv u = args;
     710  if ((u != NULL) && (u->Typ() == coneID))
     711  {
     712    gfan::initializeCddlibIfRequired();
    674713    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    675714    gfan::ZMatrix zmat = zc->getLinearForms();
    676715    res->rtyp = BIGINTMAT_CMD;
    677716    res->data = (void*) zMatrixToBigintmat(zmat);
     717    gfan::deinitializeCddlibIfRequired();
    678718    return FALSE;
    679719  }
     
    684724BOOLEAN ambientDimension(leftv res, leftv args)
    685725{
    686   gfan::initializeCddlibIfRequired();
    687726  leftv u=args;
    688727  if ((u != NULL) && (u->Typ() == coneID))
    689728  {
     729    gfan::initializeCddlibIfRequired();
    690730    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    691731    res->rtyp = INT_CMD;
    692732    res->data = (void*) (long) zc->ambientDimension();
     733    gfan::deinitializeCddlibIfRequired();
    693734    return FALSE;
    694735  }
    695736  if ((u != NULL) && (u->Typ() == fanID))
    696737  {
     738    gfan::initializeCddlibIfRequired();
    697739    gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    698740    res->rtyp = INT_CMD;
    699741    res->data = (void*) (long) getAmbientDimension(zf);
     742    gfan::deinitializeCddlibIfRequired();
    700743    return FALSE;
    701744  }
    702745  if ((u != NULL) && (u->Typ() == polytopeID))
    703746  {
     747    gfan::initializeCddlibIfRequired();
    704748    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    705749    res->rtyp = INT_CMD;
    706750    res->data = (void*) (long) getAmbientDimension(zc);
     751    gfan::deinitializeCddlibIfRequired();
    707752    return FALSE;
    708753  }
     
    713758BOOLEAN dimension(leftv res, leftv args)
    714759{
    715   gfan::initializeCddlibIfRequired();
    716760  leftv u=args;
    717761  if ((u != NULL) && (u->Typ() == coneID))
    718762  {
     763    gfan::initializeCddlibIfRequired();
    719764    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    720765    res->rtyp = INT_CMD;
    721766    res->data = (void*) (long) zc->dimension();
     767    gfan::deinitializeCddlibIfRequired();
    722768    return FALSE;
    723769  }
    724770  if ((u != NULL) && (u->Typ() == fanID))
    725771  {
     772    gfan::initializeCddlibIfRequired();
    726773    gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    727774    res->rtyp = INT_CMD;
    728775    res->data = (void*) (long) getDimension(zf);
     776    gfan::deinitializeCddlibIfRequired();
    729777    return FALSE;
    730778  }
    731779  if ((u != NULL) && (u->Typ() == polytopeID))
    732780  {
     781    gfan::initializeCddlibIfRequired();
    733782    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    734783    res->rtyp = INT_CMD;
    735784    res->data = (void*) (long) getDimension(zc);
     785    gfan::deinitializeCddlibIfRequired();
    736786    return FALSE;
    737787  }
     
    742792BOOLEAN codimension(leftv res, leftv args)
    743793{
    744   gfan::initializeCddlibIfRequired();
    745794  leftv u=args;
    746795  if ((u != NULL) && (u->Typ() == coneID))
    747     {
    748       gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    749       res->rtyp = INT_CMD;
    750       res->data = (void*) (long) zc->codimension();
    751       return FALSE;
    752     }
     796  {
     797    gfan::initializeCddlibIfRequired();
     798    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
     799    res->rtyp = INT_CMD;
     800    res->data = (void*) (long) zc->codimension();
     801    gfan::deinitializeCddlibIfRequired();
     802    return FALSE;
     803  }
    753804  if ((u != NULL) && (u->Typ() == fanID))
    754     {
    755       gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    756       res->rtyp = INT_CMD;
    757       res->data = (void*) (long) getCodimension(zf);
    758       return FALSE;
    759     }
     805  {
     806    gfan::initializeCddlibIfRequired();
     807    gfan::ZFan* zf = (gfan::ZFan*)u->Data();
     808    res->rtyp = INT_CMD;
     809    res->data = (void*) (long) getCodimension(zf);
     810    gfan::deinitializeCddlibIfRequired();
     811    return FALSE;
     812  }
    760813  if ((u != NULL) && (u->Typ() == polytopeID))
    761     {
    762       gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    763       res->rtyp = INT_CMD;
    764       res->data = (void*) (long) getCodimension(zc);
    765       return FALSE;
    766     }
     814  {
     815    gfan::initializeCddlibIfRequired();
     816    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
     817    res->rtyp = INT_CMD;
     818    res->data = (void*) (long) getCodimension(zc);
     819    gfan::deinitializeCddlibIfRequired();
     820    return FALSE;
     821  }
    767822  WerrorS("getCodimension: unexpected parameters");
    768823  return TRUE;
     
    771826BOOLEAN linealityDimension(leftv res, leftv args)
    772827{
    773   gfan::initializeCddlibIfRequired();
    774828  leftv u=args;
    775829  if ((u != NULL) && (u->Typ() == coneID))
    776830  {
     831    gfan::initializeCddlibIfRequired();
    777832    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    778833    res->rtyp = INT_CMD;
    779834    res->data = (void*) (long) zc->dimensionOfLinealitySpace();
     835    gfan::deinitializeCddlibIfRequired();
    780836    return FALSE;
    781837  }
    782838  if ((u != NULL) && (u->Typ() == fanID))
    783839  {
     840    gfan::initializeCddlibIfRequired();
    784841    gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    785842    res->rtyp = INT_CMD;
    786843    res->data = (void*) (long) getLinealityDimension(zf);
     844    gfan::deinitializeCddlibIfRequired();
    787845    return FALSE;
    788846  }
     
    793851BOOLEAN getMultiplicity(leftv res, leftv args)
    794852{
    795   gfan::initializeCddlibIfRequired();
    796   leftv u = args;
    797   if ((u != NULL) && (u->Typ() == coneID))
    798   {
     853  leftv u = args;
     854  if ((u != NULL) && (u->Typ() == coneID))
     855  {
     856    gfan::initializeCddlibIfRequired();
    799857    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    800858    number i = integerToNumber(zc->getMultiplicity());
    801859    res->rtyp = BIGINT_CMD;
    802860    res->data = (void*) i;
     861    gfan::deinitializeCddlibIfRequired();
    803862    return FALSE;
    804863  }
     
    809868BOOLEAN isOrigin(leftv res, leftv args)
    810869{
    811   gfan::initializeCddlibIfRequired();
    812   leftv u = args;
    813   if ((u != NULL) && (u->Typ() == coneID))
    814   {
     870  leftv u = args;
     871  if ((u != NULL) && (u->Typ() == coneID))
     872  {
     873    gfan::initializeCddlibIfRequired();
    815874    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    816875    int i = zc->isOrigin();
    817876    res->rtyp = INT_CMD;
    818877    res->data = (void*) (long) i;
     878    gfan::deinitializeCddlibIfRequired();
    819879    return FALSE;
    820880  }
     
    825885BOOLEAN isFullSpace(leftv res, leftv args)
    826886{
    827   gfan::initializeCddlibIfRequired();
    828   leftv u = args;
    829   if ((u != NULL) && (u->Typ() == coneID))
    830   {
     887  leftv u = args;
     888  if ((u != NULL) && (u->Typ() == coneID))
     889  {
     890    gfan::initializeCddlibIfRequired();
    831891    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    832892    int i = zc->isFullSpace();
    833893    res->rtyp = INT_CMD;
    834894    res->data = (void*) (long) i;
     895    gfan::deinitializeCddlibIfRequired();
    835896    return FALSE;
    836897  }
     
    841902BOOLEAN isSimplicial(leftv res, leftv args)
    842903{
    843   gfan::initializeCddlibIfRequired();
    844904  leftv u=args;
    845905  if ((u != NULL) && (u->Typ() == coneID))
    846906  {
     907    gfan::initializeCddlibIfRequired();
    847908    gfan::ZCone* zc = (gfan::ZCone*) u->Data();
    848909    int b = zc->isSimplicial();
    849910    res->rtyp = INT_CMD;
    850911    res->data = (void*) (long) b;
     912    gfan::deinitializeCddlibIfRequired();
    851913    return FALSE;
    852914  }
    853915  if ((u != NULL) && (u->Typ() == fanID))
    854916  {
     917    gfan::initializeCddlibIfRequired();
    855918    gfan::ZFan* zf = (gfan::ZFan*) u->Data();
    856919    bool b = isSimplicial(zf);
    857920    res->rtyp = INT_CMD;
    858921    res->data = (void*) (long) b;
     922    gfan::deinitializeCddlibIfRequired();
    859923    return FALSE;
    860924  }
     
    865929BOOLEAN containsPositiveVector(leftv res, leftv args)
    866930{
    867   gfan::initializeCddlibIfRequired();
    868   leftv u = args;
    869   if ((u != NULL) && (u->Typ() == coneID))
    870   {
     931  leftv u = args;
     932  if ((u != NULL) && (u->Typ() == coneID))
     933  {
     934    gfan::initializeCddlibIfRequired();
    871935    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    872936    int i = zc->containsPositiveVector();
    873937    res->rtyp = INT_CMD;
    874938    res->data = (void*) (long) i;
     939    gfan::deinitializeCddlibIfRequired();
    875940    return FALSE;
    876941  }
     
    881946BOOLEAN linealitySpace(leftv res, leftv args)
    882947{
    883   gfan::initializeCddlibIfRequired();
    884   leftv u = args;
    885   if ((u != NULL) && (u->Typ() == coneID))
    886   {
     948  leftv u = args;
     949  if ((u != NULL) && (u->Typ() == coneID))
     950  {
     951    gfan::initializeCddlibIfRequired();
    887952    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    888953    gfan::ZCone* zd = new gfan::ZCone(zc->linealitySpace());
    889954    res->rtyp = coneID;
    890955    res->data = (void*) zd;
     956    gfan::deinitializeCddlibIfRequired();
    891957    return FALSE;
    892958  }
     
    897963BOOLEAN dualCone(leftv res, leftv args)
    898964{
    899   gfan::initializeCddlibIfRequired();
    900   leftv u = args;
    901   if ((u != NULL) && (u->Typ() == coneID))
    902   {
     965  leftv u = args;
     966  if ((u != NULL) && (u->Typ() == coneID))
     967  {
     968    gfan::initializeCddlibIfRequired();
    903969    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    904970    gfan::ZCone* zd = new gfan::ZCone(zc->dualCone());
    905971    res->rtyp = coneID;
    906972    res->data = (void*) zd;
     973    gfan::deinitializeCddlibIfRequired();
    907974    return FALSE;
    908975  }
     
    913980BOOLEAN negatedCone(leftv res, leftv args)
    914981{
    915   gfan::initializeCddlibIfRequired();
    916   leftv u = args;
    917   if ((u != NULL) && (u->Typ() == coneID))
    918   {
     982  leftv u = args;
     983  if ((u != NULL) && (u->Typ() == coneID))
     984  {
     985    gfan::initializeCddlibIfRequired();
    919986    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    920987    gfan::ZCone* zd = new gfan::ZCone(zc->negated());
    921988    res->rtyp = coneID;
    922989    res->data = (void*) zd;
     990    gfan::deinitializeCddlibIfRequired();
    923991    return FALSE;
    924992  }
     
    929997BOOLEAN semigroupGenerator(leftv res, leftv args)
    930998{
    931   gfan::initializeCddlibIfRequired();
    932   leftv u = args;
    933   if ((u != NULL) && (u->Typ() == coneID))
    934   {
     999  leftv u = args;
     1000  if ((u != NULL) && (u->Typ() == coneID))
     1001  {
     1002    gfan::initializeCddlibIfRequired();
    9351003    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    9361004    int d = zc->dimension();
     
    9411009      res->rtyp = BIGINTMAT_CMD;
    9421010      res->data = (void*) zVectorToBigintmat(zv);
     1011      gfan::deinitializeCddlibIfRequired();
    9431012      return FALSE;
    9441013    }
     1014    gfan::deinitializeCddlibIfRequired();
    9451015    Werror("expected dim of cone one larger than dim of lin space\n"
    9461016            "but got dimensions %d and %d", d, dLS);
     
    9521022BOOLEAN relativeInteriorPoint(leftv res, leftv args)
    9531023{
    954   gfan::initializeCddlibIfRequired();
    955   leftv u = args;
    956   if ((u != NULL) && (u->Typ() == coneID))
    957   {
     1024  leftv u = args;
     1025  if ((u != NULL) && (u->Typ() == coneID))
     1026  {
     1027    gfan::initializeCddlibIfRequired();
    9581028    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    9591029    gfan::ZVector zv = zc->getRelativeInteriorPoint();
    9601030    res->rtyp = BIGINTMAT_CMD;
    9611031    res->data = (void*) zVectorToBigintmat(zv);
     1032    gfan::deinitializeCddlibIfRequired();
    9621033    return FALSE;
    9631034  }
     
    9681039BOOLEAN uniquePoint(leftv res, leftv args)
    9691040{
    970   gfan::initializeCddlibIfRequired();
    971   leftv u = args;
    972   if ((u != NULL) && (u->Typ() == coneID))
    973   {
     1041  leftv u = args;
     1042  if ((u != NULL) && (u->Typ() == coneID))
     1043  {
     1044    gfan::initializeCddlibIfRequired();
    9741045    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    9751046    gfan::ZVector zv = zc->getUniquePoint();
    9761047    res->rtyp = BIGINTMAT_CMD;
    9771048    res->data = (void*) zVectorToBigintmat(zv);
     1049    gfan::deinitializeCddlibIfRequired();
    9781050    return FALSE;
    9791051  }
     
    10051077BOOLEAN randomPoint(leftv res, leftv args)
    10061078{
    1007   gfan::initializeCddlibIfRequired();
    1008   leftv u = args;
    1009   if ((u != NULL) && (u->Typ() == coneID))
    1010   {
     1079  leftv u = args;
     1080  if ((u != NULL) && (u->Typ() == coneID))
     1081  {
     1082    gfan::initializeCddlibIfRequired();
    10111083    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    10121084    gfan::ZVector zv = randomPoint(zc);
    10131085    res->rtyp = BIGINTMAT_CMD;
    10141086    res->data = (void*) zVectorToBigintmat(zv);
     1087    gfan::deinitializeCddlibIfRequired();
    10151088    return FALSE;
    10161089  }
     
    10211094BOOLEAN setMultiplicity(leftv res, leftv args)
    10221095{
    1023   gfan::initializeCddlibIfRequired();
    10241096  leftv u = args;
    10251097  if ((u != NULL) && (u->Typ() == coneID))
     
    10291101    if ((v != NULL) && (v->Typ() == INT_CMD))
    10301102    {
     1103      gfan::initializeCddlibIfRequired();
    10311104      int val = (int)(long)v->Data();
    10321105      zc->setMultiplicity(gfan::Integer(val));
    10331106      res->rtyp = NONE;
    10341107      res->data = NULL;
     1108      gfan::deinitializeCddlibIfRequired();
    10351109      return FALSE;
    10361110    }
     
    10421116BOOLEAN setLinearForms(leftv res, leftv args)
    10431117{
    1044   gfan::initializeCddlibIfRequired();
    10451118  leftv u = args;
    10461119  if ((u != NULL) && (u->Typ() == coneID))
     
    10501123    if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
    10511124    {
     1125      gfan::initializeCddlibIfRequired();
    10521126      bigintmat* mat=NULL;
    10531127      if (v->Typ() == INTVEC_CMD)
     
    10661140      if (v->Typ() == INTVEC_CMD)
    10671141        delete mat;
    1068      return FALSE;
     1142      gfan::deinitializeCddlibIfRequired();
     1143      return FALSE;
    10691144    }
    10701145  }
     
    10951170BOOLEAN coneToPolytope(leftv res, leftv args)
    10961171{
    1097   gfan::initializeCddlibIfRequired();
    1098   leftv u = args;
    1099   if ((u != NULL) && (u->Typ() == coneID))
    1100   {
     1172  leftv u = args;
     1173  if ((u != NULL) && (u->Typ() == coneID))
     1174  {
     1175    gfan::initializeCddlibIfRequired();
    11011176    gfan::ZCone* zc = (gfan::ZCone*) u->Data();
    11021177    gfan::ZMatrix ineq=zc->getInequalities();
     
    11051180    res->rtyp = polytopeID;
    11061181    res->data = (void*) zd;
     1182    gfan::deinitializeCddlibIfRequired();
    11071183    return FALSE;
    11081184  }
     
    11131189BOOLEAN intersectCones(leftv res, leftv args)
    11141190{
    1115   gfan::initializeCddlibIfRequired();
    11161191  leftv u = args;
    11171192  if ((u != NULL) && (u->Typ() == coneID))
     
    11201195    if ((v != NULL) && (v->Typ() == coneID))
    11211196    {
     1197      gfan::initializeCddlibIfRequired();
    11221198      gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
    11231199      gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
     
    11281204        Werror("expected ambient dims of both cones to coincide\n"
    11291205                "but got %d and %d", d1, d2);
     1206        gfan::deinitializeCddlibIfRequired();
    11301207        return TRUE;
    11311208      }
     
    11341211      res->rtyp = coneID;
    11351212      res->data = (void *)new gfan::ZCone(zc3);
     1213      gfan::deinitializeCddlibIfRequired();
    11361214      return FALSE;
    11371215    }
    11381216    if ((v != NULL) && (v->Typ() == polytopeID))
    11391217    {
     1218      gfan::initializeCddlibIfRequired();
    11401219      gfan::ZCone* zc11 = (gfan::ZCone*)u->Data();
    11411220      gfan::ZCone zc1 = liftUp(*zc11);
     
    11471226        Werror("expected ambient dims of both cones to coincide\n"
    11481227                "but got %d and %d", d1, d2);
     1228        gfan::deinitializeCddlibIfRequired();
    11491229        return TRUE;
    11501230      }
     
    11531233      res->rtyp = polytopeID;
    11541234      res->data = (void *)new gfan::ZCone(zc3);
     1235      gfan::deinitializeCddlibIfRequired();
    11551236      return FALSE;
    11561237    }
     
    11611242    if ((v != NULL) && (v->Typ() == coneID))
    11621243    {
     1244      gfan::initializeCddlibIfRequired();
    11631245      gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
    11641246      gfan::ZCone* zc22 = (gfan::ZCone*)v->Data();
     
    11701252        Werror("expected ambient dims of both cones to coincide\n"
    11711253                "but got %d and %d", d1, d2);
     1254        gfan::deinitializeCddlibIfRequired();
    11721255        return TRUE;
    11731256      }
     
    11761259      res->rtyp = polytopeID;
    11771260      res->data = (void *)new gfan::ZCone(zc3);
     1261      gfan::deinitializeCddlibIfRequired();
    11781262      return FALSE;
    11791263    }
    11801264    if ((v != NULL) && (v->Typ() == polytopeID))
    11811265    {
     1266      gfan::initializeCddlibIfRequired();
    11821267      gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
    11831268      gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
     
    11881273        Werror("expected ambient dims of both cones to coincide\n"
    11891274                "but got %d and %d", d1, d2);
     1275        gfan::deinitializeCddlibIfRequired();
    11901276        return TRUE;
    11911277      }
     
    11941280      res->rtyp = polytopeID;
    11951281      res->data = (void *)new gfan::ZCone(zc3);
     1282      gfan::deinitializeCddlibIfRequired();
    11961283      return FALSE;
    11971284    }
     
    12031290BOOLEAN convexHull(leftv res, leftv args)
    12041291{
    1205   gfan::initializeCddlibIfRequired();
    12061292  leftv u = args;
    12071293  if ((u != NULL) && (u->Typ() == coneID))
     
    12101296    if ((v != NULL) && (v->Typ() == coneID))
    12111297    {
     1298      gfan::initializeCddlibIfRequired();
    12121299      gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
    12131300      gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
     
    12181305        Werror("expected ambient dims of both cones to coincide\n"
    12191306                "but got %d and %d", d1, d2);
    1220         return TRUE;
     1307       gfan::deinitializeCddlibIfRequired();
     1308       return TRUE;
    12211309      }
    12221310      gfan::ZMatrix zm1 = zc1->extremeRays();
     
    12301318      res->rtyp = coneID;
    12311319      res->data = (void*) zc;
     1320      gfan::deinitializeCddlibIfRequired();
    12321321      return FALSE;
    12331322    }
    12341323    if ((v != NULL) && (v->Typ() == polytopeID))
    12351324    {
     1325      gfan::initializeCddlibIfRequired();
    12361326      gfan::ZCone* zc11 = (gfan::ZCone*)u->Data();
    12371327      gfan::ZCone zc1 = liftUp(*zc11);
     
    12431333        Werror("expected ambient dims of both cones to coincide\n"
    12441334                "but got %d and %d", d1, d2);
     1335        gfan::deinitializeCddlibIfRequired();
    12451336        return TRUE;
    12461337      }
     
    12531344      res->rtyp = polytopeID;
    12541345      res->data = (void*) zc;
    1255       return FALSE;
     1346      gfan::deinitializeCddlibIfRequired();
     1347     return FALSE;
    12561348    }
    12571349  }
     
    12611353    if ((v != NULL) && (v->Typ() == coneID))
    12621354    {
     1355      gfan::initializeCddlibIfRequired();
    12631356      gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
    12641357      gfan::ZCone* zc22 = (gfan::ZCone*)v->Data();
     
    12701363        Werror("expected ambient dims of both cones to coincide\n"
    12711364                "but got %d and %d", d1, d2);
     1365        gfan::deinitializeCddlibIfRequired();
    12721366        return TRUE;
    12731367      }
     
    12801374      res->rtyp = polytopeID;
    12811375      res->data = (void*) zc;
     1376      gfan::deinitializeCddlibIfRequired();
    12821377      return FALSE;
    12831378    }
    12841379    if ((v != NULL) && (v->Typ() == polytopeID))
    12851380    {
     1381      gfan::initializeCddlibIfRequired();
    12861382      gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
    12871383      gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
     
    12921388        Werror("expected ambient dims of both cones to coincide\n"
    12931389                "but got %d and %d", d1, d2);
     1390        gfan::deinitializeCddlibIfRequired();
    12941391        return TRUE;
    12951392      }
     
    13011398      res->rtyp = polytopeID;
    13021399      res->data = (void*) zc;
     1400      gfan::deinitializeCddlibIfRequired();
    13031401      return FALSE;
    13041402    }
     
    13101408BOOLEAN coneLink(leftv res, leftv args)
    13111409{
    1312   gfan::initializeCddlibIfRequired();
    13131410  leftv u = args;
    13141411  if ((u != NULL) && (u->Typ() == coneID))
     
    13171414    if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
    13181415    {
     1416      gfan::initializeCddlibIfRequired();
    13191417      gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    13201418      bigintmat* iv = NULL;
     
    13331431        Werror("expected ambient dim of cone and size of vector\n"
    13341432               " to be equal but got %d and %d", d1, d2);
     1433        gfan::deinitializeCddlibIfRequired();
    13351434        return TRUE;
    13361435      }
     
    13381437      {
    13391438        WerrorS("the provided intvec does not lie in the cone");
     1439        gfan::deinitializeCddlibIfRequired();
    13401440        return TRUE;
    13411441      }
     
    13471447      if (v->Typ() == INTMAT_CMD)
    13481448        delete iv;
     1449      gfan::deinitializeCddlibIfRequired();
    13491450      return FALSE;
    13501451    }
     
    13561457BOOLEAN containsInSupport(leftv res, leftv args)
    13571458{
    1358   gfan::initializeCddlibIfRequired();
    13591459  leftv u=args;
    13601460  if ((u != NULL) && (u->Typ() == coneID))
     
    13631463    if ((v != NULL) && (v->Typ() == coneID))
    13641464    {
     1465      gfan::initializeCddlibIfRequired();
    13651466      gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    13661467      gfan::ZCone* zd = (gfan::ZCone*)v->Data();
     
    13711472        Werror("expected cones with same ambient dimensions\n but got"
    13721473               " dimensions %d and %d", d1, d2);
     1474        gfan::deinitializeCddlibIfRequired();
    13731475        return TRUE;
    13741476      }
     
    13761478      res->rtyp = INT_CMD;
    13771479      res->data = (void*) (long) b;
     1480      gfan::deinitializeCddlibIfRequired();
    13781481      return FALSE;
    13791482    }
    13801483    if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
    13811484    {
     1485      gfan::initializeCddlibIfRequired();
    13821486      gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    13831487      bigintmat* iv = NULL;
     
    13971501        Werror("expected cones with same ambient dimensions\n but got"
    13981502               " dimensions %d and %d", d1, d2);
     1503        gfan::deinitializeCddlibIfRequired();
    13991504        return TRUE;
    14001505      }
     
    14061511      if (v->Typ() == INTMAT_CMD)
    14071512        delete iv;
     1513      gfan::deinitializeCddlibIfRequired();
    14081514      return FALSE;
    14091515    }
     
    14151521BOOLEAN containsRelatively(leftv res, leftv args)
    14161522{
    1417   gfan::initializeCddlibIfRequired();
    14181523  leftv u = args;
    14191524  if ((u != NULL) && (u->Typ() == coneID))
     
    14221527    if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
    14231528    {
     1529      gfan::initializeCddlibIfRequired();
    14241530      gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    14251531      bigintmat* iv = NULL;
     
    14421548        if (v->Typ() == INTMAT_CMD)
    14431549          delete iv;
     1550        gfan::deinitializeCddlibIfRequired();
    14441551        return FALSE;
    14451552      }
     
    14471554      if (v->Typ() == INTMAT_CMD)
    14481555        delete iv;
     1556      gfan::deinitializeCddlibIfRequired();
    14491557      Werror("expected ambient dim of cone and size of vector\n"
    14501558             "to be equal but got %d and %d", d1, d2);
     
    14571565BOOLEAN hasFace(leftv res, leftv args)
    14581566{
    1459   gfan::initializeCddlibIfRequired();
    14601567  leftv u=args;
    14611568  if ((u != NULL) && (u->Typ() == coneID))
     
    14641571    if ((v != NULL) && (v->Typ() == coneID))
    14651572    {
     1573      gfan::initializeCddlibIfRequired();
    14661574      gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    14671575      gfan::ZCone* zd = (gfan::ZCone*)v->Data();
     
    14691577      res->rtyp = INT_CMD;
    14701578      res->data = (void*) (long) b;
     1579      gfan::deinitializeCddlibIfRequired();
    14711580      return FALSE;
    14721581    }
     
    14771586    if ((v != NULL) && (v->Typ() == polytopeID))
    14781587    {
     1588      gfan::initializeCddlibIfRequired();
    14791589      gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    14801590      gfan::ZCone* zd = (gfan::ZCone*)v->Data();
     
    14821592      res->rtyp = INT_CMD;
    14831593      res->data = (void*) (long) b;
     1594      gfan::deinitializeCddlibIfRequired();
    14841595      return FALSE;
    14851596    }
     
    14911602BOOLEAN canonicalizeCone(leftv res, leftv args)
    14921603{
    1493   gfan::initializeCddlibIfRequired();
    14941604  leftv u=args;
    14951605  if ((u != NULL) && (u->Typ() == coneID))
    14961606  {
     1607    gfan::initializeCddlibIfRequired();
    14971608    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    14981609    gfan::ZCone* zd = new gfan::ZCone(*zc);
     
    15001611    res->rtyp = coneID;
    15011612    res->data = (void*) zd;
     1613    gfan::deinitializeCddlibIfRequired();
    15021614    return FALSE;
    15031615  }
     
    15081620BOOLEAN containsCone(leftv res, leftv args)
    15091621{
    1510   gfan::initializeCddlibIfRequired();
    15111622  leftv u=args;
    15121623  if ((u != NULL) && (u->Typ() == LIST_CMD))
     
    15151626    if ((v != NULL) && (v->Typ() == coneID))
    15161627    {
     1628      gfan::initializeCddlibIfRequired();
    15171629      lists l = (lists) u->Data();
    15181630      gfan::ZCone* zc = (gfan::ZCone*) v->Data();
     
    15241636        {
    15251637          WerrorS("containsCone: entries of wrong type in list");
     1638          gfan::deinitializeCddlibIfRequired();
    15261639          return TRUE;
    15271640        }
     
    15361649      res->rtyp = INT_CMD;
    15371650      res->data = (char*) (long) b;
     1651      gfan::deinitializeCddlibIfRequired();
    15381652      return FALSE;
    15391653    }
     
    15451659BOOLEAN faceContaining(leftv res, leftv args)
    15461660{
    1547   gfan::initializeCddlibIfRequired();
    15481661  leftv u = args;
    15491662  if ((u != NULL) && (u->Typ() == coneID))
     
    15521665    if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTVEC_CMD)))
    15531666    {
     1667      gfan::initializeCddlibIfRequired();
    15541668      gfan::ZCone* zc = (gfan::ZCone*) u->Data();
    15551669
     
    15751689      if (v->Typ() == INTVEC_CMD)
    15761690        delete point1;
     1691      gfan::deinitializeCddlibIfRequired();
    15771692      return FALSE;
    15781693    }
  • Singular/dyn_modules/gfanlib/bbfan.cc

    re85fed r5a1c78  
    4242    gfan::ZFan* zf = (gfan::ZFan*)d;
    4343    std::string s = zf->toString(2+4+8+128);
     44    gfan::deinitializeCddlibIfRequired();
    4445    return omStrDup(s.c_str());
    4546// =======
     
    176177BOOLEAN emptyFan(leftv res, leftv args)
    177178{
    178   gfan::initializeCddlibIfRequired();
    179179  leftv u = args;
    180180  if (u == NULL)
     
    267267BOOLEAN numberOfConesOfDimension(leftv res, leftv args)
    268268{
    269   gfan::initializeCddlibIfRequired();
    270269  leftv u=args;
    271270  if ((u != NULL) && (u->Typ() == fanID))
     
    280279        if ((x != NULL) && (x->Typ() == INT_CMD))
    281280        {
     281          gfan::initializeCddlibIfRequired();
    282282          gfan::ZFan* zf = (gfan::ZFan*) u->Data();
    283283          int d = (int)(long)v->Data();
     
    296296              res->rtyp = INT_CMD;
    297297              res->data = (void*) (long) n;
     298              gfan::deinitializeCddlibIfRequired();
    298299              return FALSE;
    299300            }
    300301            res->rtyp = INT_CMD;
    301302            res->data = (void*) (long) 0;
     303            gfan::deinitializeCddlibIfRequired();
    302304            return FALSE;
    303305          }
     
    312314BOOLEAN ncones(leftv res, leftv args)
    313315{
    314   gfan::initializeCddlibIfRequired();
    315316  leftv u=args;
    316317  if ((u != NULL) && (u->Typ() == fanID))
    317318  {
     319    gfan::initializeCddlibIfRequired();
    318320    gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    319321    int d = zf->getAmbientDimension();
     
    325327    res->rtyp = INT_CMD;
    326328    res->data = (void*) (long) n;
     329    gfan::deinitializeCddlibIfRequired();
    327330    return FALSE;
    328331  }
     
    333336BOOLEAN nmaxcones(leftv res, leftv args)
    334337{
    335   gfan::initializeCddlibIfRequired();
    336338  leftv u=args;
    337339  if ((u != NULL) && (u->Typ() == fanID))
    338340  {
     341    gfan::initializeCddlibIfRequired();
    339342    gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    340343
     
    345348    res->rtyp = INT_CMD;
    346349    res->data = (void*) (long) n;
     350    gfan::deinitializeCddlibIfRequired();
    347351    return FALSE;
    348352  }
     
    372376BOOLEAN isCompatible(leftv res, leftv args)
    373377{
    374   gfan::initializeCddlibIfRequired();
    375378  leftv u=args;
    376379  if ((u != NULL) && (u->Typ() == fanID))
     
    379382    if ((v != NULL) && (v->Typ() == coneID))
    380383    {
     384      gfan::initializeCddlibIfRequired();
    381385      gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    382386      gfan::ZCone* zc = (gfan::ZCone*)v->Data();
     
    384388      res->rtyp = INT_CMD;
    385389      res->data = (void*) (long) b;
     390      gfan::deinitializeCddlibIfRequired();
    386391      return FALSE;
    387392    }
     
    393398BOOLEAN insertCone(leftv res, leftv args)
    394399{
    395   gfan::initializeCddlibIfRequired();
    396400  leftv u=args;
    397401  if ((u != NULL) && (u->rtyp==IDHDL) && (u->e==NULL) && (u->Typ() == fanID))
     
    400404    if ((v != NULL) && (v->Typ() == coneID))
    401405    {
     406      gfan::initializeCddlibIfRequired();
    402407      gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    403408      gfan::ZCone* zc = (gfan::ZCone*)v->Data();
     
    414419        {
    415420          WerrorS("insertCone: cone and fan not compatible");
     421          gfan::deinitializeCddlibIfRequired();
    416422          return TRUE;
    417423        }
     
    422428      res->data = NULL;
    423429      IDDATA((idhdl)u->data) = (char*) zf;
     430      gfan::deinitializeCddlibIfRequired();
    424431      return FALSE;
    425432    }
     
    451458BOOLEAN containsInCollection(leftv res, leftv args)
    452459{
    453   gfan::initializeCddlibIfRequired();
    454460  leftv u=args;
    455461  if ((u != NULL) && (u->Typ() == fanID))
     
    458464    if ((v != NULL) && (v->Typ() == coneID))
    459465    {
     466      gfan::initializeCddlibIfRequired();
    460467      gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    461468      gfan::ZCone* zc = (gfan::ZCone*)v->Data();
     
    464471        res->rtyp = INT_CMD;
    465472        res->data = (void*) (long) (int) containsInCollection(zf,zc);
     473        gfan::deinitializeCddlibIfRequired();
    466474        return FALSE;
    467475      }
     476      gfan::deinitializeCddlibIfRequired();
    468477      WerrorS("containsInCollection: mismatching ambient dimensions");
    469478      return TRUE;
     
    510519BOOLEAN removeCone(leftv res, leftv args)
    511520{
    512   gfan::initializeCddlibIfRequired();
    513521  leftv u=args;
    514522  if ((u != NULL) && (u->Typ() == fanID))
     
    517525    if ((v != NULL) && (v->Typ() == coneID))
    518526    {
     527      gfan::initializeCddlibIfRequired();
    519528      gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    520529      gfan::ZCone* zc = (gfan::ZCone*)v->Data();
     
    530539        {
    531540          WerrorS("removeCone: cone not contained in fan");
     541          gfan::deinitializeCddlibIfRequired();
    532542          return TRUE;
    533543        }
     
    538548      res->data = NULL;
    539549      IDDATA((idhdl)u->data) = (char*) zf;
     550      gfan::deinitializeCddlibIfRequired();
    540551      return FALSE;
    541552    }
     
    547558BOOLEAN getCone(leftv res, leftv args)
    548559{
    549   gfan::initializeCddlibIfRequired();
    550560  leftv u=args;
    551561  if ((u != NULL) && (u->Typ() == fanID))
     
    557567      if ((w != NULL) && (w->Typ() == INT_CMD))
    558568      {
     569        gfan::initializeCddlibIfRequired();
    559570        gfan::ZFan* zf = (gfan::ZFan*) u->Data();
    560571        int d = (int)(long)v->Data();
     
    589600                res->rtyp = coneID;
    590601                res->data = (void*)new gfan::ZCone(zc);
     602                gfan::deinitializeCddlibIfRequired();
    591603                return FALSE;
    592604              }
     
    594606              {
    595607                WerrorS("getCone: invalid dimension; no cones in this dimension");
     608                gfan::deinitializeCddlibIfRequired();
    596609                return TRUE;
    597610              }
     
    600613            {
    601614              WerrorS("getCone: invalid index");
     615              gfan::deinitializeCddlibIfRequired();
    602616              return TRUE;
    603617            }
     
    606620          {
    607621            WerrorS("getCone: invalid dimension");
     622            gfan::deinitializeCddlibIfRequired();
    608623            return TRUE;
    609624          }
     
    612627        {
    613628          WerrorS("getCone: invalid specifier for orbit or maximal");
     629          gfan::deinitializeCddlibIfRequired();
    614630          return TRUE;
    615631        }
     
    623639BOOLEAN getCones(leftv res, leftv args)
    624640{
    625   gfan::initializeCddlibIfRequired();
    626641  leftv u=args;
    627642  if ((u != NULL) && (u->Typ() == fanID))
     
    630645    if ((v != NULL) && (v->Typ() == INT_CMD))
    631646    {
     647      gfan::initializeCddlibIfRequired();
    632648      gfan::ZFan* zf = (gfan::ZFan*) u->Data();
    633649      int d = (int)(long)v->Data();
     
    665681            res->rtyp = LIST_CMD;
    666682            res->data = (void*) L;
     683            gfan::deinitializeCddlibIfRequired();
    667684            return FALSE;
    668685          }
     
    670687          {
    671688            WerrorS("getCones: invalid dimension; no cones in this dimension");
     689            gfan::deinitializeCddlibIfRequired();
    672690            return TRUE;
    673691          }
     
    676694        {
    677695          WerrorS("getCones: invalid dimension");
     696          gfan::deinitializeCddlibIfRequired();
    678697          return TRUE;
    679698        }
     
    682701      {
    683702        WerrorS("getCones: invalid specifier for orbit or maximal");
     703        gfan::deinitializeCddlibIfRequired();
    684704        return TRUE;
    685705      }
     
    698718BOOLEAN isPure(leftv res, leftv args)
    699719{
    700   gfan::initializeCddlibIfRequired();
    701720  leftv u=args;
    702721  if ((u != NULL) && (u->Typ() == fanID))
    703722  {
     723    gfan::initializeCddlibIfRequired();
    704724    gfan::ZFan* zf = (gfan::ZFan*) u->Data();
    705725    int b = zf->isPure();
    706726    res->rtyp = INT_CMD;
    707727    res->data = (void*) (long) b;
     728    gfan::deinitializeCddlibIfRequired();
    708729    return FALSE;
    709730  }
     
    729750BOOLEAN fVector(leftv res, leftv args)
    730751{
    731   gfan::initializeCddlibIfRequired();
    732752  leftv u=args;
    733753  if ((u != NULL) && (u->Typ() == fanID))
    734754  {
     755    gfan::initializeCddlibIfRequired();
    735756    gfan::ZFan* zf = (gfan::ZFan*) u->Data();
    736757    gfan::ZVector zv=zf->getFVector();
    737758    res->rtyp = BIGINTMAT_CMD;
    738759    res->data = (void*) zVectorToBigintmat(zv);
     760    gfan::deinitializeCddlibIfRequired();
    739761    return FALSE;
    740762  }
     
    745767gfan::ZMatrix rays(const gfan::ZFan* const zf)
    746768{
    747   gfan::initializeCddlibIfRequired();
    748769  gfan::ZMatrix rays(0,zf->getAmbientDimension());
    749770  for (int i=0; i<zf->numberOfConesOfDimension(1,0,0); i++)
     
    757778int numberOfConesWithVector(gfan::ZFan* zf, gfan::ZVector* v)
    758779{
    759   gfan::initializeCddlibIfRequired();
    760780  int count = 0;
    761781  int ambientDim = zf->getAmbientDimension();
     
    775795BOOLEAN numberOfConesWithVector(leftv res, leftv args)
    776796{
    777   gfan::initializeCddlibIfRequired();
    778797  leftv u=args;
    779798  if ((u != NULL) && (u->Typ() == fanID))
     
    782801    if ((v != NULL) && (v->Typ() == BIGINTMAT_CMD))
    783802    {
     803      gfan::initializeCddlibIfRequired();
    784804      gfan::ZFan* zf = (gfan::ZFan*) u->Data();
    785805      bigintmat* v0 = (bigintmat*) v->Data();
     
    788808      {
    789809        WerrorS("numberOfConesWithVector: mismatching dimensions");
     810        gfan::deinitializeCddlibIfRequired();
    790811        return TRUE;
    791812      }
     
    795816      res->rtyp = INT_CMD;
    796817      res->data = (void*) (long) count;
     818      gfan::deinitializeCddlibIfRequired();
    797819      return FALSE;
    798820    }
     
    804826BOOLEAN fanFromString(leftv res, leftv args)
    805827{
    806   gfan::initializeCddlibIfRequired();
    807828  leftv u=args;
    808829  if ((u != NULL) && (u->Typ() == STRING_CMD))
    809     {
    810       std::string fanInString = (char*) u->Data();
    811       std::istringstream s(fanInString);
    812       gfan::ZFan* zf = new gfan::ZFan(s);
    813       res->rtyp = fanID;
    814       res->data = (void*) zf;
    815       return FALSE;
    816     }
     830  {
     831    gfan::initializeCddlibIfRequired();
     832    std::string fanInString = (char*) u->Data();
     833    std::istringstream s(fanInString);
     834    gfan::ZFan* zf = new gfan::ZFan(s);
     835    res->rtyp = fanID;
     836    res->data = (void*) zf;
     837    gfan::deinitializeCddlibIfRequired();
     838    return FALSE;
     839  }
    817840  WerrorS("fanFromString: unexpected parameters");
    818841  return TRUE;
     
    821844BOOLEAN fanViaCones(leftv res, leftv args)
    822845{
    823   gfan::initializeCddlibIfRequired();
    824846  leftv u=args;
    825847  if ((u != NULL) && (u->Typ() == LIST_CMD))
     
    828850    if (lSize(L)>-1)
    829851    {
     852      gfan::initializeCddlibIfRequired();
    830853      if (L->m[0].Typ() != coneID)
    831854      {
     
    841864        {
    842865          WerrorS("fanViaCones: entries of wrong type in list");
     866          gfan::deinitializeCddlibIfRequired();
    843867          return TRUE;
    844868        }
     
    847871        {
    848872          WerrorS("fanViaCones: inconsistent ambient dimensions amongst cones in list");
     873          gfan::deinitializeCddlibIfRequired();
    849874          return TRUE;
    850875        }
     
    853878      res->rtyp = fanID;
    854879      res->data = (void*) zf;
     880      gfan::deinitializeCddlibIfRequired();
    855881      return FALSE;
    856882    }
     
    861887  if ((u != NULL) && (u->Typ() == coneID))
    862888  {
     889    gfan::initializeCddlibIfRequired();
    863890    gfan::ZCone* zc = (gfan::ZCone*) u->Data();
    864891    gfan::ZFan* zf = new gfan::ZFan(zc->ambientDimension());
     
    870897      {
    871898        WerrorS("fanViaCones: arguments of wrong type");
     899        gfan::deinitializeCddlibIfRequired();
     900        delete zf;
    872901        return TRUE;
    873902      }
     
    876905      {
    877906        WerrorS("fanViaCones: inconsistent ambient dimensions amongst input cones");
     907        gfan::deinitializeCddlibIfRequired();
     908        delete zf;
    878909        return TRUE;
    879910      }
     
    882913    res->rtyp = fanID;
    883914    res->data = (void*) zf;
     915    gfan::deinitializeCddlibIfRequired();
    884916    return FALSE;
    885917  }
     
    9721004BOOLEAN commonRefinement(leftv res, leftv args)
    9731005{
    974   gfan::initializeCddlibIfRequired();
    9751006  leftv u=args;
    9761007  if ((u != NULL) && (u->Typ() == fanID))
     
    9791010    if ((v != NULL) && (v->Typ() == fanID))
    9801011    {
     1012      gfan::initializeCddlibIfRequired();
    9811013      gfan::ZFan* zf = (gfan::ZFan*) u->Data();
    9821014      gfan::ZFan* zg = (gfan::ZFan*) v->Data();
     
    9841016      res->rtyp = fanID;
    9851017      res->data = (void*) zr;
     1018      gfan::deinitializeCddlibIfRequired();
    9861019      return FALSE;
    9871020    }
  • Singular/dyn_modules/gfanlib/bbpolytope.cc

    re85fed r5a1c78  
    185185BOOLEAN polytopeViaVertices(leftv res, leftv args)
    186186{
    187   gfan::initializeCddlibIfRequired();
    188187  leftv u = args;
    189188  if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
    190189  {
    191     if (u->next == NULL) return ppCONERAYS1(res, u);
     190    if (u->next == NULL)
     191    {
     192      gfan::initializeCddlibIfRequired();
     193      BOOLEAN bo = ppCONERAYS1(res, u);
     194      gfan::deinitializeCddlibIfRequired();
     195      return bo;
     196    }
    192197    leftv v = u->next;
    193198    if ((v != NULL) && (v->Typ() == INT_CMD))
    194199    {
    195       if (v->next == NULL) return ppCONERAYS3(res, u, v);
     200      if (v->next == NULL)
     201      {
     202        gfan::initializeCddlibIfRequired();
     203        BOOLEAN bo = ppCONERAYS3(res, u, v);
     204        gfan::deinitializeCddlibIfRequired();
     205        return bo;
     206      }
    196207    }
    197208  }
     
    320331BOOLEAN polytopeViaNormals(leftv res, leftv args)
    321332{
    322   gfan::initializeCddlibIfRequired();
    323333  leftv u = args;
    324334  if ((u != NULL) && ((u->Typ() == BIGINTMAT_CMD) || (u->Typ() == INTMAT_CMD)))
    325335  {
    326     if (u->next == NULL) return ppCONENORMALS1(res, u);
     336    if (u->next == NULL)
     337    {
     338      gfan::initializeCddlibIfRequired();
     339      BOOLEAN bo = ppCONENORMALS1(res, u);
     340      gfan::deinitializeCddlibIfRequired();
     341      return bo;
     342    }
    327343  }
    328344  leftv v = u->next;
    329345  if ((v != NULL) && ((v->Typ() == BIGINTMAT_CMD) || (v->Typ() == INTMAT_CMD)))
    330346  {
    331     if (v->next == NULL) return ppCONENORMALS2(res, u, v);
     347    if (v->next == NULL)
     348    {
     349      gfan::initializeCddlibIfRequired();
     350      BOOLEAN bo = ppCONENORMALS2(res, u, v);
     351      gfan::deinitializeCddlibIfRequired();
     352      return bo;
     353    }
    332354  }
    333355  leftv w = v->next;
    334356  if ((w != NULL) && (w->Typ() == INT_CMD))
    335357  {
    336     if (w->next == NULL) return ppCONENORMALS3(res, u, v, w);
     358    if (w->next == NULL)
     359    {
     360      gfan::initializeCddlibIfRequired();
     361      BOOLEAN bo = ppCONENORMALS3(res, u, v, w);
     362      gfan::deinitializeCddlibIfRequired();
     363      return bo;
     364    }
    337365  }
    338366  WerrorS("polytopeViaInequalities: unexpected parameters");
     
    342370BOOLEAN vertices(leftv res, leftv args)
    343371{
    344   gfan::initializeCddlibIfRequired();
    345372  leftv u = args;
    346373  if ((u != NULL) && (u->Typ() == polytopeID))
    347     {
    348       gfan::ZCone* zc = (gfan::ZCone*)u->Data();
    349       gfan::ZMatrix zmat = zc->extremeRays();
    350       res->rtyp = BIGINTMAT_CMD;
    351       res->data = (void*)zMatrixToBigintmat(zmat);
    352       return FALSE;
    353     }
     374  {
     375    gfan::initializeCddlibIfRequired();
     376    gfan::ZCone* zc = (gfan::ZCone*)u->Data();
     377    gfan::ZMatrix zmat = zc->extremeRays();
     378    res->rtyp = BIGINTMAT_CMD;
     379    res->data = (void*)zMatrixToBigintmat(zmat);
     380    gfan::deinitializeCddlibIfRequired();
     381    return FALSE;
     382  }
    354383  WerrorS("vertices: unexpected parameters");
    355384  return TRUE;
     
    401430BOOLEAN newtonPolytope(leftv res, leftv args)
    402431{
    403   gfan::initializeCddlibIfRequired();
    404432  leftv u = args;
    405433  if ((u != NULL) && (u->Typ() == POLY_CMD))
    406434  {
     435    gfan::initializeCddlibIfRequired();
    407436    poly p = (poly)u->Data();
    408437    res->rtyp = polytopeID;
    409438    res->data = (void*) new gfan::ZCone(newtonPolytope(p,currRing));
     439    gfan::deinitializeCddlibIfRequired();
    410440    return FALSE;
    411441  }
     
    416446BOOLEAN scalePolytope(leftv res, leftv args)
    417447{
    418   gfan::initializeCddlibIfRequired();
    419448  leftv u = args;
    420449  if ((u != NULL) && (u->Typ() == INT_CMD))
     
    423452    if ((v != NULL) && (v->Typ() == polytopeID))
    424453    {
     454      gfan::initializeCddlibIfRequired();
    425455      int s = (int)(long) u->Data();
    426456      gfan::ZCone* zp = (gfan::ZCone*) v->Data();
     
    433463      res->rtyp = polytopeID;
    434464      res->data = (void*) zq;
     465      gfan::deinitializeCddlibIfRequired();
    435466      return FALSE;
    436467    }
     
    442473BOOLEAN dualPolytope(leftv res, leftv args)
    443474{
    444   gfan::initializeCddlibIfRequired();
    445475  leftv u = args;
    446476  if ((u != NULL) && (u->Typ() == polytopeID))
    447477  {
     478    gfan::initializeCddlibIfRequired();
    448479    gfan::ZCone* zp = (gfan::ZCone*) u->Data();
    449480    gfan::ZCone* zq = new gfan::ZCone(zp->dualCone());
    450481    res->rtyp = polytopeID;
    451482    res->data = (void*) zq;
     483    gfan::deinitializeCddlibIfRequired();
    452484    return FALSE;
    453485  }
     
    458490BOOLEAN mixedVolume(leftv res, leftv args)
    459491{
    460   gfan::initializeCddlibIfRequired();
    461492  leftv u = args;
    462493  if ((u != NULL) && (u->Typ() == LIST_CMD))
    463494  {
     495    gfan::initializeCddlibIfRequired();
    464496    lists l = (lists) u->Data();
    465497    int k = lSize(l)+1;
     
    499531      {
    500532        WerrorS("mixedVolume: entries of unsupported type in list");
     533        gfan::deinitializeCddlibIfRequired();
    501534        return TRUE;
    502535      }
     
    506539    res->rtyp = BIGINT_CMD;
    507540    res->data = (void*) integerToNumber(mv);
     541    gfan::deinitializeCddlibIfRequired();
    508542    return FALSE;
    509543  }
Note: See TracChangeset for help on using the changeset viewer.