Loading...
Searching...
No Matches
Ideal.h
Go to the documentation of this file.
#ifndef IDEAL_CPP_HEADER
#define IDEAL_CPP_HEADER
#include <vector>
#include "Poly.h"
#include "kernel/ideals.h"
//base for ideals as well for modules
//doesn't need a destructor, as Polys will destroy itself
template <class poly_type> class IdealBase
{
protected:
std::vector<poly_type> storage;
public:
typedef poly_type value_type;
typedef typename std::vector<poly_type>::size_type size_type;
typedef typename std::vector<poly_type>::iterator iterator;
typedef typename std::vector<poly_type>::difference_type difference_type;
typedef typename std::vector<poly_type>::allocator_type allocator_type;
IdealBase(){}
IdealBase(iterator first,
iterator last,
const typename
std::vector<poly_type>::allocator_type& __a = allocator_type()):
storage(first,last,__a)
{}
ring getRing() const
{
//FIXME: is a hack
if (size()>0)
{
return storage[0].getRing();
}
else
return (ring) NULL;
}
poly_type& operator[] (int n)
{
return storage[n];
}
const poly_type& operator[](int n) const
{
return storage[n];
}
void push_back(const poly_type& p)
{
storage.push_back(p);
}
void push_front(const poly_type& p)
{
storage.push_front(p);
}
iterator begin()
{
return storage.begin();
}
iterator end()
{
return storage.end();
}
size_type size() const
{
return storage.size();
}
iterator
insert(iterator __position, const value_type& __x)
{
return storage.insert(__position,__x);
}
iterator
erase(iterator __position)
{
return storage.erase(__position);
}
iterator
erase(iterator __first, iterator __last)
{
return storage.erase(__first,__last);
}
void insert(iterator __pos, iterator __first, iterator __last)
{
return insert(__pos,__first,__last);
}
};
class Ideal:
public IdealBase<Poly>
{
public:
Ideal(){}
Ideal(ideal i, ring r)
{
for(int j=0;j<IDELEMS(i);j++)
{
storage.push_back(Poly(i->m[j],r));
}
}
Ideal(iterator first,
iterator last,
const allocator_type& __a = allocator_type()):
IdealBase<Poly>(first,last,__a){}
ideal as_ideal() const
{
//no checks for rings
int s=size();
if (s==0) s=1;
ideal result=idInit(s,1);
result->m[0]=NULL;
s=size();
for(int i=0;i<s;i++)
{
result->m[i]=storage[i].as_poly();
}
return result;
}
};
class Module:
public IdealBase<Vector>
{
public:
Module(ideal i, ring r)
{
for(int j=0;j<IDELEMS(i);j++)
{
storage.push_back(Vector(i->m[j],r));
}
}
ideal as_module() const
{
//no checks for rings
int s=size();
if (s==0)
s=1;
ideal result=idInit(s,1);
result->m[0]=NULL;
s=size();
for(int i=0;i<s;i++)
{
result->m[i]=storage[i].as_poly();
}
if (size()==0)
result->rank=0;
else
result->rank=id_RankFreeModule(result,storage[0].getRing());
return result;
}
Module(iterator first,
iterator last,
const allocator_type& __a = allocator_type()):
IdealBase<Vector>(first,last,__a)
{}
Module()
{}
};
#endif
Poly.h
i
int i
Definition cfEzgcd.cc:132
p
int p
Definition cfModGcd.cc:4086
IdealBase::IdealBase
IdealBase(iterator first, iterator last, const typename std::vector< poly_type >::allocator_type &__a=allocator_type())
Definition Ideal.h:20
IdealBase::erase
iterator erase(iterator __position)
Definition Ideal.h:71
IdealBase::difference_type
std::vector< poly_type >::difference_type difference_type
Definition Ideal.h:16
IdealBase::insert
iterator insert(iterator __position, const value_type &__x)
Definition Ideal.h:66
IdealBase::size
size_type size() const
Definition Ideal.h:61
IdealBase::allocator_type
std::vector< poly_type >::allocator_type allocator_type
Definition Ideal.h:17
IdealBase::end
iterator end()
Definition Ideal.h:57
IdealBase::insert
void insert(iterator __pos, iterator __first, iterator __last)
Definition Ideal.h:80
IdealBase::value_type
poly_type value_type
Definition Ideal.h:13
IdealBase::size_type
std::vector< poly_type >::size_type size_type
Definition Ideal.h:14
IdealBase::storage
std::vector< poly_type > storage
Definition Ideal.h:11
IdealBase::push_front
void push_front(const poly_type &p)
Definition Ideal.h:48
IdealBase::IdealBase
IdealBase()
Definition Ideal.h:18
IdealBase::begin
iterator begin()
Definition Ideal.h:53
IdealBase::iterator
std::vector< poly_type >::iterator iterator
Definition Ideal.h:15
IdealBase::getRing
ring getRing() const
Definition Ideal.h:26
IdealBase::operator[]
const poly_type & operator[](int n) const
Definition Ideal.h:40
IdealBase::erase
iterator erase(iterator __first, iterator __last)
Definition Ideal.h:76
IdealBase::operator[]
poly_type & operator[](int n)
Definition Ideal.h:36
IdealBase::push_back
void push_back(const poly_type &p)
Definition Ideal.h:44
Ideal::Ideal
Ideal(ideal i, ring r)
Definition Ideal.h:91
Ideal::Ideal
Ideal()
Definition Ideal.h:90
Ideal::as_ideal
ideal as_ideal() const
Definition Ideal.h:102
Ideal::Ideal
Ideal(iterator first, iterator last, const allocator_type &__a=allocator_type())
Definition Ideal.h:98
Module::Module
Module()
Definition Ideal.h:156
Module::Module
Module(ideal i, ring r)
Definition Ideal.h:123
Module::as_module
ideal as_module() const
Definition Ideal.h:130
Module::Module
Module(iterator first, iterator last, const allocator_type &__a=allocator_type())
Definition Ideal.h:151
Vector
Definition Poly.h:509
result
return result
Definition facAbsBiFact.cc:76
s
const CanonicalForm int s
Definition facAbsFact.cc:51
j
int j
Definition facHensel.cc:110
last
STATIC_VAR poly last
Definition hdegree.cc:1138
ideals.h
NULL
#define NULL
Definition omList.c:12
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35
id_RankFreeModule
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s
Definition simpleideals.cc:992
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
Poly
Definition janet.h:15