/* Tools for generating figures for IA/AA papers. */ /* Last edited on 2007-01-04 04:22:36 by stolfi */ #ifndef figprocs_H #define figprocs_H #include #include #include #include #include /* DATA TYPES */ typedef Float fpFunction (Float x); typedef AAP aaFunction (AAP x); typedef Interval iaFunction (Interval x); /* Command line options passed to the program: */ typedef struct PlotOptions { bool_t eps; /* TRUE for Encapsulated Postscript. */ bool_t color; /* TRUE uses colors, FALSE uses only grays. */ bool_t frame; /* TRUE to draw a frame around eac figure. */ char *outName; /* Prefix for output file names. */ double fontSize; /* Font size for graph labels and such. */ } PlotOptions; /* Plotting window and scales: */ typedef struct WinData { Interval xpt; /* X range of plot window. */ Interval ypt; /* Y range of plot window. */ double scale; /* Plot scale (mm per client unit). */ } WinData; /* Essential parameters for a "function graph" figure: */ typedef struct GraphData { char *tag; /* Function name (for output file names). */ char *descr; /* Function description. */ Interval xfp; /* X range for floating-point graph. */ int nfp; /* Number of steps in floating-point graph. */ Interval xia; /* X range for IA/AA graph. */ int nia; /* Number of sub-intervals in IA/AA graph. */ fpFunction *fp; /* Floating-point implementation. */ iaFunction *ia; /* Interval arithmetic implementation. */ aaFunction *aa; /* Affine arithmetic implementation. */ } GraphData; /* Essential parameters for an "affine approximation" figure: */ typedef struct ApproxData { char * tag; /* Approximation name (for output file names). */ Interval xap; /* X range of affine approximation. */ Float alpha; /* Slope. */ Float gamma; /* Intercept. */ Float delta; /* Error bound. */ } ApproxData; /* Essential parameters for a "joint range" figure: */ typedef struct RangeData { char * tag; /* Joint range name (for output file names). */ AAP x; /* The X coordinate. */ AAP y; /* The Y coordinate. */ AAP z; /* The Z coordinate, if applicable. */ } RangeData; /* FIGURE-DRAWING PROCEDURES */ /* The following procedures generate postscript files whose names start with {o->outName}, containing one or more figures. If {o->eps} is TRUE, each figure is written to a separate Encapsulated Postscript file, whose name has the form "{o->outName}-{figtag}.eps", for varying {figtag}s. The files will NOT contain "showpage" commands or captions. If {o->eps} is 0 (false), all figures are written to a single plain Postscript file ("{o->outName}.ps"), with one figure per page, with captions. The {XXXData} arguments define the functions to be plotted, the plotting area, scales, etc. In all procedures, the {title} string is a comment, used for progress reporting. */ void figprocs_plot_ia_ar_aa_graphs(PlotOptions *o, WinData *w, GraphData *g, char *title); /* Generates three figures, showing the graph of a function {g(x)} evaluated with ordinary interval arithmetic (by {g->ia}), affine arithmetic (by {g->aa}), and affine artihmetic converted to intervals. The IA and AA graphs cover the interval {g->xia}, divided into {g->nia} equal sub-intervals. Each plot also shows the graph of {g->fp} computed with floating point, with {g->nfp} equal steps over the interval {g->xfp}. If {o->eps} is true, writes three files "{o->outName}-ia.eps", "{o->outName}-aa.eps", "{outName}-ar.eps"; else writes a single file "{o->outName}.ps" The functions {f_fp}, {f_ia} and {f_aa} should be floating-point, IA and AA implementations of {f}. Arg {n} is the number of intervals into which {xd} is to be divided. Arg {m} is the number of steps for the graph of {f_fp}. */ void figprocs_plot_approx(PlotOptions *o, WinData *w, GraphData *g, ApproxData *ga, char *title); /* Generates a single figure showing the graph of a funtion {g(x)}, and the affine approximation described by {ga}. The floating-point plot uses the procedure {g->fp}, over on the interval {g->xfp}, in {g->nfp} equal steps. The function {ga} is plotted as the straight line {ga(x) = ga->alpha*x + ga->gamma}, plotted over the interval {ga->xap} slightly extended; and the parallelogram {(x,ga(x) ± ga->delta), x \in ga->xap}. If {o->eps} is TRUE, the file is "{o->outName}.eps", else it is "{o->outName}.ps". */ void figprocs_plot_joint_range(PlotOptions *o, WinData *w, RangeData *jr, char *title); /* Generates a figure showing the joint range of the affine forms {jr->x,jr->y}. If {jr->showBox} is true, also shows the IA box derived from the affine forms. If {o->eps} is TRUE, the file is "{o->outName}.eps", else it is "{o->outName}.ps". */ #endif