[35aab3] | 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 | |
---|
[8179468] | 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; |
---|
[a795c77] | 19 | |
---|
| 20 | |
---|
[35aab3] | 21 | ////////////////////////////////////////////////////////////////////////// |
---|
| 22 | // Creation/Destruction of buckets |
---|
| 23 | // |
---|
[8a8c9e] | 24 | sBucket_pt sBucketCreate(ring r); |
---|
[35aab3] | 25 | void sBucketDestroy(sBucket_pt *bucket); |
---|
| 26 | |
---|
| 27 | |
---|
[a795c77] | 28 | ////////////////////////////////////////////////////////////////////////// |
---|
| 29 | // New API: |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | /// Copy sBucket non-intrusive!!! |
---|
| 33 | sBucket_pt sBucketCopy(const sBucket_pt bucket); |
---|
| 34 | |
---|
| 35 | /// Returns bucket ring |
---|
[760a78f] | 36 | ring sBucketGetRing(const sBucket_pt bucket); |
---|
[a795c77] | 37 | |
---|
[35aab3] | 38 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 39 | // Convertion from/to SBpolys |
---|
| 40 | // |
---|
| 41 | |
---|
| 42 | // Converts p into a bucket poly (SBpoly) and destroys p |
---|
| 43 | // Assumes length <= 0 || pLength(p) == length |
---|
[b3e756] | 44 | // void sBucketInit(sBucket_pt bucket, poly p, int length); |
---|
[35aab3] | 45 | |
---|
| 46 | // creates and returns new bucket, initializes it with p |
---|
[b3e756] | 47 | // sBucket_pt sBucketInit( poly p, int length, ring r = currRing); |
---|
[35aab3] | 48 | |
---|
| 49 | // Converts SBpoly into a poly and clears bucket |
---|
| 50 | // i.e., afterwards SBpoly == 0 |
---|
| 51 | // assumes all monomials in bucket are different |
---|
| 52 | void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length); |
---|
| 53 | |
---|
| 54 | // Converts SBpoly into a poly and clears bucket |
---|
| 55 | // i.e., afterwards SBpoly == 0 |
---|
| 56 | // bucket may contain equal monials |
---|
| 57 | void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length); |
---|
| 58 | |
---|
| 59 | // Converts SBpoly into a poly and detroys bucket |
---|
| 60 | inline void sBucketDestroyMerge(sBucket_pt bucket, poly *p, int *length) |
---|
| 61 | { |
---|
| 62 | sBucketClearMerge(bucket, p, length); |
---|
| 63 | sBucketDestroy(&bucket); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | // Converts SBpoly into a poly and detroys bucket |
---|
| 67 | inline void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length) |
---|
| 68 | { |
---|
| 69 | sBucketClearAdd(bucket, p, length); |
---|
| 70 | sBucketDestroy(&bucket); |
---|
| 71 | } |
---|
| 72 | |
---|
[590f989] | 73 | void sBucketDeleteAndDestroy(sBucket_pt *bucket_pt); |
---|
[35aab3] | 74 | |
---|
| 75 | ////////////////////////////////////////////////////////////////////////// |
---|
[30664c] | 76 | |
---|
[35aab3] | 77 | /// Merges p into Spoly: assumes Bpoly and p have no common monoms |
---|
[30664c] | 78 | /// destroys p! |
---|
[35aab3] | 79 | void sBucket_Merge_p(sBucket_pt bucket, poly p, int lp); |
---|
[30664c] | 80 | |
---|
| 81 | /// adds poly p to bucket |
---|
| 82 | /// destroys p! |
---|
[35aab3] | 83 | void sBucket_Add_p(sBucket_pt bucket, poly p, int lp); |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | ////////////////////////////////////////////////////////////////////////// |
---|
| 87 | /// |
---|
[a795c77] | 88 | /// Sorts p with bucketSort: assumes all monomials of p are different |
---|
[35aab3] | 89 | /// |
---|
| 90 | poly sBucketSortMerge(poly p, ring r); |
---|
| 91 | |
---|
| 92 | ////////////////////////////////////////////////////////////////////////// |
---|
| 93 | /// |
---|
[a795c77] | 94 | /// Sorts p with bucketSort: p may have equal monomials |
---|
[35aab3] | 95 | /// |
---|
| 96 | poly sBucketSortAdd(poly p, ring r); |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | #endif // P_BUCKET_SORT |
---|