source: git/Singular/p_kBucketSetLm__Template.cc @ 6b32990

spielwiese
Last change on this file since 6b32990 was 6b32990, checked in by Olaf Bachmann <obachman@…>, 23 years ago
* dynamic kernel modules for MP and DBM links * p_Procs improvements git-svn-id: file:///usr/local/Singular/svn/trunk@4865 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.4 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__Template.cc,v 1.4 2000-12-12 08:44:51 obachman Exp $
10 *******************************************************************/
11
12LINKAGE void 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)
32        {
33          if (p != NULL) goto Greater;
34          j = i;
35          goto Continue;
36        }
37        assume(p != NULL);
38        p_MemCmp(bucket->buckets[i]->exp, p->exp, length, ordsgn, goto Equal, goto Greater, goto Continue);
39
40        Greater:
41        {
42          if (n_IsZero(pGetCoeff(p), r))
43          {
44            n_Delete(&pGetCoeff(p), r);
45            pIter(bucket->buckets[j]);
46            p_FreeBinAddr(p, r);
47            (bucket->buckets_length[j])--;
48          }
49          j = i;
50          goto Continue;
51        }
52
53        Equal:
54        {
55          number tn = pGetCoeff(p);
56          pSetCoeff0(p, n_Add(pGetCoeff(bucket->buckets[i]), tn, r));
57          n_Delete(&tn, r);
58          p = bucket->buckets[i];
59          pIter(bucket->buckets[i]);
60          n_Delete(&pGetCoeff(p), r);
61          p_FreeBinAddr(p, r);
62          (bucket->buckets_length[i])--;
63        }
64
65        Continue:;
66      }
67    }
68    p = bucket->buckets[j];
69    if (j > 0 && n_IsZero(pGetCoeff(p), r))
70    {
71      n_Delete(&pGetCoeff(p), r);
72      pIter(bucket->buckets[j]);
73      p_FreeBinAddr(p, r);
74      (bucket->buckets_length[j])--;
75      j = -1;
76    }
77  }
78  while (j < 0);
79
80  if (j == 0)
81  {
82    return;
83  }
84
85  assume(bucket->buckets[j] != NULL);
86  lt = bucket->buckets[j];
87  bucket->buckets[j] = pNext(lt);
88  bucket->buckets_length[j]--;
89  pNext(lt) = NULL;
90  bucket->buckets[0] = lt;
91  bucket->buckets_length[0] = 1;
92
93  kBucketAdjustBucketsUsed(bucket);
94}
Note: See TracBrowser for help on using the repository browser.