source: git/Singular/p_kBucketSetLm__Template.cc @ a29995

spielwiese
Last change on this file since a29995 was a29995, checked in by Olaf Bachmann <obachman@…>, 23 years ago
* towards tailRings for local case git-svn-id: file:///usr/local/Singular/svn/trunk@4777 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.3 KB
Line 
1/****************************************
2*  Computer Algebra System SINGULAR     *
3****************************************/
4/***************************************************************
5 *  File:    p_KBucketSetLm__Template.cc
6 *  Purpose: template for setting the Lm of a bucket
7 *  Author:  obachman (Olaf Bachmann)
8 *  Created: 8/00
9 *  Version: $Id: p_kBucketSetLm__Template.cc,v 1.1 2000-11-28 11:50:56 obachman Exp $
10 *******************************************************************/
11
12void p_kBucketSetLm(kBucket_pt bucket)
13{
14  int j = 0;
15  poly lt;
16  BOOLEAN zero = FALSE;
17  ring r = bucket->bucket_ring;
18  assume(bucket->buckets[0] == NULL && bucket->buckets_length[0] == 0);
19  DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
20  DECLARE_ORDSGN(const long* ordsgn = r->ordsgn);
21  poly p;
22
23  do
24  {
25    j = 0;
26    for (int i = 1; i<=bucket->buckets_used; i++)
27    {
28      if (bucket->buckets[i] != NULL)
29      {
30        p =  bucket->buckets[j];
31        if (j == 0) goto Greater;
32        p_MemCmp(bucket->buckets[i]->exp, p->exp, length, ordsgn, goto Equal, goto Greater, goto Continue);
33
34        Greater:
35        {
36          if (j > 0 && p != NULL && n_IsZero(pGetCoeff(p), r))
37          {
38            n_Delete(&pGetCoeff(p), r);
39            pIter(bucket->buckets[j]);
40            p_FreeBinAddr(p, r);
41            (bucket->buckets_length[j])--;
42          }
43          j = i;
44          goto Continue;
45        }
46
47        Equal:
48        {
49          number tn = pGetCoeff(p);
50          pSetCoeff0(p, n_Add(pGetCoeff(bucket->buckets[i]), tn, r));
51          n_Delete(&tn, r);
52          p = bucket->buckets[i];
53          pIter(bucket->buckets[i]);
54          n_Delete(&pGetCoeff(p), r);
55          p_FreeBinAddr(p, r);
56          (bucket->buckets_length[i])--;
57        }
58
59        Continue:;
60      }
61    }
62    p = bucket->buckets[j];
63    if (j > 0 && n_IsZero(pGetCoeff(p), r))
64    {
65      n_Delete(&pGetCoeff(p), r);
66      pIter(bucket->buckets[j]);
67      p_FreeBinAddr(p, r);
68      (bucket->buckets_length[j])--;
69      j = -1;
70    }
71  }
72  while (j < 0);
73
74  if (j == 0)
75  {
76    return;
77  }
78
79  assume(bucket->buckets[j] != NULL);
80  lt = bucket->buckets[j];
81  bucket->buckets[j] = pNext(lt);
82  bucket->buckets_length[j]--;
83  pNext(lt) = NULL;
84  bucket->buckets[0] = lt;
85  bucket->buckets_length[0] = 1;
86
87  kBucketAdjustBucketsUsed(bucket);
88}
Note: See TracBrowser for help on using the repository browser.