My Project
Loading...
Searching...
No Matches
Ideal.h
Go to the documentation of this file.
1#ifndef IDEAL_CPP_HEADER
2#define IDEAL_CPP_HEADER
3#include <vector>
4#include "Poly.h"
5#include "kernel/ideals.h"
6//base for ideals as well for modules
7//doesn't need a destructor, as Polys will destroy itself
8template <class poly_type> class IdealBase
9{
10 protected:
11 std::vector<poly_type> storage;
12 public:
13 typedef poly_type value_type;
14 typedef typename std::vector<poly_type>::size_type size_type;
15 typedef typename std::vector<poly_type>::iterator iterator;
16 typedef typename std::vector<poly_type>::difference_type difference_type;
17 typedef typename std::vector<poly_type>::allocator_type allocator_type;
19
22 const typename
23 std::vector<poly_type>::allocator_type& __a = allocator_type()):
24 storage(first,last,__a)
25 {}
26 ring getRing() const
27 {
28 //FIXME: is a hack
29 if (size()>0)
30 {
31 return storage[0].getRing();
32 }
33 else
34 return (ring) NULL;
35 }
36 poly_type& operator[] (int n)
37 {
38 return storage[n];
39 }
40 const poly_type& operator[](int n) const
41 {
42 return storage[n];
43 }
44 void push_back(const poly_type& p)
45 {
46 storage.push_back(p);
47 }
48 void push_front(const poly_type& p)
49 {
50 storage.push_front(p);
51 }
52
54 {
55 return storage.begin();
56 }
58 {
59 return storage.end();
60 }
62 {
63 return storage.size();
64 }
66 insert(iterator __position, const value_type& __x)
67 {
68 return storage.insert(__position,__x);
69 }
71 erase(iterator __position)
72 {
73 return storage.erase(__position);
74 }
76 erase(iterator __first, iterator __last)
77 {
78 return storage.erase(__first,__last);
79 }
80 void insert(iterator __pos, iterator __first, iterator __last)
81 {
82 return insert(__pos,__first,__last);
83 }
84};
85
86class Ideal:
87public IdealBase<Poly>
88{
89 public:
91 Ideal(ideal i, ring r)
92 {
93 for(int j=0;j<IDELEMS(i);j++)
94 {
95 storage.push_back(Poly(i->m[j],r));
96 }
97 }
100 const allocator_type& __a = allocator_type()):
101 IdealBase<Poly>(first,last,__a){}
102 ideal as_ideal() const
103 {
104 //no checks for rings
105 int s=size();
106
107 if (s==0) s=1;
108
109 ideal result=idInit(s,1);
110 result->m[0]=NULL;
111 s=size();
112 for(int i=0;i<s;i++)
113 {
114 result->m[i]=storage[i].as_poly();
115 }
116 return result;
117 }
118};
119class Module:
120public IdealBase<Vector>
121{
122public:
123 Module(ideal i, ring r)
124 {
125 for(int j=0;j<IDELEMS(i);j++)
126 {
127 storage.push_back(Vector(i->m[j],r));
128 }
129 }
130 ideal as_module() const
131 {
132 //no checks for rings
133 int s=size();
134
135 if (s==0)
136 s=1;
137
138 ideal result=idInit(s,1);
139 result->m[0]=NULL;
140 s=size();
141 for(int i=0;i<s;i++)
142 {
143 result->m[i]=storage[i].as_poly();
144 }
145 if (size()==0)
146 result->rank=0;
147 else
149 return result;
150 }
153 const allocator_type& __a = allocator_type()):
154 IdealBase<Vector>(first,last,__a)
155 {}
157 {}
158};
159#endif
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
Definition: Ideal.h:9
IdealBase(iterator first, iterator last, const typename std::vector< poly_type >::allocator_type &__a=allocator_type())
Definition: Ideal.h:20
iterator erase(iterator __position)
Definition: Ideal.h:71
std::vector< poly_type >::difference_type difference_type
Definition: Ideal.h:16
iterator insert(iterator __position, const value_type &__x)
Definition: Ideal.h:66
size_type size() const
Definition: Ideal.h:61
std::vector< poly_type >::allocator_type allocator_type
Definition: Ideal.h:17
iterator end()
Definition: Ideal.h:57
void insert(iterator __pos, iterator __first, iterator __last)
Definition: Ideal.h:80
poly_type value_type
Definition: Ideal.h:13
std::vector< poly_type >::size_type size_type
Definition: Ideal.h:14
std::vector< poly_type > storage
Definition: Ideal.h:11
void push_front(const poly_type &p)
Definition: Ideal.h:48
IdealBase()
Definition: Ideal.h:18
iterator begin()
Definition: Ideal.h:53
std::vector< poly_type >::iterator iterator
Definition: Ideal.h:15
ring getRing() const
Definition: Ideal.h:26
const poly_type & operator[](int n) const
Definition: Ideal.h:40
iterator erase(iterator __first, iterator __last)
Definition: Ideal.h:76
poly_type & operator[](int n)
Definition: Ideal.h:36
void push_back(const poly_type &p)
Definition: Ideal.h:44
Definition: Ideal.h:88
Ideal(ideal i, ring r)
Definition: Ideal.h:91
Ideal()
Definition: Ideal.h:90
ideal as_ideal() const
Definition: Ideal.h:102
Ideal(iterator first, iterator last, const allocator_type &__a=allocator_type())
Definition: Ideal.h:98
Definition: Ideal.h:121
Module()
Definition: Ideal.h:156
Module(ideal i, ring r)
Definition: Ideal.h:123
ideal as_module() const
Definition: Ideal.h:130
Module(iterator first, iterator last, const allocator_type &__a=allocator_type())
Definition: Ideal.h:151
Definition: Poly.h:509
return result
Definition: facAbsBiFact.cc:75
const CanonicalForm int s
Definition: facAbsFact.cc:51
int j
Definition: facHensel.cc:110
STATIC_VAR poly last
Definition: hdegree.cc:1173
#define NULL
Definition: omList.c:12
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
#define IDELEMS(i)
Definition: simpleideals.h:23
Definition: janet.h:15