Exemplo n.º 1
0
        /// <summary>
        /// Gets the S-polynomial as defined in section 2.6 of CLO
        /// </summary>
        /// <param name="other">The other polynomial with respect to which the S-polynomial is to be calculated.s</param>
        /// <returns>The S-polynomial of the combination - this and other.</returns>
        public Polynomial GetSPolynomial(Polynomial other)
        {
            Monomial lcm = this.GetLeadingTerm().LCM(other.GetLeadingTerm());

            Polynomial thisTerm = new Polynomial(this);

            thisTerm.MultiplyMonomial(lcm.DivideBy(this.GetLeadingTerm()));
            thisTerm.MultiplyScalar(1 / this.GetLeadingCoefficient());

            Polynomial otherTerm = new Polynomial(other);

            otherTerm.MultiplyMonomial(lcm.DivideBy(other.GetLeadingTerm()));
            otherTerm.MultiplyScalar(1 / other.GetLeadingCoefficient());

            thisTerm.Add(otherTerm, -1);

            return(thisTerm);
        }