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


C# Double.Min方法代码示例

本文整理汇总了C#中System.Double.Min方法的典型用法代码示例。如果您正苦于以下问题:C# Double.Min方法的具体用法?C# Double.Min怎么用?C# Double.Min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Double的用法示例。


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

示例1: Main

        public static void Main(string[] args)
        {
            string[] month = new string[12]{"Jan","Feb","Mar", "Apr", "may","Jun","Jul","Aug","Sep","Oct","Nov", "Dec"};
            Double[] sales = new Double[12];
            double sum = 0;

            Console.WriteLine("Enter the sales");
            for(int i=0;i<month.Length;i++)
            {
                sales[i] = Convert.ToDouble(Console.ReadLine());
                sum = sum + sales[i];
            }

            Console.WriteLine("S.no \t Month  \t Sales");
            Console.WriteLine("-------------------------------");

            for(int j=0;j<month.Length;j++)
            {
                Console.WriteLine("{0} \t {1}  \t\t {2}",j, month[j], sales[j]);
            }

            Console.WriteLine("Maximum sales recorded is on {0}", sales.Max());
            Console.WriteLine("Minimum sales recorded is on {0}", sales.Min());
            Console.WriteLine("Average sales recorded is on {0}", (sum/month.Length));
        }
开发者ID:nasreekar,项目名称:CSExercises,代码行数:25,代码来源:Ex32.cs

示例2: ImageKuwaharaFilterGS


//.........这里部分代码省略.........

                            tmpj++;
                        }

                        tmpi++;
                        tmpj = 0;
                    }

                    int[] roivector1 = new int[FilterSize * FilterSize];
                    int[] roivector2 = new int[FilterSize * FilterSize];
                    int[] roivector3 = new int[FilterSize * FilterSize];
                    int[] roivector4 = new int[FilterSize * FilterSize];

                    int tmp1 = 0;
                    for (int i = 0; i < FilterSize; i++)
                    {
                        for (int j = 0; j < FilterSize; j++)
                        {

                            roivector1[tmp1] = roi[i, j];
                            tmp1++;

                        }
                    }

                    int tmp2 = 0;
                    for (int i = 0; i < FilterSize; i++)
                    {
                        for (int j = (FilterSize - 1); j < roi.GetLength(1); j++)
                        {

                            roivector2[tmp2] = roi[i, j];
                            tmp2++;

                        }
                    }

                    int tmp3 = 0;
                    for (int i = (FilterSize - 1); i < roi.GetLength(0); i++)
                    {
                        for (int j = 0; j < FilterSize; j++)
                        {

                            roivector3[tmp3] = roi[i, j];
                            tmp3++;

                        }
                    }

                    int tmp4 = 0;
                    for (int i = (FilterSize - 1); i < roi.GetLength(0); i++)
                    {
                        for (int j = (FilterSize - 1); j < roi.GetLength(1); j++)
                        {

                            roivector4[tmp4] = roi[i, j];
                            tmp4++;

                        }
                    }

                    Double[] avg = new Double[4] { 0, 0, 0, 0 };

                    Double[] var = new Double[4] { 0, 0, 0, 0 };

                    Double[] std = new Double[4] { 0, 0, 0, 0 };

                    for (int i = 0; i < FilterSize * FilterSize; i++)
                    {

                        avg[0] += Convert.ToDouble(roivector1[i]) / (FilterSize * FilterSize);
                        avg[1] += Convert.ToDouble(roivector2[i]) / (FilterSize * FilterSize);
                        avg[2] += Convert.ToDouble(roivector3[i]) / (FilterSize * FilterSize);
                        avg[3] += Convert.ToDouble(roivector4[i]) / (FilterSize * FilterSize);

                    }

                    for (int i = 0; i < FilterSize * FilterSize; i++)
                    {

                        var[0] += Math.Pow((Convert.ToDouble(roivector1[i]) - avg[0]), 2) / (FilterSize * FilterSize);
                        var[1] += Math.Pow((Convert.ToDouble(roivector2[i]) - avg[1]), 2) / (FilterSize * FilterSize);
                        var[2] += Math.Pow((Convert.ToDouble(roivector3[i]) - avg[2]), 2) / (FilterSize * FilterSize);
                        var[3] += Math.Pow((Convert.ToDouble(roivector4[i]) - avg[3]), 2) / (FilterSize * FilterSize);

                    }

                    int minIndex = System.Array.IndexOf(var, var.Min());

                    newValue = (int)avg[minIndex];

                    if (newValue > 255) newValue = 255;
                    if (newValue < 0) newValue = 0;

                    image2.SetPixel(m, n, Color.FromArgb(255, newValue, newValue, newValue));
                }
            }

            return image2;
        }
