Changeset ef72ff3 in git


Ignore:
Timestamp:
Aug 19, 1999, 10:31:10 AM (25 years ago)
Author:
Wilfred Pohl <pohl@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
c601e113508e77c9e23dc3dbdef91c223b128d36
Parents:
6af907a7a7d71fd3623a80d151ad4a95348ff2b5
Message:
Pohl: minor


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

Legend:

Unmodified
Added
Removed
  • Singular/ideals.cc

    r6af907 ref72ff3  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: ideals.cc,v 1.51 1999-08-17 17:02:30 Singular Exp $ */
     4/* $Id: ideals.cc,v 1.52 1999-08-19 08:31:09 pohl Exp $ */
    55/*
    66* ABSTRACT - all basic methods to manipulate ideals
     
    2525
    2626
    27 #define WITH_OLD_MINOR
     27/* #define WITH_OLD_MINOR */
    2828
    2929static poly * idpower;
     
    23502350//  }
    23512351//}
    2352 /*3
    2353 * produces recursively the ideal of all arxar-minors of a
    2354 */
    2355 static void idRecMin(matrix a,int ar,poly *barDiv,ideal result,
    2356               int * nextPlace, int rowToChose=0)
    2357 {
    2358 //Print("Level: %d\n",ar);
    2359 /*--- there is no non-zero minor coming from a------------*/
    2360   if((ar<0) || (ar>min(a->ncols,a->nrows)-1))
    2361   {
    2362     idDelete((ideal *)&a);
    2363     pDelete(barDiv);
    2364     return;
    2365   }
    2366 
    2367 /*--- initializing temporary structures-------------------*/
    2368   int i,j,r=rowToChose,c,newi,newp,k;
    2369   poly p=NULL;
    2370 
    2371   if (ar==0)
    2372   {
    2373 /*--- ar is 0, the matrix-entres are minors---------------*/
    2374     for (i=a->nrows;i>0;i--)
    2375     {
    2376       for (j=a->ncols;j>0;j--)
    2377       {
    2378         p = MATELEM(a,i,j);
    2379         if (p!=NULL)
    2380         {
    2381           //idEnterSet(p,result,nextPlace);
    2382           if (*nextPlace>=IDELEMS(result))
    2383           {
    2384             pEnlargeSet(&(result->m),IDELEMS(result),IDELEMS(result));
    2385             IDELEMS(result) *=2;
    2386           }
    2387           result->m[*nextPlace] = p;
    2388           (*nextPlace)++;
    2389           MATELEM(a,i,j) = NULL;
    2390         }
    2391       }
    2392     }
    2393     idTest(result);
    2394     idDelete((ideal*)&a);
    2395     pDelete(barDiv);
    2396     return;
    2397   }
    2398 /*--- ar>0, we perform one step of the Bareiss algorithm--*/
    2399   p = pCopy(*barDiv);   //we had to store barDiv for the remaining loops
    2400   matrix nextStep = mpOneStepBareiss(a,barDiv,&r,&c);
    2401 //Print("next row is: %d, next col: %d\n",r,c);
    2402 /*--- there is no pivot - the det of matrix is zero -------------*/
    2403   if ((r*c==0) || (MATELEM(nextStep,nextStep->nrows,nextStep->ncols)==NULL))
    2404   {
    2405     idDelete((ideal*)&nextStep);
    2406     idDelete((ideal*)&a);
    2407     pDelete(&p);
    2408     // pDelete(barDiv); barDiv==NULL in this case
    2409     return;
    2410   }
    2411 /*--- we read out the r-1 x c-1 matrix for the next step--*/
    2412   if ((a->nrows-1)*(a->ncols-1)>0)
    2413   {
    2414     matrix next = mpNew(a->nrows-1,a->ncols-1);
    2415     for (i=a->nrows-1;i>0;i--)
    2416     {
    2417       for (j=a->ncols-1;j>0;j--)
    2418       {
    2419         MATELEM(next,i,j) = MATELEM(nextStep,i,j);
    2420         MATELEM(nextStep,i,j) =NULL;
    2421       }
    2422     }
    2423     idDelete((ideal*)&nextStep);
    2424 /*--- we call the next Step------------------------------*/
    2425     idRecMin(next,ar-1,barDiv,result,nextPlace);
    2426     next = NULL;
    2427   }
    2428   if ((*barDiv)!=NULL) pDelete(barDiv);
    2429 /*--- now we have to take out the r-th row...------------*/
    2430   if (((a->nrows)>1) && (rowToChose==0))
    2431   {
    2432     if (nextStep!=NULL) idDelete((ideal*)&nextStep);
    2433     nextStep = mpNew(a->nrows-1,a->ncols);
    2434     for (i=r-1;i>0;i--)
    2435     {
    2436       for (j=a->ncols;j>0;j--)
    2437       {
    2438         MATELEM(nextStep,i,j) = pCopy(MATELEM(a,i,j));
    2439       }
    2440     }
    2441     for (i=a->nrows;i>r;i--)
    2442     {
    2443       for (j=a->ncols;j>0;j--)
    2444       {
    2445         MATELEM(nextStep,i-1,j) = pCopy(MATELEM(a,i,j));
    2446       }
    2447     }
    2448 /*--- and to perform the algorithm with the rest---------*/
    2449     poly q=pCopy(p);
    2450     idRecMin(nextStep,ar,&q,result,nextPlace);
    2451     assume(q==NULL);
    2452     nextStep = NULL;
    2453   }
    2454 /*--- now we have to take out the c-th col...------------*/
    2455   if ((a->nrows)>1)
    2456   {
    2457     if (nextStep!=NULL) idDelete((ideal*)&nextStep);
    2458     nextStep = mpNew(a->nrows,a->ncols-1);
    2459     for (i=a->nrows;i>0;i--)
    2460     {
    2461       for (j=c-1;j>0;j--)
    2462       {
    2463         MATELEM(nextStep,i,j) = MATELEM(a,i,j);
    2464         MATELEM(a,i,j) = NULL;
    2465       }
    2466     }
    2467     for (i=a->nrows;i>0;i--)
    2468     {
    2469       for (j=a->ncols;j>c;j--)
    2470       {
    2471         MATELEM(nextStep,i,j-1) = MATELEM(a,i,j);
    2472         MATELEM(a,i,j) = NULL;
    2473       }
    2474     }
    2475 /*--- and to perform the algorithm with the rest---------*/
    2476     idDelete((ideal*)&a);
    2477     idRecMin(nextStep,ar,&p,result,nextPlace,r);
    2478     //assume(p==NULL);
    2479     nextStep = NULL;
    2480   }
    2481 /*--- deleting temporary structures and returns----------*/
    2482   pDelete(&p);
    2483   return;
    2484 }
    24852352
    24862353#ifdef WITH_OLD_MINOR
     
    25552422/*2
    25562423* compute all ar-minors of the matrix a
    2557 * the caller of idRecMin
     2424* the caller of mpRecMin
    25582425*/
    25592426ideal idMinors(matrix a, int ar)
    25602427{
     2428  ideal result;
     2429  int elems=0;
     2430
    25612431  if((ar<=0) || (ar>min(a->ncols,a->nrows)))
    25622432  {
     
    25642434    return NULL;
    25652435  }
    2566   int i=0;
    2567   poly barDiv=NULL;
    2568   ideal result=idInit(16,1);
    2569   if (a->ncols>=a->nrows)
    2570   {
    2571     idRecMin(mpCopy(a),ar-1,&barDiv,result,&i);
    2572   }
    2573   else
    2574   {
    2575     idRecMin(mpTransp(a),ar-1,&barDiv,result,&i);
    2576   }
     2436  a = mpCopy(a);
     2437  result=idInit(31,1);
     2438  if(ar>1) mpRecMin(ar-1,result,elems,a,a->nrows,a->ncols,NULL);
     2439  else mpMinorToResult(result,elems,a,a->nrows,a->ncols);
     2440  idDelete((ideal *)&a);
    25772441  idSkipZeroes(result);
     2442  idTest(result);
    25782443  return result;
    25792444}
    25802445#endif
    2581 
    25822446
    25832447/*2
  • Singular/matpol.cc

    r6af907 ref72ff3  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: matpol.cc,v 1.24 1999-06-29 13:03:31 pohl Exp $ */
     4/* $Id: matpol.cc,v 1.25 1999-08-19 08:31:10 pohl Exp $ */
    55
    66/*
     
    2929/*0 implementation*/
    3030
     31static void ppp(matrix);
     32static void qqq() {int i=0;}
     33
    3134typedef int perm[100];
    32 static poly mpDivide(poly a, poly b);
    3335static void mpReplace(int j, int n, int &sign, int *perm);
    34 static float mpPolyWeight(poly p);
    3536static int mpNextperm(perm * z, int max);
    3637static poly mpLeibnitz(matrix a);
    3738static poly minuscopy (poly p);
    3839static poly pInsert(poly p1, poly p2);
     40static poly mpExdiv ( poly m, poly d);
    3941static poly mpSelect (poly fro, poly what);
    40 static poly mpExdiv ( poly m, poly d);
     42
     43static void mpPartClean(matrix, int, int);
     44static void mpFinalClean(matrix);
     45static int mpPrepareRow (matrix, int, int);
     46static int mpPreparePiv (matrix, int, int);
     47static int mpPivBar(matrix, int, int);
     48static int mpPivRow(matrix, int, int);
     49static float mpPolyWeight(poly);
     50static void mpSwapRow(matrix, int, int, int);
     51static void mpSwapCol(matrix, int, int, int);
     52static void mpElimBar(matrix, matrix, poly, int, int);
    4153
    4254/*2
     
    336348
    337349/*2
    338 *  caller of 'Bareiss' algorithm,
    339 *  return an list of a matrix and an intvec:
    340 *    the matrix is lower triangular and the result,
    341 *    the intvec is the performed permutation of columns.
    342 */
    343 lists mpBareiss (matrix a, BOOLEAN sw)
    344 {
    345   poly div;
    346   matrix c = mpCopy(a);
    347   mp_permmatrix *Bareiss = new mp_permmatrix(c);
    348   row_col_weight w(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
    349   intvec *v = new intvec(Bareiss->mpGetCdim());
    350   lists res=(lists)Alloc(sizeof(slists));
    351 
    352   if (sw) WarnS(feNotImplemented);
    353   /* Bareiss */
    354   div = NULL;
    355   while(Bareiss->mpPivotBareiss(&w))
    356   {
    357     Bareiss->mpElimBareiss(div);
    358     div = Bareiss->mpGetElem(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
    359   }
    360   Bareiss->mpToIntvec(v);
    361   Bareiss->mpRowReorder();
    362   Bareiss->mpColReorder();
    363   Bareiss->mpSaveArray();
    364   delete Bareiss;
    365 
    366   res->Init(2);
    367   res->m[0].rtyp=MATRIX_CMD;
    368   res->m[0].data=(void *)c;
    369   res->m[1].rtyp=INTVEC_CMD;
    370   res->m[1].data=(void *)v;
    371   return res;
    372 }
    373 
    374 /*2
    375 *  one step of 'Bareiss' algorithm
    376 *  for application in minor
    377 *  assume to have a full matrix
    378 *  if *H!=0, then divide by *H (the pivot from the step before)
    379 *  returns the choosen pivot *H=m[*r,*c]
    380 *  the result has the pivot at the right lower corner
    381 */
    382 matrix mpOneStepBareiss (matrix a, poly *H, int *r, int *c)
    383 {
    384   poly div=*H;
    385   matrix re = mpCopy(a);
    386   mp_permmatrix *Bareiss = new mp_permmatrix(re);
    387   row_col_weight w(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
    388   int row = *r;
    389 
    390   /* step of Bareiss */
    391   if(((row!=0) && Bareiss->mpPivotRow(&w,row-1)) || Bareiss->mpPivotBareiss(&w))
    392   {
    393     Bareiss->mpElimBareiss(div);
    394     div = Bareiss->mpGetElem(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
    395     pDelete(H);
    396     *H = pCopy(div);
    397     *c = Bareiss->mpGetCol()+1;
    398     *r = Bareiss->mpGetRow()+1;
    399     Bareiss->mpRowReorder();
    400     Bareiss->mpColReorder();
     350* entries of a are minors and go to result
     351*/
     352void mpMinorToResult(ideal result, int &elems, matrix a, int r, int c)
     353{
     354  poly *q1;
     355  int e=IDELEMS(result);
     356  int i,j;
     357
     358  if(e<0X80000000)
     359  {   
     360    for (i=r-1;i>=0;i--)
     361    {
     362      q1 = &(a->m)[i*a->ncols];
     363      for (j=c-1;j>=0;j--)
     364      {
     365        if (q1[j]!=NULL)
     366        {
     367          if (elems>=e)
     368          {
     369            pEnlargeSet(&(result->m),e,e+1);
     370            e += e+1;
     371            IDELEMS(result) =e;
     372          }
     373          result->m[elems] = q1[j];
     374          q1[j] = NULL;
     375          elems++;
     376        }
     377      }
     378    }
    401379  }
    402380  else
    403381  {
    404     pDelete(H);
    405     *H = NULL;
    406     *c = *r = 0;
    407   }
    408   Bareiss->mpSaveArray();
    409   idTest((ideal)re);
    410   delete Bareiss;
    411   return re;
     382    for (i=r-1;i>=0;i--)
     383    {
     384      q1 = &(a->m)[i*a->ncols];
     385      for (j=c-1;j>=0;j--)
     386      {
     387        if (q1[j]!=NULL)
     388        {
     389          if (elems>=e)
     390          {
     391            Werror("stop after %d minors",elems);
     392            HALT();
     393          }
     394          result->m[elems] = q1[j];
     395          q1[j] = NULL;
     396          elems++;
     397        }
     398      }
     399    }
     400  }
     401}
     402
     403/*2
     404* produces recursively the ideal of all arxar-minors of a
     405*/
     406void mpRecMin(int ar,ideal result,int &elems,matrix a,int lr,int lc,poly barDiv)
     407{
     408  int k;
     409  int kr=lr-1,kc=lc-1;
     410  matrix nextLevel=mpNew(kr,kc);
     411
     412  loop
     413  {
     414/*--- look for an optimal row and bring it to last position ------------*/
     415    if(mpPrepareRow(a,lr,lc)==0) break;
     416/*--- now take all pivotŽs from the last row ------------*/
     417    k = lc;
     418    loop
     419    {
     420      if(mpPreparePiv(a,lr,k)==0) break;
     421      mpElimBar(a,nextLevel,barDiv,lr,k);
     422      k--;
     423      if (ar>1)
     424      {
     425        mpRecMin(ar-1,result,elems,nextLevel,kr,k,a->m[kr*a->ncols+k]);
     426        mpPartClean(nextLevel,kr,k);
     427      }
     428      else mpMinorToResult(result,elems,nextLevel,kr,k);
     429      if (ar>k-1) break;
     430    }
     431    if (ar>=kr) break;
     432/*--- now we have to take out the last row...------------*/
     433    lr = kr;
     434    kr--;
     435  }
     436  mpFinalClean(nextLevel);
    412437}
    413438
     
    852877}
    853878
     879/*2
     880*exact divisor: let d  == x^i*y^j, m is thought to have only one term;
     881*    return m/d iff d divides m, and no x^k*y^l (k>i or l>j) divides m
     882*/
     883static poly mpExdiv ( poly m, poly d)
     884{
     885  int i;
     886  poly h = pHead(m);
     887  for (i=1; i<=pVariables; i++)
     888  {
     889    if (pGetExp(d,i) > 0)
     890    {
     891      if (pGetExp(d,i) != pGetExp(h,i))
     892      {
     893        pDelete(&h);
     894        return NULL;
     895      }
     896      pSetExp(h,i,0);
     897    }
     898  }
     899  pSetm(h);
     900  return h;
     901}
     902
    854903void mpCoef2(poly v, poly mon, matrix *c, matrix *m)
    855904{
     
    14021451}
    14031452
    1404 /*2
    1405 * exact division a/b, used in Bareiss algorithm
    1406 * a destroyed, b NOT destroyed
    1407 */
    1408 static poly mpDivide(poly a, poly b)
    1409 {
    1410   number x, y, z;
    1411   poly r, tail, t, h, h0;
    1412   int i, deg;
    1413 
    1414   r = a;
    1415   x = pGetCoeff(b);
    1416   deg = pTotaldegree(b);
    1417   tail = pNext(b);
    1418   if (tail == NULL)
    1419   {
    1420     do
    1421     {
    1422       if (deg != 0)
    1423       {
    1424         for (i=pVariables; i; i--)
    1425           pSubExp(r,i,  pGetExp(b,i));
    1426         pSetm(r);
    1427       }
    1428       y = nDiv(pGetCoeff(r),x);
    1429       nNormalize(y);
    1430       pSetCoeff(r,y);
    1431       pIter(r);
    1432     } while (r != NULL);
    1433     //pTest(a);
    1434     return a;
    1435   }
    1436   h0 = pInit();
    1437   do
    1438   {
    1439     if (deg != 0)
    1440     {
    1441       for (i=pVariables; i>0; i--)
    1442         pSubExp(r,i,pGetExp(b,i));
    1443       pSetm(r);
    1444     }
    1445     y = nDiv(pGetCoeff(r), x);
    1446     nNormalize(y);
    1447     pSetCoeff(r,y);
    1448     t = tail;
    1449     h = h0;
    1450     do
    1451     {
    1452       h = pNext(h) = pInit();
    1453       for (i=pVariables; i>0; i--)
    1454         pSetExp(h,i, pGetExp(r,i)+pGetExp(t,i));
    1455       pSetm(h);
    1456       z = nMult(y, pGetCoeff(t));
    1457       pSetCoeff0(h,nNeg(z));
    1458       pIter(t);
    1459     } while (t != NULL);
    1460     pNext(h) = NULL;
    1461     r = pNext(r) = pAdd(pNext(r),pNext(h0));
    1462   } while (r!=NULL);
    1463   pFree1(h0);
    1464   //pTest(a);
    1465   return a;
    1466 }
    1467 
    14681453/*
    14691454* perform replacement for pivot strategy in Bareiss algorithm
     
    14811466    sign = -sign;
    14821467  }
    1483 }
    1484 
    1485 /*
    1486 * weigth of a polynomial, for pivot strategy
    1487 * modify this for characteristic 0 !!!
    1488 */
    1489 static float mpPolyWeight(poly p)
    1490 {
    1491   int i;
    1492   float res;
    1493 
    1494   if (pNext(p) == NULL)
    1495   {
    1496     res = (float)nSize(pGetCoeff(p));
    1497     if (pTotaldegree(p) != 0) res += 1.0;
    1498   }
    1499   else
    1500   {
    1501     i = 0;
    1502     res = 0.0;
    1503     do
    1504     {
    1505       i++;
    1506       res += (float)nSize(pGetCoeff(p));
    1507       pIter(p);
    1508     }
    1509     while (p);
    1510     res += (float)i;
    1511   }
    1512   return res;
    15131468}
    15141469
     
    16891644}
    16901645
    1691 /*2
    1692 *exact divisor: let d  == x^i*y^j, m is thought to have only one term;
    1693 *    return m/d iff d divides m, and no x^k*y^l (k>i or l>j) divides m
    1694 */
    1695 static poly mpExdiv ( poly m, poly d)
     1646/*
     1647*static void ppp(matrix a)
     1648*{
     1649*  int j,i,r=a->nrows,c=a->ncols;
     1650*  for(j=1;j<=r;j++)
     1651*  {
     1652*    for(i=1;i<=c;i++)
     1653*    {
     1654*      if(MATELEM(a,j,i)!=NULL) Print("X");
     1655*      else Print("0");
     1656*    }
     1657*    Print("\n");
     1658*  }
     1659*}
     1660*/
     1661
     1662static void mpPartClean(matrix a, int lr, int lc)
     1663{
     1664  poly *q1;
     1665  int i,j;
     1666
     1667  for (i=lr-1;i>=0;i--)
     1668  {
     1669    q1 = &(a->m)[i*a->ncols];
     1670    for (j=lc-1;j>=0;j--) if(q1[j]) pDelete(&q1[j]);
     1671  }
     1672}
     1673
     1674static void mpFinalClean(matrix a)
     1675{
     1676  Free((ADDRESS)a->m,a->nrows*a->ncols*sizeof(poly));
     1677  Free((ADDRESS)a,sizeof(*a));
     1678}
     1679
     1680/*2
     1681*  prepare one step of 'Bareiss' algorithm
     1682*  for application in minor
     1683*/
     1684static int mpPrepareRow (matrix a, int lr, int lc)
     1685{
     1686  int r;
     1687
     1688  r = mpPivBar(a,lr,lc);
     1689  if(r==0) return 0;
     1690  if(r<lr) mpSwapRow(a, r, lr, lc);
     1691  return 1;
     1692}
     1693
     1694/*2
     1695*  prepare one step of 'Bareiss' algorithm
     1696*  for application in minor
     1697*/
     1698static int mpPreparePiv (matrix a, int lr, int lc)
     1699{
     1700  int c;
     1701
     1702  c = mpPivRow(a, lr, lc);
     1703  if(c==0) return 0;
     1704  if(c<lc) mpSwapCol(a, c, lr, lc);
     1705  return 1;
     1706}
     1707
     1708/*
     1709* find best row
     1710*/
     1711static int mpPivBar(matrix a, int lr, int lc)
     1712{
     1713  float f1, f2;
     1714  poly *q1;
     1715  int i,j,io;
     1716
     1717  io = -1;
     1718  f1 = 1.0e30;
     1719  for (i=lr-1;i>=0;i--)
     1720  {
     1721    q1 = &(a->m)[i*a->ncols];
     1722    f2 = 0.0;
     1723    for (j=lc-1;j>=0;j--)
     1724    {
     1725      if (q1[j]!=NULL)
     1726        f2 += mpPolyWeight(q1[j]);
     1727    }
     1728    if ((f2!=0.0) && (f2<f1))
     1729    {
     1730      f1 = f2;
     1731      io = i;
     1732    }
     1733  }
     1734  if (io<0) return 0;
     1735  else return io+1;
     1736}
     1737
     1738/*
     1739* find pivot in the last row
     1740*/
     1741static int mpPivRow(matrix a, int lr, int lc)
     1742{
     1743  float f1, f2;
     1744  poly *q1;
     1745  int j,jo;
     1746
     1747  jo = -1;
     1748  f1 = 1.0e30;
     1749  q1 = &(a->m)[(lr-1)*a->ncols];
     1750  for (j=lc-1;j>=0;j--)
     1751  {
     1752    if (q1[j]!=NULL)
     1753    {
     1754      f2 = mpPolyWeight(q1[j]);
     1755      if (f2<f1)
     1756      {
     1757        f1 = f2;
     1758        jo = j;
     1759      }
     1760    }
     1761  }
     1762  if (jo<0) return 0;
     1763  else return jo+1;
     1764}
     1765
     1766/*
     1767* weigth of a polynomial, for pivot strategy
     1768*/
     1769static float mpPolyWeight(poly p)
    16961770{
    16971771  int i;
    1698   poly h = pHead(m);
    1699   for (i=1; i<=pVariables; i++)
    1700   {
    1701     if (pGetExp(d,i) > 0)
    1702     {
    1703       if (pGetExp(d,i) != pGetExp(h,i))
    1704       {
    1705         pDelete(&h);
    1706         return NULL;
    1707       }
    1708       pSetExp(h,i,0);
    1709     }
    1710   }
    1711   pSetm(h);
    1712   return h;
    1713 }
    1714 
     1772  float res;
     1773
     1774  if (pNext(p) == NULL)
     1775  {
     1776    res = (float)nSize(pGetCoeff(p));
     1777    for (i=pVariables;i>0;i--)
     1778    {
     1779      if(pGetExp(p,i)!=0)
     1780      {
     1781        res += 2.0;
     1782        break;
     1783      }
     1784    }
     1785  }
     1786  else
     1787  {
     1788    res = 0.0;
     1789    do
     1790    {
     1791      res += (float)nSize(pGetCoeff(p))+2.0;
     1792      pIter(p);
     1793    }
     1794    while (p);
     1795  }
     1796  return res;
     1797}
     1798
     1799static void mpSwapRow(matrix a, int pos, int lr, int lc)
     1800{
     1801  poly sw;
     1802  int j;
     1803  polyset a2 = a->m, a1 = &a2[a->ncols*(pos-1)];
     1804
     1805  a2 = &a2[a->ncols*(lr-1)];
     1806  for (j=lc-1; j>=0; j--)
     1807  {
     1808    sw = a1[j];
     1809    a1[j] = a2[j];
     1810    a2[j] = sw;
     1811  }
     1812}
     1813
     1814static void mpSwapCol(matrix a, int pos, int lr, int lc)
     1815{
     1816  poly sw;
     1817  int j;
     1818  polyset a2 = a->m, a1 = &a2[pos-1];
     1819
     1820  a2 = &a2[lc-1];
     1821  for (j=a->ncols*(lr-1); j>=0; j-=a->ncols)
     1822  {
     1823    sw = a1[j];
     1824    a1[j] = a2[j];
     1825    a2[j] = sw;
     1826  }
     1827}
     1828
     1829static void mpElimBar(matrix a0, matrix re, poly div, int lr, int lc)
     1830{
     1831  int r=lr-1, c=lc-1;
     1832  poly *b = a0->m, *x = re->m;
     1833  poly piv, elim, q1, q2, *ap, *a, *q;
     1834  int i, j;
     1835
     1836  ap = &b[r*a0->ncols];
     1837  piv = ap[c];
     1838  for(j=c-1; j>=0; j--)
     1839    if (ap[j] != NULL) ap[j] = pNeg(ap[j]);
     1840  for(i=r-1; i>=0; i--)
     1841  {
     1842    a = &b[i*a0->ncols];
     1843    q = &x[i*re->ncols];
     1844    if (a[c] != NULL)
     1845    {
     1846      elim = a[c];
     1847      for (j=c-1; j>=0; j--)
     1848      {
     1849        q1 = NULL;
     1850        if (a[j] != NULL)
     1851        {
     1852          q1 = smMultDiv(a[j], piv, div);
     1853          if (ap[j] != NULL)
     1854          {
     1855            q2 = smMultDiv(ap[j], elim, div);
     1856            q1 = pAdd(q1,q2);
     1857          }
     1858        }
     1859        else if (ap[j] != NULL)
     1860          q1 = smMultDiv(ap[j], elim, div);
     1861        if (q1 != NULL)
     1862        {
     1863          if (div)
     1864            smSpecialPolyDiv(q1, div);
     1865          q[j] = q1;
     1866        }
     1867      }
     1868    }
     1869    else
     1870    {
     1871      for (j=c-1; j>=0; j--)
     1872      {
     1873        if (a[j] != NULL)
     1874        {
     1875          q1 = smMultDiv(a[j], piv, div);
     1876          if (div)
     1877            smSpecialPolyDiv(q1, div);
     1878          q[j] = q1;
     1879        }
     1880      }
     1881    }
     1882  }
     1883}
  • Singular/matpol.h

    r6af907 ref72ff3  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: matpol.h,v 1.7 1998-07-16 06:44:29 obachman Exp $ */
     6/* $Id: matpol.h,v 1.8 1999-08-19 08:31:10 pohl Exp $ */
    77/*
    88* ABSTRACT
     
    4646poly TraceOfProd ( matrix a, matrix b, int n);
    4747
    48 lists mpBareiss (matrix a, BOOLEAN diagonal);
    49 matrix mpOneStepBareiss (matrix a, poly *H, int *r, int *c);
    5048poly mpDet (matrix m);
    5149matrix mpWedge(matrix a, int ar);
     
    7068Thus f = sum co[1,i]*co[2,i], i = 1..cols, rows equals 2. */
    7169void mpCoef2(poly v, poly vars, matrix *c, matrix *m);
     70/* for minors with Bareiss */
     71void mpRecMin(int, ideal, int &, matrix, int, int, poly);
     72void mpMinorToResult(ideal, int &, matrix, int, int);
    7273
    7374#endif
Note: See TracChangeset for help on using the changeset viewer.