Exemple #1
0
        // Token: 0x060004F1 RID: 1265 RVA: 0x0001A4B8 File Offset: 0x000186B8
        private static bool AllRealPartsNegative(int degree, double[] coeff)
        {
            if (coeff[degree - 1] <= 0.0)
            {
                return(false);
            }
            if (degree == 1)
            {
                return(true);
            }
            double[] array = new double[degree];
            array[0] = 2.0 * coeff[0] * coeff[degree - 1];
            for (int i = 1; i <= degree - 2; i++)
            {
                array[i] = coeff[degree - 1] * coeff[i];
                if ((degree - i) % 2 == 0)
                {
                    array[i] -= coeff[i - 1];
                }
                array[i] *= 2.0;
            }
            array[degree - 1] = 2.0 * coeff[degree - 1] * coeff[degree - 1];
            int num = degree - 1;

            while (num >= 0 && array[num] == 0.0)
            {
                num--;
            }
            for (int i = 0; i <= num - 1; i++)
            {
                coeff[i] = array[i] / array[num];
            }
            return(PolynomialRoots.AllRealPartsNegative(num, coeff));
        }
Exemple #2
0
        // Token: 0x060004F0 RID: 1264 RVA: 0x0001A3E4 File Offset: 0x000185E4
        public bool AllRealPartsPositive(Polynomial1 poly)
        {
            int degree = poly.Degree;

            double[] array = new double[degree + 1];
            int      num   = 0;

            foreach (double num2 in poly.Coefficients)
            {
                array[num++] = num2;
            }
            int i;

            if (array[degree] != 1.0)
            {
                double num3 = 1.0 / array[degree];
                for (i = 0; i < degree; i++)
                {
                    array[i] *= num3;
                }
                array[degree] = 1.0;
            }
            int num4 = -1;

            i = degree - 1;
            while (i >= 0)
            {
                array[i] *= (double)num4;
                i--;
                num4 = -num4;
            }
            return(PolynomialRoots.AllRealPartsNegative(degree, array));
        }