开发者ID:litdev1,项目名称:LitDev,代码行数:101,代码来源:FIP.cs

示例3: ShowTrainingData

        //Method that updates the chart with the data vectors      
        public void ShowTrainingData(Double[][] classA, Double[][] classB)
        {
            //create data series from the vectors
            var class1 = AlgorithmHelpers.JaggedToMD(classA);
            var class2 = AlgorithmHelpers.JaggedToMD(classB);

            //Compute the minimum and maximum numbers for the X axis
            var maxX = classA.Max(0)[0] > classB.Max(0)[0] ? classA.Max(0)[0] : classB.Max(0)[0];
            var minX = classA.Min(0)[0] < classB.Min(0)[0] ? classA.Min(0)[0] : classB.Min(0)[0];

            //Update the range of the X axis with the max and the min
            perceChart.RangeX = new Range((float)minX, (float)maxX);
            nnChart.RangeX = new Range((float)minX, (float)maxX);
            lsChart.RangeX = new Range((float)minX, (float)maxX);

            //Update the Perceptron chart with the loaded data
            perceChart.UpdateDataSeries("class1", class1);
            perceChart.UpdateDataSeries("class2", class2);
            //Update the BackPropagation chart with the loaded data
            nnChart.UpdateDataSeries("class1", class1);
            nnChart.UpdateDataSeries("class2", class2);
            //Update the LS chart
            lsChart.UpdateDataSeries("class1", class1);
            lsChart.UpdateDataSeries("class2", class2);
        }
开发者ID:salufa,项目名称:MachineLearning,代码行数:26,代码来源:MainForm.cs

示例4: ImageKuwaharaFilterColor


