Changeset 6b15a76 in git for libpolys


Ignore:
Timestamp:
Nov 19, 2018, 2:19:50 PM (5 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
Children:
38554beb085c7b26c5d00d8dd399ee6b5bb7bca8
Parents:
1bbd47fd39d8d0bee713b13b974dba118d689cd3
Message:
extend freeAlagebra to ordering a (+wp/Wp/dp/Dp) OR lp
Location:
libpolys/polys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/shiftop.cc

    r1bbd47 r6b15a76  
    735735}
    736736
     737/// substitute weights from orderings a,wp,Wp
     738/// by d copies of it at position p
     739static BOOLEAN freeAlgebra_weights(const ring old_ring, ring new_ring, int p, int d)
     740{
     741  omFree(new_ring->wvhdl[p]);
     742  int *w=(int*)omAlloc(new_ring->N*sizeof(int));
     743  for(int b=0;b<d;b++)
     744  {
     745    for(int i=old_ring->N-1;i>=0;i--)
     746    {
     747      if (old_ring->wvhdl[p][i]<-0) return TRUE;
     748      w[b*old_ring->N+i]=old_ring->wvhdl[p][i];
     749    }
     750  }
     751  new_ring->wvhdl[p]=w;
     752  new_ring->block1[p]=new_ring->N;
     753  return FALSE;
     754}
     755
    737756ring freeAlgebra(ring r, int d)
    738757{
     
    747766  R->N=r->N*d;
    748767  R->isLPring=r->N;
     768  // create R->order
     769  BOOLEAN has_order_a=FALSE;
     770  while (r->order[p]==ringorder_a)
     771  {
     772    if (freeAlgebra_weights(r,R,p,d))
     773    {
     774      WerrorS("weights must be positive");
     775      return NULL;
     776    }
     777    has_order_a=TRUE;
     778    p++;
     779  }
    749780  R->block1[p]=R->N; /* only dp,Dp,wp,Wp; will be discarded for lp*/
    750   // create R->order
    751781  switch(r->order[p])
    752782  {
     
    756786    case ringorder_wp:
    757787    case ringorder_Wp:
    758     {
    759       omFree(R->wvhdl[p]);
    760       int *w=(int*)omAlloc(R->N*sizeof(int));
    761       for(int b=1;b<d;b++)
     788      if (freeAlgebra_weights(r,R,p,d))
    762789      {
    763         for(int i=r->N-1;i>=0;i--)
    764           w[b*r->N+i]=r->wvhdl[p][i];
     790        WerrorS("weights must be positive");
     791        return NULL;
    765792      }
    766       R->wvhdl[p]=w;
    767793      break;
    768     }
    769794    case ringorder_lp:
    770795    case ringorder_rp:
    771796    {
     797      if(has_order_a)
     798      {
     799        WerrorS("ordering (a(..),lp/rp not implemented for LP-rings");
     800        return NULL;
     801      }
    772802      int ** wvhdl=(int**)omAlloc0((r->N+2)*sizeof(int*));
    773803      rRingOrder_t* ord=(rRingOrder_t*)omAlloc0((r->N+2)*sizeof(rRingOrder_t));
     
    798828      // copy component order
    799829      if (p==1) ord[0]=r->order[0];
    800       else /*p==0*/ ord[r->N+1]=r->order[1];
     830      else if (p==0) ord[r->N+1]=r->order[1];
     831      else
     832      { // should never happen:
     833        WerrorS("ordering not implemented for LP-rings");
     834        return NULL;
     835      }
    801836      break;
    802837    }
  • libpolys/polys/shiftop.h

    r1bbd47 r6b15a76  
    5454poly p_LPVarAt(poly p, int pos, const ring r);
    5555
     56/// create the letterplace ring corresponding to r up to degree d
    5657ring freeAlgebra(ring r, int d);
    5758#endif
Note: See TracChangeset for help on using the changeset viewer.