Changeset 3c85f1 in git


Ignore:
Timestamp:
May 13, 2014, 3:13:37 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '38077648e7239f98078663eb941c3c979511150a')
Children:
199c1c827e8061d465d255caee5fce75bc264b04
Parents:
ebe8ba01aa526904424efa0b47af1640aaaaad9f
Message:
add: ssi-qrings
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/links/ssiLink.cc

    rebe8ba r3c85f1  
    5757#include <time.h>
    5858
    59 #define SSI_VERSION 7
     59#define SSI_VERSION 8
    6060// 5->6: changed newstruct representation
    6161// 6->7: attributes
     62// 7->8: qring
    6263
    6364// 64 bit version:
     
    9192volatile BOOLEAN ssiToBeClosed_inactive=TRUE;
    9293
     94// forward declarations:
     95void ssiWritePoly_R(const ssiInfo *d, int typ, poly p, const ring r);
     96void ssiWriteIdeal(const ssiInfo *d, int typ,ideal I);
     97poly ssiReadPoly_R(const ssiInfo *D, const ring r);
     98ideal ssiReadIdeal_R(const ssiInfo *d,const ring r);
     99
    93100// the helper functions:
    94101void ssiSetCurrRing(const ring r)
     
    108115}
    109116// the implementation of the functions:
    110 void ssiWriteInt(ssiInfo *d,const int i)
     117void ssiWriteInt(const ssiInfo *d,const int i)
    111118{
    112119  fprintf(d->f_write,"%d ",i);
     
    114121}
    115122
    116 void ssiWriteString(ssiInfo *d,const char *s)
     123void ssiWriteString(const ssiInfo *d,const char *s)
    117124{
    118125  fprintf(d->f_write,"%d %s ",(int)strlen(s),s);
    119126  //if (d->f_debug!=NULL) fprintf(d->f_debug,"stringi: %d \"%s\" ",strlen(s),s);
    120127}
    121 
    122128
    123129void ssiWriteBigInt(const ssiInfo *d, const number n)
     
    142148}
    143149
    144 void ssiWritePoly_R(const ssiInfo *d, int typ, poly p, const ring r);
    145150void ssiWriteNumber_CF(const ssiInfo *d, const number n, const coeffs cf)
    146151{
     
    178183void ssiWriteRing(ssiInfo *d,const ring r)
    179184{
    180   /* 5 <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... */
     185  /* 5 <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <Q-ideal> */
    181186  /* ch=-1: transext, coeff ring follows */
    182187  /* ch=-2: algext, coeff ring and minpoly follows */
     
    239244      i++;
    240245    }
     246    /* Q-ideal :*/
     247    if (r->qideal!=NULL)
     248    {
     249      ssiWriteIdeal(d,IDEAL_CMD,r->qideal);
     250    }
     251    else
     252    {
     253      fprintf(d->f_write,"0 "/*ideal with 0 entries */);
     254    }
    241255    if ((rFieldType(r)==n_transExt)
    242256    || (rFieldType(r)==n_algExt))
     
    258272{
    259273  fprintf(d->f_write,"%d ",pLength(p));//number of terms
    260   int i;
    261274
    262275  while(p!=NULL)
     
    279292}
    280293
    281 void ssiWriteIdeal(ssiInfo *d, int typ,ideal I)
     294void ssiWriteIdeal(const ssiInfo *d, int typ,ideal I)
    282295{
    283296   // syntax: 7 # of elements <poly 1> <poly2>.....
     
    320333}
    321334
    322 void ssiWriteProc(ssiInfo *d,procinfov p)
     335void ssiWriteProc(const ssiInfo *d,procinfov p)
    323336{
    324337  if (p->data.s.body==NULL)
     
    341354  }
    342355}
    343 void ssiWriteIntvec(ssiInfo *d,intvec * v)
     356void ssiWriteIntvec(const ssiInfo *d,intvec * v)
    344357{
    345358  fprintf(d->f_write,"%d ",v->length());
     
    350363  }
    351364}
    352 void ssiWriteIntmat(ssiInfo *d,intvec * v)
     365void ssiWriteIntmat(const ssiInfo *d,intvec * v)
    353366{
    354367  fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
     
    360373}
    361374
    362 void ssiWriteBigintmat(ssiInfo *d,bigintmat * v)
     375void ssiWriteBigintmat(const ssiInfo *d,bigintmat * v)
    363376{
    364377  fprintf(d->f_write,"%d %d ",v->rows(),v->cols());
     
    370383}
    371384
    372 char *ssiReadString(ssiInfo *d)
     385char *ssiReadString(const ssiInfo *d)
    373386{
    374387  char *buf;
     
    388401}
    389402
    390 number ssiReadBigInt(ssiInfo *d)
     403number ssiReadBigInt(const ssiInfo *d)
    391404{
    392405  int sub_type=-1;
     
    413426}
    414427
    415 static number ssiReadQNumber(ssiInfo *d)
    416 {
    417   int sub_type=-1;
    418   sub_type=s_readint(d->f_read);
    419   switch(sub_type)
    420   {
    421      case 0:
    422      case 1:
    423        {// read mpz_t, mpz_t
    424          number n=nlRInit(0);
    425          mpz_init(n->n);
    426          s_readmpz(d->f_read,n->z);
    427          s_readmpz(d->f_read,n->n);
    428          n->s=sub_type;
    429          return n;
    430        }
    431 
    432      case 3:
    433        {// read mpz_t
    434          number n=nlRInit(0);
    435          s_readmpz(d->f_read,n->z);
    436          n->s=3; /*sub_type*/
    437          return n;
    438        }
    439      case 4:
    440        {
    441          LONG dd=s_readlong(d->f_read);
    442          //#if SIZEOF_LONG == 8
    443          return INT_TO_SR(dd);
    444          //#else
    445          //return nlInit(dd,NULL);
    446          //#endif
    447        }
    448      case 5:
    449      case 6:
    450        {// read raw mpz_t, mpz_t
    451          number n=nlRInit(0);
    452          mpz_init(n->n);
    453          s_readmpz_base (d->f_read,n->z, SSI_BASE);
    454          s_readmpz_base (d->f_read,n->n, SSI_BASE);
    455          n->s=sub_type-5;
    456          return n;
    457        }
    458      case 8:
    459        {// read raw mpz_t
    460          number n=nlRInit(0);
    461          s_readmpz_base (d->f_read,n->z, SSI_BASE);
    462          n->s=sub_type=3; /*subtype-5*/
    463          return n;
    464        }
    465 
    466      default: Werror("error in reading number: invalid subtype %d",sub_type);
    467               return NULL;
    468   }
    469   return NULL;
    470 }
    471 
    472 poly ssiReadPoly_R(ssiInfo *D, const ring r);
    473 number ssiReadNumber_CF(ssiInfo *d, const coeffs cf)
     428number ssiReadNumber_CF(const ssiInfo *d, const coeffs cf)
    474429{
    475430  if (cf->cfReadFd!=NULL)
     
    495450}
    496451
    497 number ssiReadNumber(ssiInfo *d)
     452number ssiReadNumber(const ssiInfo *d)
    498453{
    499454  return ssiReadNumber_CF(d,d->r->cf);
    500455}
    501456
    502 ring ssiReadRing(ssiInfo *d)
    503 {
    504 /* syntax is <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... */
    505   int ch, N,i,l;
     457ring ssiReadRing(const ssiInfo *d)
     458{
     459/* syntax is <ch> <N> <l1> <v1> ...<lN> <vN> <number of orderings> <ord1> <block0_1> <block1_1> .... <Q-ideal> */
     460  int ch, N,i;
    506461  char **names;
    507462  ch=s_readint(d->f_read);
     
    561516    return NULL;
    562517  }
    563   else if (ch>=0) /* Q, Z/p */
    564     return rDefault(ch,N,names,num_ord,ord,block0,block1,wvhdl);
    565   else if (ch==-1) /* trans ext. */
    566   {
    567     TransExtInfo T;
    568     T.r=ssiReadRing(d);
    569     coeffs cf=nInitChar(n_transExt,&T);
    570     return rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
    571   }
    572   else if (ch==-2) /* alg ext. */
    573   {
    574     TransExtInfo T;
    575     T.r=ssiReadRing(d);
    576     T.r->qideal=idInit(1,1);
    577     T.r->qideal->m[0]=ssiReadPoly_R(d,T.r);
    578     coeffs cf=nInitChar(n_algExt,&T);
    579     return rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
    580   }
    581518  else
    582519  {
    583     Werror("ssi: read unknown coeffs type (%d)",ch);
    584     return NULL;
    585   }
    586 }
    587 
    588 poly ssiReadPoly_R(ssiInfo *D, const ring r)
     520    ring r=NULL;
     521    if (ch>=0) /* Q, Z/p */
     522      r=rDefault(ch,N,names,num_ord,ord,block0,block1,wvhdl);
     523    else if (ch==-1) /* trans ext. */
     524    {
     525      TransExtInfo T;
     526      T.r=ssiReadRing(d);
     527      coeffs cf=nInitChar(n_transExt,&T);
     528      r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
     529    }
     530    else if (ch==-2) /* alg ext. */
     531    {
     532      TransExtInfo T;
     533      T.r=ssiReadRing(d);
     534      T.r->qideal=idInit(1,1);
     535      T.r->qideal->m[0]=ssiReadPoly_R(d,T.r);
     536      coeffs cf=nInitChar(n_algExt,&T);
     537      r=rDefault(cf,N,names,num_ord,ord,block0,block1,wvhdl);
     538    }
     539    else
     540    {
     541      Werror("ssi: read unknown coeffs type (%d)",ch);
     542      return NULL;
     543    }
     544    ideal q=ssiReadIdeal_R(d,r);
     545    if (IDELEMS(q)==0) omFreeBin(q,sip_sideal_bin);
     546    else r->qideal=q;
     547    return r;
     548  }
     549}
     550
     551poly ssiReadPoly_R(const ssiInfo *D, const ring r)
    589552{
    590553// < # of terms> < term1> < .....
     
    593556  //Print("poly: terms:%d\n",n);
    594557  poly p;
    595   int j;
    596   j=0;
    597558  poly ret=NULL;
    598559  poly prev=NULL;
     
    619580}
    620581
    621 poly ssiReadPoly(ssiInfo *D)
     582poly ssiReadPoly(const ssiInfo *D)
    622583{
    623584// < # of terms> < term1> < .....
     
    625586}
    626587
    627 ideal ssiReadIdeal(ssiInfo *d)
     588ideal ssiReadIdeal_R(const ssiInfo *d,const ring r)
    628589{
    629590  int n,i;
     
    633594  for(i=0;i<IDELEMS(I);i++) // read n terms
    634595  {
    635     I->m [i]=ssiReadPoly(d);
     596    I->m [i]=ssiReadPoly_R(d,r);
    636597  }
    637598  return I;
    638599}
    639600
    640 matrix ssiReadMatrix(ssiInfo *d)
    641 {
    642   int n,m,i,j;
     601ideal ssiReadIdeal(const ssiInfo *d)
     602{
     603  return ssiReadIdeal_R(d,d->r);
     604}
     605
     606matrix ssiReadMatrix(const ssiInfo *d)
     607{
     608  int n,m;
    643609  m=s_readint(d->f_read);
    644610  n=s_readint(d->f_read);
     
    700666}
    701667
    702 procinfov ssiReadProc(ssiInfo *d)
     668procinfov ssiReadProc(const ssiInfo *d)
    703669{
    704670  char *s=ssiReadString(d);
     
    728694  return L;
    729695}
    730 intvec* ssiReadIntvec(ssiInfo *d)
     696intvec* ssiReadIntvec(const ssiInfo *d)
    731697{
    732698  int nr;
     
    739705  return v;
    740706}
    741 intvec* ssiReadIntmat(ssiInfo *d)
     707intvec* ssiReadIntmat(const ssiInfo *d)
    742708{
    743709  int r,c;
     
    751717  return v;
    752718}
    753 bigintmat* ssiReadBigintmat(ssiInfo *d)
     719bigintmat* ssiReadBigintmat(const ssiInfo *d)
    754720{
    755721  int r,c;
     
    889855          d->fd_read=pc[0];
    890856          d->fd_write=cp[1];
    891           //d->r=currRing;
    892           //if (d->r!=NULL) d->r->ref++;
     857          //d->r=currRing;
     858          //if (d->r!=NULL) d->r->ref++;
    893859          l->data=d;
    894860          omFree(l->mode);
     
    928894          SI_LINK_SET_RW_OPEN_P(l);
    929895          d->send_quit_at_exit=1;
    930           //d->r=currRing;
    931           //if (d->r!=NULL) d->r->ref++;
     896          //d->r=currRing;
     897          //if (d->r!=NULL) d->r->ref++;
    932898        }
    933899        else
     
    944910        int sockfd, newsockfd, portno, clilen;
    945911        struct sockaddr_in serv_addr, cli_addr;
    946         int n;
    947912        sockfd = socket(AF_INET, SOCK_STREAM, 0);
    948913        if(sockfd < 0)
     
    1005970        int sockfd, newsockfd, portno, clilen;
    1006971        struct sockaddr_in serv_addr, cli_addr;
    1007         int n;
    1008972        sockfd = socket(AF_INET, SOCK_STREAM, 0);
    1009973        if(sockfd < 0)
     
    10881052      {
    10891053        char* host = (char*)omAlloc(256);
    1090         int sockfd, portno, n;
     1054        int sockfd, portno;
    10911055        struct sockaddr_in serv_addr;
    10921056        struct hostent *server;
     
    12961260    case 5:{
    12971261             d->r=ssiReadRing(d);
    1298              res->rtyp=RING_CMD;
    12991262             res->data=(char*)d->r;
     1263             if (d->r->qideal==NULL)
     1264               res->rtyp=RING_CMD;
     1265             else
     1266               res->rtyp=QRING_CMD;
    13001267             // we are in the top-level, so set the basering to d->r:
    13011268             if (d->r!=NULL)
     
    14701437                          ssiWriteNumber(d,(number)dd);
    14711438                        break;
     1439          case QRING_CMD:
    14721440          case RING_CMD:fputs("5 ",d->f_write);
    14731441                        ssiWriteRing(d,(ring)dd);
     
    15781546  && (strcmp(request, "read") == 0))
    15791547  {
    1580     fd_set  mask, fdmask;
     1548    fd_set  mask;
    15811549    struct timeval wt;
    15821550    if (s_isready(d->f_read)) return "ready";
     
    18381806  }
    18391807  int portno;
    1840   int n;
    18411808  ssiReserved_sockfd = socket(AF_INET, SOCK_STREAM, 0);
    18421809  if(ssiReserved_sockfd < 0)
Note: See TracChangeset for help on using the changeset viewer.