Changeset 43580ac in git


Ignore:
Timestamp:
Apr 14, 1998, 5:26:12 PM (25 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
fd0608510d11eb671d534d98bbfe452dfc598852
Parents:
b7c8bdcf3068d073e49fa3669429999b074c12d0
Message:
* hannes/siebert: bug fix for version 1.19 -> 1.21


git-svn-id: file:///usr/local/Singular/svn/trunk@1373 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/ideals.cc

    rb7c8bd r43580ac  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ideals.cc,v 1.20 1998-02-27 16:27:58 Singular Exp $ */
     4/* $Id: ideals.cc,v 1.21 1998-04-14 15:26:12 Singular Exp $ */
    55/*
    66* ABSTRACT - all basic methods to manipulate ideals
     
    149149      j = 0;
    150150    else
    151     { 
     151    {
    152152      for (k=j+1; k<IDELEMS(ide); k++)
    153153        ide->m[k] = NULL;
     
    21522152  tmpR.wvhdl = wv;
    21532153  rComplete(&tmpR);
    2154  
     2154
    21552155  // change into the new ring
    21562156  pChangeRing(pVariables,currRing->OrdSgn,ord,block0,block1,wv);
     
    21972197}
    21982198
    2199 /*2
    2200 * compute all ar-minors of the matrix a
    2201 */
    2202 ideal idMinors(matrix a, int ar)
    2203 {
    2204   if(ar<=0)
    2205   {
    2206     Werror("%d-th minor ",ar);
    2207     return NULL;
    2208   }
    2209   int     i,j,k,size;
    2210   int *rowchoise,*colchoise;
    2211   BOOLEAN rowch,colch;
    2212   ideal result;
    2213   matrix tmp;
    2214   poly p;
    2215 
    2216   i = binom(a->rows(),ar);
    2217   j = binom(a->cols(),ar);
    2218 
    2219   rowchoise=(int *)Alloc(ar*sizeof(int));
    2220   colchoise=(int *)Alloc(ar*sizeof(int));
    2221   if ((i>512) || (j>512) || (i*j >512)) size=512;
    2222   else size=i*j;
    2223   result=idInit(size,1);
    2224   tmp=mpNew(ar,ar);
    2225   k = 0; /* the index in result*/
    2226   idInitChoise(ar,1,a->rows(),&rowch,rowchoise);
    2227   while (!rowch)
    2228   {
    2229     idInitChoise(ar,1,a->cols(),&colch,colchoise);
    2230     while (!colch)
    2231     {
    2232       for (i=1; i<=ar; i++)
    2233       {
    2234         for (j=1; j<=ar; j++)
    2235         {
    2236           MATELEM(tmp,i,j) = MATELEM(a,rowchoise[i-1],colchoise[j-1]);
    2237         }
    2238       }
    2239       p = mpDet(tmp);
    2240       if (p!=NULL)
    2241       {
    2242         if (k>=size)
    2243         {
    2244           pEnlargeSet(&result->m,size,32);
    2245           size += 32;
    2246         }
    2247         result->m[k] = p;
    2248         k++;
    2249       }
    2250       idGetNextChoise(ar,a->cols(),&colch,colchoise);
    2251     }
    2252     idGetNextChoise(ar,a->rows(),&rowch,rowchoise);
    2253   }
    2254   /*delete the matrix tmp*/
    2255   for (i=1; i<=ar; i++)
    2256   {
    2257     for (j=1; j<=ar; j++) MATELEM(tmp,i,j) = NULL;
    2258   }
    2259   idDelete((ideal*)&tmp);
    2260   if (k==0)
    2261   {
    2262     k=1;
    2263     result->m[0]=NULL;
    2264   }
    2265   Free((ADDRESS)rowchoise,ar*sizeof(int));
    2266   Free((ADDRESS)colchoise,ar*sizeof(int));
    2267   pEnlargeSet(&result->m,size,k-size);
    2268   IDELEMS(result) = k;
    2269   return (result);
    2270 }
    2271 
    22722199/*3
    22732200* produces recursively the ideal of all arxar-minors of a
    22742201*/
    22752202static void idRecMin(matrix a,int ar,poly *barDiv,ideal result,
    2276               int * nextPlace, intvec * pfRows, intvec * iv)
     2203              int * nextPlace, int rowToChose=0)
    22772204{
    22782205//Print("Level: %d\n",ar);
     
    22842211
    22852212/*--- initializing temporary structures-------------------*/
    2286   int i,j,r,c,newi,newp,k;
     2213  int i,j,r=rowToChose,c,newi,newp,k;
    22872214  poly p=NULL,pp;
    2288   BOOLEAN justChosen=FALSE;
    22892215
    22902216  if (ar==0)
     
    23042230          }
    23052231          MATELEM(a,i,j) = NULL;
    2306 //if ((*nextPlace==21) || (*nextPlace==37))
    2307 //{
    2308 //  Print("Hier sind sie!\n");
    2309 //}
    2310 //pWrite(p);
    23112232          result->m[*nextPlace] = p;
    23122233          (*nextPlace)++;
     
    23142235      }
    23152236    }
     2237    idTest(result);
    23162238    idDelete((ideal*)&a);
    23172239    return;
     
    23212243  pp = pCopy(p);   //we had to store barDiv for the remaining loops
    23222244  matrix nextStep = mpOneStepBareiss(a,barDiv,&r,&c);
    2323 /*--- we compute the row-index of the chosen row r -------*/
    2324   newi = 0;
    2325   while ((newi<iv->length()) && ((*iv)[newi]!=0)) newi++;
    2326   k = (*iv)[newi] = r;
    2327   for (j=newi-1;j>0;j--)
    2328   {
    2329     if (k>=(*iv)[j]) k++;
    2330   }
    2331   newp = 0;
    2332   while ((newp<pfRows->length()) && ((*pfRows)[newp]!=0))
    2333   {
    2334     if ((*pfRows)[newp]==k)
    2335     {
    2336       justChosen = TRUE;
    2337 //Print("just chosen\n");
    2338       break;
    2339     }
    2340     newp++;
    2341   }
    2342   if (!justChosen) (*pfRows)[newp] = k;
    2343 //Print("Chosen: ");pfRows->show();PrintLn();
    2344 //Print("Deleted: ");iv->show();PrintLn();
     2245//Print("next row is: %d, next col: %d\n",r,c);
     2246/*--- there is no pivot - the matrix is zero -------------*/
     2247  if (r*c==0)
     2248  {
     2249    idDelete((ideal*)&a);
     2250    return;
     2251  }
    23452252/*--- we read out the r-1 x c-1 matrix for the next step--*/
    23462253  if ((a->nrows-1)*(a->ncols-1)>0)
     
    23572264    idDelete((ideal*)&nextStep);
    23582265/*--- we call the next Step------------------------------*/
    2359     idRecMin(next,ar-1,barDiv,result,nextPlace,pfRows,iv);
     2266    idRecMin(next,ar-1,barDiv,result,nextPlace);
    23602267    next = NULL;
    23612268  }
    23622269/*--- now we have to take out the r-th row...------------*/
    2363 //Print("back for rows on Level: %d\n",ar);
    2364 //Print("The actual row was %d\n",k);
    2365 //Print("Chosen: ");pfRows->show();PrintLn();
    2366 //Print("Deleted: ");iv->show();PrintLn();
    2367   if (((a->nrows)>1) && (!justChosen))
     2270  if (((a->nrows)>1) && (rowToChose==0))
    23682271  {
    23692272    nextStep = mpNew(a->nrows-1,a->ncols);
     
    23832286    }
    23842287/*--- and to perform the algorithm with the rest---------*/
    2385     idRecMin(nextStep,ar,&p,result,nextPlace,pfRows,iv);
     2288    idRecMin(nextStep,ar,&p,result,nextPlace);
    23862289    nextStep = NULL;
    23872290  }
    23882291/*--- now we have to take out the c-th col...------------*/
    2389 //Print("back for cols on Level: %d\n",ar);
    2390 //Print("Chosen: ");pfRows->show();PrintLn();
    2391 //Print("Deleted: ");iv->show();PrintLn();
    23922292  if ((a->nrows)>1)
    23932293  {
     
    24092309      }
    24102310    }
     2311/*--- and to perform the algorithm with the rest---------*/
    24112312    idDelete((ideal*)&a);
    2412 /*--- and to perform the algorithm with the rest---------*/
    2413     (*iv)[newi] = 0;
    2414     idRecMin(nextStep,ar,&p,result,nextPlace,pfRows,iv);
     2313    idRecMin(nextStep,ar,&p,result,nextPlace,r);
    24152314    nextStep = NULL;
    24162315  }
    24172316/*--- deleting temporary structures and returns----------*/
    2418   if (!justChosen) (*pfRows)[newp] = 0;
    24192317  pDelete(barDiv);
    24202318  pDelete(&p);
     
    24272325* the caller of idRecMin
    24282326*/
    2429 ideal idMinors1(matrix a, int ar)
     2327ideal idMinors(matrix a, int ar)
    24302328{
    24312329  if((ar<=0) || (ar>min(a->ncols,a->nrows)))
     
    24352333  }
    24362334  int i=0;
    2437   intvec * iv=new intvec(a->nrows+1);
    2438   intvec * pv=new intvec(a->nrows+1);
    24392335  poly barDiv=NULL;
    2440   ideal result=idInit(16,0);
    2441 
    2442   idRecMin(mpCopy(a),ar-1,&barDiv,result,&i,pv,iv);
     2336  ideal result=idInit(16,1);
     2337  idTest(result);
     2338
     2339  idRecMin(mpCopy(a),ar-1,&barDiv,result,&i);
    24432340  idSkipZeroes(result);
    2444   delete iv;
    2445   delete pv;
    24462341  return result;
    24472342}
     
    31913086  return res;
    31923087}
     3088
Note: See TracChangeset for help on using the changeset viewer.