Пример #1
0
        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);
        }
Пример #2
0
 public override Rational ModularPower(Rational value, Rational exponent, Rational modulus)
 {
     return(IntegerMath.ModularPower(value, exponent, modulus));
 }
Пример #3
0
 public override uint ModularPower(uint value, uint exponent, uint modulus)
 {
     return(IntegerMath.ModularPower(value, exponent, modulus));
 }
Пример #4
0
 public IResidue <int> Power(int x)
 {
     r = IntegerMath.ModularPower(r, x, reducer.Modulus);
     return(this);
 }
Пример #5
0
 public IResidue <long> Power(long x)
 {
     r = IntegerMath.ModularPower(r, x, reducer.Modulus);
     return(this);
 }
Пример #6
0
 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));
 }
Пример #10
0
 public IResidue <BigInteger> Power(BigInteger x)
 {
     r = IntegerMath.ModularPower(r, x, reducer.Modulus);
     return(this);
 }
Пример #11
0
 public override IResidue <UInt128> Power(UInt128 x)
 {
     r = IntegerMath.ModularPower(r, x, reducer.modulus);
     return(this);
 }