Beispiel #1
0
        internal override void Operate(BinaryInterval operands, ref IntervalSet output)
        {
            Polynomial poly1  = Interval.GetPolynomial(operands.Coefficients1);
            Polynomial poly2  = Interval.GetPolynomial(operands.Coefficients2);
            Polynomial result = poly1 + poly2 - (poly1 * poly2);

            output.AddInterval(new Interval(output, operands.LowerBound, operands.UpperBound, result));
        }
Beispiel #2
0
        internal override void Operate(BinaryInterval operands, ref IntervalSet output)
        {
            Polynomial poly1 = Interval.GetPolynomial(operands.Coefficients1);
            Polynomial poly2 = Interval.GetPolynomial(operands.Coefficients2);
            Polynomial sum   = poly1 + poly2 + (new Polynomial(-1));

            BinaryInterval temp = new BinaryInterval(operands.LowerBound, operands.UpperBound, sum.Coefficients, (new Polynomial(0)).Coefficients);

            GetMinMax(temp, ref output, false);
        }
Beispiel #3
0
        internal override void Operate(BinaryInterval operands, ref IntervalSet output)
        {
            Polynomial poly1 = Interval.GetPolynomial(operands.Coefficients1);
            Polynomial poly2 = Interval.GetPolynomial(operands.Coefficients2);

            Polynomial multipl = (Operand1Power ? poly1 ^ 2 : poly1) + (Operand2Power ? poly2 ^ 2 : poly2);

            if (this.FinalDivision)
            {
                multipl = multipl / RssDescendantCount;
            }

            output.AddInterval(new Interval(output, operands.LowerBound, operands.UpperBound, multipl));
        }
Beispiel #4
0
 internal override void Operate(BinaryInterval operands, ref IntervalSet output)
 {
     GetMinMax(operands, ref output, false);
 }
Beispiel #5
0
        /// <summary>
        /// Builds minimum/maximum function for the given interval. The method is used directly in AndM and OrM, and as a part of calculation in other operators.
        /// </summary>
        /// <param name="operands"></param>
        /// <param name="output"></param>
        /// <param name="minimum"></param>

        internal static void GetMinMax(BinaryInterval operands, ref IntervalSet output, bool minimum)
        {
            //Find all points where operand1 = operand2 for the given interval

            Polynomial poly1 = Interval.GetPolynomial(operands.Coefficients1);
            Polynomial poly2 = Interval.GetPolynomial(operands.Coefficients2);

            Polynomial difference = poly1 - poly2;

            if (Interval.IsEmpty(difference)) //both opearands are equal
            {
                output.AddInterval(new Interval(output, operands.LowerBound, operands.UpperBound, poly1));
            }
            else
            {
                decimal[] roots = Interval.RealRoots(difference, operands.LowerBound, operands.UpperBound);

                if (roots.Length == 0)
                {   //just find out which function is higher for the whole interval
                    double r1 = poly1.Evaluate(new Complex((double)operands.LowerBound)).Re;
                    double r2 = poly2.Evaluate(new Complex((double)operands.LowerBound)).Re;

                    if ((minimum && r1 <= r2) || (!minimum && r1 > r2))
                    {
                        output.AddInterval(new Interval(output, operands.LowerBound, operands.UpperBound, poly1));
                    }
                    else
                    {
                        output.AddInterval(new Interval(output, operands.LowerBound, operands.UpperBound, poly2));
                    }
                }
                else
                {
                    List <decimal> crossPoints = new List <decimal>();
                    crossPoints.AddRange(roots);
                    if (!crossPoints.Contains(operands.LowerBound))
                    {
                        crossPoints.Add(operands.LowerBound);
                    }
                    if (!crossPoints.Contains(operands.UpperBound))
                    {
                        crossPoints.Add(operands.UpperBound);
                    }
                    crossPoints.Sort();

                    //Declares that value of operand1 is higher than the value of operand2 for the given range;

                    for (int i = 0; i < crossPoints.Count() - 1; i++)
                    {
                        bool firstIsPreffered;

                        if (roots.Contains(crossPoints[i]))
                        {
                            double deriv1 = poly1.Differentiate(new Complex((double)crossPoints[i])).Re;
                            double deriv2 = poly2.Differentiate(new Complex((double)crossPoints[i])).Re;
                            firstIsPreffered = (minimum && deriv1 < deriv2) || (!minimum && deriv1 > deriv2);
                        }
                        else
                        { //it must be the second one, then
                            double deriv1 = poly1.Differentiate(new Complex((double)crossPoints[i + 1])).Re;
                            double deriv2 = poly2.Differentiate(new Complex((double)crossPoints[i + 1])).Re;
                            firstIsPreffered = (minimum && deriv2 < deriv1) || (!minimum && deriv2 > deriv1);
                        }


                        output.AddInterval(new Interval(output, crossPoints[i], crossPoints[i + 1], firstIsPreffered ? poly1 : poly2));
                    }
                }
            }
        }
Beispiel #6
0
 internal virtual void Operate(BinaryInterval operands, ref IntervalSet output)
 {
     throw new NotImplementedException();
 }