1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | |
---|
3 | #ifndef INCL_CF_RANDOM_H |
---|
4 | #define INCL_CF_RANDOM_H |
---|
5 | |
---|
6 | // #include "config.h" |
---|
7 | |
---|
8 | #include "canonicalform.h" |
---|
9 | |
---|
10 | /*BEGINPUBLIC*/ |
---|
11 | |
---|
12 | /** |
---|
13 | * virtual class for random element generation |
---|
14 | **/ |
---|
15 | class CFRandom { |
---|
16 | public: |
---|
17 | virtual ~CFRandom() {} |
---|
18 | virtual CanonicalForm generate() const { return 0; } |
---|
19 | virtual CFRandom * clone() const { return new CFRandom(); } |
---|
20 | }; |
---|
21 | |
---|
22 | /** |
---|
23 | * generate random elements in GF |
---|
24 | **/ |
---|
25 | class GFRandom : public CFRandom |
---|
26 | { |
---|
27 | public: |
---|
28 | GFRandom() {}; |
---|
29 | ~GFRandom() {} |
---|
30 | CanonicalForm generate() const; |
---|
31 | CFRandom * clone() const; |
---|
32 | }; |
---|
33 | |
---|
34 | /** |
---|
35 | * generate random elements in F_p |
---|
36 | **/ |
---|
37 | class FFRandom : public CFRandom |
---|
38 | { |
---|
39 | public: |
---|
40 | FFRandom() {} |
---|
41 | ~FFRandom() {} |
---|
42 | CanonicalForm generate() const; |
---|
43 | CFRandom * clone() const; |
---|
44 | }; |
---|
45 | |
---|
46 | /** |
---|
47 | * generate random integers |
---|
48 | **/ |
---|
49 | class IntRandom : public CFRandom |
---|
50 | { |
---|
51 | private: |
---|
52 | int max; |
---|
53 | public: |
---|
54 | IntRandom(); |
---|
55 | IntRandom( int m ); |
---|
56 | ~IntRandom(); |
---|
57 | CanonicalForm generate() const; |
---|
58 | CFRandom * clone() const; |
---|
59 | }; |
---|
60 | |
---|
61 | /** |
---|
62 | * generate random elements in F_p(alpha) |
---|
63 | **/ |
---|
64 | class AlgExtRandomF : public CFRandom { |
---|
65 | private: |
---|
66 | Variable algext; |
---|
67 | CFRandom * gen; |
---|
68 | int n; |
---|
69 | AlgExtRandomF(); |
---|
70 | AlgExtRandomF( const Variable & v, CFRandom * g, int nn ); |
---|
71 | AlgExtRandomF& operator= ( const AlgExtRandomF & ); |
---|
72 | public: |
---|
73 | AlgExtRandomF( const AlgExtRandomF & ); |
---|
74 | AlgExtRandomF( const Variable & v ); |
---|
75 | AlgExtRandomF( const Variable & v1, const Variable & v2 ); |
---|
76 | ~AlgExtRandomF(); |
---|
77 | CanonicalForm generate() const; |
---|
78 | CFRandom * clone() const; |
---|
79 | }; |
---|
80 | |
---|
81 | class CFRandomFactory { |
---|
82 | public: |
---|
83 | static CFRandom * generate(); |
---|
84 | }; |
---|
85 | |
---|
86 | /// random integers with abs less than n |
---|
87 | int factoryrandom( int n ); |
---|
88 | |
---|
89 | /// random seed initializer |
---|
90 | void factoryseed( int s ); |
---|
91 | |
---|
92 | /*ENDPUBLIC*/ |
---|
93 | |
---|
94 | #endif /* ! INCL_CF_RANDOM_H */ |
---|