Changeset 1745e5 in git


Ignore:
Timestamp:
Aug 1, 2011, 4:07:53 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
57592b355247b69310d60aa0448d638c327ad3e8
Parents:
283ef732868790f43d179f5c606f84691eaba355
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-08-01 16:07:53+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 13:01:18+01:00
Message:
int64.* ->misc, rCopy0AndAddA ->ring.h, fix walkSupport.cc
Files:
7 edited
2 moved

Legend:

Unmodified
Added
Removed
  • kernel/makefile

    r283ef7 r1745e5  
    6565    hdegree.cc hilb.cc hutil.cc \
    6666    gr_kstd2.cc \
    67     ideals.cc int64vec.cc \
     67    ideals.cc \
    6868    khstd.cc kstdfac.cc \
    6969    kstd1.cc kstd2.cc kutil.cc \
     
    9797
    9898HEADERS=hutil.h idrec.h stairc.h ideals.h \
    99         structs.h int64vec.h \
     99        structs.h \
    100100        syz.h \
    101101        fast_maps.h \
  • kernel/structs.h

    r283ef7 r1745e5  
    2626
    2727#define BITSET  unsigned int
    28 
    29 #if SIZEOF_LONG == 4
    30 typedef long long int64;
    31 #elif SIZEOF_LONG == 8
    32 typedef long int64;
    33 #else
    34 #error int64 undefined
    35 #endif
    3628
    3729
  • kernel/walkSupport.cc

    r283ef7 r1745e5  
    22#include <kernel/mod2.h>
    33#include <misc/intvec.h>
    4 #include <kernel/int64vec.h>
     4#include <misc/int64vec.h>
    55#include <polys/polys.h>
    66#include <kernel/ideals.h>
     
    253253}
    254254
     255///////////////////////////////////////////////////////////////////
     256//scalarProduct64
     257///////////////////////////////////////////////////////////////////
     258//Description: returns the scalar product of int64vecs a and b
     259///////////////////////////////////////////////////////////////////
     260//Assume: Overflow tests assumes input has nonnegative entries
     261///////////////////////////////////////////////////////////////////
     262//Uses: none
     263///////////////////////////////////////////////////////////////////
     264
     265static inline int64  scalarProduct64(int64vec* a, int64vec* b)
     266{
     267  assume( a->length() ==  b->length());
     268  int i, n = a->length();
     269  int64 result = 0;
     270  int64 temp1,temp2;
     271  for(i=n-1; i>=0; i--)
     272  {
     273    temp1=(*a)[i] * (*b)[i];
     274    if((*a)[i]!=0 && (temp1/(*a)[i])!=(*b)[i]) overflow_error=1;
     275
     276    temp2=result;
     277    result += temp1;
     278
     279    //since both vectors always have nonnegative entries in init64
     280    //result should be >=temp2
     281    if(temp2>result) overflow_error=2;
     282  }
     283
     284  return result;
     285}
    255286///////////////////////////////////////////////////////////////////
    256287
     
    790821
    791822
    792 ///////////////////////////////////////////////////////////////////
    793 //scalarProduct64
    794 ///////////////////////////////////////////////////////////////////
    795 //Description: returns the scalar product of int64vecs a and b
    796 ///////////////////////////////////////////////////////////////////
    797 //Assume: Overflow tests assumes input has nonnegative entries
    798 ///////////////////////////////////////////////////////////////////
    799 //Uses: none
    800 ///////////////////////////////////////////////////////////////////
    801 
    802 static inline int64  scalarProduct64(int64vec* a, int64vec* b)
    803 {
    804   assume( a->length() ==  b->length());
    805   int i, n = a->length();
    806   int64 result = 0;
    807   int64 temp1,temp2;
    808   for(i=n-1; i>=0; i--)
    809   {
    810     temp1=(*a)[i] * (*b)[i];
    811     if((*a)[i]!=0 && (temp1/(*a)[i])!=(*b)[i]) overflow_error=1;
    812 
    813     temp2=result;
    814     result += temp1;
    815 
    816     //since both vectors always have nonnegative entries in init64
    817     //result should be >=temp2
    818     if(temp2>result) overflow_error=2;
    819   }
    820 
    821   return result;
    822 }
    823823
    824824///////////////////////////////////////////////////////////////////
     
    10041004  rChangeCurrRing(rnew);
    10051005}
    1006 
    1007 ///////////////////////////////////////////////////////////////////
    1008 
    1009 
    1010 ///////////////////////////////////////////////////////////////////
    1011 //rCopy0AndAddA
    1012 ///////////////////////////////////////////////////////////////////
    1013 //Description: returns a copy of currRing with the
    1014 //int64vec wv64 added in front of the current order
    1015 //i.e. if old order was O, then the new one will be (A(w),O)
    1016 ///////////////////////////////////////////////////////////////////
    1017 //Uses: omAllocBin,memcpy,sizeof,nCopy,omStrDup,omMemDup,
    1018 //idrCopyR_NoSort
    1019 ///////////////////////////////////////////////////////////////////
    1020 
    1021 ring rCopy0AndAddA(ring r, int64vec *wv64, BOOLEAN copy_qideal,
    1022                    BOOLEAN copy_ordering)
    1023 {
    1024 
    1025   if (r == NULL) return NULL;
    1026   int i,j;
    1027   ring res=(ring)omAllocBin(sip_sring_bin);
    1028 
    1029   memcpy(res,r,sizeof(ip_sring));
    1030   res->VarOffset = NULL;
    1031   res->ref=0;
    1032   if (r->extRing!=NULL)
    1033     r->extRing->ref++;
    1034   if (r->parameter!=NULL)
    1035   {
    1036     res->minpoly=nCopy(r->minpoly);
    1037     int l=rPar(r);
    1038     res->parameter=(char **)omAlloc(l*sizeof(char_ptr));
    1039     int i;
    1040     for(i=0;i<rPar(r);i++)
    1041     {
    1042       res->parameter[i]=omStrDup(r->parameter[i]);
    1043     }
    1044   }
    1045 
    1046   i=rBlocks(r);
    1047   res->wvhdl   = (int **)omAlloc((i+1) * sizeof(int_ptr));
    1048   res->order   = (int *) omAlloc((i+1) * sizeof(int));
    1049   res->block0  = (int *) omAlloc((i+1) * sizeof(int));
    1050   res->block1  = (int *) omAlloc((i+1) * sizeof(int));
    1051   for (j=0; j<i; j++)
    1052   {
    1053     if (r->wvhdl[j]!=NULL)
    1054     {
    1055       res->wvhdl[j+1] = (int*) omMemDup(r->wvhdl[j]);
    1056     }
    1057     else
    1058       res->wvhdl[j+1]=NULL;
    1059   }
    1060   for (j=0;j<i;j++)
    1061   {
    1062     res->order[j+1]=r->order[j];
    1063     res->block0[j+1]=r->block0[j];
    1064     res->block1[j+1]=r->block1[j];
    1065   }
    1066 
    1067  //the added A
    1068   res->order[0]=ringorder_a64;
    1069   int length=wv64->rows();
    1070   int64 *A=(int64 *)omAlloc(length*sizeof(int64));
    1071   for(j=length-1;j>=0;j--)
    1072   {
    1073     A[j]=(*wv64)[j];
    1074   }
    1075   res->wvhdl[0]=(int *)A;
    1076   res->block0[0]=1;
    1077   res->block1[0]=length;
    1078 
    1079   res->names   = (char **)omAlloc0(rVar(r) * sizeof(char_ptr));
    1080   for (i=rVar(res)-1;i>=0; i--)
    1081   {
    1082     res->names[i] = omStrDup(r->names[i]);
    1083   }
    1084   res->idroot = NULL;
    1085   if (r->qideal!=NULL)
    1086   {
    1087     if (copy_qideal) res->qideal= idrCopyR_NoSort(r->qideal, r);
    1088     else res->qideal = NULL;
    1089   }
    1090 
    1091   return res;
    1092 }
    1093 
    1094 ///////////////////////////////////////////////////////////////////
    1095 
    10961006
    10971007///////////////////////////////////////////////////////////////////
  • kernel/walkSupport.h

    r283ef7 r1745e5  
    33
    44#include <misc/intvec.h>
    5 #include <kernel/int64vec.h>
     5#include <misc/int64vec.h>
    66
    77int tdeg(poly p);
     
    3030matrix matIdLift(ideal Gomega, ideal M);
    3131void rCopyAndChangeA(int64vec* w);
    32 ring rCopy0AndAddA(ring r, int64vec *wv64, BOOLEAN copy_qideal = TRUE,
    33                    BOOLEAN copy_ordering = TRUE);
    3432int64vec* rGetGlobalOrderMatrix(ring r);
    3533int64vec* rGetGlobalOrderWeightVec(ring r);
  • libpolys/misc/Makefile.am

    r283ef7 r1745e5  
    1515INCLUDES = -I${top_srcdir} -I${top_srcdir}/.. -I${top_builddir} -I${top_builddir}/..
    1616
    17 SOURCES  = intvec.cc options.c
     17SOURCES  = intvec.cc int64vec.cc options.c
    1818libmisc_a_SOURCES   = $(SOURCES)
    1919libmisc_g_a_SOURCES = $(SOURCES)
     
    2626#libmisc_g_a_libdir=${libdir}/libpolys
    2727
    28 MISCHEADERS  = auxiliary.h mylimits.h options.h intvec.h
     28MISCHEADERS  = auxiliary.h mylimits.h options.h intvec.h int64vec.h
    2929libmisc_a_include_HEADERS   = $(MISCHEADERS)
    3030libmisc_g_a_include_HEADERS = $(MISCHEADERS)
  • libpolys/misc/int64vec.cc

    r283ef7 r1745e5  
    66* ABSTRACT: class int64vec: lists/vectors of int64
    77*/
    8 #include <kernel/mod2.h>
    9 #include <kernel/structs.h>
    10 #include <kernel/febase.h>
    11 #include <kernel/int64vec.h>
     8#include <misc/int64vec.h>
    129#include <misc/intvec.h>
    1310#include <omalloc/omalloc.h>
  • libpolys/misc/int64vec.h

    r283ef7 r1745e5  
    99*/
    1010#include <string.h>
    11 #include <kernel/structs.h>
    1211#include <omalloc/omalloc.h>
    13 #include <kernel/febase.h>
     12#include <misc/auxiliary.h>
    1413#include <misc/intvec.h>
    1514
     
    7978  int64vec * iv=new int64vec(o);
    8079  return iv;
    81 };
     80}
    8281
    8382int64vec * iv64Add(int64vec * a, int64vec * b);
  • libpolys/polys/monomials/ring.cc

    r283ef7 r1745e5  
    1313#include <omalloc/omalloc.h>
    1414#include <misc/options.h>
    15 #include <misc/intvec.h>
     15#include <misc/int64vec.h>
    1616
    1717#include <coeffs/numbers.h>
     
    12971297
    12981298/*2
    1299  * create a copy of the ring r, which must be equivalent to currRing
     1299 * create a copy of the ring r
    13001300 * used for qring definition,..
    1301  * (i.e.: normal rings: same nCopy as currRing;
    1302  *        qring:        same nCopy, same idCopy as currRing)
    13031301 * DOES NOT CALL rComplete
    13041302 */
     
    14141412  //memset:   res->block1 = NULL;
    14151413  //memset: }
     1414
     1415  res->names   = (char **)omAlloc0(rVar(r) * sizeof(char *));
     1416  for (i=0; i<rVar(res); i++)
     1417  {
     1418    res->names[i] = omStrDup(r->names[i]);
     1419  }
     1420  if (r->qideal!=NULL)
     1421  {
     1422    if (copy_qideal)
     1423    {
     1424      #ifndef NDEBUG
     1425      if (!copy_ordering)
     1426        WerrorS("internal error: rCopy0(Q,TRUE,FALSE)");
     1427      else
     1428      #endif
     1429      {
     1430      #ifndef NDEBUG
     1431        WarnS("internal bad stuff: rCopy0(Q,TRUE,TRUE)");
     1432      #endif
     1433        rComplete(res);
     1434        res->qideal= idrCopyR_NoSort(r->qideal, r, res);
     1435        rUnComplete(res);
     1436      }
     1437    }
     1438    //memset: else res->qideal = NULL;
     1439  }
     1440  //memset: else res->qideal = NULL;
     1441  //memset: res->GetNC() = NULL; // copy is purely commutative!!!
     1442  return res;
     1443}
     1444
     1445/*2
     1446 * create a copy of the ring r
     1447 * used for qring definition,..
     1448 * DOES NOT CALL rComplete
     1449 */
     1450ring rCopy0AndAddA(const ring r,  int64vec *wv64, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
     1451{
     1452  if (r == NULL) return NULL;
     1453  int i,j;
     1454  ring res=(ring)omAllocBin(sip_sring_bin);
     1455  memset(res,0,sizeof(ip_sring));
     1456  //memcpy(res,r,sizeof(ip_sring));
     1457  //memset: res->idroot=NULL; /* local objects */
     1458  //ideal      minideal;
     1459  res->options=r->options; /* ring dependent options */
     1460
     1461  //memset: res->ordsgn=NULL;
     1462  //memset: res->typ=NULL;
     1463  //memset: res->VarOffset=NULL;
     1464  //memset: res->firstwv=NULL;
     1465
     1466  //struct omBin   PolyBin; /* Bin from where monoms are allocated */
     1467  //memset: res->PolyBin=NULL; // rComplete
     1468  res->cf=r->cf;     /* coeffs */
     1469  res->cf->ref++;
     1470
     1471  //memset: res->ref=0; /* reference counter to the ring */
     1472
     1473  res->float_len=r->float_len; /* additional char-flags */
     1474  res->float_len2=r->float_len2; /* additional char-flags */
     1475
     1476  res->N=rVar(r);      /* number of vars */
     1477  res->OrdSgn=r->OrdSgn; /* 1 for polynomial rings, -1 otherwise */
     1478
     1479  res->firstBlockEnds=r->firstBlockEnds;
     1480#ifdef HAVE_PLURAL
     1481  res->real_var_start=r->real_var_start;
     1482  res->real_var_end=r->real_var_end;
     1483#endif
     1484
     1485#ifdef HAVE_SHIFTBBA
     1486  res->isLPring=r->isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
     1487#endif
     1488
     1489  res->VectorOut=r->VectorOut;
     1490  res->ShortOut=r->ShortOut;
     1491  res->CanShortOut=r->CanShortOut;
     1492  res->LexOrder=r->LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
     1493  res->MixedOrder=r->MixedOrder; // ?? 1 for lex ordering (except ls), -1 otherwise
     1494  res->ComponentOrder=r->ComponentOrder;
     1495
     1496  //memset: res->ExpL_Size=0;
     1497  //memset: res->CmpL_Size=0;
     1498  //memset: res->VarL_Size=0;
     1499  //memset: res->pCompIndex=0;
     1500  //memset: res->pOrdIndex=0;
     1501  //memset: res->OrdSize=0;
     1502  //memset: res->VarL_LowIndex=0;
     1503  //memset: res->MinExpPerLong=0;
     1504  //memset: res->NegWeightL_Size=0;
     1505  //memset: res->NegWeightL_Offset=NULL;
     1506  //memset: res->VarL_Offset=NULL;
     1507
     1508  // the following are set by rComplete unless predefined
     1509  // therefore, we copy these values: maybe they are non-standard
     1510  /* mask for getting single exponents */
     1511  res->bitmask=r->bitmask;
     1512  res->divmask=r->divmask;
     1513  res->BitsPerExp = r->BitsPerExp;
     1514  res->ExpPerLong =  r->ExpPerLong;
     1515
     1516  //memset: res->p_Procs=NULL;
     1517  //memset: res->pFDeg=NULL;
     1518  //memset: res->pLDeg=NULL;
     1519  //memset: res->pFDegOrig=NULL;
     1520  //memset: res->pLDegOrig=NULL;
     1521  //memset: res->p_Setm=NULL;
     1522  //memset: res->cf=NULL;
     1523  res->options=r->options;
     1524
     1525/*
     1526  if (r->extRing!=NULL)
     1527    r->extRing->ref++;
     1528 
     1529  res->extRing=r->extRing; 
     1530  //memset: res->minideal=NULL;
     1531*/
     1532 
     1533 
     1534  if (copy_ordering == TRUE)
     1535  {
     1536    i=rBlocks(r)+1; // DIFF to rCopy0
     1537    res->wvhdl   = (int **)omAlloc(i * sizeof(int *));
     1538    res->order   = (int *) omAlloc(i * sizeof(int));
     1539    res->block0  = (int *) omAlloc(i * sizeof(int));
     1540    res->block1  = (int *) omAlloc(i * sizeof(int));
     1541    for (j=0; j<i-1; j++)
     1542    {
     1543      if (r->wvhdl[j]!=NULL)
     1544      {
     1545        res->wvhdl[j+1] = (int*) omMemDup(r->wvhdl[j]); //DIFF
     1546      }
     1547      else
     1548        res->wvhdl[j+1]=NULL; //DIFF
     1549    }
     1550    memcpy(&(res->order[1]),r->order,(i-1) * sizeof(int)); //DIFF
     1551    memcpy(&(res->block0[1]),r->block0,(i-1) * sizeof(int)); //DIFF
     1552    memcpy(&(res->block1[1]),r->block1,(i-1) * sizeof(int)); //DIFF
     1553  }
     1554  //memset: else
     1555  //memset: {
     1556  //memset:   res->wvhdl = NULL;
     1557  //memset:   res->order = NULL;
     1558  //memset:   res->block0 = NULL;
     1559  //memset:   res->block1 = NULL;
     1560  //memset: }
     1561
     1562  //the added A
     1563  res->order[0]=ringorder_a64;
     1564  int length=wv64->rows();
     1565  int64 *A=(int64 *)omAlloc(length*sizeof(int64));
     1566  for(j=length-1;j>=0;j--)
     1567  {
     1568     A[j]=(*wv64)[j];
     1569  }
     1570  res->wvhdl[0]=(int *)A;
     1571  res->block0[0]=1;
     1572  res->block1[0]=length;
     1573  //
    14161574
    14171575  res->names   = (char **)omAlloc0(rVar(r) * sizeof(char *));
  • libpolys/polys/monomials/ring.h

    r283ef7 r1745e5  
    2828typedef struct ip_sring *         ring;
    2929class intvec;
     30class int64vec;
    3031struct p_Procs_s;
    3132typedef struct p_Procs_s p_Procs_s;
     
    346347ring   rCopy(ring r);
    347348ring   rCopy0(const ring r, BOOLEAN copy_qideal = TRUE, BOOLEAN copy_ordering = TRUE);
     349ring rCopy0AndAddA(ring r, int64vec *wv64, BOOLEAN copy_qideal = TRUE,
     350                   BOOLEAN copy_ordering = TRUE);
    348351ring   rOpposite(ring r);
    349352ring   rEnvelope(ring r);
Note: See TracChangeset for help on using the changeset viewer.