sbuckets.h
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /***************************************************************
5  * File: sbuckets.h
6  * Purpose: declaration of routines for sorting and adding up polys using
7  * a bucket sort
8  * Note: If you need to extract the leading momonial of a bucket,
9  * use kbuckets, instead.
10  * Author: obachman (Olaf Bachmann)
11  * Created: 9/00
12  *******************************************************************/
13 #ifndef S_BUCKETS_H
14 #define S_BUCKETS_H
15 
16 class sBucket; typedef sBucket* sBucket_pt;
17 struct spolyrec; typedef struct spolyrec polyrec; typedef polyrec* poly;
18 struct ip_sring; typedef struct ip_sring* ring; typedef struct ip_sring const* const_ring;
19 
20 
21 
22 //////////////////////////////////////////////////////////////////////////
23 // Creation/Destruction of buckets
24 //
27 
28 //////////////////////////////////////////////////////////////////////////
29 // New API:
30 //
31 
32 /// Copy sBucket non-intrusive!!!
34 
35 /// Returns bucket ring
36 ring sBucketGetRing(const sBucket_pt bucket);
37 
38 /// Test whether bucket is empty!?
39 bool sIsEmpty(const sBucket_pt bucket);
40 
41 
42 
43 /////////////////////////////////////////////////////////////////////////////
44 // Convertion from/to SBpolys
45 //
46 
47 // Converts p into a bucket poly (SBpoly) and destroys p
48 // Assumes length <= 0 || pLength(p) == length
49 // void sBucketInit(sBucket_pt bucket, poly p, int length);
50 
51 // creates and returns new bucket, initializes it with p
52 // sBucket_pt sBucketInit( poly p, int length, ring r = currRing);
53 
54 // Converts SBpoly into a poly and clears bucket
55 // i.e., afterwards SBpoly == 0
56 // assumes all monomials in bucket are different
57 void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length);
58 
59 // Converts SBpoly into a poly and clears bucket
60 // i.e., afterwards SBpoly == 0
61 // bucket may contain equal monials
62 void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length);
63 
64 // Converts SBpoly into a poly and detroys bucket
65 inline void sBucketDestroyMerge(sBucket_pt bucket, poly *p, int *length)
66 {
67  sBucketClearMerge(bucket, p, length);
68  sBucketDestroy(&bucket);
69 }
70 
71 // Converts SBpoly into a poly and detroys bucket
72 inline void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
73 {
74  sBucketClearAdd(bucket, p, length);
75  sBucketDestroy(&bucket);
76 }
77 
78 void sBucketDeleteAndDestroy(sBucket_pt *bucket_pt);
79 
80 //////////////////////////////////////////////////////////////////////////
81 
82 /// Merges p into Spoly: assumes Bpoly and p have no common monoms
83 /// destroys p!
84 void sBucket_Merge_p(sBucket_pt bucket, poly p, int lp);
85 
86 /// adds poly p to bucket
87 /// destroys p!
88 void sBucket_Add_p(sBucket_pt bucket, poly p, int lp);
89 
90 
91 //////////////////////////////////////////////////////////////////////////
92 ///
93 /// Sorts p with bucketSort: assumes all monomials of p are different
94 ///
95 poly sBucketSortMerge(poly p, const ring r);
96 
97 //////////////////////////////////////////////////////////////////////////
98 ///
99 /// Sorts p with bucketSort: p may have equal monomials
100 ///
101 poly sBucketSortAdd(poly p, const ring r);
102 
103 
104 #endif // P_BUCKET_SORT
void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.cc:232
void sBucketDestroy(sBucket_pt *bucket)
Definition: sbuckets.cc:127
return P p
Definition: myNF.cc:203
void sBucketDestroyMerge(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:65
void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.h:72
Definition: ring.h:255
void sBucket_Merge_p(sBucket_pt bucket, poly p, int lp)
Merges p into Spoly: assumes Bpoly and p have no common monoms destroys p!
Definition: sbuckets.cc:176
bool sIsEmpty(const sBucket_pt bucket)
Test whether bucket is empty!?
Definition: sbuckets.cc:55
const ring r
Definition: syzextra.cc:208
poly sBucketSortAdd(poly p, const ring r)
Sorts p with bucketSort: p may have equal monomials.
Definition: sbuckets.cc:364
polyrec * poly
Definition: sbuckets.h:17
sBucket * sBucket_pt
Definition: sbuckets.h:16
P bucket
Definition: myNF.cc:79
sBucket_pt sBucketCreate(ring r)
Definition: sbuckets.cc:120
ring sBucketGetRing(const sBucket_pt bucket)
Returns bucket ring.
Definition: sbuckets.cc:51
void sBucketDeleteAndDestroy(sBucket_pt *bucket_pt)
Definition: sbuckets.cc:134
void sBucket_Add_p(sBucket_pt bucket, poly p, int lp)
adds poly p to bucket destroys p!
Definition: sbuckets.cc:201
sBucket_pt sBucketCopy(const sBucket_pt bucket)
Copy sBucket non-intrusive!!!
Definition: sbuckets.cc:75
void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length)
Definition: sbuckets.cc:270
poly sBucketSortMerge(poly p, const ring r)
Sorts p with bucketSort: assumes all monomials of p are different.
Definition: sbuckets.cc:327
#define const
Definition: fegetopt.c:41
polyrec * poly
Definition: hilb.h:10