Пример #1
0
        Add(RealRationalPolynomial lhs, RealRationalPolynomial rhs)
        {
            /*  nL          nR
             * p^2+2p+2    p^2+5p+6
             * ───────── + ────────
             * p^2+ p+1    p^2+3p+4
             *  dL          dR
             *
             *          dL       dR
             * 分母 = (p^2+p+1) (p^2+3p+4)
             * 分母の次数 = degree(dL) + degree(dR) + 1
             *
             *          nL       dR           nR        dL
             * 分子 = (p^2+2p+2)(p^2+3p+4) + (p^2+5p+4)(p^2+p+1)
             * 分子の次数 = degree(nL) + degree(dR) + 1 か degree(nR) * degree(dL) + 1の大きいほう
             */

            var denomL = lhs.DenomPolynomial();
            var numerL = lhs.NumerPolynomial();
            var denomR = rhs.DenomPolynomial();
            var numerR = rhs.NumerPolynomial();

            // 分母の項
            var denom = Mul(denomL, denomR);

            // 分子の項
            var numer = Add(Mul(numerL, denomR), Mul(numerR, denomL));

            return(new RealRationalPolynomial(numer, denom));
        }
Пример #2
0
        Mul(RealRationalPolynomial lhs, RealRationalPolynomial rhs)
        {
            var nl = lhs.NumerPolynomial();
            var nr = rhs.NumerPolynomial();
            var n  = Mul(nl, nr);

            var dl = lhs.DenomPolynomial();
            var dr = rhs.DenomPolynomial();
            var d  = Mul(dl, dr);

            return(new RealRationalPolynomial(n.Coeffs(), d.Coeffs()));
        }
Пример #3
0
 public RealRationalPolynomial(RealRationalPolynomial from) :
     this(from.NumerCoeffs(), from.DenomCoeffs())
 {
 }