Aller au contenu

Mathc matrices/07m

Un livre de Wikilivres.


Application

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

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

double tb[RA*C1]={
/*    = 0   */
       +1,   
       +0,   
       +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 
     +1.00     +16.00      +1.00      +4.00      +1.00 
     +4.00     +25.00      +2.00      +5.00      +1.00 
     +9.00     +49.00      +3.00      -7.00      +1.00 
    +16.00     +25.00      +4.00      +5.00      +1.00 

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

 Press return to continue. 


 U :
   +0.0038    +0.0524    +0.0822    +0.3335    -0.9377 
   +0.2443    +0.0601    -0.6059    +0.7251    +0.2091 
   +0.3913    +0.1571    -0.6311    -0.5979    -0.2576 
   +0.7709    -0.5601    +0.3010    +0.0351    +0.0107 
   +0.4391    +0.8095    +0.3705    +0.0649    +0.1026 

 V :
   +0.2441    +0.6734    -0.6777    +0.0840    -0.1436 
   +0.9661    -0.1805    +0.1773    -0.0138    -0.0492 
   +0.0788    +0.1504    -0.0627    -0.4203    +0.8892 
   -0.0041    +0.7001    +0.7075    -0.0408    -0.0875 
   +0.0286    +0.0363    +0.0686    +0.9025    +0.4228 

 Press return to continue. 


 U_TAV :
   +64.6364     +0.0000     +0.0000     -0.0000     +0.0000 
    +0.0000    +12.8479     +0.0000     -0.0000     +0.0000 
    -0.0000     +0.0000     -8.2453     +0.0000     +0.0000 
    -0.0000     -0.0000     -0.0000     +0.2518     +0.0000 
    -0.0000     -0.0000     +0.0000     +0.0000     +0.1531 

 inv(U_TAV) :
+1.5471e-02 +0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00 
+0.0000e+00 +7.7834e-02 +0.0000e+00 +0.0000e+00 +0.0000e+00 
+0.0000e+00 +0.0000e+00 -1.2128e-01 +0.0000e+00 +0.0000e+00 
+0.0000e+00 +0.0000e+00 +0.0000e+00 +3.9718e+00 +0.0000e+00 
+0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00 +6.5301e+00 

 Pinv =  V * inv(U_TAV) * U_T:
  +1.0000e+00   -4.7052e-10   +3.8688e-10   -2.2504e-11   -4.1605e-11 
  +2.8030e-01   -9.0909e-02   +1.3258e-01   +7.5758e-03   -4.9242e-02 
  -6.0000e+00   +2.9160e-09   -5.0000e-01   +1.3977e-10   +5.0000e-01 
  +4.7727e-01   -1.8182e-01   +3.0682e-01   -6.8182e-02   -5.6818e-02 
  -1.3939e+00   +3.1818e+00   -2.8485e+00   +1.5152e-01   +5.1515e-01 

 Press return to continue. 


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

        x = Pinv b  
     +1.0000 
     +0.2803 
     -6.0000 
     +0.4773 
     -1.3939 

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

  +1.00x**2 +0.28y**2 -6.00x +0.48y -1.39 = 0

 Press return to continue.