//.........这里部分代码省略.........
                    {
                        for (int j = 0; j < FilterSize; j++)
                        {

                            roivector3[0, tmp3] = roi[0, i, j];
                            roivector3[1, tmp3] = roi[1, i, j];
                            roivector3[2, tmp3] = roi[2, i, j];
                            tmp3++;

                        }
                    }

                    int tmp4 = 0;
                    for (int i = (FilterSize - 1); i < roi.GetLength(0); i++)
                    {
                        for (int j = (FilterSize - 1); j < roi.GetLength(1); j++)
                        {

                            roivector4[0, tmp4] = roi[0, i, j];
                            roivector4[1, tmp4] = roi[1, i, j];
                            roivector4[2, tmp4] = roi[2, i, j];
                            tmp4++;

                        }
                    }
                    // tutaj

                    Double[] avgR = new Double[4] { 0, 0, 0, 0 };
                    Double[] avgG = new Double[4] { 0, 0, 0, 0 };
                    Double[] avgB = new Double[4] { 0, 0, 0, 0 };

                    Double[] varR = new Double[4] { 0, 0, 0, 0 };
                    Double[] varG = new Double[4] { 0, 0, 0, 0 };
                    Double[] varB = new Double[4] { 0, 0, 0, 0 };

                    for (int i = 0; i < FilterSize * FilterSize; i++)
                    {

                        avgR[0] += Convert.ToDouble(roivector1[0, i]) / (FilterSize * FilterSize);
                        avgR[1] += Convert.ToDouble(roivector2[0, i]) / (FilterSize * FilterSize);
                        avgR[2] += Convert.ToDouble(roivector3[0, i]) / (FilterSize * FilterSize);
                        avgR[3] += Convert.ToDouble(roivector4[0, i]) / (FilterSize * FilterSize);

                        avgG[0] += Convert.ToDouble(roivector1[1, i]) / (FilterSize * FilterSize);
                        avgG[1] += Convert.ToDouble(roivector2[1, i]) / (FilterSize * FilterSize);
                        avgG[2] += Convert.ToDouble(roivector3[1, i]) / (FilterSize * FilterSize);
                        avgG[3] += Convert.ToDouble(roivector4[1, i]) / (FilterSize * FilterSize);

                        avgB[0] += Convert.ToDouble(roivector1[2, i]) / (FilterSize * FilterSize);
                        avgB[1] += Convert.ToDouble(roivector2[2, i]) / (FilterSize * FilterSize);
                        avgB[2] += Convert.ToDouble(roivector3[2, i]) / (FilterSize * FilterSize);
                        avgB[3] += Convert.ToDouble(roivector4[2, i]) / (FilterSize * FilterSize);

                    }

                    for (int i = 0; i < FilterSize * FilterSize; i++)
                    {

                        varR[0] += Math.Pow((Convert.ToDouble(roivector1[0, i]) - avgR[0]), 2) / (FilterSize * FilterSize);
                        varR[1] += Math.Pow((Convert.ToDouble(roivector2[0, i]) - avgR[1]), 2) / (FilterSize * FilterSize);
                        varR[2] += Math.Pow((Convert.ToDouble(roivector3[0, i]) - avgR[2]), 2) / (FilterSize * FilterSize);
                        varR[3] += Math.Pow((Convert.ToDouble(roivector4[0, i]) - avgR[3]), 2) / (FilterSize * FilterSize);

                        varG[0] += Math.Pow((Convert.ToDouble(roivector1[1, i]) - avgG[0]), 2) / (FilterSize * FilterSize);
                        varG[1] += Math.Pow((Convert.ToDouble(roivector2[1, i]) - avgG[1]), 2) / (FilterSize * FilterSize);
                        varG[2] += Math.Pow((Convert.ToDouble(roivector3[1, i]) - avgG[2]), 2) / (FilterSize * FilterSize);
                        varG[3] += Math.Pow((Convert.ToDouble(roivector4[1, i]) - avgG[3]), 2) / (FilterSize * FilterSize);

                        varB[0] += Math.Pow((Convert.ToDouble(roivector1[2, i]) - avgB[0]), 2) / (FilterSize * FilterSize);
                        varB[1] += Math.Pow((Convert.ToDouble(roivector2[2, i]) - avgB[1]), 2) / (FilterSize * FilterSize);
                        varB[2] += Math.Pow((Convert.ToDouble(roivector3[2, i]) - avgB[2]), 2) / (FilterSize * FilterSize);
                        varB[3] += Math.Pow((Convert.ToDouble(roivector4[2, i]) - avgB[3]), 2) / (FilterSize * FilterSize);

                    }

                    int minIndexR = System.Array.IndexOf(varR, varR.Min());
                    int minIndexG = System.Array.IndexOf(varG, varG.Min());
                    int minIndexB = System.Array.IndexOf(varB, varB.Min());

                    newValueR = (int)avgR[minIndexR];

                    if (newValueR > 255) newValueR = 255;
                    if (newValueR < 0) newValueR = 0;

                    newValueG = (int)avgG[minIndexG];

                    if (newValueG > 255) newValueG = 255;
                    if (newValueG < 0) newValueG = 0;

                    newValueB = (int)avgB[minIndexB];

                    if (newValueB > 255) newValueB = 255;
                    if (newValueB < 0) newValueB = 0;

                    image2.SetPixel(m, n, Color.FromArgb(255, newValueR, newValueG, newValueB));
                }
            }

            return image2;
        }
开发者ID:litdev1,项目名称:LitDev,代码行数:101,代码来源:FIP.cs


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