1 | /**************************************** |
---|
2 | * Computer Algebra System SINGULAR * |
---|
3 | ****************************************/ |
---|
4 | /*************************************************************** |
---|
5 | * File: fast_maps.cc |
---|
6 | * Purpose: implementation of fast maps |
---|
7 | * Author: obachman (Olaf Bachmann), hannes (Hannes Schoenemann), |
---|
8 | * bricken (Michael Brickenstein) |
---|
9 | * Created: 01/02 |
---|
10 | * Version: $Id$ |
---|
11 | *******************************************************************/ |
---|
12 | |
---|
13 | /******************************************************************************* |
---|
14 | ** |
---|
15 | *S mapoly, macoeff . . . . . . . . . . . . definition of structs/classes |
---|
16 | */ |
---|
17 | #ifndef FAST_MAPS_HEADER |
---|
18 | #define FAST_MAPS_HEADER |
---|
19 | class macoeff_s; |
---|
20 | class mapoly_s; |
---|
21 | class maideal_s; |
---|
22 | typedef class mapoly_s* mapoly; |
---|
23 | typedef class macoeff_s* macoeff; |
---|
24 | typedef class maideal_s* maideal; |
---|
25 | |
---|
26 | class mapoly_s |
---|
27 | { |
---|
28 | public: |
---|
29 | mapoly next; |
---|
30 | poly src; // monomial from WeightedRing |
---|
31 | poly dest; // poly in CompRing |
---|
32 | mapoly f1, f2; // if f1 != NULL && f2 != NULL then dest = f1*f2 |
---|
33 | int ref; // use to catch last usage to save last copy |
---|
34 | macoeff coeff; // list of coeffs to use |
---|
35 | }; |
---|
36 | |
---|
37 | class macoeff_s |
---|
38 | { |
---|
39 | public: |
---|
40 | macoeff next; |
---|
41 | number n; |
---|
42 | sBucket_pt bucket; |
---|
43 | }; |
---|
44 | |
---|
45 | class maideal_s |
---|
46 | { |
---|
47 | public: |
---|
48 | int n; |
---|
49 | sBucket_pt* buckets; |
---|
50 | }; |
---|
51 | |
---|
52 | /******************************************************************************* |
---|
53 | ** |
---|
54 | *S definition of basic routines |
---|
55 | */ |
---|
56 | void maMonomial_Out(mapoly monomial, ring src_r, ring dest_r = NULL); |
---|
57 | void maPoly_Out(mapoly mpoly, ring src_ring, ring dest_r = NULL); |
---|
58 | |
---|
59 | // creates a new maMonomial |
---|
60 | // if bucket != NULL, a coeff with the bucket is created, as well |
---|
61 | mapoly maMonomial_Create(poly p, ring , sBucket_pt bucket = NULL); |
---|
62 | // unconditionally destroys a maMonomial: |
---|
63 | // src: LmFree |
---|
64 | // dest: p_Delete |
---|
65 | // coeffs: delete list |
---|
66 | void maMonomial_Destroy(mapoly monomial, ring src_r, ring dest_r = NULL); |
---|
67 | // decrements ref counter, if 0, calls Destroy |
---|
68 | inline mapoly maMonomial_Free(mapoly monomial, ring src_r, ring dest_r = NULL) |
---|
69 | { |
---|
70 | monomial->ref--; |
---|
71 | if (monomial->ref <= 0) |
---|
72 | { maMonomial_Destroy(monomial, src_r, dest_r); return NULL;} |
---|
73 | return monomial; |
---|
74 | } |
---|
75 | |
---|
76 | // inserts ("adds") monomial what into poly into |
---|
77 | // returns the maMonomial which was inserted, or, if an equal one was found, |
---|
78 | // the monomial which "swalloed" the monomial |
---|
79 | // It furthermore might reset into |
---|
80 | mapoly maPoly_InsertMonomial(mapoly &into, mapoly what, ring src_r); |
---|
81 | mapoly maPoly_InsertMonomial(mapoly &into, poly p, ring src_r, sBucket_pt bucket = NULL); |
---|
82 | |
---|
83 | // optimizes mpoly for later evaluation |
---|
84 | void maPoly_Optimize(mapoly mpoly, ring src_r); |
---|
85 | |
---|
86 | // evaluates mpoly and destroys it, on the fly |
---|
87 | void maPoly_Eval(mapoly mpoly, ring src_r, ideal dest_id, ring dest_r, int total_cost); |
---|
88 | |
---|
89 | // creates mpoly and mideal |
---|
90 | void maMap_CreatePolyIdeal(ideal map_id, ring map_r, |
---|
91 | ring src_r, ring dest_r, |
---|
92 | mapoly &mp, maideal &mideal); |
---|
93 | // creates src_r: rings with weights |
---|
94 | // dest_r: where we do our computations |
---|
95 | void maMap_CreateRings(ideal map_id, ring map_r, |
---|
96 | ideal image_id, ring image_r, |
---|
97 | ring &src_r, ring &dest_r, BOOLEAN &no_sort); |
---|
98 | |
---|
99 | // collects tthe results into an ideal and destroys maideal |
---|
100 | ideal maIdeal_2_Ideal(maideal ideal, ring dest_r); |
---|
101 | |
---|
102 | // main routine: map_id: the ideal to map |
---|
103 | // map_r: the base ring for map_id |
---|
104 | // image_id: the image of the variables |
---|
105 | // image_r: the base ring for image_id |
---|
106 | ideal fast_map(ideal map_id, ring map_r, ideal image_id, ring image_r); |
---|
107 | |
---|
108 | #endif |
---|
109 | |
---|
110 | |
---|