MCPcopy Create free account
hub / github.com/Singular/Singular / randomElement

Function randomElement

factory/cfModGcd.cc:379–418  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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
379static inline CanonicalForm
380randomElement (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
420static inline
421Variable chooseExtension (const Variable & alpha)

Callers 4

modGCDFqFunction · 0.85
modGCDFpFunction · 0.85
sparseGCDFqFunction · 0.85
sparseGCDFpFunction · 0.85

Calls 10

getMipoFunction · 0.85
getCharacteristicFunction · 0.85
degreeFunction · 0.85
findFunction · 0.85
mvarMethod · 0.80
powFunction · 0.50
FFunction · 0.50
lengthMethod · 0.45
generateMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected