Beispiel #1
0
 public void ProcessArrayTest(double[] data, double expectedAvg, double eps)
 {
     CustomArrayUtils.ProcessArray(data, out double min, out double max, out double avg);
     Array.Sort(data);
     Assert.IsTrue(Math.Abs(expectedAvg - avg) <= eps);
     Assert.IsTrue(Math.Abs(data[0] - min) <= eps);
     Assert.IsTrue(Math.Abs(data[data.Length - 1] - max) <= eps);
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            double    startX = 1, dx = 0.5;
            const int size = 10;

            double[] arr = CustomArrayUtils.CreateArrayFromTemplate(startX, dx, size, x => Func2(x * 2.76, x * 0.5));
            CustomArrayUtils.PrintArray(arr);

            CustomArrayUtils.ProcessArray(arr, out double min, out double max, out double avg);

            Console.WriteLine("Min={0:#0.####}, Max={1:#0.####}, Avg={2:#0.####}", min, max, avg);

            int count = CustomArrayUtils.PostProcessArray(arr, x => x >= 0.9 * avg && x <= 1.1 * avg);

            Console.WriteLine("R={0}", count);
        }