void save_poly(char* fname, vector<T>& poly_params, const int degX, const int degY) { int sizex = (degX + 1) * (degX + 2) / 2; int sizey = (degY + 1) * (degY + 2) / 2; vector<T> paramsX = poly_params.copyRef(0, sizex-1); vector<T> paramsY = poly_params.copyRef(sizex, sizex+sizey-1); FILE *pfile; pfile = fopen(fname, "wt"); if(pfile == NULL) error("cannot open file %s.\n", fname); int idx = 0; fprintf(pfile, "# polyX(x,y): \n"); for (int i = degX; i >= 0; i--) { for (int j = 0; j <= i; j++) { printMono(pfile, paramsX[idx], i-j, j); idx++; } } idx = 0; fprintf(pfile, "# polyY(x,y): \n"); for (int i = degY; i >= 0; i--) { for (int j = 0; j <= i; j++) { printMono(pfile, paramsY[idx], i-j, j); idx++; } } fclose(pfile); }
vector<T> polyInv(const vector<T>& poly_params, const int degX, const int degY, int wi, int he, T xp, T yp) { int sizex = (degX + 1) * (degX + 2) / 2; int sizey = (degY + 1) * (degY + 2) / 2; return getParamsInv(poly_params.copyRef(0, sizex-1), poly_params.copyRef(sizex, sizex+sizey-1), degX, degY, wi, he, xp, yp);; }