| 1168 | } |
| 1169 | |
| 1170 | static inline |
| 1171 | CanonicalForm |
| 1172 | FpRandomElement (const CanonicalForm& F, CFList& list, bool& fail) |
| 1173 | { |
| 1174 | fail= false; |
| 1175 | Variable x= F.mvar(); |
| 1176 | FFRandom genFF; |
| 1177 | CanonicalForm random; |
| 1178 | int p= getCharacteristic(); |
| 1179 | int bound= p; |
| 1180 | do |
| 1181 | { |
| 1182 | if (list.length() == bound) |
| 1183 | { |
| 1184 | fail= true; |
| 1185 | break; |
| 1186 | } |
| 1187 | if (list.length() < 1) |
| 1188 | random= 0; |
| 1189 | else |
| 1190 | { |
| 1191 | random= genFF.generate(); |
| 1192 | while (find (list, random)) |
| 1193 | random= genFF.generate(); |
| 1194 | } |
| 1195 | if (F (random, x) == 0) |
| 1196 | { |
| 1197 | list.append (random); |
| 1198 | continue; |
| 1199 | } |
| 1200 | } while (find (list, random)); |
| 1201 | return random; |
| 1202 | } |
| 1203 | |
| 1204 | #if defined(HAVE_NTL) || defined(HAVE_FLINT) |
| 1205 | CanonicalForm |