source: git/kernel/p_kBucketSetLm__T.cc @ 6b9532

spielwiese
Last change on this file since 6b9532 was 35aab3, checked in by Hans Schönemann <hannes@…>, 21 years ago
This commit was generated by cvs2svn to compensate for changes in r6879, which included commits to RCS files with non-trunk default branches. git-svn-id: file:///usr/local/Singular/svn/trunk@6880 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.0 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: 12/00
9 *  Version: $Id: p_kBucketSetLm__T.cc,v 1.1.1.1 2003-10-06 12:16:00 Singular Exp $
10 *******************************************************************/
11#undef USE_COEF_BUCKETS
12#ifdef HAVE_COEF_BUCKETS
13#define USE_COEF_BUCKETS
14#endif
15
16#ifdef USE_COEF_BUCKETS
17#define MULTIPLY_BUCKET(B,I) do                                        \
18  { if (B->coef[I]!=NULL)                                              \
19    {                                                                  \
20      B->buckets[I]=p_Mult_q(B->buckets[I],B->coef[I],B->bucket_ring); \
21      B->coef[I]=NULL;                                                 \
22    }                                                                  \
23  } while(0)
24#else
25#define MULTIPLY_BUCKET(B,I)
26#endif
27LINKAGE void p_kBucketSetLm(kBucket_pt bucket)
28{
29  int j = 0;
30  poly lt;
31  BOOLEAN zero = FALSE;
32  ring r = bucket->bucket_ring;
33  assume(bucket->buckets[0] == NULL && bucket->buckets_length[0] == 0);
34  DECLARE_LENGTH(const unsigned long length = r->ExpL_Size);
35  DECLARE_ORDSGN(const long* ordsgn = r->ordsgn);
36  poly p;
37
38  do
39  {
40    j = 0;
41    for (int i = 1; i<=bucket->buckets_used; i++)
42    {
43      if (bucket->buckets[i] != NULL)
44      {
45        MULTIPLY_BUCKET(bucket,i);
46        p =  bucket->buckets[j];
47        if (j == 0)
48        {
49          if (p != NULL) goto Greater;
50          j = i;
51          goto Continue;
52        }
53        assume(p != NULL);
54        p_MemCmp(bucket->buckets[i]->exp, p->exp, length, ordsgn, goto Equal, goto Greater, goto Continue);
55
56        Greater:
57        {
58          if (n_IsZero(pGetCoeff(p), r))
59          {
60            n_Delete(&pGetCoeff(p), r);
61            pIter(bucket->buckets[j]);
62            p_FreeBinAddr(p, r);
63            (bucket->buckets_length[j])--;
64          }
65          j = i;
66          goto Continue;
67        }
68
69        Equal:
70        {
71          MULTIPLY_BUCKET(bucket,i);
72          number tn = pGetCoeff(p);
73          pSetCoeff0(p, n_Add(pGetCoeff(bucket->buckets[i]), tn, r));
74          n_Delete(&tn, r);
75          p = bucket->buckets[i];
76          pIter(bucket->buckets[i]);
77          n_Delete(&pGetCoeff(p), r);
78          p_FreeBinAddr(p, r);
79          (bucket->buckets_length[i])--;
80        }
81
82        Continue:;
83      }
84    }
85    p = bucket->buckets[j];
86    if (j > 0 && n_IsZero(pGetCoeff(p), r))
87    {
88      n_Delete(&pGetCoeff(p), r);
89      pIter(bucket->buckets[j]);
90      p_FreeBinAddr(p, r);
91      (bucket->buckets_length[j])--;
92      j = -1;
93    }
94  }
95  while (j < 0);
96
97  if (j == 0)
98  {
99    return;
100  }
101
102  assume(bucket->buckets[j] != NULL);
103  lt = bucket->buckets[j];
104  bucket->buckets[j] = pNext(lt);
105  bucket->buckets_length[j]--;
106  pNext(lt) = NULL;
107  bucket->buckets[0] = lt;
108  bucket->buckets_length[0] = 1;
109
110  kBucketAdjustBucketsUsed(bucket);
111}
Note: See TracBrowser for help on using the repository browser.