예제 #1
0
        public ComplexPolynomial(List <double> coeffs)
        {
            int p = coeffs.Count() - 1;

            _f = null;
            _s = "";

            foreach (double coeff in coeffs)
            {
                ComplexPolynomialTerm f1 = new ComplexPolynomialTerm(p, coeff);
                if (_f == null)
                {
                    _f = f1;
                }
                else
                {
                    _f = new ComplexAdd(_f, f1);
                }

                if (coeff != 0.0)
                {
                    if (_s.Length > 0)
                    {
                        _s += " + ";
                    }

                    if (coeff == 1.0)
                    {
                        if (p > 0)
                        {
                            _s += String.Format("x^{0}", p);
                        }
                        else
                        {
                            _s += "1";
                        }
                    }
                    else
                    {
                        if (p > 0)
                        {
                            _s += String.Format("{0}x^{1}", coeff, p);
                        }
                        else
                        {
                            _s += String.Format("{0}x", coeff);
                        }
                    }
                }

                --p;
            }
        }
예제 #2
0
 public ComplexAdd(ComplexMathFunction f1, ComplexMathFunction f2)
 {
     _f1 = f1;
     _f2 = f2;
 }