source: git/factory/cf_generator.h

spielwiese
Last change on this file was abddbe, checked in by Martin Lee <martinlee84@…>, 10 years ago
chg: added brief descriptions to some files
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2
3/**
4 * @file cf_generator.h
5 *
6 * generate integers, elements of finite fields
7**/
8
9#ifndef INCL_CF_GENERATOR_H
10#define INCL_CF_GENERATOR_H
11
12// #include "config.h"
13
14#include "canonicalform.h"
15
16/*BEGINPUBLIC*/
17
18/**
19 * virtual class for generators
20**/
21class CFGenerator
22{
23public:
24    CFGenerator() {}
25    virtual ~CFGenerator() {}
26    virtual bool hasItems() const { return false; }
27    virtual void reset() {};
28    virtual CanonicalForm item() const { return 0; }
29    virtual void next() {};
30    virtual CFGenerator * clone() const { return new CFGenerator();}
31};
32
33/**
34 * generate integers starting from 0
35**/
36class IntGenerator : public CFGenerator
37{
38private:
39    int current;
40public:
41    IntGenerator() : current(0) {}
42    ~IntGenerator() {}
43    bool hasItems() const;
44    void reset() { current = 0; }
45    CanonicalForm item() const;
46    void next();
47    void operator++ () { next(); }
48    void operator++ ( int ) { next(); }
49    CFGenerator * clone() const;
50};
51
52/**
53 * generate all elements in F_p starting from 0
54**/
55class FFGenerator : public CFGenerator
56{
57private:
58    int current;
59public:
60    FFGenerator() : current(0) {}
61    ~FFGenerator() {}
62    bool hasItems() const;
63    void reset() { current = 0; }
64    CanonicalForm item() const;
65    void next();
66    void operator++ () { next(); }
67    void operator++ ( int ) { next(); }
68    CFGenerator * clone() const;
69};
70
71/**
72 * generate all elements in GF starting from 0
73**/
74class GFGenerator : public CFGenerator
75{
76private:
77    int current;
78public:
79    GFGenerator();
80    ~GFGenerator() {}
81    bool hasItems() const;
82    void reset();
83    CanonicalForm item() const;
84    void next();
85    void operator++ () { next(); }
86    void operator++ ( int ) { next(); }
87    CFGenerator * clone() const;
88};
89
90/**
91 * generate all elements in F_p(alpha) starting from 0
92**/
93class AlgExtGenerator: public CFGenerator
94{
95private:
96    Variable algext;
97    FFGenerator **gensf;
98    GFGenerator **gensg;
99    int n;
100    bool nomoreitems;
101    AlgExtGenerator();
102    AlgExtGenerator( const AlgExtGenerator & );
103    AlgExtGenerator& operator= ( const AlgExtGenerator & );
104public:
105    AlgExtGenerator( const Variable & a );
106    ~AlgExtGenerator();
107
108    bool hasItems() const { return ! nomoreitems; }
109    void reset();
110    CanonicalForm item() const;
111    void next();
112    void operator++ () { next(); }
113    void operator++ ( int ) { next(); }
114    CFGenerator * clone() const;
115};
116
117class CFGenFactory
118{
119public:
120    static CFGenerator* generate();
121};
122
123/*ENDPUBLIC*/
124
125#endif /* ! INCL_CF_GENERATOR_H */
Note: See TracBrowser for help on using the repository browser.