當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。