Changeset b5ae52 in git


Ignore:
Timestamp:
Oct 15, 1997, 9:58:54 AM (27 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
309f679293c6bbca5f6a90d4264f81251290c122
Parents:
499bdc5e258e4f3d05720339759579c6bf80618c
Message:
* hannes/pohl: degree bounded kbase: hdegree.cc iparith.cc stairc.h


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

Legend:

Unmodified
Added
Removed
  • Singular/hdegree.cc

    r499bdc rb5ae52  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: hdegree.cc,v 1.4 1997-04-02 15:07:01 Singular Exp $ */
     4/* $Id: hdegree.cc,v 1.5 1997-10-15 07:58:51 Singular Exp $ */
    55/*
    66*  ABSTRACT -  dimension, multiplicity, HC, kbase
     
    1616#include "polys.h"
    1717#include "intvec.h"
     18#include "numbers.h"
    1819#include "hutil.h"
    1920#include "stairc.h"
     
    10921093//  kbase
    10931094
    1094 static polyset Kbase;
    1095 static int  count;
    1096 
    1097 static void scInKbase( poly p, int  start)
    1098 {
    1099   int  i, j;
    1100   poly q;
    1101   scmon x;
    1102   for (i = 0; i < hNstc; i++)
    1103   {
    1104     x = hstc[i];
    1105     j = pVariables;
     1095static poly last;
     1096static scmon act;
     1097
     1098static void scElKbase()
     1099{
     1100  poly q = pNew();
     1101  pSetCoeff0(q,nInit(1));
     1102  pSetExpV(q,act);
     1103  pSetm(q);
     1104  pNext(q) = NULL;
     1105  last = pNext(last) = q;
     1106}
     1107
     1108static short scMax( int i, scfmon stc, int Nvar)
     1109{
     1110  short x, y=stc[0][Nvar];
     1111  for (; i;)
     1112  {
     1113    i--;
     1114    x = stc[i][Nvar];
     1115    if (x > y) y = x;
     1116  }
     1117  return y;
     1118}
     1119
     1120static short scMin( int i, scfmon stc, int Nvar)
     1121{
     1122  short x, y=stc[0][Nvar];
     1123  for (; i;)
     1124  {
     1125    i--;
     1126    x = stc[i][Nvar];
     1127    if (x < y) y = x;
     1128  }
     1129  return y;
     1130}
     1131
     1132static short scRestrict( int &Nstc, scfmon stc, int Nvar)
     1133{
     1134  unsigned short x, y;
     1135  int i, j, Istc = Nstc;
     1136
     1137  y = 0XFFFF;
     1138  for (i=Nstc-1; i>=0; i--)
     1139  {
     1140    j = Nvar-1;
    11061141    loop
    11071142    {
    1108       if (x[j] > p->exp[j])
     1143      if(stc[i][j] != 0) break;
     1144      j--;
     1145      if (j == 0)
     1146      {
     1147        Istc--;
     1148        x = stc[i][Nvar];
     1149        if (x < y) y = x;
     1150        stc[i] = NULL;
    11091151        break;
    1110       j--;
    1111       if (j==0)
    1112       {
    1113         pDelete1(&p);
    1114         return;
    1115       }
    1116     }
    1117   }
    1118   pSetm(p);
    1119   Kbase[count] = p;
    1120   count++;
    1121   for (i = start; i <= pVariables; i++)
    1122   {
    1123     q = pCopy(p);
    1124     q->exp[i]++;
    1125     scInKbase(q, i);
    1126   }
    1127 }
    1128 
    1129 
    1130 extern ideal scKBase(ideal s, ideal Q)
    1131 {
    1132   int  i, a;
     1152      }
     1153    }
     1154  }
     1155  if (Istc < Nstc)
     1156  {
     1157    j = 0;
     1158    while (stc[j]) j++;
     1159    i = j+1;
     1160    for(; i<Nstc; i++)
     1161    {
     1162      if (stc[i])
     1163      {
     1164        stc[j] = stc[i];
     1165        j++;
     1166      }
     1167    }
     1168    Nstc = Istc;
     1169    return y;
     1170  }
     1171  else
     1172    return -1;
     1173}
     1174
     1175static void scAll( int Nvar, short deg)
     1176{
     1177  int i;
     1178  short d = deg;
     1179  if (d == 0)
     1180  {
     1181    for (i=Nvar; i; i--) act[i] = 0;
     1182    scElKbase();
     1183    return;
     1184  }
     1185  if (Nvar == 1)
     1186  {
     1187    act[1] = d;
     1188    scElKbase();
     1189    return;
     1190  }
     1191  do
     1192  {
     1193    act[Nvar] = d;
     1194    scAll(Nvar-1, deg-d);
     1195    d--;
     1196  } while (d >= 0);
     1197}
     1198
     1199static void scAllKbase( int Nvar, short ideg, short deg)
     1200{
     1201  do
     1202  {
     1203    act[Nvar] = ideg;
     1204    scAll(Nvar-1, deg-ideg);
     1205    ideg--;
     1206  } while (ideg >= 0);
     1207}
     1208
     1209static void scDegKbase( scfmon stc, int Nstc, int Nvar, short deg)
     1210{
     1211  int  Ivar, Istc, i, j;
     1212  scfmon sn;
     1213  short x, ideg;
     1214
     1215  if (deg == 0)
     1216  {
     1217    for (i=Nvar; i; i--) act[i] = 0;
     1218    scElKbase();
     1219    return;
     1220  }
     1221  if (Nvar == 1)
     1222  {
     1223    for (i=Nstc-1; i>=0; i--) if(deg >= stc[i][1]) return;
     1224    act[1] = deg;
     1225    scElKbase();
     1226    return;
     1227  }
     1228  Ivar = Nvar-1;
     1229  sn = hGetmem(Nstc, stc, stcmem[Ivar]);
     1230  x = scRestrict(Nstc, sn, Nvar);
     1231  if (x < 0) ideg = deg;
     1232  else
     1233  {
     1234    if (Nstc == 0)
     1235    {
     1236      if (deg >= x) return;
     1237      act[Nvar] = deg;
     1238      for (i=Ivar; i; i--) act[i] = 0;
     1239      scElKbase();
     1240      return;
     1241    }
     1242    if (deg < x) ideg = deg;
     1243    else ideg = x-1;
     1244  }
     1245  loop
     1246  {
     1247    x = scMax(Nstc, sn, Nvar);
     1248    while (ideg >= x)
     1249    {
     1250      act[Nvar] = ideg;
     1251      scDegKbase(sn, Nstc, Ivar, deg-ideg);
     1252      ideg--;
     1253    }
     1254    if (ideg < 0) return;
     1255    Istc = Nstc;
     1256    for (i=Nstc-1; i>=0; i--)
     1257    {
     1258      if (ideg < sn[i][Nvar])
     1259      {
     1260        Istc--;
     1261        sn[i] = NULL;
     1262      }
     1263    }
     1264    if (Istc == 0)
     1265    {
     1266      scAllKbase(Nvar, ideg, deg);
     1267      return;
     1268    }
     1269    j = 0;
     1270    while (sn[j]) j++;
     1271    i = j+1;
     1272    for (; i<Nstc; i++)
     1273    {
     1274      if (sn[i])
     1275      {
     1276        sn[j] = sn[i];
     1277        j++;
     1278      }
     1279    }
     1280    Nstc = Istc;
     1281  }
     1282}
     1283
     1284static void scInKbase( scfmon stc, int Nstc, int Nvar)
     1285{
     1286  int  Ivar, Istc, i, j;
     1287  scfmon sn;
     1288  short x, ideg;
     1289
     1290  if (Nvar == 1)
     1291  {
     1292    ideg = scMin(Nstc, stc, 1);
     1293    while (ideg > 0)
     1294    {
     1295      ideg--;
     1296      act[1] = ideg;
     1297      scElKbase();
     1298    }
     1299    return;
     1300  }
     1301  Ivar = Nvar-1;
     1302  sn = hGetmem(Nstc, stc, stcmem[Ivar]);
     1303  x = scRestrict(Nstc, sn, Nvar);
     1304  if (Nstc == 0)
     1305  {
     1306    if (x == 0) return;
     1307    for (i=Ivar; i; i--) act[i] = 0;
     1308    do
     1309    {
     1310      x--;
     1311      act[Nvar] = x;
     1312      scElKbase();
     1313    } while(x > 0);
     1314    return;
     1315  }
     1316  ideg = x-1;
     1317  loop
     1318  {
     1319    x = scMax(Nstc, sn, Nvar);
     1320    while (ideg >= x)
     1321    {
     1322      act[Nvar] = ideg;
     1323      scInKbase(sn, Nstc, Ivar);
     1324      ideg--;
     1325    }
     1326    if (ideg < 0) return;
     1327    Istc = Nstc;
     1328    for (i=Nstc-1; i>=0; i--)
     1329    {
     1330      if (ideg < sn[i][Nvar])
     1331      {
     1332        Istc--;
     1333        sn[i] = NULL;
     1334      }
     1335    }
     1336    j = 0;
     1337    while (sn[j]) j++;
     1338    i = j+1;
     1339    for (; i<Nstc; i++)
     1340    {
     1341      if (sn[i])
     1342      {
     1343        sn[j] = sn[i];
     1344        j++;
     1345      }
     1346    }
     1347    Nstc = Istc;
     1348  }
     1349}
     1350
     1351static ideal scIdKbase()
     1352{
     1353  polyset mm;
     1354  ideal res;
     1355  poly p, q = last;
     1356  int i = pLength(q);
     1357  res = idInit(i,1);
     1358  mm = res->m;
     1359  i = 0;
     1360  do
     1361  {
     1362    mm[i] = q;
     1363    i++;
     1364    p = pNext(q);
     1365    pNext(q) = NULL;
     1366    q = p;
     1367  } while (q);
     1368  return res;
     1369}
     1370
     1371extern ideal scKBase(int deg, ideal s, ideal Q)
     1372{
     1373  int  i, di;
    11331374  poly p;
    1134   ideal res;
    1135   a = scMult0Int(s, Q);
    1136   if (a <= 0)
    1137     return idInit(1,s->rank);
    1138   res = idInit(a,s->rank);
    1139   Kbase = res->m;
     1375
     1376  if (deg < 0)
     1377  {
     1378    di = scDimInt(s, Q);
     1379    if (di != 0)
     1380    {
     1381      Werror("KBase not finite");
     1382      return idInit(1,0);
     1383    }
     1384  }
     1385  stcmem = hCreate(pVariables - 1);
    11401386  hexist = hInit(s, Q, &hNexist);
    1141   count = 0;
     1387  p = last = pNew();
     1388  pNext(p) = NULL;
     1389  act = (scmon)Alloc((pVariables + 1) * sizeof(short));
     1390  *act = 0;
     1391  if (!hNexist)
     1392  {
     1393    scAll(pVariables, deg);
     1394    goto ende;
     1395  }
    11421396  if (!hisModule)
    11431397  {
    1144     hstc = hexist;
    1145     hNstc = hNexist;
    1146     p = pOne();
    1147     scInKbase(p, 1);
     1398    if (deg < 0) scInKbase(hexist, hNexist, pVariables);
     1399    else scDegKbase(hexist, hNexist, pVariables, deg);
    11481400  }
    11491401  else
     
    11521404    for (i = 1; i <= hisModule; i++)
    11531405    {
     1406      *act = i;
    11541407      hComp(hexist, hNexist, i, hstc, &hNstc);
    11551408      if (hNstc)
    11561409      {
    1157         p = pOne();
    1158         p->exp[0] = i;
    1159         scInKbase(p, 1);
    1160       }
     1410        if (deg < 0) scInKbase(hstc, hNstc, pVariables);
     1411        else scDegKbase(hstc, hNstc, pVariables, deg);
     1412      }
     1413      else
     1414        scAll(pVariables, deg);
    11611415    }
    11621416    Free((ADDRESS)hstc, hNexist * sizeof(scmon));
    11631417  }
     1418ende:
    11641419  Free((ADDRESS)hexist, hNexist * sizeof(scmon));
    1165   return res;
    1166 }
    1167 
    1168 
     1420  Free((ADDRESS)act, (pVariables + 1) * sizeof(short));
     1421  hKill(stcmem, pVariables - 1);
     1422  pDelete1(&p);
     1423  if (p == NULL)
     1424    return idInit(1,0);
     1425  else
     1426  {
     1427    last = p;
     1428    return scIdKbase();
     1429  }
     1430}
     1431
     1432
     1433
  • Singular/iparith.cc

    r499bdc rb5ae52  
    184184  { "jacob",       0, JACOB_CMD ,         CMD_1},
    185185  { "jet",         0, JET_CMD ,           CMD_23},
    186   { "kbase",       0, KBASE_CMD ,         CMD_1},
     186  { "kbase",       0, KBASE_CMD ,         CMD_12},
    187187  { "keepring",    0, KEEPRING_CMD ,      KEEPRING_CMD},
    188188  { "kill",        0, KILL_CMD ,          KILL_CMD},
     
    15381538{
    15391539  res->data = (char *)idJet((ideal)u->Data(),(int)v->Data());
     1540  return FALSE;
     1541}
     1542static BOOLEAN jjKBASE2(leftv res, leftv u, leftv v)
     1543{
     1544  assumeStdFlag(u);
     1545  res->data = (char *)scKBase((int)v->Data(),
     1546                              (ideal)(u->Data()),currQuotient);
    15401547  return FALSE;
    15411548}
     
    20392046,{jjJET_P,     JET_CMD,        VECTOR_CMD,     VECTOR_CMD, INT_CMD PROFILER}
    20402047,{jjJET_ID,    JET_CMD,        MODUL_CMD,      MODUL_CMD,  INT_CMD PROFILER}
     2048,{jjKBASE2,    KBASE_CMD,      IDEAL_CMD,      IDEAL_CMD,  INT_CMD PROFILER}
     2049,{jjKBASE2,    KBASE_CMD,      MODUL_CMD,      MODUL_CMD,  INT_CMD PROFILER}
    20412050,{atKILLATTR2, KILLATTR_CMD,   NONE,           IDHDL,      STRING_CMD PROFILER}
    20422051,{jjKoszul,    KOSZUL_CMD,     MATRIX_CMD,     INT_CMD,    INT_CMD PROFILER}
     
    24492458{
    24502459  assumeStdFlag(v);
    2451   res->data = (char *)scKBase((ideal)(v->Data()),currQuotient);
     2460  res->data = (char *)scKBase(-1,(ideal)(v->Data()),currQuotient);
    24522461  return FALSE;
    24532462}
  • Singular/stairc.h

    r499bdc rb5ae52  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: stairc.h,v 1.3 1997-04-09 12:20:13 Singular Exp $ */
     6/* $Id: stairc.h,v 1.4 1997-10-15 07:58:54 Singular Exp $ */
    77/*
    88* ABSTRACT
     
    2020void scDegree(ideal  s,ideal Q=NULL);
    2121
    22 ideal scKBase(ideal  s, ideal Q=NULL);
     22ideal scKBase(int deg, ideal  s, ideal Q=NULL);
    2323//void scHilbertPoly(ideal  s,ideal Q=NULL);
    2424//intvec *scHilbert(ideal  s,ideal Q=NULL);
     
    3535#endif
    3636
     37
Note: See TracChangeset for help on using the changeset viewer.