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


C# BigNumber类代码示例

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


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

示例1: Sqrt

        /// <summary>开方</summary>
        static internal BigNumber Sqrt(BigNumber value, int precision) {
            if (!value.IsPlus)
                throw new ExpressionException("只有正数才有开平方运算");

            List<int> div = new List<int>();
            int index = 0;
            int resultIntCount = (value.IntPart.Count + 1) / 2;

            List<int> result = GetFirstDiv(value, ref div, ref index);

            div = FirstTry(result, div);
            div.AddRange(GetNewTwoDiv(value, ref index));
            BigCalculate.RemoveStartZero(div);
            //考虑精度的计算
            while (true) {
                div = TryDiv(div, result);
                if (result.Count - resultIntCount >= precision)
                    break;

                div.AddRange(GetNewTwoDiv(value, ref index));
                BigCalculate.RemoveStartZero(div);
            }

            return new BigNumber(result.GetRange(0, resultIntCount), result.GetRange(resultIntCount, result.Count - resultIntCount), true);
        }
开发者ID:JoshuaHe2015,项目名称:VISAP2.0_Advanced,代码行数:26,代码来源:DecimalCalculator.cs

示例2: Main

 static void Main(string[] args) 
 {
     BigNumber e = new BigNumber("1");
     BigNumber[,] table = new BigNumber[3, 3] { { 52*e, 64*e, 24*e },{60*e,59*e,52*e},{50*e,65*e,74*e} };
     Console.WriteLine(contingency(table));
     Console.ReadKey();
 }
开发者ID:Cg87521,项目名称:stats,代码行数:7,代码来源:Xsquare_Independence_test.cs

示例3: Quantile

 static BigNumber Quantile(BigNumber[] NumberSeries, double quan)
 {
     int len = NumberSeries.Length;
     double position = quan * (double)len;
     position = Convert.ToDouble(round(position.ToString(), 0));
     return NumberSeries[Convert.ToInt32(position - 1)];
 }
开发者ID:JoshuaHe2015,项目名称:VISAP_Basic,代码行数:7,代码来源:MeanAndSort.cs

示例4: Minus

 /// <summary>减</summary>
 public static BigNumber Minus(BigNumber one, BigNumber two) {
     BigNumber oneAbsolute = one.AbsoluteNumber;
     BigNumber twoAbsolute = two.AbsoluteNumber;
     //正数减正数
     if (one.IsPlus && two.IsPlus) {
         if (oneAbsolute.CompareTo(twoAbsolute) == 1)
             return PlusMinus(one, two);
         else if (oneAbsolute.CompareTo(twoAbsolute) == -1)
             return PlusMinus(two, one).ReverseNumber;
         else
             return BigNumber.Zero;
     }
         //正数减负数
     else if (one.IsPlus && !two.IsPlus) {
         return PlusAdd(oneAbsolute, twoAbsolute);
     }
         //负数减正数
     else if (!one.IsPlus && two.IsPlus) {
         return PlusAdd(oneAbsolute, twoAbsolute).ReverseNumber;
     }
         //负数减负数
     else if (!one.IsPlus && !two.IsPlus) {
         return Add(one, twoAbsolute);
     }
     throw new Exception("不可能到达的地方");
 }
开发者ID:JoshuaHe2015,项目名称:VISAP2.0_GUI,代码行数:27,代码来源:BigCalculate.cs

示例5: Main

       public  static void Main(string[] args)
        {
            Console.WriteLine("请输入x的值,用逗号分开");
            string numberseriesx = Console.ReadLine();
            Console.WriteLine("请输入y的值,用逗号分开");
            string numberlinresy = Console.ReadLine();
            char[] separator = { ',' };
            string[] numbersx = numberseriesx.Split(separator);
            string[] numbersy = numberlinresy.Split(separator);
            int n = numbersx.Length;
            BigNumber[] x = new BigNumber[n];
            BigNumber[] y = new BigNumber[n];
            for (int i = 0; i < n; i++)
            {
                x[i] = new BigNumber(numbersx[i]);

            }
            for (int j = 0; j < n; j++)
            {
                y[j] = new BigNumber(numbersy[j]);
            }
            Console.WriteLine( Regression(x,y,n));
            Console.ReadKey();

        }
开发者ID:Cg87521,项目名称:stats,代码行数:25,代码来源:onevariable_regression.cs

示例6: Mode

        //仅限于寻找有序数列中的众数
        //多个众数时返回最小的众数
        public static string Mode(BigNumber[] NumberSeries)
        {

            double MaxCount = 0;
            double CurrentCount = 0;
            BigNumber MaxNumber = new BigNumber("0");
            BigNumber CurrentNumber = new BigNumber("0");
            int len = NumberSeries.Length;
            for (int i = 1; i < len; i++)
            {
                if (CompareNumber.Compare(NumberSeries[i - 1], NumberSeries[i]) == 0)
                {
                    CurrentCount++;
                    if (CurrentCount > MaxCount)
                    {
                        MaxCount = CurrentCount;
                        MaxNumber = NumberSeries[i];
                    }
                }
                else
                {
                    CurrentCount = 0;
                }
            }
            if (MaxCount == 0)
            {
                return "NA";
            }
            else
            {
                return MaxNumber.ToString();
            }
        }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:35,代码来源:MatCorr.cs

