Aller au contenu

Mathc matrices/07g

Un livre de Wikilivres.


Application

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

c00b.c
/* ------------------------------------ */
/*  Xave as :   c00b.c                  */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define RA R5
#define CA C5 
#define Cb C1 
/* ------------------------------------ */
#define FACTOR_E  +0.5E-1   
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double ta[RA*CA]={
/* x**2     y**2     x        y        e     */
  +1,      +0,      +0,      +0,      +0,       
  +0,      +1,      +0,      +0,      +0,       
  +1,      +1,      +1,      -1,      +1,        
  +4,     +81,      +2,      -9,      +1,       
  +9,     +64,      +3,      -8,      +1,       
};

double tb[RA*C1]={
/*     b  */
      +1,   
      +1,   
      +0,   
      +0,   
      +0,  
};
    
double **A   =      ca_A_mRZ(ta,i_mZ(RA,CA));
double **A_T = ctranspose_mZ(A, i_mZ(CA,RA));
 
double **b =       ca_A_mRZ(tb, i_mZ(RA,C1));

double **x =                    i_mZ(CA,C1);

double **V =                    i_mZ(CA,CA);
double **V_T =                  i_mZ(CA,CA);

double **U =                    i_mZ(RA,CA);
double **U_T =                  i_mZ(CA,RA);  

double **U_TA =                 i_mZ(CA,CA);  // CA,RA RA,CA  :CA,CA

double **U_TAV =                i_mZ(CA,CA);  // CA,CA CA,CA  :CA,CA  

double **invU_TAV =             i_mZ(CA,CA);  //              :CA,CA 

double **V_invU_TAV =           i_mZ(CA,CA);  // CA,CA CA,CA  :CA,CA 

double **Pinv =                 i_mZ(CA,RA);   
//       Pinv = V_invU_TAV * U_T              // CA,CA CA,RA  :CA,RA

  clrscrn();
  printf(" A :");
  p_mRZ(A, S10,P2, C6);
  
  printf(" b :");
  p_mRZ(b, S10,P2, C6);
  stop(); 
   
  clrscrn();  
  printf(" U :");
  X_U_mZ(A_T,U,FACTOR_E);
    p_mRZ(U, S10,P4, C6);
    
  printf(" V :");
  X_V_mZ(A_T,V,FACTOR_E);
    p_mRZ(V, S10,P4, C6); 
  
  ctranspose_mZ(U,U_T);
  ctranspose_mZ(V,V_T);  
  stop(); 
   
  clrscrn();   
  printf(" U_TAV :");
  mul_mZ(U_T, A, U_TA);              // U_TA    CA,RA RA,CA  :CA,CA
  mul_mZ(U_TA, V, U_TAV );           //     V                :CA,CA
    p_mRZ(U_TAV, S11,P4, C6);        // U_TAV   CA,CA CA,CA  :CA,CA
   
  printf(" inv(U_TAV) :");
  X_inv_mZ(U_TAV, invU_TAV);      
     pE_mRZ(invU_TAV, S10,P4, C6);
 
  printf(" Pinv =  V * inv(U_TAV) * U_T:"); 
  mul_mZ(V, invU_TAV, V_invU_TAV);
  mul_mZ(V_invU_TAV, U_T, Pinv); 
   pE_mRZ(Pinv, S13,P4, C6);
  stop(); 
   
   clrscrn();      
   printf("      A x =      b   \n"  
          " Pinv A x = Pinv b   \n"  
          " Ide    x = Pinv b \n\n"                        
          "        x = Pinv b  ");   
   mul_mZ(Pinv, b, x); 
   p_mRZ(x, S12,P4, C6); 
  printf(" The coefficients a, b, c, d, e, of the curve are : \n\n"
         "  %+.2fx**2 %+.2fy**2 %+.2fx %+.2fy %+.2f = 0\n\n"
            ,x[R1][C1],x[R2][C1],x[R3][C1],x[R4][C1],x[R5][C1]);  
   stop();  
   
   f_mZ(A);
   f_mZ(A_T);

   f_mZ(b);
   f_mZ(x);
      
   f_mZ(V);
   f_mZ(V_T);
     
   f_mZ(U);
   f_mZ(U_T);
   f_mZ(U_TA);
   
   f_mZ(invU_TAV);
   f_mZ(V_invU_TAV);
   f_mZ(Pinv);  
   
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
 A :
     +1.00      +0.00      +0.00      +0.00      +0.00 
     +0.00      +1.00      +0.00      +0.00      +0.00 
     +1.00      +1.00      +1.00      -1.00      +1.00 
     +4.00     +81.00      +2.00      -9.00      +1.00 
     +9.00     +64.00      +3.00      -8.00      +1.00 

 b :
     +1.00 
     +1.00 
     +0.00 
     +0.00 
     +0.00 

 Press return to continue. 


 U :
   +0.0008    +0.1880    +0.2090    -0.9487    -0.1445 
   +0.0095    -0.0218    +0.0431    -0.1453    +0.9882 
   +0.0118    +0.2675    -0.9498    -0.1599    +0.0237 
   +0.7815    -0.5917    -0.1341    -0.1408    -0.0354 
   +0.6237    +0.7365    +0.1851    +0.1829    +0.0290 

 V :
   +0.0839    +0.9418    -0.2852    +0.1569    -0.0110 
   +0.9891    -0.1090    -0.0588    +0.0240    +0.0754 
   +0.0330    +0.2583    +0.4857    -0.6481    +0.5256 
   -0.1153    -0.1665    -0.4952    +0.2185    +0.8161 
   +0.0136    +0.0823    +0.6588    +0.7121    +0.2279 

 Press return to continue. 


 U_TAV :
  +104.3744     -0.0000     -0.0000     +0.0000     -0.0000 
    +0.0000     +5.0091     -0.0000     +0.0000     -0.0000 
    +0.0000     +0.0000     -1.3642     -0.0000     +0.0000 
    +0.0000     +0.0000     -0.0000     -0.1654     +0.0000 
    +0.0000     -0.0000     -0.0000     -0.0000     +0.0763 

 inv(U_TAV) :
+9.5809e-03 +0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00 
+0.0000e+00 +1.9964e-01 +0.0000e+00 +0.0000e+00 +0.0000e+00 
+0.0000e+00 +0.0000e+00 -7.3301e-01 +0.0000e+00 +0.0000e+00 
+0.0000e+00 +0.0000e+00 +0.0000e+00 -6.0465e+00 +0.0000e+00 
+0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00 +1.3107e+01 

 Pinv =  V * inv(U_TAV) * U_T:
  +1.0000e+00   -1.8424e-09   +8.3717e-10   +6.9737e-10   -8.6707e-10 
  -3.5773e-08   +1.0000e+00   -6.0148e-09   -5.2960e-09   +6.8851e-09 
  -4.7778e+00   +6.2222e+00   -1.1111e-01   -7.7778e-01   +8.8889e-01 
  -2.2222e-01   +1.0778e+01   +1.1111e-01   -2.2222e-01   +1.1111e-01 
  +3.5556e+00   +3.5556e+00   +1.2222e+00   +5.5556e-01   -7.7778e-01 

 Press return to continue. 


      A x =      b   
 Pinv A x = Pinv b   
 Ide    x = Pinv b 

        x = Pinv b  
     +1.0000 
     +1.0000 
     +1.4444 
    +10.5556 
     +7.1111 

 The coefficients a, b, c, d, e, of the curve are : 

  +1.00x**2 +1.00y**2 +1.44x +10.56y +7.11 = 0

 Press return to continue.