Ignore:
Timestamp:
Feb 18, 2015, 9:41:53 AM (9 years ago)
Author:
Yue Ren <ren@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
9f7a9cd448041b035d092b0dcf11b4d5f14ac002
Parents:
4a6847d88eb8e6f833551e2a34563ba917cb5c52
Message:
new: functions for groebnerFans, groebnerComplexes
File:
1 edited

Legend:

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

    r4a6847 r1d85871  
    1414BITSET bitsetSave1, bitsetSave2;
    1515
     16
    1617/***
    1718 * sets option(redSB)
     
    2223  si_opt_1|=Sy_bit(OPT_REDSB);
    2324}
     25
    2426
    2527/***
     
    4042}
    4143
     44
    4245BOOLEAN tropicalVariety(leftv res, leftv args)
    4346{
    4447  leftv u = args;
     48  if ((u!=NULL) && (u->Typ()==POLY_CMD))
     49  {
     50    poly g = (poly) u->Data();
     51    leftv v = u->next;
     52    if (v==NULL)
     53    {
     54      try
     55      {
     56        ideal I = idInit(1);
     57        I->m[0] = g;
     58        tropicalStrategy currentStrategy(I,currRing);
     59        std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,&currentStrategy);
     60        res->rtyp = fanID;
     61        res->data = (char*) toZFan(maxCones);
     62        I->m[0] = NULL;
     63        id_Delete(&I,currRing);
     64        return FALSE;
     65      }
     66      catch (const std::exception& ex)
     67      {
     68        WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
     69        return TRUE;
     70      }
     71    }
     72    if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
     73    {
     74      try
     75      {
     76        ideal I = idInit(1);
     77        I->m[0] = g;
     78        number p = (number) v->Data();
     79        tropicalStrategy currentStrategy(I,p,currRing);
     80        ideal startingIdeal = currentStrategy.getStartingIdeal();
     81        ring startingRing = currentStrategy.getStartingRing();
     82        poly gStart = startingIdeal->m[0];
     83        std::set<gfan::ZCone> maxCones = tropicalVariety(gStart,startingRing,&currentStrategy);
     84        res->rtyp = fanID;
     85        res->data = (char*) toZFan(maxCones);
     86        I->m[0] = NULL;
     87        id_Delete(&I,currRing);
     88        return FALSE;
     89      }
     90      catch (const std::exception& ex)
     91      {
     92        WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
     93        return TRUE;
     94      }
     95
     96    }
     97  }
    4598  if ((u!=NULL) && (u->Typ()==IDEAL_CMD))
    4699  {
     
    53106      if (v==NULL)
    54107      {
    55         tropicalStrategy currentStrategy(I,currRing);
    56         std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,&currentStrategy);
    57         // gfan::ZFan* zf = toZFan(maxCones);
    58         // delete zf;
    59         // res->rtyp = NONE;
    60         // res->data = NULL;
    61         // while (1)
    62         // {
    63         //   omUpdateInfo();
    64         //   Print("usedBytesAfter=%ld\n",om_Info.UsedBytes);
    65         //   tropicalStrategy debugTest(I,currRing);
    66         //   maxCones = tropicalVariety(g,currRing,debugTest);
    67         //   gfan::ZFan* zf = toZFan(maxCones);
    68         //   delete zf;
    69         // }
    70         res->rtyp = fanID;
    71         res->data = (char*) toZFan(maxCones);
    72         return FALSE;
     108        try
     109        {
     110          tropicalStrategy currentStrategy(I,currRing);
     111          std::set<gfan::ZCone> maxCones = tropicalVariety(g,currRing,&currentStrategy);
     112          res->rtyp = fanID;
     113          res->data = (char*) toZFan(maxCones);
     114          return FALSE;
     115        }
     116        catch (const std::exception& ex)
     117        {
     118          WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
     119          return TRUE;
     120        }
    73121      }
    74122      if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
    75123      {
    76         number p = (number) v->Data();
    77         tropicalStrategy currentStrategy(I,p,currRing);
    78         ideal startingIdeal = currentStrategy.getStartingIdeal();
    79         ring startingRing = currentStrategy.getStartingRing();
    80         poly gStart = startingIdeal->m[0];
    81         std::set<gfan::ZCone> maxCones = tropicalVariety(gStart,startingRing,&currentStrategy);
    82         res->rtyp = fanID;
    83         res->data = (char*) toZFan(maxCones);
    84         return FALSE;
     124        try
     125        {
     126          number p = (number) v->Data();
     127          tropicalStrategy currentStrategy(I,p,currRing);
     128          ideal startingIdeal = currentStrategy.getStartingIdeal();
     129          ring startingRing = currentStrategy.getStartingRing();
     130          poly gStart = startingIdeal->m[0];
     131          std::set<gfan::ZCone> maxCones = tropicalVariety(gStart,startingRing,&currentStrategy);
     132          res->rtyp = fanID;
     133          res->data = (char*) toZFan(maxCones);
     134          return FALSE;
     135        }
     136        catch (const std::exception& ex)
     137        {
     138          WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
     139          return TRUE;
     140        }
    85141      }
    86142    }
     
    88144    if (v==NULL)
    89145    {
    90       setOptionRedSB();
    91       // ideal stdI;
    92       // if (!hasFlag(u,FLAG_STD))
    93       //   stdI = gfanlib_kStd_wrapper(I,currRing);
    94       // else
    95       //   stdI = id_Copy(I,currRing);
    96       tropicalStrategy currentStrategy(I,currRing);
    97       gfan::ZFan* tropI = tropicalVariety(currentStrategy);
    98       res->rtyp = fanID;
    99       res->data = (char*) tropI;
    100       undoSetOptionRedSB();
    101       // id_Delete(&stdI,currRing);
    102       return FALSE;
     146      try
     147      {
     148        setOptionRedSB();
     149        ideal stdI;
     150        if (!hasFlag(u,FLAG_STD))
     151          stdI = gfanlib_kStd_wrapper(I,currRing);
     152        else
     153          stdI = id_Copy(I,currRing);
     154        tropicalStrategy currentStrategy(stdI,currRing);
     155        gfan::ZFan* tropI = tropicalVariety(currentStrategy);
     156        res->rtyp = fanID;
     157        res->data = (char*) tropI;
     158        undoSetOptionRedSB();
     159        id_Delete(&stdI,currRing);
     160        return FALSE;
     161      }
     162      catch (const std::exception& ex)
     163      {
     164        WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
     165        return TRUE;
     166      }
    103167    }
    104168    if ((v!=NULL) && (v->Typ()==NUMBER_CMD))
    105169    {
    106       number p = (number) v->Data();
    107       // ideal stdI;
    108       // if (!hasFlag(u,FLAG_STD))
    109       //   stdI = gfanlib_kStd_wrapper(I,currRing);
    110       // else
    111       //   stdI = id_Copy(I,currRing);
    112       // tropicalStrategy currentStrategy(stdI,p,currRing);
    113       tropicalStrategy currentStrategy(I,p,currRing);
    114       gfan::ZFan* tropI = tropicalVariety(currentStrategy);
    115       res->rtyp = fanID;
    116       res->data = (char*) tropI;
    117       // id_Delete(&stdI,currRing);
    118       return FALSE;
     170      try
     171      {
     172        number p = (number) v->Data();
     173        ideal stdI;
     174        if (!hasFlag(u,FLAG_STD))
     175          stdI = gfanlib_kStd_wrapper(I,currRing);
     176        else
     177          stdI = id_Copy(I,currRing);
     178        tropicalStrategy currentStrategy(stdI,p,currRing);
     179        gfan::ZFan* tropI = tropicalVariety(currentStrategy);
     180        res->rtyp = fanID;
     181        res->data = (char*) tropI;
     182        id_Delete(&stdI,currRing);
     183        return FALSE;
     184      }
     185      catch (const std::exception& ex)
     186      {
     187        WerrorS("ERROR: "); WerrorS(ex.what()); WerrorS("\n");
     188        return TRUE;
     189      }
    119190    }
    120191    return FALSE;
Note: See TracChangeset for help on using the changeset viewer.