Пример #1
0
        public void TestMax()
        {
            double[] d = new double[100];
            d[0]  = 1.1; d[1] = 2.1; d[2] = 3.1; d[3] = 4.1;
            d[4]  = 5.1; d[5] = 6.1; d[6] = 7.1; d[7] = 8.1;
            d[8]  = 9.1; d[9] = 10.1; d[10] = 11.1; d[11] = 12.1;
            d[12] = 13.1; d[13] = 14.1; d[14] = 15.1; d[15] = 16.1;
            d[16] = 17.1; d[17] = 18.1; d[18] = 19.1; d[19] = 20.1;

            double m = MathX.Max(d);

            AssertEquals("Max ", 20.1, m);

            d = new double[1000];
            m = MathX.Max(d);
            AssertEquals("Max ", 0, m);

            d[0]  = -1.1; d[1] = 2.1; d[2] = -3.1; d[3] = 4.1;
            d[4]  = -5.1; d[5] = 6.1; d[6] = -7.1; d[7] = 8.1;
            d[8]  = -9.1; d[9] = 10.1; d[10] = -11.1; d[11] = 12.1;
            d[12] = -13.1; d[13] = 14.1; d[14] = -15.1; d[15] = 16.1;
            d[16] = -17.1; d[17] = 18.1; d[18] = -19.1; d[19] = 20.1;
            m     = MathX.Max(d);
            AssertEquals("Max ", 20.1, m);

            d     = new double[20];
            d[0]  = -1.1; d[1] = -2.1; d[2] = -3.1; d[3] = -4.1;
            d[4]  = -5.1; d[5] = -6.1; d[6] = -7.1; d[7] = -8.1;
            d[8]  = -9.1; d[9] = -10.1; d[10] = -11.1; d[11] = -12.1;
            d[12] = -13.1; d[13] = -14.1; d[14] = -15.1; d[15] = -16.1;
            d[16] = -17.1; d[17] = -18.1; d[18] = -19.1; d[19] = -20.1;
            m     = MathX.Max(d);
            AssertEquals("Max ", -1.1, m);
        }
Пример #2
0
 protected internal override double Evaluate(double[] values)
 {
     return(values.Length > 0 ? MathX.Max(values) : 0);
 }