Aller au contenu

Mathc complexes/Fichiers h : vfpm

Un livre de Wikilivres.

Bibliothèque

Installer ce fichier dans votre répertoire de travail.

wpfm.h
/* ------------------------------------ */
/*  Save as :   wpfm.h                   */
/* ------------------------------------ */
double **fp_mZ(
double **A,
char FileName[],
char MatrixName[],
int Sr,
int Pr,
int Si,
int Pi,
int Cn
)
{
FILE * fp = fopen(FileName,"a");

int r;
int c;
int n_c;
int n_c_LAST;
int n_c_FIRST;

fprintf(fp,"%s",MatrixName);


n_c = R1;

while(n_c<A[C_SIZE][C0])
     {
      n_c+=Cn*C2;
                          n_c_FIRST = n_c-Cn*C2;
      if(n_c<A[C_SIZE][C0])n_c_LAST  = n_c;
      else                n_c_LAST  = A[C_SIZE][C0];

 	  for(r=R1; r<A[R_SIZE][C0]; r++)
         {
          fprintf(fp,"\n");
 	      for (c=n_c_FIRST; c<n_c_LAST; c+=C2)
               fprintf(fp,"%+*.*f%+*.*fi ",Sr,Pr,A[r][c],Si,Pi,A[r][c+C1]);
          }
      fprintf(fp,"\n");
     }
fprintf(fp,"\n");

fclose(fp);

return(A);
}
/* ------------------------------------ */
double **fpE_mZ(
double **A,
char FileName[],
char MatrixName[],
int Sr,
int Pr,
int Si,
int Pi,
int Cn
)
{
FILE * fp = fopen(FileName,"a");

int r;
int c;
int n_c;
int n_c_LAST;
int n_c_FIRST;

fprintf(fp,"%s",MatrixName);

n_c = R1;

while(n_c<A[C_SIZE][C0])
     {
      n_c+=Cn*C2;
                          n_c_FIRST = n_c-Cn*C2;
      if(n_c<A[C_SIZE][C0])n_c_LAST  = n_c;
      else                n_c_LAST  = A[C_SIZE][C0];

 	  for(r=R1; r<A[R_SIZE][C0]; r++)
         {
          fprintf(fp,"\n");
 	      for (c=n_c_FIRST; c<n_c_LAST; c+=C2)
               fprintf(fp,"%+*.*e%+*.*ei ",Sr,Pr,A[r][c],Si,Pi,A[r][c+C1]);
          }
      fprintf(fp,"\n");
     }
fprintf(fp,"\n");

fclose(fp);

return(A);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **fP_mZ(
double **A,
char FileName[],
char MatrixName[],
int Sr,
int Pr,
int Si,
int Pi,
int Cn
)
{
FILE * fp = fopen(FileName,"a");

int r;
int c;
int n_c;
int n_c_LAST;
int n_c_FIRST;

fprintf(fp,"%s",MatrixName);


n_c = R1;

while(n_c<A[C_SIZE][C0])
     {
      n_c+=Cn*C2;
                          n_c_FIRST = n_c-Cn*C2;
      if(n_c<A[C_SIZE][C0])n_c_LAST  = n_c;
      else                n_c_LAST  = A[C_SIZE][C0];

 	  for(r=R1; r<A[R_SIZE][C0]; r++)
         {
          fprintf(fp,"\n");
 	      for (c=n_c_FIRST; c<n_c_LAST; c+=C2)
               fprintf(fp,"%+*.*f,%+*.*f, ",Sr,Pr,A[r][c],Si,Pi,A[r][c+C1]);
          }
      fprintf(fp,"\n");
     }
fprintf(fp,"\n");

fclose(fp);

return(A);
}
/* ------------------------------------ */
double **fPE_mZ(
double **A,
char FileName[],
char MatrixName[],
int Sr,
int Pr,
int Si,
int Pi,
int Cn
)
{
FILE * fp = fopen(FileName,"a");

int r;
int c;
int n_c;
int n_c_LAST;
int n_c_FIRST;

fprintf(fp,"%s",MatrixName);

n_c = R1;

while(n_c<A[C_SIZE][C0])
     {
      n_c+=Cn*C2;
                          n_c_FIRST = n_c-Cn*C2;
      if(n_c<A[C_SIZE][C0])n_c_LAST  = n_c;
      else                n_c_LAST  = A[C_SIZE][C0];

 	  for(r=R1; r<A[R_SIZE][C0]; r++)
         {
          fprintf(fp,"\n");
 	      for (c=n_c_FIRST; c<n_c_LAST; c+=C2)
               fprintf(fp,"%+*.*e,%+*.*e, ",Sr,Pr,A[r][c],Si,Pi,A[r][c+C1]);
          }
      fprintf(fp,"\n");
     }
fprintf(fp,"\n");

fclose(fp);

return(A);
}
/* ------------------------------------ */
/* ------------------------------------ */


Ces fonctions permettent d'imprimer une matrice dans un fichier.

On peut contrôler la taille des colonnes, le nombre de chiffres après la virgule, le nombre de colonnes par ligne.