当前位置: 首页>>代码示例>>C#>>正文


C# NET.mpz_t类代码示例

本文整理汇总了C#中Mpir.NET.mpz_t的典型用法代码示例。如果您正苦于以下问题:C# mpz_t类的具体用法?C# mpz_t怎么用?C# mpz_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


mpz_t类属于Mpir.NET命名空间,在下文中一共展示了mpz_t类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MpirCalcs

 static void MpirCalcs()
 {
     mpz_t a = new mpz_t(12345678901234567890);
     mpz_t b = new mpz_t(9876543210987654321);
     mpz_t c = a * b;
     System.Console.WriteLine("{0}", c);
 }
开发者ID:cdycdr,项目名称:Mpir.NET,代码行数:7,代码来源:MpirSample.cs

示例2: Main

 static void Main(string[] args)
 {
     //Creating our collection of tasks that compute the partial sums.
     List<Task<mpz_t>> tasks = new List<Task<mpz_t>>();
     //For loop for assigning a dynamic number of threads.
     for (int k = 0; k < numThreads; k++)
     {
         //DO NOT REMOVE! This is neccesary, because of how threading works. k will change each iteration, but tempk stays at whatever it is for that thread. The important part is, DO NOT TOUCH!
         int tempk = k;
         //Add a new method to compute for each k and add it to the tasks list.
         tasks.Add(Task.Factory.StartNew(() => {
            //Each one calculates a piece of the digits.
            return PSum_Arctan_2Term(numTerms / numThreads, tempk);
         }));
     }
     //Makes sure all are done before adding them up. If you don't it messes up the final value. One doesn't finish much faster than another thread, due to the nature of the algorithm.
     Task.WaitAll(tasks.ToArray());
     //Adding all the parts of the digits together in a loop.
     for (int j = 0; j < tasks.Count; j++)
     {
         //Adding all the parts of pi to the final static variable.
         final += tasks[j].Result;
     }
     //We write out a message so people see that the calculations are done, and the time it took.
     Console.WriteLine("#" + (numThreads * numTerms) + " numTerms of " + digits + " digits took " + (DateTime.Now - started) + " time. Your file is located at " + path + "pi_numTerms=" + (numThreads * numTerms) + "_digits=" + digits + ".txt");
     //Write to the file
     File.WriteAllText(path + "pi_numTerms=" + (numThreads * numTerms) + "_digits=" + digits + ".txt", "#" + (numThreads * numTerms) + " of " + digits + " digits " + (DateTime.Now - started) + Environment.NewLine + final);
     //Used so the program doesnt stop. Just press enter after the message appears to stop it.
     Console.ReadLine();
 }
开发者ID:randbrown,项目名称:FastestPiApproximator,代码行数:30,代码来源:Program+-+mpir.cs

示例3: Bar

 static void Bar()
 {
     // [using-sample]
     using (mpz_t a = new mpz_t(12345678901234567890))
     using (mpz_t b = new mpz_t(9876543210987654321)) 
     using (mpz_t c = a * b)
     {
         System.Console.WriteLine("{0}", c.ToString());
     }
     // [/using-sample]
 }
开发者ID:cdycdr,项目名称:Mpir.NET,代码行数:11,代码来源:MpirSample.cs

示例4: Xor

 public mpz_t Xor(mpz_t x)
 {
     return (this ^ x);
 }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:4,代码来源:mpz_t.cs

示例5: And

 public mpz_t And(mpz_t x)
 {
     return (this & x);
 }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:4,代码来源:mpz_t.cs

示例6: DivideExactly

 public mpz_t DivideExactly(uint x)
 {
     mpz_t z = new mpz_t();
     mpir.mpz_divexact_ui(z, this, x);
     return z;
 }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:6,代码来源:mpz_t.cs

示例7: IsDivisibleBy

 public bool IsDivisibleBy(mpz_t x)
 {
     return mpir.mpz_divisible_p(this, x) != 0;
 }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:4,代码来源:mpz_t.cs

示例8: Divide

        public mpz_t Divide(uint x, out int remainder)
        {
            mpz_t quotient = new mpz_t();
            uint uintRemainder = mpir.mpz_tdiv_q_ui(quotient, this, x);
            if(uintRemainder > (uint)int.MaxValue)
                throw new OverflowException();

            if(this >= 0)
                remainder = (int)uintRemainder;
            else
                remainder = -(int)uintRemainder;

            return quotient;
        }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:14,代码来源:mpz_t.cs

示例9: ArgumentOutOfRangeException

        public static mpz_t operator %(mpz_t x, int mod)
        {
            if(mod < 0)
                throw new ArgumentOutOfRangeException();

            mpz_t z = new mpz_t();
            mpir.mpz_fdiv_r_ui(z, x, (uint)mod);
            return z;
        }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:9,代码来源:mpz_t.cs

示例10: mpz_t

 public static mpz_t operator %(mpz_t x, mpz_t mod)
 {
     mpz_t z = new mpz_t();
     mpir.mpz_mod(z, x, mod);
     return z;
 }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:6,代码来源:mpz_t.cs

示例11: Remainder

 public mpz_t Remainder(mpz_t x)
 {
     mpz_t z = new mpz_t();
     mpir.mpz_tdiv_r(z, this, x);
     return z;
 }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:6,代码来源:mpz_t.cs

示例12: ChangeBit

        public mpz_t ChangeBit(int bitIndex, int value)
        {
            mpz_t z = new mpz_t(this);

            if(value == 0)
                mpir.mpz_clrbit(z, (uint)bitIndex);
            else
                mpir.mpz_setbit(z, (uint)bitIndex);

            return z;
        }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:11,代码来源:mpz_t.cs

示例13: Abs

 /// Returns a new mpz_t which is the absolute value of this value.
 public mpz_t Abs()
 {
     mpz_t result = new mpz_t();
     mpir.mpz_abs(result, this);
     return result;
 }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:7,代码来源:mpz_t.cs

示例14: DivideMod

 public mpz_t DivideMod(mpz_t x, mpz_t mod)
 {
     return (this * x.InvertMod(mod)) % mod;
 }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:4,代码来源:mpz_t.cs

示例15: Add

 public mpz_t Add(mpz_t x)
 {
     return this + x;
 }
开发者ID:sourcebinary,项目名称:Mpir.NET,代码行数:4,代码来源:mpz_t.cs


注:本文中的Mpir.NET.mpz_t类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。