private static bool IsPossiblePerfectPower <T>(T a, int p) { if (moduliMap == null) { CreateModuliMap(); } if (!moduliMap.ContainsKey(p)) { return(true); } var moduli = moduliMap[p]; for (int i = 0; i < moduli.Length; i++) { var modulus = moduli[i]; var exponent = (modulus - 1) / p; var value = (int)((Number <T>)a % modulus); if (value != 0 && IntegerMath.ModularPower(value, exponent, modulus) != 1) { return(false); } } return(true); }
public override Rational ModularPower(Rational value, Rational exponent, Rational modulus) { return(IntegerMath.ModularPower(value, exponent, modulus)); }
public override uint ModularPower(uint value, uint exponent, uint modulus) { return(IntegerMath.ModularPower(value, exponent, modulus)); }
public IResidue <int> Power(int x) { r = IntegerMath.ModularPower(r, x, reducer.Modulus); return(this); }
public IResidue <long> Power(long x) { r = IntegerMath.ModularPower(r, x, reducer.Modulus); return(this); }
public override ulong ModularPower(ulong value, ulong exponent, ulong modulus) { return(IntegerMath.ModularPower(value, exponent, modulus)); }
public override double ModularPower(double value, double exponent, double modulus) { return((double)IntegerMath.ModularPower(ToBigInteger(value), ToBigInteger(exponent), ToBigInteger(modulus))); }
public override Complex ModularPower(Complex value, Complex exponent, Complex modulus) { return((Complex)IntegerMath.ModularPower(ToBigInteger(value), ToBigInteger(exponent), ToBigInteger(modulus))); }
public override BigInteger ModularPower(BigInteger value, BigInteger exponent, BigInteger modulus) { return(IntegerMath.ModularPower(value, exponent, modulus)); }
public IResidue <BigInteger> Power(BigInteger x) { r = IntegerMath.ModularPower(r, x, reducer.Modulus); return(this); }
public override IResidue <UInt128> Power(UInt128 x) { r = IntegerMath.ModularPower(r, x, reducer.modulus); return(this); }