Mini-Wrapper for some of MPIR's BigInt functions.
Example #1
0
        public XInt PowMod(XInt exp, XInt mod)
        {
            var result = new XInt();

            mpz_powm(ref result.impl, ref this.impl, ref exp.impl, ref mod.impl);
            return(result);
        }
Example #2
0
        public static XInt GreatestCommonDivisor(XInt x, XInt y)
        {
            var z = new XInt();

            mpz_gcd(ref z.impl, ref x.impl, ref y.impl);
            return(z);
        }
Example #3
0
        public static XInt PrimeSwingParallelFactorial(Int32 x)
        {
            var z = new XInt();

            _PrimeSwingParallelFactorial(ref z.impl, (UInt32)x);
            return(z);
        }
Example #4
0
        public static XInt Pow(UInt32 bas, UInt32 exp)
        {
            var result = new XInt();

            mpz_ui_pow_ui(ref result.impl, bas, exp);
            return(result);
        }
Example #5
0
        public static XInt Sqrt(XInt i)
        {
            var result = new XInt();

            mpz_sqrt(ref result.impl, ref i.impl);
            return(result);
        }
Example #6
0
        public static XInt Pow(XInt bas, UInt32 exp)
        {
            var result = new XInt();

            mpz_pow_ui(ref result.impl, ref bas.impl, exp);
            return(result);
        }
Example #7
0
        public static XInt operator /(XInt x, XInt y)
        {
            var result = new XInt();

            mpz_tdiv_q(ref result.impl, ref x.impl, ref y.impl);
            return(result);
        }
Example #8
0
        public static XInt operator <<(XInt x, Int32 shiftAmount)
        {
            var z = new XInt();

            mpz_mul_2exp(ref z.impl, ref x.impl, (UInt32)shiftAmount);
            return(z);
        }
Example #9
0
        public static XInt operator *(XInt x, UInt32 y)
        {
            var z = new XInt();

            mpz_mul_ui(ref z.impl, ref x.impl, y);
            return(z);
        }
Example #10
0
        public static XInt operator +(XInt x, UInt32 y)
        {
            var result = new XInt();

            mpz_add_ui(ref result.impl, ref x.impl, y);
            return(result);
        }
Example #11
0
        public static XInt operator *(UInt32 x, XInt y)
        {
            var z = new XInt();

            mpz_mul_ui(ref z.impl, ref y.impl, x);
            return(z);
        }
Example #12
0
        public static XInt operator %(XInt x, XInt mod)
        {
            var result = new XInt();

            mpz_mod(ref result.impl, ref x.impl, ref mod.impl);
            return(result);
        }
Example #13
0
        public static XInt Factorial(Int32 x)
        {
            var z = new XInt();

            mpz_fac_ui(ref z.impl, (UInt32)x);
            return(z);
        }
Example #14
0
        public static XInt SchoenhageParallelFactorial(Int32 x)
        {
            var z = new XInt();

            _SchoenhageParallelFactorial(ref z.impl, (UInt32)x);
            return(z);
        }
Example #15
0
        public bool Equals(XInt other)
        {
            if (object.ReferenceEquals(other, null))
            {
                return(false);
            }

            return(mpz_cmp(ref other.impl, ref this.impl) == 0);
        }
Example #16
0
        public XInt(XInt value)
        {
            if (ReferenceEquals(value, null))
            {
                throw new NullReferenceException();
            }

            mpz_init(ref impl);
            mpz_set(ref impl, ref value.impl);
        }
Example #17
0
 public static XInt Pow(XInt bas, Int32 exp)
 {
     if (exp == 2)
     {
         return(bas * bas);
     }
     if (exp >= 0)
     {
         return(Pow(bas, (UInt32)exp));
     }
     throw new ArgumentOutOfRangeException(nameof(exp));
 }
 public XInt PowMod(XInt exp, XInt mod)
 {
     var result = new XInt();
     mpz_powm(ref result.impl, ref this.impl, ref exp.impl, ref mod.impl);
     return result;
 }
 public static XInt Pow(UInt32 bas, UInt32 exp)
 {
     var result = new XInt();
     mpz_ui_pow_ui(ref result.impl, bas, exp);
     return result;
 }
 public static XInt Pow(XInt bas, Int32 exp)
 {
     if (exp == 2) return bas * bas;
     if (exp >= 0) return Pow(bas, (UInt32)exp);
     throw new ArgumentOutOfRangeException(nameof(exp));
 }
 public static XInt Pow(XInt bas, UInt32 exp)
 {
     var result = new XInt();
     mpz_pow_ui(ref result.impl, ref bas.impl, exp);
     return result;
 }
 public static XInt Sqrt(XInt i)
 {
     var result = new XInt();
     mpz_sqrt(ref result.impl, ref i.impl);
     return result;
 }
 public static XInt operator <<(XInt x, Int32 shiftAmount)
 {
     var z = new XInt();
     mpz_mul_2exp(ref z.impl, ref x.impl, (UInt32)shiftAmount);
     return z;
 }
 public static XInt PrimeSwingParallelFactorial(Int32 x)
 {
     var z = new XInt();
     _PrimeSwingParallelFactorial(ref z.impl, (UInt32)x);
     return z;
 }
 public static XInt operator +(XInt x, UInt32 y)
 {
     var result = new XInt();
     mpz_add_ui(ref result.impl, ref x.impl,  y);
     return result;
 }
 public static XInt operator *(XInt x, UInt32 y)
 {
     var z = new XInt();
     mpz_mul_ui(ref z.impl, ref x.impl, y);
     return z;
 }
 public static XInt operator *(UInt32 x, XInt y)
 {
     var z = new XInt();
     mpz_mul_ui(ref z.impl, ref y.impl, x);
     return z;
 }
 public static XInt operator %(XInt x, XInt mod)
 {
     var result = new XInt();
     mpz_mod(ref result.impl, ref x.impl, ref mod.impl);
     return result;
 }
        public bool Equals(XInt other)
        {
            if (object.ReferenceEquals(other, null))
                return false;

            return mpz_cmp(ref other.impl, ref this.impl) == 0;
        }
 public Int32 CompareTo(XInt other)
 {
     return mpz_cmp(ref impl, ref other.impl);
 }
Example #31
0
 public Int32 CompareTo(XInt other)
 {
     return(mpz_cmp(ref impl, ref other.impl));
 }
 public static XInt GreatestCommonDivisor(XInt x, XInt y)
 {
     var z = new XInt();
     mpz_gcd(ref z.impl, ref x.impl, ref y.impl);
     return z;
 }
 public static XInt Factorial(Int32 x)
 {
     var z = new XInt();
     mpz_fac_ui(ref z.impl, (UInt32)x);
     return z;
 }
 public static XInt operator /(XInt x, XInt y)
 {
     var result = new XInt();
     mpz_tdiv_q(ref result.impl, ref x.impl, ref y.impl);
     return result;
 }
 public static XInt SchoenhageParallelFactorial(Int32 x)
 {
     var z = new XInt();
     _SchoenhageParallelFactorial(ref z.impl, (UInt32)x);
     return z;
 }
        public XInt(XInt value)
        {
            if (ReferenceEquals(value, null))
                throw new NullReferenceException();

            mpz_init(ref impl);
            mpz_set(ref impl, ref value.impl);
        }