示例#1
0
        public void addTerm(term t)
        {
            int  i;
            frac zero = new frac(0);

            if ((i = canJoin(ref t)) >= 0)
            {
                terms[i].c += t.c;
                if (terms[i].c == zero)
                {
                    delTerm(i);
                }
            }
            else if (count < terms.Length)
            {
                terms[count] = new term(t);
                count++;
                if (terms[count - 1].c == zero)
                {
                    delTerm(count - 1);
                }
            }
            else
            {
                throw new Exception("poly is full!");
            }
        }
示例#2
0
        public term integralX()
        {
            term temp = new term(this);

            temp.xp++;
            temp.c /= new frac(temp.xp);
            return(temp);
        }
示例#3
0
 public poly(poly p)
 {
     count = p.count;
     for (int i = 0; i < count; i++)
     {
         terms[i] = new term(p.terms[i]);
     }
 }
示例#4
0
        public static poly operator -(poly p1, poly p2)
        {
            poly a   = new poly();
            term neg = new term(-1);

            a.extend(p1);
            a.extend(neg * p2);
            return(a);
        }
示例#5
0
 public int canJoin(ref term t)
 {
     for (int i = 0; i < count; i++)
     {
         if (t.xp == terms[i].xp && t.yp == terms[i].yp)
         {
             return(i);
         }
     }
     return(-1);
 }
示例#6
0
 public term(term t)
 {
     c = t.c; xp = t.xp; yp = t.yp;
 }
示例#7
0
 public poly(term t)
 {
     addTerm(t);
 }
示例#8
0
 static poly pol(term t)
 {
     return(new poly(t));
 }