Changeset dd8182 in git for libpolys/polys/simpleideals.cc


Ignore:
Timestamp:
May 28, 2015, 1:49:46 PM (9 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'a719bcf0b8dbc648b128303a49777a094b57592c')
Children:
37118282b339c44c8ed29fe938c803f9a24fcfec
Parents:
f255f00715b2e38983ecf37e5ec5aaea460c09d8
Message:
fix: id_Mult (Tst/Buch?Example_1_8_2)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libpolys/polys/simpleideals.cc

    rf255f0 rdd8182  
    3939{
    4040  assume( idsize >= 0 && rank >= 0 );
    41  
     41
    4242  ideal hh = (ideal)omAllocBin(sip_sideal_bin);
    4343
     
    4545  hh->nrows = 1; // ideal/module!
    4646
    47   hh->rank = rank; // ideal: 1, module: >= 0! 
    48  
     47  hh->rank = rank; // ideal: 1, module: >= 0!
     48
    4949  if (idsize>0)
    5050    hh->m = (poly *)omAlloc0(idsize*sizeof(poly));
    5151  else
    5252    hh->m = NULL;
    53  
     53
    5454  return hh;
    5555}
     
    101101ideal id_MaxIdeal (const ring r)
    102102{
    103   const int N = rVar(r);
    104   ideal hh = idInit(N, 1);
    105   for (int l=0; l < N; l++)
     103  ideal hh = idInit(rVar(r), 1);
     104  for (int l=rVar(r)-1; l>=0; l--)
    106105  {
    107106    hh->m[l] = p_One(r);
     
    120119
    121120  id_Test(*h, r);
    122  
     121
    123122  const int elems = (*h)->nrows * (*h)->ncols;
    124123
     
    126125  {
    127126    assume( (*h)->m != NULL );
    128    
     127
    129128    int j = elems;
    130129    do
     
    134133      if (pp!=NULL) p_Delete(&pp, r);
    135134    }
    136     while (j>0);   
    137    
     135    while (j>0);
     136
    138137    omFreeSize((ADDRESS)((*h)->m),sizeof(poly)*elems);
    139138  }
    140  
     139
    141140  omFreeBin((ADDRESS)*h, sip_sideal_bin);
    142141  *h=NULL;
     
    148147{
    149148  id_Test(*h, r);
    150  
     149
    151150  if (*h == NULL)
    152151    return;
    153  
     152
    154153  int j,elems;
    155154  elems=j=(*h)->nrows*(*h)->ncols;
     
    172171{
    173172  assume (ide != NULL);
    174  
     173
    175174  int k;
    176175  int j = -1;
    177   BOOLEAN change=FALSE; 
    178  
     176  BOOLEAN change=FALSE;
     177
    179178  for (k=0; k<IDELEMS(ide); k++)
    180179  {
     
    210209{
    211210  assume (F != NULL);
    212  
     211
    213212  int i=0,j=IDELEMS(F)-1;
    214213
     
    227226{
    228227  id_Test(ide, r);
    229  
     228
    230229  assume( ide != NULL );
    231230  assume( k <= IDELEMS(ide) );
    232  
     231
    233232  ideal newI = idInit(k, ide->rank);
    234  
     233
    235234  for (int i = 0; i < k; i++)
    236235    newI->m[i] = p_Copy(ide->m[i],r);
    237  
     236
    238237  return newI;
    239238}
     
    347346{
    348347  id_Test(id, r);
    349  
     348
    350349  int i, j;
    351350  int k = IDELEMS(id)-1;
     
    398397{
    399398  id_Test(id, r);
    400  
     399
    401400  for (int k = IDELEMS(id)-1; k>=0; k--)
    402401  {
     
    423422{
    424423  if (h1 != NULL)
    425   { 
     424  {
    426425    // assume(IDELEMS(h1) > 0); for ideal/module, does not apply to matrix
    427426    omCheckAddrSize(h1,sizeof(*h1));
     
    429428    assume( h1->ncols >= 0 );
    430429    assume( h1->nrows >= 0 ); // matrix case!
    431    
     430
    432431    assume( h1->rank >= 0 );
    433432
     
    438437    if( h1->m != NULL && n > 0 )
    439438      omdebugAddrSize(h1->m, n * sizeof(poly));
    440    
     439
    441440    long new_rk = 0; // inlining id_RankFreeModule(h1, r, tailRing);
    442441
     
    451450    // dense matrices only contain polynomials:
    452451    // h1->nrows == h1->rank > 1 && new_rk == 0!
    453     assume( !( h1->nrows == h1->rank && h1->nrows > 1 && new_rk > 0 ) ); // 
    454    
     452    assume( !( h1->nrows == h1->rank && h1->nrows > 1 && new_rk > 0 ) ); //
     453
    455454    if(new_rk > h1->rank)
    456455    {
     
    603602  id_Test(h1, R);
    604603  id_Test(h2, R);
    605  
     604
    606605  if ( idIs0(h1) ) return id_Copy(h2,R);
    607606  if ( idIs0(h2) ) return id_Copy(h1,R);
     
    609608  int j = IDELEMS(h1)-1;
    610609  while ((j >= 0) && (h1->m[j] == NULL)) j--;
    611  
     610
    612611  int i = IDELEMS(h2)-1;
    613612  while ((i >= 0) && (h2->m[i] == NULL)) i--;
    614  
     613
    615614  const int r = si_max(h1->rank, h2->rank);
    616  
     615
    617616  ideal result = idInit(i+j+2,r);
    618617
    619618  int l;
    620  
     619
    621620  for (l=j; l>=0; l--)
    622621    result->m[l] = p_Copy(h1->m[l],R);
    623  
     622
    624623  j = i+j+1;
    625624  for (l=i; l>=0; l--, j--)
    626625    result->m[j] = p_Copy(h2->m[l],R);
    627  
     626
    628627  return result;
    629628}
     
    635634  if (h2==NULL) return FALSE;
    636635  assume (h1 != NULL);
    637  
     636
    638637  int j = IDELEMS(h1) - 1;
    639  
     638
    640639  while ((j >= 0) && (h1->m[j] == NULL)) j--;
    641640  j++;
     
    695694
    696695/// h1 * h2
    697 /// h1 must be an ideal (with at least one column)
    698 /// h2 may be a module (with no columns at all)
    699 ideal  id_Mult (ideal h1,ideal  h2, const ring r)
    700 {
    701   id_Test(h1, r);
    702   id_Test(h2, r);
    703 
    704   assume( h1->rank == 1 );
     696/// one h_i must be an ideal (with at least one column)
     697/// the other h_i may be a module (with no columns at all)
     698ideal  id_Mult (ideal h1,ideal  h2, const ring R)
     699{
     700  id_Test(h1, R);
     701  id_Test(h2, R);
    705702
    706703  int j = IDELEMS(h1);
    707704  while ((j > 0) && (h1->m[j-1] == NULL)) j--;
    708  
     705
    709706  int i = IDELEMS(h2);
    710707  while ((i > 0) && (h2->m[i-1] == NULL)) i--;
    711708
    712   j = j * i;
    713  
    714   ideal  hh = idInit(j, si_max( h2->rank, h1->rank ));
    715  
    716   if (j==0) return hh;
    717  
     709  j *= i;
     710  int r = si_max( h2->rank, h1->rank );
     711  if (j==0)
     712  {
     713    if ((IDELEMS(h1)>0) && (IDELEMS(h2)>0)) j=1;
     714    return idInit(j, r);
     715  }
     716  ideal  hh = idInit(j, r);
     717
    718718  int k = 0;
    719719  for (i=0; i<IDELEMS(h1); i++)
     
    725725        if (h2->m[j] != NULL)
    726726        {
    727           hh->m[k] = pp_Mult_qq(h1->m[i],h2->m[j],r);
     727          hh->m[k] = pp_Mult_qq(h1->m[i],h2->m[j],R);
    728728          k++;
    729729        }
     
    731731    }
    732732  }
    733  
    734   id_Compactify(hh,r);
     733
     734  id_Compactify(hh,R);
    735735  return hh;
    736736}
     
    741741  assume (h != NULL); // will fail :(
    742742//  if (h == NULL) return TRUE;
    743  
    744   for( int i = IDELEMS(h)-1; i >= 0; i-- )   
     743
     744  for( int i = IDELEMS(h)-1; i >= 0; i-- )
    745745    if(h->m[i] != NULL)
    746746      return FALSE;
     
    754754{
    755755  id_TestTail(s, lmRing, tailRing);
    756  
     756
    757757  long j = 0;
    758758
     
    768768      }
    769769  }
    770  
     770
    771771  return j; //  return -1;
    772772}
     
    908908  assume(i >= 0);
    909909  ideal h = idInit(i, i);
    910  
     910
    911911  for (int j=0; j<i; j++)
    912912  {
     
    915915    p_SetmComp(h->m[j],r);
    916916  }
    917  
     917
    918918  return h;
    919919}
     
    10871087    if (h->m[i]!=NULL)
    10881088      m->m[i]=p_Head(h->m[i],r);
    1089  
     1089
    10901090  return m;
    10911091}
     
    13751375  r->ncols = i-> ncols;
    13761376  //r->rank = i-> rank;
    1377  
     1377
    13781378  for(int k=(i->nrows)*(i->ncols)-1;k>=0; k--)
    13791379    r->m[k]=pp_Jet(i->m[k],d,R);
    1380  
     1380
    13811381  return r;
    13821382}
     
    17431743
    17441744//  assume( s >= 0 ); // negative is also possible // TODO: verify input ideal in such a case!?
    1745  
     1745
    17461746  for(int i=IDELEMS(M)-1; i>=0;i--)
    17471747    p_Shift(&(M->m[i]),s,r);
    1748  
     1748
    17491749  M->rank += s;
    1750  
     1750
    17511751//  id_Test( M, r );
    17521752}
Note: See TracChangeset for help on using the changeset viewer.