1 | #ifndef IDEAL_CPP_HEADER |
---|
2 | #define IDEAL_CPP_HEADER |
---|
3 | //$Id: Ideal.h,v 1.3 2005-09-09 07:52:04 bricken Exp $ |
---|
4 | #include "Poly.h" |
---|
5 | #include "ideals.h" |
---|
6 | //base for ideals as well for modules |
---|
7 | |
---|
8 | template <class poly_type> class IdealBase { |
---|
9 | protected: |
---|
10 | std::vector<poly_type> storage; |
---|
11 | public: |
---|
12 | typedef poly_type value_type; |
---|
13 | typedef typename std::vector<poly_type>::size_type size_type; |
---|
14 | typedef typename std::vector<poly_type>::iterator iterator; |
---|
15 | typedef typename std::vector<poly_type>::difference_type difference_type; |
---|
16 | typedef typename std::vector<poly_type>::allocator_type allocator_type; |
---|
17 | IdealBase(){ |
---|
18 | } |
---|
19 | IdealBase(iterator first, |
---|
20 | iterator last, |
---|
21 | const typename |
---|
22 | std::vector<poly_type>::allocator_type& __a = allocator_type()): |
---|
23 | storage(first,last,__a) |
---|
24 | { |
---|
25 | |
---|
26 | } |
---|
27 | poly_type& operator[] (int n){ |
---|
28 | return storage[n]; |
---|
29 | } |
---|
30 | const poly_type& operator[](int n) const{ |
---|
31 | return storage[n]; |
---|
32 | } |
---|
33 | void push_back(const poly_type& p){ |
---|
34 | storage.push_back(p); |
---|
35 | } |
---|
36 | void push_front(const poly_type& p){ |
---|
37 | storage.push_front(p); |
---|
38 | } |
---|
39 | |
---|
40 | iterator begin(){ |
---|
41 | return storage.begin(); |
---|
42 | } |
---|
43 | iterator end(){ |
---|
44 | return storage.end(); |
---|
45 | } |
---|
46 | size_type size() const{ |
---|
47 | return storage.size(); |
---|
48 | } |
---|
49 | iterator |
---|
50 | insert(iterator __position, const value_type& __x){ |
---|
51 | return storage.insert(__position,__x); |
---|
52 | } |
---|
53 | iterator |
---|
54 | erase(iterator __position){ |
---|
55 | return storage.erase(__position); |
---|
56 | } |
---|
57 | iterator |
---|
58 | erase(iterator __first, iterator __last){ |
---|
59 | return storage.erase(__first,__last); |
---|
60 | } |
---|
61 | void insert(iterator __pos, iterator __first, iterator __last){ |
---|
62 | return insert(__pos,__first,__last); |
---|
63 | } |
---|
64 | |
---|
65 | }; |
---|
66 | |
---|
67 | class Ideal: |
---|
68 | public IdealBase<Poly>{ |
---|
69 | public: |
---|
70 | Ideal(){ |
---|
71 | } |
---|
72 | Ideal(ideal i, ring r){ |
---|
73 | for(int j=0;j<IDELEMS(i);j++){ |
---|
74 | storage.push_back(Poly(i->m[j],r)); |
---|
75 | } |
---|
76 | } |
---|
77 | Ideal(iterator first, |
---|
78 | iterator last, |
---|
79 | const allocator_type& __a = allocator_type()): |
---|
80 | IdealBase<Poly>(first,last,__a){ |
---|
81 | } |
---|
82 | ideal as_ideal() const{ |
---|
83 | //no checks for rings |
---|
84 | int s=size(); |
---|
85 | ideal result=idInit(s,1); |
---|
86 | |
---|
87 | for(int i=0;i<s;i++){ |
---|
88 | result->m[i]=storage[i].as_poly(); |
---|
89 | } |
---|
90 | return result; |
---|
91 | } |
---|
92 | }; |
---|
93 | class Modul: |
---|
94 | public IdealBase<Vector>{ |
---|
95 | }; |
---|
96 | #endif |
---|