/* See {minn_plot.h}. */ /* Last edited on 2023-03-27 17:39:11 by stolfi */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include void minn_plot_goal ( FILE *wr, int32_t n, double u0[], double urad0, double u1[], double urad1, bool_t box, double step, minn_goal_t *F ) { /* ; */ minn_plot_print_vector(stderr, "u0", n, u0, urad0); minn_plot_print_vector(stderr, "u1", n, u1, urad1); /* Plot on a grid along {u0,u1}: */ int32_t n0 = (int32_t)floor(urad0/step + 0.001); int32_t n1 = (int32_t)floor(urad1/step + 0.001); double rad_fudge = 1.0e-10; /* Fudge to get edges of grid inside the domain. */ double v[n]; /* Probe vector. */ for (int32_t i0 = -n0; i0 <= +n0; i0++) { double s0 = i0*step; for (int32_t i1 = -n1; i1 <= +n1; i1++) { double s1 = i1*step; bool_t inside = (box ? TRUE : hypot(s0/urad0, s1/urad1) <= 1.0 + rad_fudge); if (inside) { /* Compute the probe vector {v[0..n-1]}. */ rn_mix(n, s0, u0, s1, u1, v); /* Evaluate the function and plot: */ double Fval = F(n, v); fprintf(wr, "%+9.6f %+9.6f %12.6f\n", s0, s1, Fval); } } /* Blank line between scanlines, for {gnuplot}: */ fprintf(wr, "\n"); } fflush(wr); return; } void minn_plot_print_vector(FILE *wr, char *name, int32_t n, double u[], double urad) { fprintf(wr, " %s = ", name); rn_print(wr, n, u); fprintf(wr, " rad = %12.7f\n", urad); }