Aller au contenu

Mathc matrices/a92

Un livre de Wikilivres.


Application


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


c00a.c
/* ------------------------------------ */
/*  Save as :  c00a.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define  TAB  C2 
#define  RCA  R5  
/* ------------------------------------ */
void fun(void)
{
double **A[TAB];
double **InvA[TAB];

double **P    =   r_mR(  i_mR(RCA,RCA),99); 
double **InvP = inv_mR(P,i_mR(RCA,RCA)   );

double **T        = i_mR(RCA,RCA);
double **P_1_InvA0_P = i_mR(RCA,RCA);
int c;

  for(c=C0; c<TAB; c++)
     {   
         A[c] = i_mR(RCA,RCA); 
       InvA[c] = i_mR(RCA,RCA);   
	   }
	    
  rsymmetric_mR(A[R0],99);
  
  mul_mR(InvP,A[C0],T); 
  mul_mR(T,P,A[C0+C1]);

  clrscrn();
  printf(" The two similar matrices :\n\n"
         " A[%d] = P**(-1) A[%d] P   \n\n",C1,C0);
  for(c=C0; c<TAB; c++)
     {
	  printf(" A[%d] : ",c);      
      p_mR(A[c],S12,P4,C6); 
     }   
  stop();    

  clrscrn();      
  printf(" The inverse of the two similar matrices : \n\n");    
    for(c=C0; c<TAB; c++)
     {
	  printf(" inVA[%d] : ", c);      
      pE_mR(inv_mR(A[c],InvA[c]),S12,P4,C6); 
     } 
  stop();    

   clrscrn();     
   mul_mR(InvP,InvA[C0],T); 
   mul_mR(T,P,P_1_InvA0_P);    
   printf(" InVA[%d] = P**(-1) InVA[%d] P \n\n",C1,C0); 
   printf(" InVA[%d] : ",C1);      
   pE_mR(InvA[1],S12,P4,C6); 
   printf(" P**(-1) InVA[%d] P : ",C0);      
   pE_mR(P_1_InvA0_P,S12,P4,C6); 


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

  srand(time(&t));
  
  do{
        fun();
        
  }while(stop_w());

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


Je crée une suite de deux Matrices semblables.


Exemple de sortie écran :
 --------------------------------
 The two similar matrices :

 A[1] = P**(-1) A[0] P   

 A[0] : 
    +35.0000      +6.0000     -76.0000     -19.0000     -83.0000 
     +6.0000     -29.0000      +7.0000     +85.0000     +66.0000 
    -76.0000      +7.0000     -45.0000     -92.0000     +55.0000 
    -19.0000     +85.0000     -92.0000     +63.0000     +23.0000 
    -83.0000     +66.0000     +55.0000     +23.0000     -43.0000 

 A[1] : 
   -301.4072    +178.1993    +446.6857      -4.6939     +54.1201 
   -515.0931    +927.9275    +806.4553     +18.2792    +501.5759 
    -82.8418     -56.1180    +136.8056      +8.1428     -45.4983 
  -1352.1784   +1164.7454   +2242.0871     +14.3362    +503.5888 
   +857.1939   -1426.4624   -1348.0146     -49.9780    -796.6621 

 Press return to continue. 


 --------------------------------
 The inverse of the two similar matrices : 

 inVA[0] : 
 -9.0639e-03  -1.2330e-02  -8.6761e-03  +4.8573e-03  -9.9291e-03 
 -1.2330e-02  -1.5976e-02  -6.0784e-03  +1.0091e-02  -3.0985e-03 
 -8.6761e-03  -6.0784e-03  -4.7194e-03  -1.5155e-03  +5.7026e-04 
 +4.8573e-03  +1.0091e-02  -1.5155e-03  -1.1660e-05  +4.1681e-03 
 -9.9291e-03  -3.0985e-03  +5.7026e-04  +4.1681e-03  -5.8873e-03 

 inVA[1] : 
 -2.8665e-02  +1.2678e-02  +5.0058e-03  +6.9387e-03  +1.0135e-02 
 -9.1496e-03  +4.8196e-02  +4.5941e-02  -3.2636e-03  +2.5036e-02 
 -1.5292e-02  -9.8480e-04  -4.2025e-03  +5.2426e-03  +1.8951e-03 
 -2.5164e-02  +5.9997e-02  +1.2673e-01  -1.1240e-02  +2.1722e-02 
 +1.2994e-02  -7.4753e-02  -7.7712e-02  +5.1438e-03  -3.9747e-02 

 Press return to continue. 


 --------------------------------
 InVA[1] = P**(-1) InVA[0] P 

 InVA[1] : 
 -2.8665e-02  +1.2678e-02  +5.0058e-03  +6.9387e-03  +1.0135e-02 
 -9.1496e-03  +4.8196e-02  +4.5941e-02  -3.2636e-03  +2.5036e-02 
 -1.5292e-02  -9.8480e-04  -4.2025e-03  +5.2426e-03  +1.8951e-03 
 -2.5164e-02  +5.9997e-02  +1.2673e-01  -1.1240e-02  +2.1722e-02 
 +1.2994e-02  -7.4753e-02  -7.7712e-02  +5.1438e-03  -3.9747e-02 

 P**(-1) InVA[0] P : 
 -2.8665e-02  +1.2678e-02  +5.0058e-03  +6.9387e-03  +1.0135e-02 
 -9.1496e-03  +4.8196e-02  +4.5941e-02  -3.2636e-03  +2.5036e-02 
 -1.5292e-02  -9.8480e-04  -4.2025e-03  +5.2426e-03  +1.8951e-03 
 -2.5164e-02  +5.9997e-02  +1.2673e-01  -1.1240e-02  +2.1722e-02 
 +1.2994e-02  -7.4753e-02  -7.7712e-02  +5.1438e-03  -3.9747e-02 


 Press   return to continue
 Press X return to stop