Changeset 2b3caae in git


Ignore:
Timestamp:
Dec 18, 2009, 5:09:26 PM (15 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b52fc4b2495505785981d640dcf7eb3e456778ef')
Children:
9821ca7eb7f00bcded47abfce2ebbf6fee5c0e6d
Parents:
1c35568d7e5a5987077ae991beaea0a846eec9ce
Message:

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

Legend:

Unmodified
Added
Removed
  • kernel/ideals.cc

    r1c35568 r2b3caae  
    191191    IDELEMS(ide) = j+1;
    192192  }
     193}
     194
     195/*2
     196* copies the first k (>= 1) entries of the given ideal
     197* and returns these as a new ideal
     198* (Note that the copied polynomials may be zero.)
     199*/
     200ideal idCopyFirstK (const ideal ide, const int k)
     201{
     202  ideal newI = idInit(k, 0);
     203  for (int i = 0; i < k; i++)
     204    newI->m[i] = pCopy(ide->m[i]);
     205  return newI;
    193206}
    194207
     
    560573
    561574/*2
    562 * insert h2 into h1 (if h2 is neither the zero polynomial
    563 * nor a generator in h1)
     575* insert h2 into h1 depending on the two boolean parameters:
     576* - if zeroOk is true, then h2 will also be inserted when it is zero
     577* - if duplicateOk is true, then h2 will also be inserted when it is
     578*   already present in h1
    564579* return TRUE iff h2 was indeed inserted
    565580*/
    566 BOOLEAN idInsertPolyNoDuplicates (ideal h1, poly h2)
    567 {
    568   bool h2FoundInH1 = false;
    569   int i = 0;
    570   while ((i < IDELEMS(h1)) && (!h2FoundInH1))
    571   {
    572     h2FoundInH1 = pEqualPolys(h1->m[i], h2);
    573     i++;
    574   }
    575   if (!h2FoundInH1) return idInsertPoly(h1, h2);
    576   else return FALSE;
     581BOOLEAN idInsertPolyWithTests (ideal h1, const int validEntries,
     582  const poly h2, const bool zeroOk, const bool duplicateOk)
     583{
     584  if ((!zeroOk) && (h2 == NULL)) return FALSE;
     585  if (!duplicateOk)
     586  {
     587    bool h2FoundInH1 = false;
     588    int i = 0;
     589    while ((i < validEntries) && (!h2FoundInH1))
     590    {
     591      h2FoundInH1 = pEqualPolys(h1->m[i], h2);
     592      i++;
     593    }
     594    if (h2FoundInH1) return FALSE;
     595  }
     596  if (validEntries == IDELEMS(h1))
     597  {
     598    pEnlargeSet(&(h1->m), IDELEMS(h1), 16);
     599    IDELEMS(h1) += 16;
     600  }
     601  h1->m[validEntries] = h2;
     602  return TRUE;
    577603}
    578604
  • kernel/ideals.h

    r1c35568 r2b3caae  
    1212#ifdef PDEBUG
    1313ideal idDBInit (int size, int rank, const char *f, int l);
     14ideal idCopyFirstK (const ideal ide, const int k);
    1415#define idInit(A,B) idDBInit(A,B,__FILE__,__LINE__)
    1516#else
    1617/*- creates an ideal -*/
    1718ideal idInit (int size, int rank=1);
     19ideal idCopyFirstK (const ideal ide, const int k);
    1820#endif
    1921/*- deletes an ideal -*/
     
    5658BOOLEAN idInsertPoly (ideal h1,poly h2);
    5759  /* h1 + h2 */
    58 BOOLEAN idInsertPolyNoDuplicates (ideal h1,poly h2);
     60BOOLEAN idInsertPolyWithTests (ideal h1, const int validEntries,
     61  const poly h2, const bool zeroOk, const bool duplicateOk);
    5962  /* h1 + h2 */
    6063ideal idMult (ideal h1,ideal h2);
Note: See TracChangeset for help on using the changeset viewer.