source: git/libpolys/polys/sbuckets.h @ 53b958

fieker-DuValspielwiese
Last change on this file since 53b958 was 53b958, checked in by Hans Schoenemann <hannes@…>, 7 years ago
add; sBucket_Add_m, sBucket_Merge_m
  • Property mode set to 100644
File size: 3.3 KB
Line 
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
16class sBucket; typedef sBucket*           sBucket_pt;
17struct  spolyrec; typedef struct spolyrec polyrec; typedef polyrec* poly;
18struct ip_sring; typedef struct ip_sring* ring; typedef struct ip_sring const* const_ring;
19
20
21
22//////////////////////////////////////////////////////////////////////////
23// Creation/Destruction of buckets
24//
25sBucket_pt    sBucketCreate(ring r);
26void          sBucketDestroy(sBucket_pt *bucket);
27
28//////////////////////////////////////////////////////////////////////////
29// New API:
30//
31
32/// Copy sBucket non-intrusive!!!
33sBucket_pt    sBucketCopy(const sBucket_pt bucket);
34
35/// Returns bucket ring
36ring sBucketGetRing(const sBucket_pt bucket);
37
38/// Test whether bucket is empty!?
39bool 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
57void 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
62void sBucketClearAdd(sBucket_pt bucket, poly *p, int *length);
63
64// Converts SBpoly into a poly and detroys bucket
65inline 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
72inline void sBucketDestroyAdd(sBucket_pt bucket, poly *p, int *length)
73{
74  sBucketClearAdd(bucket, p, length);
75  sBucketDestroy(&bucket);
76}
77
78void sBucketDeleteAndDestroy(sBucket_pt *bucket_pt);
79
80//////////////////////////////////////////////////////////////////////////
81
82/// Merges p into Spoly: assumes Bpoly and p have no common monoms
83/// destroys p!
84void sBucket_Merge_p(sBucket_pt bucket, poly p, int lp);
85void sBucket_Merge_m(sBucket_pt bucket, poly p);
86
87/// adds poly p to bucket
88/// destroys p!
89void sBucket_Add_p(sBucket_pt bucket, poly p, int lp);
90void sBucket_Add_m(sBucket_pt bucket, poly p);
91
92
93//////////////////////////////////////////////////////////////////////////
94///
95/// Sorts p with bucketSort: assumes all monomials of p are different
96///
97poly sBucketSortMerge(poly p, const ring r);
98
99//////////////////////////////////////////////////////////////////////////
100///
101/// Sorts p with bucketSort: p may have equal monomials
102///
103poly sBucketSortAdd(poly p, const ring r);
104
105
106#endif // P_BUCKET_SORT
Note: See TracBrowser for help on using the repository browser.