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