source: git/kernel/Ideal.h @ 92a473

spielwiese
Last change on this file since 92a473 was 92a473, checked in by Michael Brickenstein <bricken@…>, 19 years ago
*bricken: ring extraction git-svn-id: file:///usr/local/Singular/svn/trunk@8633 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.3 KB
Line 
1#ifndef IDEAL_CPP_HEADER
2#define IDEAL_CPP_HEADER
3//$Id: Ideal.h,v 1.6 2005-09-21 07:13:10 bricken Exp $
4#include <vector>
5#include "Poly.h"
6#include "ideals.h"
7//base for ideals as well for modules
8//doesn't need a destructor, as Polys will destroy itself
9template <class poly_type> class IdealBase {
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;
18 IdealBase(){
19 }
20 
21 IdealBase(iterator first, 
22             iterator last,
23             const typename
24             std::vector<poly_type>::allocator_type& __a = allocator_type()):
25   storage(first,last,__a)
26   {
27   
28 }
29 ring getRing() const{
30  //FIXME: is a hack
31  if (size()>0){
32    return storage[0].getRing();
33  }
34  else
35  return (ring) NULL;
36 }
37 poly_type& operator[] (int n){
38   return storage[n];
39 }
40 const poly_type& operator[](int n) const{
41   return storage[n];
42 }
43 void push_back(const poly_type& p){
44   storage.push_back(p);
45 }
46 void push_front(const poly_type& p){
47   storage.push_front(p);
48 }
49
50 iterator begin(){
51   return storage.begin();
52 }
53 iterator end(){
54   return storage.end();
55 }
56 size_type size() const{
57   return storage.size();
58 }
59 iterator
60   insert(iterator __position, const value_type& __x){
61   return storage.insert(__position,__x);
62 }
63 iterator
64   erase(iterator __position){
65   return storage.erase(__position);
66 }
67 iterator
68   erase(iterator __first, iterator __last){
69   return storage.erase(__first,__last);
70 }
71 void insert(iterator __pos, iterator __first, iterator __last){
72   return insert(__pos,__first,__last);
73 }
74
75};
76
77class Ideal:
78public IdealBase<Poly>{
79 public:
80  Ideal(){
81  }
82  Ideal(ideal i, ring r){
83    for(int j=0;j<IDELEMS(i);j++){
84      storage.push_back(Poly(i->m[j],r));
85    }
86  }
87  Ideal(iterator first, 
88        iterator last,
89        const allocator_type& __a = allocator_type()):
90    IdealBase<Poly>(first,last,__a){
91  }
92 ideal as_ideal() const{
93   //no checks for rings
94   int s=size();
95   ideal result=idInit(s,1);
96   
97   for(int i=0;i<s;i++){
98     result->m[i]=storage[i].as_poly();
99   }
100   return result;
101 }
102};
103class Modul:
104public IdealBase<Vector>{
105};
106#endif
Note: See TracBrowser for help on using the repository browser.