public frac value(int x, int y) { frac a = frac.pow(new frac(x), xp); frac b = frac.pow(new frac(y), yp); return(new frac(a * b * c)); }
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!"); } }
public frac value(frac x, frac y) { frac a = frac.pow(x, xp); frac b = frac.pow(y, yp); return(new frac(a * b * c)); }
public static frac pow(frac f, int p) { frac ret = new frac(1); for (int i = 0; i < p; i++) { ret *= f; } return(ret); }
public frac value(int x, int y) { frac s = new frac(0); for (int i = 0; i < count; i++) { s += terms[i].value(x, y); } return(s); }
static frac doubleItgYX(poly f, poly y_x0, poly y_x1, frac x0, frac x1) { frac res = new frac(0); f.print(); poly iy_f = f.integralY(); iy_f.print(); poly f_x = iy_f.substitudeY(y_x1) - iy_f.substitudeY(y_x0); f_x.print(); poly F = f_x.integralX(); F.print(); res = F.value(x1, new frac(0)) - F.value(x0, new frac(0)); return(res); }
static public frac sub(frac frac1, frac frac2) { frac frac0 = sum(frac1.X, frac1.Y, -1 * frac2.X, frac2.Y); return(frac0); }
//减法运算 static public frac sub(int a, int b, int c, int d) { frac frac0 = sum(a, b, -1 * c, d); return(frac0); }
static public frac sum(frac frac1, frac frac2) { return(sum(frac1.X, frac1.Y, frac2.X, frac2.Y)); }
public frac(frac s) { X = s.X; Y = s.Y; }
static public frac dev(frac frac1, frac frac2) { return(mul(frac1.X, frac1.Y, frac2.Y, frac2.X)); }
public term(term t) { c = t.c; xp = t.xp; yp = t.yp; }
public term(frac coe, int x_p = 0, int y_p = 0) { c = coe; xp = x_p; yp = y_p; }
public term(int coe, int x_p = 0, int y_p = 0) { c = new frac(coe); xp = x_p; yp = y_p; }
static term ter(frac coe, int x_p = 0, int y_p = 0) { return(new term(coe, x_p, y_p)); }