292 int degree, gridsize, length;
294 double *scratch, *result, *gridbuf, *mm;
295 double *xdata, *ydata;
296 bool rot, increasing;
297 double dx, dy, lx = 0, ly = 0;
307 fprintf(
cp_err,
"Error: polydegree is %d, can't plot...\n",
314 if ((gridsize < 0) || (gridsize > 10000)) {
315 fprintf(
cp_err,
"Error: bad grid size %d\n", gridsize);
318 if (gridsize && xs) {
321 for (i = 0; i < xs->
v_length - 1; i++)
325 "Warning: scale not monotonic, gridsize not relevant.\n");
333 for (i = 0; i < xs->
v_length - 1; i++)
337 "Warning: scale not monotonic, gridsize not relevant.\n");
365 0.0, (j==i ? 1 : i));
383 if ((degree == 1) && (gridsize == 0)) {
384 for (i = 0, j = v->
v_length; i < j; i++) {
399 if (gridsize < degree + 1)
404 gridbuf = (
double *)
tmalloc(gridsize *
sizeof (
double));
405 result = (
double *)
tmalloc(gridsize *
sizeof (
double));
424 dx = (mm[1] - mm[0]) / gridsize;
426 for (i = 0, dy = mm[0]; i < gridsize; i++, dy += dx)
429 for (i = 0, dy = mm[1]; i < gridsize; i++, dy -= dx)
433 fprintf(
cp_err,
"Error: can't put %s on gridsize %d\n",
441 for (i = 0; i < gridsize; i++)
442 gr_point(v, gridbuf[i], result[i], gridbuf[i ? (i - 1)
443 : i], result[i ? (i - 1) : i], -1);
457 scratch = (
double *)
tmalloc((degree + 1) * (degree + 2) *
459 result = (
double *)
tmalloc((degree + 1) *
sizeof (double));
460 xdata = (
double *)
tmalloc((degree + 1) *
sizeof (double));
461 ydata = (
double *)
tmalloc((degree + 1) *
sizeof (double));
469 for (i = 0; i <= degree; i++)
475 for (i = 0; i <= degree; i++)
479 while (!
ft_polyfit(xdata, ydata, result, degree, scratch)) {
484 if (
ft_polyfit(ydata, xdata, result, degree, scratch)) {
489 fprintf(
cp_err,
"plotcurve: Internal Error: ack...\n");
495 for (i = 0; i < degree; i++)
507 for (l = degree + 1; l < length; l++) {
510 for (i = 0; i < degree; i++) {
511 xdata[i] = xdata[i + 1];
512 ydata[i] = ydata[i + 1];
524 while (!
ft_polyfit(xdata, ydata, result, degree, scratch)) {
525 if (
ft_polyfit(ydata, xdata, result, degree, scratch)) {
531 "plotcurve: Internal Error: ack...\n");
537 result, degree,
true);
540 result, degree,
false);
static void plotinterval()
bool cp_getvar(char *n, int t, char *r)
void gr_point(struct dvec *dv, double newx, double newy, double oldx, double oldy, int np)