Mathc matrices/Fichiers c : mul diag


Application


Installer et compiler ces fichiers dans votre répertoire de travail.

mul_diag.c
/* ------------------------------------ */
/*  Save as :   mul_diag.c              */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int rc)
{
double **A  = rdiag_mR(i_mR(rc,rc),9);
double **B  = rdiag_mR(i_mR(rc,rc),9);
double **AB =          i_mR(rc,rc);

  clrscrn();

  printf(" A : ");
  p_mR(A,S4,P0,C6);

  printf(" B : ");
  p_mR(B,S4,P0,C6);

  printf(" AB : ");
  p_mR(mul_mR(A,B,AB),S4,P0,C6);
  
  f_mR(A);
  f_mR(B);
  f_mR(AB);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
  
   do 
         fun(rp_I(RC6));
        
    while(stop_w());
        
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */



Si nous multiplions deux matrices diagonales, nous obtenons une matrice diagonale.


Exemple de sortie écran :

  A : 
  +4   +0   +0 
  +0   +6   +0 
  +0   +0   +2 

 B : 
  -3   +0   +0 
  +0   +8   +0 
  +0   +0   -5 

 AB : 
 -12   +0   +0 
  +0  +48   +0 
  +0   +0  -10 


 Press return to continue
 Press X      to stop