Aller au contenu

Mathc initiation/0004

Un livre de Wikilivres.


Sommaire


Installer ce fichier dans votre répertoire de travail.

kg_fabp.h
/* --------------------------------- */
/* save as  kg_fabp.h                */
/* --------------------------------- */
void G_fabp_2d(
CTRL_splot                w,
double     (*P_f)(double x),
tvalue                    p
)
{
FILE *fp = fopen("a_main.plt","w");

double i = p.min;

fprintf(fp," reset\n"
           " set zeroaxis lt 8\n"
           " set grid\n\n"
           " set size ratio -1\n"
           " plot [%0.3f:%0.3f] [%0.3f:%0.3f]\\\n"
           " \"a\"    with linesp lt 7 lw 3 pt 1,\\\n"
           " \"b\"    with linesp lt 7 lw 3 pt 1,\\\n"
           " \"fab\"  with line   lt 8 lw 3,\\\n"
           " \"p\"    with linesp lt 6 lw 5 ps 3\n\n",
             w.xmin,w.xmax,w.ymin,w.ymax);
  fclose(fp);


  fp = fopen("a",  "w");
     fprintf(fp," %0.6f   %0.6f\n", p.min, (*P_f)(p.min));
     fprintf(fp," %0.6f   %0.6f\n", p.min, 0.0);
      fclose(fp);


  fp = fopen("b",  "w");
     fprintf(fp," %0.6f   %0.6f\n", p.max, (*P_f)(p.max));
     fprintf(fp," %0.6f   %0.6f\n", p.max, 0.0);
      fclose(fp);
      
                
  fp = fopen("fab",  "w");
  do{ 
	  fprintf(fp," %0.6f   %0.6f\n", i,(*P_f)(i));
      i += p.step;
    }while(i <= p.max + p.step);
  fclose(fp);
          
          
  fp = fopen("p","w");
  fprintf(fp,"  %6.5f  %6.5f  \n", p.value, (*P_f)(p.value));
   fclose(fp);   
}
/* --------------------------------- */
/* --------------------------------- */