compute a random element a of \f$ F_{p}(\alpha ) \f$ , 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
| 377 | /// s.t. F(a) \f$ \neq 0 \f$ , F is a univariate polynomial, returns |
| 378 | /// fail if there are no field elements left which have not been used before |
| 379 | static inline CanonicalForm |
| 380 | randomElement (const CanonicalForm & F, const Variable & alpha, CFList & list, |
| 381 | bool & fail) |
| 382 | { |
| 383 | fail= false; |
| 384 | Variable x= F.mvar(); |
| 385 | AlgExtRandomF genAlgExt (alpha); |
| 386 | FFRandom genFF; |
| 387 | CanonicalForm random, mipo; |
| 388 | mipo= getMipo (alpha); |
| 389 | int p= getCharacteristic (); |
| 390 | int d= degree (mipo); |
| 391 | double bound= pow ((double) p, (double) d); |
| 392 | do |
| 393 | { |
| 394 | if (list.length() == bound) |
| 395 | { |
| 396 | fail= true; |
| 397 | break; |
| 398 | } |
| 399 | if (list.length() < p) |
| 400 | { |
| 401 | random= genFF.generate(); |
| 402 | while (find (list, random)) |
| 403 | random= genFF.generate(); |
| 404 | } |
| 405 | else |
| 406 | { |
| 407 | random= genAlgExt.generate(); |
| 408 | while (find (list, random)) |
| 409 | random= genAlgExt.generate(); |
| 410 | } |
| 411 | if (F (random, x) == 0) |
| 412 | { |
| 413 | list.append (random); |
| 414 | continue; |
| 415 | } |
| 416 | } while (find (list, random)); |
| 417 | return random; |
| 418 | } |
| 419 | |
| 420 | static inline |
| 421 | Variable chooseExtension (const Variable & alpha) |
no test coverage detected