示例7: BigNum

        public void BigNum()
        {
            var x = new BigNumber(9007199254740992);

            Assert.Equal(@"{
  ""Number"": ""9007199254740992""
}", JsonObject.FromObject(x).ToString());
        }
开发者ID:carbon,项目名称:Data,代码行数:8,代码来源:XSerializationTests.cs

示例8: LilNumber

        public void LilNumber()
        {
            var x = new BigNumber(1);

            Assert.Equal(@"{
  ""Number"": 1
}", JsonObject.FromObject(x).ToString());
        }
开发者ID:carbon,项目名称:Data,代码行数:8,代码来源:XSerializationTests.cs

示例9: Regression

       public static string Regression(BigNumber[] x,BigNumber[] y,int n)
        {
            BigNumber sumx = new BigNumber("0");
            BigNumber sumy = new BigNumber("0");
            BigNumber lxy = new BigNumber("0");
            BigNumber lxx = new BigNumber("0");
            BigNumber xbar, ybar, beta0, beta1;

            for (int i = 0; i < n; i++)
            {
                sumx = sumx + x[i];
            }

            xbar = sumx / new BigNumber(x.Length.ToString());
            for (int a = 0; a <= n-1; a++)
            {
                lxx = lxx + (x[a] - xbar).Power(new BigNumber("2"));
            }
            for (int i = 0; i <= n-1; i++)
            {
                sumy = sumy + y[i];
            }
            ybar = sumy / new BigNumber(y.Length.ToString());
            for (int i = 0; i <= n-1; i++)
            {
                lxy = lxy + (x[i] - xbar) * (y[i] - ybar);
            }
            beta1 = lxy / lxx;
            beta0 = ybar - beta1 * xbar;
          
            BigNumber[] Ey = new BigNumber[n];
            BigNumber[] residual = new BigNumber[n];
            BigNumber SSR = new BigNumber("0");
            BigNumber SSE = new BigNumber("0");
            BigNumber Fvalue, Rsquare;
            for (int i =0;i <= n-1; i++)
            {
                Ey[i] = beta0 + beta1 * x[i];
            }
            for (int i=0; i <= n-1;i++)
            {
                residual[i] = y[i] - Ey[i];
            }
            for (int i = 0; i <= n - 1; i++)
            {
                SSR = SSR + (Ey[i] - ybar).Power(new BigNumber("2"));
                SSE = SSE + (y[i] - Ey[i]).Power(new BigNumber("2"));
            }
            Fvalue = SSR / SSE * (new BigNumber( n.ToString()) - new BigNumber("2"));
            string f = Fvalue.ToString();
            double F =  Convert.ToDouble(f);
            Rsquare = SSR / (SSR+SSE);
           // BigNumber Fa = new BigNumber(Stat.FdistUa(0.05, 2,1).ToString());
            //BigNumber FF =new BigNumber("1") / Fa;
            BigNumber p = new BigNumber(Stat.FCDF(F, 1, 2).ToString());
            return p.ToString()+" "+f;//+" "+ Fvalue.ToString();//"回归方程为:y=" + MathV.round(beta0.ToString(),3,0)+ "+" + MathV.round(beta1.ToString(),3,0) + "*x"+" Rsquare:"+MathV.round(Rsquare.ToString(),3,0)+" Fvalue:"+MathV.round(Fvalue.ToString(),3,0);
        }
开发者ID:Cg87521,项目名称:stats,代码行数:57,代码来源:onevariable_regression.cs

示例10: Variance

 //输入为BigNumber数组,返回为BigNumber值
 //n - 1个自由度
 public static BigNumber Variance(BigNumber[] NumberSeries)
 {
     BigNumber sum = new BigNumber("0");
     int len = NumberSeries.Length;
     BigNumber mean_series = Mean(NumberSeries);
     foreach (BigNumber SingleNumber in NumberSeries)
     {
         sum += (SingleNumber - mean_series).Power(new BigNumber("2"), 30);
     }
     return sum / new BigNumber((len - 1).ToString());
 }
开发者ID:Yangruipis,项目名称:Genesis,代码行数:13,代码来源:MatCorr.cs

