Changeset c4d065 in git


Ignore:
Timestamp:
Nov 26, 2010, 4:37:58 PM (13 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
92e2cd1822dc1be6a8ef69173615a30e5bd67d0e
Parents:
9e7d85ecc0703de24759963ee74edd60d4139c09
Message:
coding at Goettingen (cones&fans)

git-svn-id: file:///usr/local/Singular/svn/trunk@13677 2c84dea3-7e68-4137-9b89-c4e89433aadc
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    r9e7d85 rc4d065  
    34753475  return FALSE;
    34763476}*/
     3477static BOOLEAN jjINSERTCONE(leftv res, leftv u, leftv v)
     3478{
     3479        gfan::ZFan* zf = (gfan::ZFan*)u->Data();
     3480        gfan::ZCone* zc = (gfan::ZCone*)v->Data();
     3481        zf->insert(*zc);
     3482        return FALSE;
     3483}
    34773484static BOOLEAN jjGETPROPC(leftv res, leftv u, leftv v)
    34783485{
     
    50255032    case RESOLUTION_CMD: res->data=omStrDup("resolution");break;
    50265033#ifdef HAVE_FANS
    5027 //    case FAN_CMD:        res->data=omStrDup("fan");break;
     5034    case FAN_CMD:        res->data=omStrDup("fan");break;
    50285035    case CONE_CMD:       res->data=omStrDup("cone");break;
    50295036#endif /* HAVE_FANS */
     
    50875094  return FALSE;
    50885095}
    5089 
    50905096BOOLEAN jjWAITALL1(leftv res, leftv a)
    50915097{
     
    51045110  return FALSE;
    51055111}
    5106 
    51075112#ifdef HAVE_FANS
     5113static BOOLEAN jjFANEMPTY_I(leftv res, leftv v)
     5114{
     5115        int ambientDim = (int)(long)v->Data();
     5116        if (ambientDim < 0)
     5117        {
     5118          Werror("expected non-negative ambient dim but got %d", ambientDim);
     5119          return TRUE;
     5120        }
     5121        res->data = (char*)(new gfan::ZFan(ambientDim));
     5122        return FALSE;
     5123}
     5124static BOOLEAN jjFANEMPTY_IM(leftv res, leftv v)
     5125{
     5126        intvec* permutations = (intvec*)v->Data();
     5127        // todo: check that permutations contains sensible elements of S_n
     5128        int ambientDim = permutations->cols();
     5129        gfan::SymmetryGroup sg = gfan::SymmetryGroup(ambientDim);
     5130        gfan::ZMatrix zm = intmat2ZMatrix(permutations);
     5131        gfan::IntMatrix im = gfan::ZToIntMatrix(zm);
     5132        sg.computeClosure(im);
     5133        res->data = (char*)(new gfan::ZFan(sg));
     5134        return FALSE;
     5135}
     5136static BOOLEAN jjFANFULL_I(leftv res, leftv v)
     5137{
     5138        int ambientDim = (int)(long)v->Data();
     5139        if (ambientDim < 0)
     5140        {
     5141          Werror("expected non-negative ambient dim but got %d", ambientDim);
     5142          return TRUE;
     5143        }
     5144        gfan::ZFan* zf = new gfan::ZFan(gfan::ZFan::fullFan(ambientDim));
     5145        res->data = (char*)zf;
     5146        return FALSE;
     5147}
     5148static BOOLEAN jjFANFULL_IM(leftv res, leftv v)
     5149{
     5150        intvec* permutations = (intvec*)v->Data();
     5151        // todo: check that permutations contains sensible elements of S_n
     5152        int ambientDim = permutations->cols();
     5153        gfan::SymmetryGroup sg = gfan::SymmetryGroup(ambientDim);
     5154        gfan::ZMatrix zm = intmat2ZMatrix(permutations);
     5155        gfan::IntMatrix im = gfan::ZToIntMatrix(zm);
     5156        sg.computeClosure(im);
     5157        gfan::ZFan* zf = new gfan::ZFan(gfan::ZFan::fullFan(sg));
     5158        res->data = (char*)zf;
     5159        return FALSE;
     5160}
    51085161static BOOLEAN jjCONERAYS1(leftv res, leftv v)
    51095162{
  • Singular/ipassign.cc

    r9e7d85 rc4d065  
    324324}
    325325#ifdef HAVE_FANS
    326 /*
    327326static BOOLEAN jiA_FAN(leftv res, leftv a, Subexpr e)
    328327{
     
    334333  if (res->data!=NULL)
    335334  {
    336     Fan* fff = (Fan*)res->data;
     335    gfan::ZFan* zf = (gfan::ZFan*)res->data;
    337336    res->data = NULL;
    338     delete fff;
    339   }
    340   Fan* fff = (Fan*)a->CopyD(FAN_CMD);
    341   res->data=(void*)fff;
    342   return FALSE;
    343 }*/
     337    delete zf;
     338  }
     339  gfan::ZFan* zf = (gfan::ZFan*)a->CopyD(FAN_CMD);
     340  res->data=(void*)zf;
     341  return FALSE;
     342}
    344343static BOOLEAN jiA_CONE(leftv res, leftv a, Subexpr e)
    345344{
     
    13391338}
    13401339#ifdef HAVE_FANS
    1341 /*
    13421340BOOLEAN jjAssignFan(leftv l, leftv r)
    1343 {*/
     1341{
    13441342  /* method for generating a fan;
    1345      valid parametrizations: (intmat or 0, intmat or 0, intmat or 0),
    1346      The intmat's capture the maximal rays, facet normals and the
    1347      lineality space of the new fan.
    1348      Any of the arguments may be the int 0. But either the 1st or
    1349      2nd argument must be an intmat, thus not both simultaneously
    1350      the int 0.
     1343     valid parametrizations: int (ambient dimension),
    13511344     Errors will be invoked in the following cases:
    1352      - 1st and 2nd argument simultaneously the int 0,
    1353      - numbers of rows in 1st, 2nd, and/or 3rd argument intmat
    1354        disagree */
    1355 //  intvec* maxRays = NULL;    /* maximal rays */
    1356 //  intvec* facetNs = NULL;    /* facet normals */
    1357 //  intvec* linSpace = NULL;   /* lineality space */
    1358 /*
    1359   leftv x = r;
    1360   if (x->Typ() == INTMAT_CMD) maxRays = (intvec*)x->Data();
    1361   else if ((x->Typ() != INT_CMD) ||
    1362            ((x->Typ() == INT_CMD) && ((int)(long)x->Data() != 0)))
    1363   {
    1364     WerrorS("expected '0' or an intmat as 1st argument");
     1345     - argument < 0
     1346     The resulting fan has no cones, its lineality space
     1347     is the entire ambient space. */
     1348  if (r->Typ() != INT_CMD)
     1349  {
     1350    WerrorS("expected an int as argument");
    13651351    return TRUE;
    13661352  }
    1367   x = x->next;
    1368   if (x->Typ() == INTMAT_CMD) facetNs = (intvec*)x->Data();
    1369   else if ((x->Typ() != INT_CMD) ||
    1370            ((x->Typ() == INT_CMD) && ((int)(long)x->Data() != 0)))
    1371   {
    1372     WerrorS("expected '0' or an intmat as 2nd argument");
     1353  int ambientDim = (int)(long)r->Data();
     1354  if (ambientDim < 0)
     1355  {
     1356    Werror("expected an int >= 0, but got %d", ambientDim);
    13731357    return TRUE;
    13741358  }
    1375   if ((maxRays == NULL) && (facetNs == NULL))
    1376   {
    1377     WerrorS("expected 1st or 2nd argument to be a valid intmat");
    1378     return TRUE;
    1379   }
    1380   x = x->next;
    1381   if (x->Typ() == INTMAT_CMD) linSpace = (intvec*)x->Data();
    1382   else if ((x->Typ() != INT_CMD) ||
    1383            ((x->Typ() == INT_CMD) && ((int)(long)x->Data() != 0)))
    1384   {
    1385     WerrorS("expected '0' or an intmat as 3rd argument");
    1386     return TRUE;
    1387   }
    1388   if ((maxRays != NULL) && (facetNs != NULL) &&
    1389       (maxRays->rows() != facetNs->rows()))
    1390   {
    1391     WerrorS("vector space dims do not agree (1st vs. 2nd argument)");
    1392     return TRUE;
    1393   }
    1394   if ((maxRays != NULL) && (linSpace != NULL) &&
    1395       (maxRays->rows() != linSpace->rows()))
    1396   {
    1397     WerrorS("vector space dims do not agree (1st vs. 3rd argument)");
    1398     return TRUE;
    1399   }
    1400 
    14011359  if (IDDATA((idhdl)l->data) != NULL)
    14021360  {
    1403     Fan* fff = (Fan*)IDDATA((idhdl)l->data);
    1404     delete fff;
    1405   }
    1406   Fan* fff = new Fan(maxRays, facetNs, linSpace);
    1407   IDDATA((idhdl)l->data) = (char*)fff;
    1408   return FALSE;
    1409 }*/
     1361    gfan::ZFan* zf = (gfan::ZFan*)IDDATA((idhdl)l->data);
     1362    delete zf;
     1363  }
     1364  gfan::ZFan* zf = new gfan::ZFan(ambientDim);
     1365  IDDATA((idhdl)l->data) = (char*)zf;
     1366  return FALSE;
     1367}
    14101368BOOLEAN jjAssignCone(leftv l, leftv r)
    14111369{
     
    14981456      if ((l->Typ() == CONE_CMD) && (r->Typ() == INT_CMD))
    14991457        return jjAssignCone(l, r);
     1458      if ((l->Typ() == FAN_CMD) && (r->Typ() == INT_CMD))
     1459        return jjAssignFan(l, r);
    15001460#endif
    15011461      /* system variables = ... */
  • Singular/ipid.cc

    r9e7d85 rc4d065  
    204204    }
    205205#ifdef HAVE_FANS
    206 /*
    207206    else if (t == FAN_CMD)
    208207    {
    209       IDSTRING(h) = (char*)(new Fan());
    210     }*/
     208      IDSTRING(h) = (char*)(new gfan::ZFan(0));
     209    }
    211210    else if (t == CONE_CMD)
    212211    {
     
    479478#ifdef HAVE_FANS
    480479  // fan -------------------------------------------------------------
    481 /*  else if (IDTYP(h) == FAN_CMD)
    482   {
    483     Fan* fff = (Fan*)IDDATA(h);
    484     delete fff;
     480  else if (IDTYP(h) == FAN_CMD)
     481  {
     482    gfan::ZFan* zf = (gfan::ZFan*)IDDATA(h);
     483    delete zf;
    485484    IDDATA(h) = NULL;
    486   }*/
     485  }
    487486  // cone ------------------------------------------------------------
    488487  else if (IDTYP(h) == CONE_CMD)
  • Singular/subexpr.cc

    r9e7d85 rc4d065  
    127127}
    128128
     129/* not used */
    129130std::string toPrintString(gfan::ZCone const &c, char *nameOfCone)
    130131{
     
    234235#ifdef HAVE_FANS
    235236       case CONE_CMD:
    236        //case FAN_CMD:
     237       case FAN_CMD:
    237238          PrintNSpaces(spaces);
    238239          {
     
    576577      }
    577578#ifdef HAVE_FANS
    578 /*    case FAN_CMD:
    579       {
    580         Fan* fff = (Fan*)d;
    581         Fan* ggg = new Fan(*fff);
    582         return ggg;
    583       }*/
     579    case FAN_CMD:
     580      {
     581        gfan::ZFan* zf = (gfan::ZFan*)d;
     582        gfan::ZFan* newZf = new gfan::ZFan(*zf);
     583        return newZf;
     584      }
    584585    case CONE_CMD:
    585586      {
     
    874875          return s;
    875876#ifdef HAVE_FANS
    876 /*        case FAN_CMD:
    877         {
    878           Fan* fff = (Fan*)d;
    879           s = fff->toString();
    880           char* ns = (char*) omAlloc(strlen(s) + 10);
    881           sprintf(ns, "%s", s);
     877        case FAN_CMD:
     878        {
     879          gfan::ZFan* zf = (gfan::ZFan*)d;
     880          std::string s = zf->toString();
     881          char* ns = (char*) omAlloc(strlen(s.c_str()) + 10);
     882          sprintf(ns, "%s", s.c_str());
    882883          omCheckAddr(ns);
    883           omFree(s);
    884884          return ns;
    885         }*/
     885        }
    886886        case CONE_CMD:
    887887        {
  • Singular/table.h

    r9e7d85 rc4d065  
    291291//,{D(jjMAXCONE1),   MAXCONE_CMD,     LIST_CMD,       FAN_CMD       , ALLOW_PLURAL |ALLOW_RING}
    292292//,{D(jjADJACENCY1), ADJACENCY_CMD,   INTMAT_CMD,     FAN_CMD       , ALLOW_PLURAL |ALLOW_RING}
    293 ,{D(jjCONERAYS1),  CONERAYS_CMD,    CONE_CMD,      INTMAT_CMD       , ALLOW_PLURAL |ALLOW_RING}
    294 ,{D(jjCONENORMALS1),CONENORMALS_CMD,CONE_CMD,      INTMAT_CMD       , ALLOW_PLURAL |ALLOW_RING}
     293,{D(jjCONERAYS1),  CONERAYS_CMD,    CONE_CMD,       INTMAT_CMD    , ALLOW_PLURAL |ALLOW_RING}
     294,{D(jjCONENORMALS1),CONENORMALS_CMD,CONE_CMD,       INTMAT_CMD    , ALLOW_PLURAL |ALLOW_RING}
     295,{D(jjFANEMPTY_I),  FANEMPTY_CMD,   FAN_CMD,        INT_CMD       , ALLOW_PLURAL |ALLOW_RING}
     296,{D(jjFANEMPTY_IM), FANEMPTY_CMD,   FAN_CMD,        INTMAT_CMD    , ALLOW_PLURAL |ALLOW_RING}
     297,{D(jjFANFULL_I),   FANFULL_CMD,    FAN_CMD,        INT_CMD       , ALLOW_PLURAL |ALLOW_RING}
     298,{D(jjFANFULL_IM),  FANFULL_CMD,    FAN_CMD,        INTMAT_CMD    , ALLOW_PLURAL |ALLOW_RING}
    295299#endif /* HAVE_FANS */
    296300,{NULL,             0,               0,              0             , NO_PLURAL |NO_RING}
     
    670674,{D(jjCONTAINS2), CONTAINS_CMD,   INT_CMD,        CONE_CMD,   CONE_CMD, ALLOW_PLURAL |ALLOW_RING}
    671675,{D(jjGETPROPC),  GETPROP_CMD,    ANY_TYPE/*set by p*/,CONE_CMD,STRING_CMD, ALLOW_PLURAL |ALLOW_RING}
     676,{D(jjINSERTCONE),INSERTCONE_CMD, NONE,           FAN_CMD,    CONE_CMD, ALLOW_PLURAL | ALLOW_RING}
    672677//,{D(jjADDMCONE1), ADDMCONE_CMD,   NONE,           FAN_CMD,    CONE_CMD, ALLOW_PLURAL | ALLOW_RING}
    673678//,{D(jjADDMCONE2), ADDMCONE_CMD,   NONE,           FAN_CMD,    LIST_CMD, ALLOW_PLURAL | ALLOW_RING}
     
    874879  { "cone_via_rays",0, CONERAYS_CMD,      CMD_123},
    875880  { "cone_via_normals",0,CONENORMALS_CMD, CMD_123},
     881  { "fan_empty",   0, FANEMPTY_CMD,       CMD_1},
     882  { "fan_full",    0, FANEMPTY_CMD,       CMD_1},
     883  { "insert_cone", 0, INSERTCONE_CMD,     CMD_2},
    876884  { "cone_intersect",0,INTERSC_CMD,       CMD_2},
    877885  { "cone_link",   0, CONELINK_CMD,       CMD_2},
     
    879887  { "getprop",     0, GETPROP_CMD,        CMD_2},
    880888  { "setprop",     0, SETPROP_CMD,        CMD_3},
     889  { "fan",         0, FAN_CMD,            ROOT_DECL},
    881890  #endif /* HAVE_FANS */
    882891  { "alias",       0, ALIAS_CMD ,         PARAMETER},
     
    12391248,{D(jiA_LINK),     LINK_CMD,       LINK_CMD }
    12401249#ifdef HAVE_FANS
    1241 //,{D(jiA_FAN),      FAN_CMD,        FAN_CMD }
     1250,{D(jiA_FAN),      FAN_CMD,        FAN_CMD }
    12421251,{D(jiA_CONE),     CONE_CMD,       CONE_CMD }
    12431252#endif /* HAVE_FANS */
  • Singular/tok.h

    r9e7d85 rc4d065  
    5454//#ifdef HAVE_FANS
    5555  CONE_CMD,
     56  FAN_CMD,
    5657  CONELINK_CMD,
    5758  CONERAYS_CMD,
    5859  CONENORMALS_CMD,
     60  FANEMPTY_CMD,
     61  FANFULL_CMD,
     62  INSERTCONE_CMD,
    5963  CONTAINS_CMD,
    6064  FACECONT_CMD,
  • factory/cf_gcd.cc

    r9e7d85 rc4d065  
    2222#include "fieldGCD.h"
    2323#include "cf_gcd_smallp.h"
    24 
    2524
    2625#ifdef HAVE_NTL
  • gfanlib/gfanlib_matrix.h

    r9e7d85 rc4d065  
    568568typedef Matrix<Integer> ZMatrix;
    569569typedef Matrix<Rational> QMatrix;
     570typedef Matrix<int> IntMatrix;
    570571
    571572inline QMatrix ZToQMatrix(ZMatrix const &m)
     
    580581  ZMatrix ret(m.getHeight(),m.getWidth());
    581582  for(int i=0;i<m.getHeight();i++)ret[i]=QToZVectorPrimitive(m[i]);
     583  return ret;
     584}
     585
     586
     587inline IntMatrix ZToIntMatrix(ZMatrix const &m)
     588{
     589  IntMatrix ret(m.getHeight(),m.getWidth());
     590  for(int i=0;i<m.getHeight();i++)ret[i]=ZToIntVector(m[i]);
     591  return ret;
     592}
     593
     594
     595inline ZMatrix IntToZMatrix(IntMatrix const &m)
     596{
     597  ZMatrix ret(m.getHeight(),m.getWidth());
     598  for(int i=0;i<m.getHeight();i++)ret[i]=IntToZVector(m[i]);
    582599  return ret;
    583600}
  • gfanlib/gfanlib_polymakefile.cpp

    r9e7d85 rc4d065  
    1010#include <assert.h>
    1111#include <sstream>
     12#include <istream>
    1213
    1314using namespace std;
     
    3132}
    3233
    33 static string readUntil(FILE *f, int c)
     34static string readUntil(istream &f, int c)
    3435{
    3536  stringstream ret;
    3637  int c2;
    37   c2=fgetc(f);
    38   while(c2!=c && c2!=EOF)
    39     {
     38  c2=f.get();
     39//  c2=fgetc(f);
     40//  while(c2!=c && c2!=EOF)
     41  while(c2!=c && !f.eof())
     42  {
    4043      ret<<char(c2);
    41       c2=fgetc(f);
    42     }
     44      //c2=fgetc(f);
     45      c2=f.get();
     46  }
    4347  return ret.str();
    4448}
     
    6771
    6872
    69 void PolymakeFile::open(const char *fileName_)
     73void PolymakeFile::open(std::istream &f)
     74{
     75  isXml=false;
     76//  fileName=string(fileName_);
     77
     78//  FILE *f=fopen(fileName.c_str(),"r");
     79//  if(!f)//fprintf(Stderr,"Could not open file:\"%s\"\n",fileName_);
     80//  assert(f);
     81
     82  int c=f.get();//fgetc(f);
     83  while(!f.eof())
     84    {
     85      if(c=='_')
     86        {
     87          readUntil(f,'\n');
     88        }
     89      else if(c!='\n')
     90        {
     91          f.unget();
     92          //          ungetc(c,f);
     93          string name=readUntil(f,'\n');
     94
     95//          fprintf(Stderr,"Reading:\"%s\"\n",name.c_str());
     96          stringstream value;
     97          while(1)
     98            {
     99              string l=readUntil(f,'\n');
     100              if(l.size()==0)break;
     101              value << l <<endl;
     102            }
     103          properties.push_back(PolymakeProperty(name.c_str(),value.str().c_str()));
     104        }
     105      c=f.get();//fgetc(f);
     106    }
     107}
     108
     109/*void PolymakeFile::open(const char *fileName_)
    70110{
    71111  isXml=false;
     
    101141    }
    102142}
    103 
    104 
     143*/
    105144void PolymakeFile::create(const char *fileName_, const char *application_, const char *type_, bool isXml_)
    106145{
     
    244283ZMatrix PolymakeFile::readMatrixProperty(const char *p, int height, int width)
    245284{
    246   ZMatrix ret(height,width);
     285  ZMatrix ret(0,width);
    247286
    248287  assert(hasProperty(p,true));
    249288  list<PolymakeProperty>::iterator prop=findProperty(p);
    250289  stringstream s(prop->value);
    251   for(int i=0;i<height;i++)
     290//  for(int i=0;i<height;i++)
     291  for(int i=0;;i++)
     292  {
     293    if(i==height)break;
     294    ZVector w(width);
    252295    for(int j=0;j<width;j++)
    253       {
    254         int v;
    255         eatComment(s);
    256         s>>v;
    257         ret[i][j]=v;
    258       }
     296        {
     297          int v;
     298          eatComment(s);
     299          s>>v;
     300          if(s.eof())goto done;
     301          w[j]=v;
     302        }
     303    ret.appendRow(w);
     304  }
     305  done:
     306
     307  if(height>=0)assert(ret.getHeight()==height);
     308//  cerr<<p;
     309 //   eatComment(s);
     310   // int v;
     311   // s>>v;
     312//  while(!s.eof())std::cerr<<char(s.get());
     313 // assert(s.eof());
    259314
    260315  return ret;
  • gfanlib/gfanlib_polymakefile.h

    r9e7d85 rc4d065  
    3636  bool isXml;
    3737 public:
    38   void open(const char *fileName_);
     38//   void open(const char *fileName_);
     39   void open(std::istream &f);
    3940  void create(const char *fileName_, const char *application_, const char *type_, bool isXml_=false);
    4041  void writeStream(std::ostream &file);
  • gfanlib/gfanlib_symmetriccomplex.cpp

    r9e7d85 rc4d065  
    247247  int dimLow=this->linealitySpace.getHeight();
    248248  int dimHigh=this->getMaxDim();
     249  if(dimHigh<dimLow)dimHigh=dimLow-1;
    249250  if(conelist)*conelist=std::vector<std::vector<IntVector> >(dimHigh-dimLow+1);
    250 
    251251  for(int d=dimLow;d<=dimHigh;d++)
    252252    {
     
    292292        }
    293293    }
    294 
    295294
    296295}
     
    364363{
    365364  int min=getMinDim();
    366   ZVector ret(getMaxDim()-min+1);
     365  int dimHigh=getMaxDim();
     366  if(dimHigh<min)dimHigh=min-1;
     367  ZVector ret(dimHigh-min+1);
    367368
    368369  for(ConeContainer::const_iterator i=cones.begin();i!=cones.end();i++)
     
    523524
    524525
    525     polymakeFile.writeMatrixProperty("LINEALITY_SPACE",kernel(linealitySpace),n);
    526     polymakeFile.writeMatrixProperty("ORTH_LINEALITY_SPACE",linealitySpace,n);
     526    polymakeFile.writeMatrixProperty("LINEALITY_SPACE",linealitySpace,n);
     527    polymakeFile.writeMatrixProperty("ORTH_LINEALITY_SPACE",kernel(linealitySpace),n);
    527528
    528529/*
     
    585586    polymakeFile.writeCardinalProperty("PURE",isPure());
    586587  //  log1 fprintf(Stderr,"Done checking.\n");
     588
     589
     590    polymakeFile.writeStringProperty("CONES",toStringJustCones(getMinDim(),getMaxDim(),false,flags&FPF_group, 0,false,flags&FPF_tPlaneSort));
     591    polymakeFile.writeStringProperty("MAXIMAL_CONES",toStringJustCones(getMinDim(),getMaxDim(),true,flags&FPF_group, 0,false,flags&FPF_tPlaneSort));
     592    polymakeFile.writeStringProperty("CONES_ORBITS",toStringJustCones(getMinDim(),getMaxDim(),false,flags&FPF_group, 0,true,flags&FPF_tPlaneSort));
     593    polymakeFile.writeStringProperty("MAXIMAL_CONES_ORBITS",toStringJustCones(getMinDim(),getMaxDim(),true,flags&FPF_group, 0,true,flags&FPF_tPlaneSort));
     594
     595    if(!sym.isTrivial())
     596      {
     597        polymakeFile.writeMatrixProperty("SYMMETRY_GENERATORS",IntToZMatrix(sym.getGenerators()));
     598      }
    587599
    588600    std::stringstream s;
  • gfanlib/gfanlib_symmetry.cpp

    r9e7d85 rc4d065  
    212212}
    213213
     214IntMatrix SymmetryGroup::getGenerators()const
     215{
     216  IntMatrix ret(0,this->sizeOfBaseSet());
     217  for(ElementContainer::const_iterator i=elements.begin();i!=elements.end();i++)ret.appendRow(i->toIntVector());
     218  return ret;
     219}
     220
    214221void SymmetryGroup::computeClosure(Permutation const &v) //does this work??
    215222{
     
    220227  while(!newOnes.empty())
    221228    {
    222       static int i;
    223       i++;
    224 
    225229      Permutation v=*newOnes.begin();
    226230      for(ElementContainer::const_iterator i=elements.begin();i!=elements.end();i++)
     
    232236          }
    233237          {
    234             Permutation n=v.apply(*i);
     238            Permutation n=v.apply(v);
    235239            if(0==elements.count(n))
    236240              newOnes.insert(n);
     
    243247
    244248
    245 /*
    246 
    247 void SymmetryGroup::computeClosure(IntegerVectorList const &l)
    248 {
    249   //  for(IntegerVectorList::const_iterator i=l.begin();i!=l.end();i++)
    250   //  computeClosure(*i);
    251 
    252   bool growing=true;
    253   while(growing)
    254     {
    255       growing=false;
    256       for(ElementContainer::const_iterator i=elements.begin();i!=elements.end();i++)
    257         {
    258           for(IntegerVectorList::const_iterator j=l.begin();j!=l.end();j++)
    259             {
    260               {
    261                 IntegerVector n(compose(*i,*j));
    262                 growing|=(0==elements.count(n));
    263                 elements.insert(n);
    264               }
    265               {
    266                 IntegerVector n(compose(*i,*j));
    267                 growing|=(0==elements.count(n));
    268                 elements.insert(n);
    269               }
    270             }
    271         }
    272     }
    273 }
    274 */
     249void SymmetryGroup::computeClosure(IntMatrix const &l)
     250{
     251  for(int i=0;i<l.getHeight();i++)computeClosure(Permutation(l[i]));
     252}
     253
    275254
    276255/*
  • gfanlib/gfanlib_symmetry.h

    r9e7d85 rc4d065  
    118118  SymmetryGroup(int n);
    119119  void computeClosure(Permutation const &v);
    120   void computeClosure(ZMatrix const &l);
     120  void computeClosure(IntMatrix const &l);
     121  IntMatrix getGenerators()const;
    121122  int orbitSize(ZVector const &stable)const;
    122123  bool isTrivial()const;
  • gfanlib/gfanlib_vector.h

    r9e7d85 rc4d065  
    313313  QVector ret(v.size());
    314314  for(int i=0;i<v.size();i++)ret[i]=Rational(v[i]);
     315  return ret;
     316}
     317
     318
     319inline IntVector ZToIntVector(ZVector const &v)
     320{
     321  IntVector ret(v.size());
     322  for(int i=0;i<v.size();i++)ret[i]=v[i].toInt();
     323  return ret;
     324}
     325
     326
     327inline ZVector IntToZVector(IntVector const &v)
     328{
     329  ZVector ret(v.size());
     330  for(int i=0;i<v.size();i++)ret[i]=Integer(v[i]);
    315331  return ret;
    316332}
  • gfanlib/gfanlib_z.h

    r9e7d85 rc4d065  
    163163    return mpz_get_si(value);
    164164  }
     165  bool fitsInInt()const
     166  {
     167    mpz_t v;
     168    mpz_init(v);
     169    this->setGmp(v);
     170    bool ret=(mpz_fits_sint_p(v)!=0);
     171    mpz_clear(v);
     172    return ret;
     173  }
     174  int toInt()const
     175  {
     176    mpz_t v;
     177    mpz_init(v);
     178    this->setGmp(v);
     179    int ret=0;
     180    if(mpz_fits_sint_p(v))
     181      ret=mpz_get_si(v);
     182//    else
     183//      ok=false;
     184    mpz_clear(v);
     185    return ret;
     186  }
    165187};
    166188
  • gfanlib/gfanlib_zfan.cpp

    r9e7d85 rc4d065  
    77
    88#include "gfanlib_zfan.h"
     9#include "gfanlib_polymakefile.h"
     10
     11using namespace std;
    912
    1013namespace gfan
     
    5457        assert(coneCollection);
    5558        complex = new SymmetricComplex(coneCollection->toSymmetricComplex());
     59        std::cerr<<"D"<<std::endl;
    5660        complex->buildConeLists(false,false,&cones);
     61        std::cerr<<"D"<<std::endl;
    5762        complex->buildConeLists(true,false,&maximalCones);
     63        std::cerr<<"D"<<std::endl;
    5864        complex->buildConeLists(false,true,&coneOrbits);
     65        std::cerr<<"D"<<std::endl;
    5966        complex->buildConeLists(true,true,&maximalConeOrbits);
    60       }
    61   }
     67        std::cerr<<"D"<<std::endl;
     68      }
     69  }
     70  ZFan::ZFan(std::istream &f):
     71    coneCollection(0),
     72    complex(0)
     73  {
     74//    PolyhedralFan PolyhedralFan::readFan(string const &filename, bool onlyMaximal, IntegerVector *w, set<int> const *coneIndices, SymmetryGroup const *sym, bool readCompressedIfNotSym)
     75    PolymakeFile inFile;
     76    //assert(0);
     77     inFile.open(f);
     78
     79    int n=inFile.readCardinalProperty("AMBIENT_DIM").toInt();
     80    int nRays=inFile.readCardinalProperty("N_RAYS").toInt();
     81    ZMatrix rays=inFile.readMatrixProperty("RAYS",nRays,n);
     82    int linealityDim=inFile.readCardinalProperty("LINEALITY_DIM").toInt();
     83    ZMatrix linealitySpace=inFile.readMatrixProperty("LINEALITY_SPACE",linealityDim,n);
     84
     85    SymmetryGroup sym(n);
     86    bool readingSymmetricComplex=false;
     87    if(inFile.hasProperty("SYMMETRY_GENERATORS"))
     88      {
     89        sym.computeClosure(ZToIntMatrix(inFile.readMatrixProperty("SYMMETRY_GENERATORS",-1,n)));
     90        readingSymmetricComplex=true;
     91      }
     92
     93
     94    const char *sectionName=0;
     95    const char *sectionNameMultiplicities=0;
     96    if(readingSymmetricComplex)
     97      {
     98        if(inFile.hasProperty("MAXIMAL_CONES_ORBITS"))
     99          {
     100            sectionName="MAXIMAL_CONES_ORBITS";
     101            sectionNameMultiplicities="MULTIPLICITIES_ORBITS";
     102          }
     103        else
     104          {
     105            sectionName="CONES_ORBITS";
     106          }
     107      }
     108    else
     109      {
     110        if(inFile.hasProperty("MAXIMAL_CONES"))
     111          {
     112            sectionName="MAXIMAL_CONES";
     113            sectionNameMultiplicities="MULTIPLICITIES";
     114          }
     115        else
     116          {
     117            sectionName="CONES";
     118          }
     119      }
     120
     121    /*    if(sym || readCompressedIfNotSym)
     122      {
     123        sectionName=(onlyMaximal)?"MAXIMAL_CONES_ORBITS":"CONES_ORBITS";
     124        sectionNameMultiplicities=(onlyMaximal)?"MULTIPLICITIES_ORBITS":"DUMMY123";
     125      }
     126    else
     127*/
     128    /*{
     129        sectionName="MAXIMAL_CONES";//(onlyMaximal)?"MAXIMAL_CONES":"CONES";
     130        sectionNameMultiplicities="MULTIPLICITIES";//(onlyMaximal)?"MULTIPLICITIES":"DUMMY123";
     131      }
     132*/
     133//    ZVector w2(n);
     134//    if(w==0)w=&w2;
     135
     136 //       SymmetryGroup sym2(n);
     137 //       if(sym==0)sym=&sym2;
     138
     139/*  sectionName=0;
     140  if(inFile.hasProperty("MAXIMAL_CONES"))
     141    sectionName="MAXIMAL_CONES";
     142  else
     143    {  if(inFile.hasProperty("CONES"))
     144      sectionName="CONES";
     145    else
     146      assert(0);
     147    }*/
     148
     149  vector<list<int> > cones=inFile.readMatrixIncidenceProperty(sectionName);
     150//        IntegerVectorList r;
     151
     152        bool hasMultiplicities=inFile.hasProperty(sectionNameMultiplicities);
     153        ZMatrix multiplicities(0,0);
     154        if(hasMultiplicities)multiplicities=inFile.readMatrixProperty(sectionNameMultiplicities,cones.size(),1);
     155
     156        ZFan ret(sym);
     157
     158//        log2 cerr<< "Number of orbits to expand "<<cones.size()<<endl;
     159        for(int i=0;i<cones.size();i++)
     160        //  if(coneIndices==0 || coneIndices->count(i))
     161            {
     162//              log2 cerr<<"Expanding symmetries of cone"<<endl;
     163              {
     164                ZMatrix coneRays(0,n);
     165                for(list<int>::const_iterator j=cones[i].begin();j!=cones[i].end();j++)
     166                  coneRays.appendRow((rays[*j]));
     167                ZCone C=ZCone::givenByRays(coneRays,linealitySpace);
     168                if(hasMultiplicities)C.setMultiplicity(multiplicities[i][0]);
     169//                for(SymmetryGroup::ElementContainer::const_iterator perm=sym->elements.begin();perm!=sym->elements.end();perm++)
     170                  {
     171//                    if(C.contains(perm.applyInverse(*w)))
     172//                      {
     173 //                       PolyhedralCone C2=C.permuted(*perm);
     174//                        C2.canonicalize();
     175//                        ret.insert(C2);
     176 //                     }
     177                    ret.insert(C);
     178                  }
     179              }
     180            }
     181//        return ret;
     182        *this=ret;
     183  }
     184
    62185  ZFan::~ZFan()
    63186  {
     
    90213    if(this!=&f)
    91214      {
     215std::cerr<<"COPYING\n";
    92216        if(complex)
    93217          {
     
    95219            complex=0;
    96220          }
     221        std::cerr<<"1COPYING\n";
    97222        if(coneCollection)
    98223          {
     
    100225            coneCollection=0;
    101226          }
     227        std::cerr<<"2COPYING\n";
    102228        if(f.coneCollection)
    103229          {
    104230            coneCollection=new PolyhedralFan(*f.coneCollection);
    105231          }
     232        std::cerr<<"3COPYING\n";
    106233        if(f.complex)
    107234          {
    108235            complex=new SymmetricComplex(*f.complex);
    109236          }
     237        std::cerr<<"DONE COPYING\n";
    110238      }
    111239    return *this;
     
    165293  return complex->toString(flags);//complex->getMinDim(),complex->getMaxDim(),0,0);
    166294//  return "NEEDTOFIXTHIS";
     295
    167296  //return theFan.toString();
    168297}
  • gfanlib/gfanlib_zfan.h

    r9e7d85 rc4d065  
    6262  ~ZFan();
    6363  ZFan(ZFan const& f);
     64  /**
     65   *
     66   * To read from string, do the following:
     67   *       std::string test="TEST";
     68   *   std::istringstream s(test);
     69   *   ZFan G(s);
     70   *
     71   */
     72  ZFan(std::istream  &f);
    6473  ZFan& operator=(ZFan const &f);
    6574  /**
Note: See TracChangeset for help on using the changeset viewer.