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 | * Version: $Id: sbuckets.h,v 1.3 2009-05-27 16:15:14 motsak Exp $ |
---|
13 | *******************************************************************/ |
---|
14 | #ifndef S_BUCKETS_H |
---|
15 | #define S_BUCKETS_H |
---|
16 | |
---|
17 | #include "structs.h" |
---|
18 | |
---|
19 | |
---|
20 | |
---|
21 | ////////////////////////////////////////////////////////////////////////// |
---|
22 | // Creation/Destruction of buckets |
---|
23 | // |
---|
24 | sBucket_pt sBucketCreate(ring r = currRing); |
---|
25 | void sBucketDestroy(sBucket_pt *bucket); |
---|
26 | |
---|
27 | |
---|
28 | ////////////////////////////////////////////////////////////////////////// |
---|
29 | // New API: |
---|
30 | // |
---|
31 | |
---|
32 | /// Copy sBucket non-intrusive!!! |
---|
33 | sBucket_pt sBucketCopy(const sBucket_pt bucket); |
---|
34 | |
---|
35 | /// Returns bucket ring |
---|
36 | const ring sBucketGetRing(const sBucket_pt bucket); |
---|
37 | |
---|
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 |
---|
44 | // void sBucketInit(sBucket_pt bucket, poly p, int length); |
---|
45 | |
---|
46 | // creates and returns new bucket, initializes it with p |
---|
47 | // sBucket_pt sBucketInit( poly p, int length, ring r = currRing); |
---|
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 | |
---|
73 | |
---|
74 | ////////////////////////////////////////////////////////////////////////// |
---|
75 | /// |
---|
76 | /// Merges p into Spoly: assumes Bpoly and p have no common monoms |
---|
77 | /// |
---|
78 | void sBucket_Merge_p(sBucket_pt bucket, poly p, int lp); |
---|
79 | // adds poly p to bucket |
---|
80 | void sBucket_Add_p(sBucket_pt bucket, poly p, int lp); |
---|
81 | |
---|
82 | |
---|
83 | ////////////////////////////////////////////////////////////////////////// |
---|
84 | /// |
---|
85 | /// Sorts p with bucketSort: assumes all monomials of p are different |
---|
86 | /// |
---|
87 | poly sBucketSortMerge(poly p, ring r); |
---|
88 | |
---|
89 | ////////////////////////////////////////////////////////////////////////// |
---|
90 | /// |
---|
91 | /// Sorts p with bucketSort: p may have equal monomials |
---|
92 | /// |
---|
93 | poly sBucketSortAdd(poly p, ring r); |
---|
94 | |
---|
95 | |
---|
96 | #endif // P_BUCKET_SORT |
---|