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

Function GFRandomElement

factory/cfModGcd.cc:818–851  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

816/// univariate polynomial, returns fail if there are no field elements left
817/// which have not been used before
818static inline
819CanonicalForm
820GFRandomElement (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
853CanonicalForm
854modGCDGF (const CanonicalForm& F, const CanonicalForm& G,

Callers 1

modGCDGFFunction · 0.85

Calls 9

getCharacteristicFunction · 0.85
getGFDegreeFunction · 0.85
ipowerFunction · 0.85
findFunction · 0.85
mvarMethod · 0.80
FFunction · 0.50
lengthMethod · 0.45
generateMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected