Aller au contenu

Mathc matrices/Fichiers c : mul r r

Un livre de Wikilivres.


Application

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

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

  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),S8,P0,C6);
  stop();

  clrscrn();
  printf(" Copy/Paste into the octave window.\n\n");  
  p_Octave_mR(A,"A", P0);
  p_Octave_mR(B,"B", P0);
  printf("A * B\n");
  
  p_mR(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(R4),rp_I(RC4),rp_I(C4));
        
    while(stop_w());
        
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Exemple de sortie écran :

A : 
  -3   -5   -1 
  +4   -5   -3 
  -5   -9   -5 
  +4   -9   +2 

 B : 
  -9   -7   +2   -3 
  -9   +8   +8   -5 
  -7   +2   -1   +4 

 AB : 
     +79      -21      -45      +30 
     +30      -74      -29       +1 
    +161      -47      -77      +40 
     +31      -96      -66      +41 


 Press return to continue
 Press X      to stop