Aller au contenu

Mathc matrices/Fichiers c : sub r

Un livre de Wikilivres.


Application

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

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

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

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

  printf(" A - B : ");
  p_mR(sub_mR(A,B,AmnsB),S4,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(AmnsB,S4,P0,C6);  

  f_mR(A);
  f_mR(B);
  f_mR(AmnsB);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
  
   do 
        fun(rp_I(R4),rp_I(C4)+C2);
        
    while(stop_w());
        
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Exemple de sortie écran :

 A : 
  +16   -85   +26 
  +68   -83   -53 
  +44   +96   -69 
  +74   +54   +78 

 B : 
  -55   -25   -63 
  +44   +28   +12 
   +8   +44   -99 
  +18   -99   +40 

 AmnsB : 
  +71   -60   +89 
  +24  -111   -65 
  +36   +52   +30 
  +56  +153   +38 


 Press return to continue
 Press X      to stop