Aller au contenu

Mathc matrices/c23b

Un livre de Wikilivres.


Application


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


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

  clrscrn();
  printf(" A :");
  p_mR(A,S3,P0,C6);
  printf(" B :");
  p_mR(B,S3,P0,C6);
 
  sub_mR(A,B,AmnsB);
  
  printf("  d(A,B) = ||u-v||^(1/2)  \n\n");
  printf("  d(A,B) = %.4f   norm_TR_R(AmnsB)\n", norm_TR_R(AmnsB));
  printf("  d(B,A) = %.4f   dist_TR_R(A,B)\n", dist_TR_R(A,B));
  printf("  d(A,B) = %.4f   dist_TR_R(B,A)\n\n", dist_TR_R(B,A));

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

  srand(time(&t));
  
do
{
  fun(rp_I(R3)+R2);

} while(stop_w());

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


Nous calculons la distance entre les deux matrices.


Exemple de sortie écran :
 ------------------------------------ 
 A :
+26  -1 +26 +54 +94 
-11 +10 +94 +12 -21 
+88 -67 +26 -99 +10 
-27 +60 +38 +24 +56 
+84 -35 +62 -79 +60 

 B :
-65 +98 +66 -19 -97 
-99 +44 +96 -23 -95 
+88 -33  -5 -81 -43 
+24 -69  +8 -49 +68 
+18 -73 -29 -53 +96 

  d(A,B) = ||u-v||^(1/2)  

  d(A,B) = 352.158   norm_traceAtB_R(AmnsB)
  d(B,A) = 352.158   dist_traceAtB_R(A,B)
  d(A,B) = 352.158   dist_traceAtB_R(B,A)


 Press return to continue
 Press X      to stop