示例11: test_ecdh_curve

		private void test_ecdh_curve(Asn1Object obj, string text, BigNumber.Context ctx) {
			Key a = Key.FromCurveName(obj);
			Key b = Key.FromCurveName(obj);
			BigNumber x_a = new BigNumber();
			BigNumber y_a = new BigNumber();
			BigNumber x_b = new BigNumber();
			BigNumber y_b = new BigNumber();
			
			try {
				Console.Write("Testing key generation with {0}", text);
				
				a.GenerateKey();
				if (a.Group.Method.FieldType == Objects.NID.X9_62_prime_field.NID) {
					a.PublicKey.GetAffineCoordinatesGFp(x_a, y_a, ctx);
				}
				else {
					a.PublicKey.GetAffineCoordinatesGF2m(x_a, y_a, ctx);
				}
				Console.Write(".");
				
				b.GenerateKey();
				if (b.Group.Method.FieldType == Objects.NID.X9_62_prime_field.NID) {
					b.PublicKey.GetAffineCoordinatesGFp(x_b, y_b, ctx);
				}
				else {
					b.PublicKey.GetAffineCoordinatesGF2m(x_b, y_b, ctx);
				}
				Console.Write(".");
				
				byte[] abuf = new byte[MessageDigest.SHA1.Size];
				int aout = a.ComputeKey(b, abuf, KDF1_SHA1);
				Console.Write(".");
				
				byte[] bbuf = new byte[MessageDigest.SHA1.Size];
				int bout = b.ComputeKey(a, bbuf, KDF1_SHA1);
				Console.Write(".");
				
				Assert.Greater(aout, 4);
				Assert.AreEqual(aout, bout);
				Assert.IsTrue(Compare(abuf, bbuf));

				Console.Write(" ok");
			}
			finally {
				a.Dispose();
				b.Dispose();
				x_a.Dispose();
				y_a.Dispose();
				x_b.Dispose();
				y_b.Dispose();
			}
			
			Console.WriteLine();
		}
开发者ID:Nangal,项目名称:http2-katana,代码行数:54,代码来源:TestECDH.cs

示例12: Mean

 static BigNumber Mean(BigNumber[] NumberSeries)
 {
     BigNumber sum = new BigNumber("0");
     foreach (BigNumber SingleNumber in NumberSeries)
     {
         sum += SingleNumber;
     }
     int len = NumberSeries.Length;
     BigNumber len_bignumber = new BigNumber(len.ToString());
     return sum / len_bignumber;
 }
开发者ID:JoshuaHe2015,项目名称:VISAP_Basic,代码行数:11,代码来源:MeanAndSort.cs

示例13: Exp

        /// <summary>e次幂</summary>
        public static BigNumber Exp(BigNumber value, int precision) {
            BigNumber sum = new BigNumber("0");

            for (BigNumber n = new BigNumber("0"); ; n++) {
                BigNumber r = BigNumber.Division(value.Power(n), n.Factorial(), precision + 1);

                if (r.GetPrecision(0) > precision)
                    break;
                sum = sum + r;
            }
            Remove(sum, precision);
            return sum;
        }
开发者ID:JoshuaHe2015,项目名称:VISAP2.0_GUI,代码行数:14,代码来源:TaylorFunction.cs

示例14: ParaEasti

    } //计算分位数值
 static string ParaEasti(BigNumber[] NumberSeries, double significance, int tail, BigNumber goalnumber)
    {
        //总体均值的区间估计
        //tail == 1单尾,为2则双尾
        BigNumber n = new BigNumber(NumberSeries.Length.ToString());
        if (tail == 2)
        {
            significance = significance / 2;
        }
        BigNumber lower = Proportion(NumberSeries, goalnumber)-new BigNumber(NORMSINV(significance).ToString())*(Proportion(NumberSeries, goalnumber) * (new BigNumber("1") - Proportion(NumberSeries, goalnumber)) / n).Power(new BigNumber("0.5"));
        BigNumber upper = Proportion(NumberSeries, goalnumber)+new BigNumber(NORMSINV(significance).ToString())*(Proportion(NumberSeries, goalnumber) * (new BigNumber("1") - Proportion(NumberSeries, goalnumber)) / n).Power(new BigNumber("0.5"));
        return lower.ToString() + "," + upper.ToString();
    }
开发者ID:Cg87521,项目名称:stats,代码行数:14,代码来源:ztest_proportion.cs

示例15: Multiply

        /// <summary> 乘  </summary>
        public static BigNumber Multiply(BigNumber one, BigNumber two) {
            List<int> oneText = new List<int>();
            List<int> twoText = new List<int>();
            oneText.AddRange(one.IntPart);
            oneText.AddRange(one.DecimalPart);
            twoText.AddRange(two.IntPart);
            twoText.AddRange(two.DecimalPart);
            List<int> resultText = Multiply(oneText, twoText);

            int decimalLength = one.DecimalPart.Count + two.DecimalPart.Count;
            List<int> intPart = resultText.GetRange(0, resultText.Count - decimalLength);
            List<int> decimalPart = resultText.GetRange(resultText.Count - decimalLength, decimalLength);
            return new BigNumber(intPart, decimalPart, !(one.IsPlus ^ two.IsPlus));
        }
开发者ID:JoshuaHe2015,项目名称:VISAP2.0_GUI,代码行数:15,代码来源:BigCalculate.cs


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