source: git/kernel/Ideal.h @ ef413f

spielwiese
Last change on this file since ef413f was ef413f, checked in by Michael Brickenstein <bricken@…>, 19 years ago
*bricken: + ring support git-svn-id: file:///usr/local/Singular/svn/trunk@8626 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.2 KB
Line 
1#ifndef IDEAL_CPP_HEADER
2#define IDEAL_CPP_HEADER
3//$Id: Ideal.h,v 1.4 2005-09-19 14:01:31 bricken Exp $
4#include "Poly.h"
5#include "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 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 
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 }
47 size_type size() const{
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 }
65
66};
67
68class Ideal:
69public IdealBase<Poly>{
70 public:
71  Ideal(){
72  }
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  }
78  Ideal(iterator first, 
79        iterator last,
80        const allocator_type& __a = allocator_type()):
81    IdealBase<Poly>(first,last,__a){
82  }
83 ideal as_ideal() const{
84   //no checks for rings
85   int s=size();
86   ideal result=idInit(s,1);
87   
88   for(int i=0;i<s;i++){
89     result->m[i]=storage[i].as_poly();
90   }
91   return result;
92 }
93};
94class Modul:
95public IdealBase<Vector>{
96};
97#endif
Note: See TracBrowser for help on using the repository browser.