示例#1
0
        public override bool Equals(object obj)
        {
            GeneralPolynomial f = obj as GeneralPolynomial;

            if (f == null)
            {
                return(false);
            }

            return(this.p.Equals(f.p) && this.inner.Equals(f.inner));
        }
示例#2
0
        public override Function Multiply(Function f)
        {
            GeneralPolynomial poly = f as GeneralPolynomial;

            if (poly == null || !this.inner.Equals(poly.inner))
            {
                return(base.Multiply(f));
            }

            Poly p = this.p * poly.p;

            return(new GeneralPolynomial(this.inner, p));
        }
示例#3
0
        public override Function Subtract(Function f)
        {
            GeneralPolynomial poly = f as GeneralPolynomial;

            if (poly == null || !this.inner.Equals(poly.inner))
            {
                return(base.Subtract(f));
            }

            Poly p = this.p - poly.p;

            return(new GeneralPolynomial(this.inner, p));
        }
示例#4
0
        public override Function Add(Function f)
        {
            GeneralPolynomial poly = f as GeneralPolynomial;

            if (poly == null || !this.inner.Equals(poly.inner))
            {
                return(base.Add(f));
            }

            //! f is Variable / Constant のときの処理を加える

            Poly p = this.p + poly.p;

            return(new GeneralPolynomial(this.inner, p));
        }
示例#5
0
        protected override void GetComplexPart(Function reX, Function imX, out Function reY, out Function imY)
        {
            Polynomial[] reCoef = new Polynomial[this.p.Coef.Length];
            Polynomial[] imCoef = new Polynomial[this.p.Coef.Length];

            reY = new GeneralPolynomial(reX, reCoef);
            imY = new GeneralPolynomial(reX, imCoef);

            Function z = imX / reX;

            for (int n = 0; n < this.p.Coef.Length; ++n)
            {
                reCoef[n] = new Polynomial(z, n);
                imCoef[n] = new Polynomial(z, n);

                for (int k = 0; k <= n; ++k)
                {
                    switch (k % 4)
                    {
                    case 0:
                        reCoef[n].p.Coef[k] = this.p.Coef[n] * Misc.Combination(n, k);
                        imCoef[n].p.Coef[k] = 0;
                        break;

                    case 1:
                        reCoef[n].p.Coef[k] = 0;
                        imCoef[n].p.Coef[k] = this.p.Coef[n] * Misc.Combination(n, k);
                        break;

                    case 2:
                        reCoef[n].p.Coef[k] = -this.p.Coef[n] * Misc.Combination(n, k);
                        imCoef[n].p.Coef[k] = 0;
                        break;

                    default:
                        reCoef[n].p.Coef[k] = 0;
                        imCoef[n].p.Coef[k] = -this.p.Coef[n] * Misc.Combination(n, k);
                        break;
                    }
                }
            }
        }