Exemplo n.º 1
0
static void printMath2 (FILE * f, double x, double y)
{
   /* Writes the pair (x, y) in file f, in a format understood */
   /* by Mathematica */
   char S[41];

   fprintf (f, "   { ");
   if ((x != 0.0) && (x < 0.1 || x > 1.0)) {
      sprintf (S, "%16.7E", x);
      mystr_Subst (S, "E", "*10^(");
      strcat (S, ")");
   } else {
      sprintf (S, "%16.8g", x);
   }
   fprintf (f, ",     ");

   if (y != 0.0 && (y < 0.1 || y > 1.0)) {
      sprintf (S, "%16.7E", y);
      mystr_Subst (S, "E", "*10^(");
      strcat (S, ")");
   } else {
      sprintf (S, "%16.8g", y);
   }
   fprintf (f, " }");
}
Exemplo n.º 2
0
void tables_WriteMatrixD (double **Mat, int i1, int i2, int j1, int j2,
                          int w, int p, tables_StyleType style, char Nom[])
{
    int k;
    int m;
    int j;
    int i;
    size_t bidon;
    double prec;
    double x;
    size_t trouve;
    char S[32];

    FixeDelim (style);
    if (strlen (Nom) > 0) {
        printf ("%s = ", Nom);
    }
    prec = pow (10.0, (double) p);
    printf ("%c\n", OuvrantMat);
    for (i = i1; i <= i2; i++) {
        printf ("%c", OuvrantVec);
        for (j = j1; j <= j2; j++) {
            printf (" ");
            switch (style) {
            case tables_Mathematica:
                x = Mat[i][j];
                if (((x != 0.0) && (fabs (x) < 0.1)) || (fabs (x) > prec)) {
                    sprintf (S, "%.*G", (int) p, x);
                    /* automatique avec %G ... : myst_Subst(S, "e", "E"); */
                    mystr_Position ("E", S, 0, &bidon, &trouve);
                    if (trouve) {
                        mystr_Subst (S, "E", "*10^(");
                        strncat (S, ")", (size_t) 2);
                    }
                } else
                    sprintf (S, "%.*f", (int) p, x);
                m = (int) strlen (S);
                for (k = 1; k <= w - m; k++) {
                    printf (" ");
                }
                printf ("%s", S);
                break;
            default:
                /* tables_Matlab, Default */
                printf ("%*.*G", (int) w, (int) p, Mat[i][j]);
                break;
            }
            if (j < j2)
                printf ("%c", SepareElem);
        }
        printf ("%c", FermantVec);
        if (i < i2)
            printf ("%c\n", SepareVec);
    }
    printf ("%c\n\n", FermantMat);
}
Exemplo n.º 3
0
static void BottomGraphTex (
   unif01_Gen *gen,
   FILE *f               /* Latex output file */
   )
/*
 * Write the Latex commands after the points have been written.
 */
{
   const double Epsilon = 1.0E-32;
   int j;
   char *p;
   size_t len;

   fprintf (f, "/ \\endpicture\n\n");
   /* fprintf (f, "\\parindent=0pt\n"); */
   fprintf (f,
           "\\def\\bornes#1#2#3 {$\\null\\ \\ \\ #2 < u_{n+#1} < #3$\\\\ }\n"
           "\\def\\bornez#1#2 {$\\null\\ \\ \\ #1 < u_{n} < #2$\\\\ }\n"
           "\\def\\stat#1#2 {\n"
           "Number of vectors generated: \\hbox to 1in {\\hfil #1.}\\\\\n"
           "Number of points plotted: \\hbox to 1in {\\hfil #2.}\\\\ }\n\n"
           "\\bigskip\\noindent {\\bf Generator:} \n");

   if ((p = strstr (gen->name, "Read"))) {
      /* This generator is from ufile. Write complete generator's name */
      strncpy (Title, gen->name, (size_t) LEN);
      p = strchr (gen->name, '\n');
      if (p)
         mystr_Subst (Title, "\n", "\n\n");
   } else {
      /* Remove initial seeds from gen name, but write filter if any */
      p = strchr (gen->name, ':');
      len = p - gen->name;
      strncpy (Title, gen->name, (size_t) len);
      Title[len] = '\0';
      p = strchr (gen->name, '\n');
      if (p) {
         strcat (Title, "\n");
         strcat (Title, p);
      }
   }

   /* Replace the _ in the generator name by \_ for Latex */
   mystr_Subst (Title, "_", "\\_");
   mystr_Subst (Title, "01_", "01\\_");
   fprintf (f, Title);

   fprintf (f, "\n\nHypercube in %1d dimensions.\\\\\n", scatter_t);
   fprintf (f, " Over = ");
   if (scatter_Over)
      fprintf (f, "TRUE");
   else
      fprintf (f, "FALSE");

   fprintf (f, "\\\\\n");
   for (j = 1; j <= scatter_t; j++) {
      if (scatter_L[j] > Epsilon || 1.0 - scatter_H[j] > Epsilon) {
	 if (j == 1) {
	    fprintf (f, "\\bornez {%9.4G}{%9.4G}\n",
                        scatter_L[j], scatter_H[j]);
	 } else {
	    fprintf (f, "\\bornes {%1d}{%9.4G}{%9.4G}\n",
                        j - 1, scatter_L[j], scatter_H[j]);
	 }
      }
   }
   /*
   if (scatter_Lacunary) {
      fprintf (f, "Lacunary indices = \\{");
      for (j = 0; j < scatter_t; j++) {
	if (j < scatter_t - 1)
           fprintf (f, " %ld,", scatter_LacI[j]);
        else
           fprintf (f, " %ld", scatter_LacI[j]);
      }
      fprintf (f, " \\}\\\\\n");
   }
   */
   fprintf (f, "\\stat {%10ld}{%10ld}\n", scatter_N, scatter_Nkept);
   fprintf (f, "Total CPU time : %12.2f", chrono_Val (chro, chrono_sec));
   fprintf (f, " seconds.\n"
               "\\end {figure}\n"
               "\\end {document}\n");
}