compute a random element a of GF, s.t. F(a) \f$ \neq 0 \f$ , F is a univariate polynomial, returns fail if there are no field elements left which have not been used before
| 816 | /// univariate polynomial, returns fail if there are no field elements left |
| 817 | /// which have not been used before |
| 818 | static inline |
| 819 | CanonicalForm |
| 820 | GFRandomElement (const CanonicalForm& F, CFList& list, bool& fail) |
| 821 | { |
| 822 | fail= false; |
| 823 | Variable x= F.mvar(); |
| 824 | GFRandom genGF; |
| 825 | CanonicalForm random; |
| 826 | int p= getCharacteristic(); |
| 827 | int d= getGFDegree(); |
| 828 | int bound= ipower (p, d); |
| 829 | do |
| 830 | { |
| 831 | if (list.length() == bound) |
| 832 | { |
| 833 | fail= true; |
| 834 | break; |
| 835 | } |
| 836 | if (list.length() < 1) |
| 837 | random= 0; |
| 838 | else |
| 839 | { |
| 840 | random= genGF.generate(); |
| 841 | while (find (list, random)) |
| 842 | random= genGF.generate(); |
| 843 | } |
| 844 | if (F (random, x) == 0) |
| 845 | { |
| 846 | list.append (random); |
| 847 | continue; |
| 848 | } |
| 849 | } while (find (list, random)); |
| 850 | return random; |
| 851 | } |
| 852 | |
| 853 | CanonicalForm |
| 854 | modGCDGF (const CanonicalForm& F, const CanonicalForm& G, |
no test coverage detected