Mathc matrices/a98

Un livre de Wikilivres.


Application

Installer et compiler ce fichier dans votre répertoire de travail.

c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h" 
/* ------------------------------------ */
/* ------------------------------------ */
#define  TAB  C3
#define   RA  R3
#define   CA  C1
#define   CB  RA+C1
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A[TAB];
double **T[TAB];
double   s[TAB];

double **B  =        i_mR(RA,CB);
double **ID = eye_mR(i_mR(RA,RA));
int c;
   
  clrscrn();
                
  for(c=C0; c<TAB; c++)
     {
      T[c] = i_mR(RA,CA);
      
      c_c_mR(ID,c+C1, T[c],C1); 
      c_c_mR(T[c],C1, B,c+C1);
     }
  
  printf(" The Three Standard Columns Vectors \n\n"  
         "    A[0]   A[1]   A[2] :");	     
  p_mR(B,S6,P0,C10);
  
  stop();

  clrscrn();

  for(c=C0; c<TAB; c++)
     {
	  A[c] = i_mR(RA,CA);	 
      s[c] = r_I(9);

      smul_mR(s[c],T[c],A[c]);
      c_c_mR(A[c],C1, B,c+C1);
     } 
     
  add_mR(A[0],A[1],T[0]); 
  add_mR(T[0],A[2],T[1]); 
  c_c_mR(T[1],C1, B,CB);
   
  printf(" V is a linear combination of    \n"  
         " the three Standard Columns Vectors of R_3 :\n\n"       
         "    %+.0f*A[0]  %+.0f*A[1]  %+.0f*A[1]     V",s[0],s[1],s[2]);	     
  p_mR(B,S8,P0,C10);

  for(c=C0; c<TAB; c++)
     {
       f_mR(A[c]); 
       f_mR(T[c]);        
     }   
       
  f_mR(B);
  f_mR(ID);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  fun();

} while(stop_w());

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


L'affichage des vecteurs d'une colonne prend trop de place. J'ai donc tenté de les installer dans une matrice avant de les afficher.


Exemple de sortie écran :

 ------------------------
 The Three Standard Columns Vectors 

    A[0]   A[1]   A[1] :
    +1     +0     +0     +0 
    +0     +1     +0     +0 
    +0     +0     +1     +0 

 Press return to continue. 


 ------------------------
 V is a linear combination of    
 the three Standard Columns Vectors of R_3 :

    -3*A[0]  +5*A[1]  -4*A[1]     V
      -3       +0       -0       -3 
      -0       +5       -0       +5 
      -0       +0       -4       -4 


 Press   return to continue
 Press X return to stop