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.1 2000-12-31 15:17:47 obachman Exp $ |
---|
13 | *******************************************************************/ |
---|
14 | #ifndef S_BUCKETS_H |
---|
15 | #define S_BUCKETS_H |
---|
16 | |
---|
17 | #include "mod2.h" |
---|
18 | #include "structs.h" |
---|
19 | |
---|
20 | ////////////////////////////////////////////////////////////////////////// |
---|
21 | // Creation/Destruction of buckets |
---|
22 | // |
---|
23 | sBucket_pt sBucketCreate(ring r = currRing); |
---|
24 | void sBucketDestroy(sBucket_pt *bucket); |
---|
25 | |
---|
26 | |
---|
27 | ///////////////////////////////////////////////////////////////////////////// |
---|
28 | // Convertion from/to SBpolys |
---|
29 | // |
---|
30 | |
---|
31 | // Converts p into a bucket poly (SBpoly) and destroys p |
---|
32 | // Assumes length <= 0 || pLength(p) == length |
---|
33 | void sBucketInit(sBucket_pt bucket, poly p, int length); |
---|
34 | |
---|
35 | // creates and returns new bucket, initializes it with p |
---|
36 | sBucket_pt sBucketInit( poly p, int length, ring r = currRing); |
---|
37 | |
---|
38 | // Converts SBpoly into a poly and clears bucket |
---|
39 | // i.e., afterwards SBpoly == 0 |
---|
40 | // assumes all monomials in bucket are different |
---|
41 | void sBucketClearMerge(sBucket_pt bucket, poly *p, int *length); |
---|
42 | |
---|
43 | // Converts SBpoly into a poly and clears bucket |
---|
44 | // i.e., afterwards SBpoly == 0 |
---|
45 | // bucket may contain equal monials |
---|
46 | void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length); |
---|
47 | |
---|
48 | // Converts SBpoly into a poly and detroys bucket |
---|
49 | inline void sBucketDestroyMerge(sBucket_pt bucket, poly *p, int *length) |
---|
50 | { |
---|
51 | sBucketClearMerge(bucket, p, length); |
---|
52 | sBucketDestroy(&bucket); |
---|
53 | } |
---|
54 | |
---|
55 | // Converts SBpoly into a poly and detroys bucket |
---|
56 | inline void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length) |
---|
57 | { |
---|
58 | sBucketClearAdd(bucket, p, length); |
---|
59 | sBucketDestroy(&bucket); |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
63 | ////////////////////////////////////////////////////////////////////////// |
---|
64 | /// |
---|
65 | /// Merges p into Spoly: assumes Bpoly and p have no common monoms |
---|
66 | /// |
---|
67 | void sBucket_Merge_p(sBucket_pt bucket, poly p, int lp); |
---|
68 | // adds poly p to bucket |
---|
69 | void sBucket_Add_p(sBucket_pt bucket, poly p, int lp); |
---|
70 | |
---|
71 | |
---|
72 | ////////////////////////////////////////////////////////////////////////// |
---|
73 | /// |
---|
74 | /// Sorts p with bucektSort: assumes all monomials of p are different |
---|
75 | /// |
---|
76 | poly sBucketSortMerge(poly p, ring r); |
---|
77 | |
---|
78 | ////////////////////////////////////////////////////////////////////////// |
---|
79 | /// |
---|
80 | /// Sorts p with bucektSort: p may have equal monomials |
---|
81 | /// |
---|
82 | poly sBucketSortAdd(poly p, ring r); |
---|
83 | |
---|
84 | |
---|
85 | #endif // P_BUCKET_SORT |
---|