source: git/Singular/kbuckets.h @ 48aa42

spielwiese
Last change on this file since 48aa42 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: 5.4 KB
Line 
1#ifndef KBUCKETS_H
2#define KBUCKETS_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: kbuckets.h,v 1.13 2000-11-28 11:50:52 obachman Exp $ */
7#include "structs.h"
8#include "p_Procs.h"
9#include "pShallowCopyDelete.h"
10
11/////////////////////////////////////////////////////////////////////////
12// configuration
13//
14
15// define to not really use the bucket feature
16// #define HAVE_PSEUDO_BUCKETS
17
18//////////////////////////////////////////////////////////////////////////
19// Creation/Destruction of buckets
20//
21kBucket_pt kBucketCreate(ring r = currRing);
22// only free memory allocated for bucket
23void kBucketDestroy(kBucket_pt *bucket);
24// frees polys/monomials in bucket and destroys bucket
25void kBucketDeleteAndDestroy(kBucket_pt *bucket);
26
27
28/////////////////////////////////////////////////////////////////////////////
29// Convertion from/to Bpolys
30//
31
32// Converts p into a bucket poly (Bpoly) and destroys p
33// Assumes length <= 0 || pLength(p) == length
34void kBucketInit(kBucket_pt bucket, poly p, int length);
35
36// Converts Bpoly into a poly and clears bucket
37// i.e., afterwards Bpoly == 0
38void kBucketClear(kBucket_pt bucket, poly *p, int *length);
39
40// Canonicalizes Bpoly, i.e. converts polys of buckets into one poly in
41// one bucket: Returns number of bucket into which it is canonicalized
42int kBucketCanonicalize(kBucket_pt bucket);
43
44/////////////////////////////////////////////////////////////////////////////
45// Gets leading monom of bucket, does NOT change Bpoly!!!!!
46// Returned monom is READ ONLY, i.e. no manipulations are allowed !!!!
47//
48inline const poly kBucketGetLm(kBucket_pt bucket);
49
50/////////////////////////////////////////////////////////////////////////////
51// Extracts lm of Bpoly, i.e. Bpoly is changed s.t.
52// Bpoly == Bpoly - Lm(Bpoly)
53//
54inline poly kBucketExtractLm(kBucket_pt bucket);
55
56/////////////////////////////////////////////////////////////////////////////
57// Reduces Bpoly (say, q) with p, i.e.:
58// q = (Lc(p) / gcd(Lc(p), Lc(q)))*q - (Lc(q)/gcd(Lc(p),Lc(q)))*p*(Lm(q)/Lm(p))
59// Assumes p1 != NULL, Bpoly != NULL
60//         Lm(p1) divides Lm(Bpoly)
61//         pLength(p1) == l1
62// Returns: Lc(p) / gcd(Lc(p), Lc(q))
63number kBucketPolyRed(kBucket_pt bucket,
64                      poly p, int l,
65                      poly spNoether);
66
67
68/////////////////////////////////////////////////////////////////////////////
69//
70// Extract all monomials from bucket with component comp
71// Return as a polynomial *p with length *l
72// In other words, afterwards
73// Bpoly == Bpoly - (poly consisting of all monomials with component comp)
74// and components of monomials of *p are all 0
75
76void kBucketTakeOutComp(kBucket_pt bucket,
77                        Exponent_t comp,
78                        poly *p, int *l);
79
80// Here we only extract such monoms which have component == comp and
81// degree == order
82// ASSUME: monomial ordering is Order compatible, i.e., if m1, m2 Monoms then
83//         m1 >= m2 ==> pGetOrder(m1) >= pGetOrder(m2)
84void kBucketDecrOrdTakeOutComp(kBucket_pt bucket,
85                               Exponent_t comp, Order_t order,
86                               poly *p, int *l);
87
88//////////////////////////////////////////////////////////////////////////
89///
90/// Multiply Bucket by number ,i.e. Bpoly == n*Bpoly
91///
92void kBucket_Mult_n(kBucket_pt bucket, number n);
93
94
95//////////////////////////////////////////////////////////////////////////
96///
97/// Bpoly == Bpoly - m*p; where m is a monom
98/// Does not destroy p and m
99/// assume (*l <= 0 || pLength(p) == *l)
100void kBucket_Minus_m_Mult_p(kBucket_pt bucket, poly m, poly p, int *l,
101                            poly spNother = NULL);
102
103
104//////////////////////////////////////////////////////////////////////////
105///
106/// For changing the ring of the Bpoly to new_tailBin
107///
108void kBucketShallowCopyDelete(kBucket_pt bucket, 
109                              ring new_tailRing, omBin new_tailBin,
110                              pShallowCopyDeleteProc p_shallow_copy_delete);
111
112//////////////////////////////////////////////////////////////////////////
113///
114/// Tests
115///
116///
117#ifdef KDEBUG
118BOOLEAN kbTest(kBucket_pt bucket);
119#else
120#define kbTest(bucket)  ((void)0)
121#endif
122
123//////////////////////////////////////////////////////////////////////////
124///
125/// Bucket definition (should be no one elses business, though)
126///
127
128// define this if length of bucket polys are 2, 4, 8, etc
129// instead of 4, 16, 64 ... --
130// this seems to be less efficient, both, in theory and in practice
131// #define BUCKET_TWO_BASE
132#ifdef BUCKET_TWO_BASE
133#define MAX_BUCKET 28
134#else
135#define MAX_BUCKET 14 // suitable for polys up to a length of 4^14 = 2^28
136#endif
137
138class kBucket
139{
140public:
141#ifdef HAVE_PSEUDO_BUCKETS
142  poly p;
143  int l;
144#else
145  poly buckets[MAX_BUCKET + 1];        // polys in bucket
146  int  buckets_length[MAX_BUCKET + 1]; // length if i-th poly
147  int buckets_used;                    // max number of used bucket
148#endif
149  ring bucket_ring;
150};
151
152inline void kBucketAdjustBucketsUsed(kBucket_pt bucket)
153{
154  while ( bucket->buckets_used > 0 &&
155          bucket->buckets[bucket->buckets_used] == NULL)
156    (bucket->buckets_used)--;
157}
158
159inline const poly kBucketGetLm(kBucket_pt bucket)
160{
161  if (bucket->buckets[0] == NULL)
162    bucket->bucket_ring->p_Procs->p_kBucketSetLm(bucket);
163  return bucket->buckets[0];
164}
165
166inline poly kBucketExtractLm(kBucket_pt bucket)
167{
168  poly lm = kBucketGetLm(bucket);
169  bucket->buckets[0] = NULL;
170  bucket->buckets_length[0] = 0;
171  return lm;
172}
173
174#endif /* KBUCKETS_H */
Note: See TracBrowser for help on using the repository browser.