Aller au contenu

Mathc matrices/07k

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  +1.E-2   
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double ta[RA*CA]={
/* x**2     y**2     x        y        e     */
  +1,      +0,      +0,      +0,      +0,       
  +1,      +1,      +1,      +1,      +1,     
  +4,     +16,      +2,      +4,      +1,         
  +9,     +81,      +3,      +9,      +1,        
 +16,    +256,      +4,     +16,      +1,      
};	
	
	
double tb[RA*C1]={
/* = 0   */
  +1.00, 
  +0.00, 
  +0.00, 
  +0.00, 
  +0.00, 
};

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  = 0\n\n"
            ,x[R1][C1],x[R4][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      +1.00      +1.00      +1.00      +1.00 
     +4.00     +16.00      +2.00      +4.00      +1.00 
     +9.00     +81.00      +3.00      +9.00      +1.00 
    +16.00    +256.00      +4.00     +16.00      +1.00 

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

 Press return to continue. 


 U :
   +0.0002    -0.0886    -0.4279    +0.8992    +0.0225 
   +0.0043    -0.2318    +0.7915    +0.3646    -0.4322 
   +0.0611    -0.6120    +0.2214    +0.0261    +0.7563 
   +0.3030    -0.7029    -0.3630    -0.2301    -0.4790 
   +0.9510    +0.2643    +0.0980    +0.0698    +0.1060 

 V :
   +0.0673    +0.6566    -0.4387    +0.6099    -0.0019 
   +0.9953    -0.0949    +0.0181    +0.0054    -0.0061 
   +0.0179    +0.3383    +0.5241    +0.0083    -0.7814 
   +0.0673    +0.6446    -0.0214    -0.7159    +0.2587 
   +0.0049    +0.1730    +0.7295    +0.3397    +0.5679 

 Press return to continue. 


 U_TAV :
  +270.2602     +0.0000     +0.0000     -0.0000     +0.0000 
    -0.0000     -7.4106     -0.0000     +0.0000     -0.0000 
    +0.0000     +0.0000     +1.0253     -0.0000     +0.0000 
    +0.0000     +0.0000     -0.0000     +0.6782     +0.0000 
    -0.0000     -0.0000     +0.0000     -0.0000     -0.0862 

 inv(U_TAV) :
+3.7001e-03 +0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00 
+0.0000e+00 -1.3494e-01 +0.0000e+00 +0.0000e+00 +0.0000e+00 
+0.0000e+00 +0.0000e+00 +9.7532e-01 +0.0000e+00 +0.0000e+00 
+0.0000e+00 +0.0000e+00 +0.0000e+00 +1.4744e+00 +0.0000e+00 
+0.0000e+00 +0.0000e+00 +0.0000e+00 +0.0000e+00 -1.1606e+01 

 Pinv =  V * inv(U_TAV) * U_T:
  +1.0000e+00   -1.3846e-09   -4.8158e-10   +7.0406e-10   -1.8740e-10 
  -7.1060e-12   -1.6667e-02   +5.0000e-02   -5.0000e-02   +1.6667e-02 
  -2.0384e-09   -3.5000e+00   +7.0000e+00   -4.5000e+00   +1.0000e+00 
  -1.0000e+00   +9.1667e-01   -2.2500e+00   +1.7500e+00   -4.1667e-01 
  +1.6819e-09   +3.6000e+00   -4.8000e+00   +2.8000e+00   -6.0000e-01 

 Press return to continue. 


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

        x = Pinv b  
     +1.0000 
     -0.0000 
     -0.0000 
     -1.0000 
     +0.0000 

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

  +1.00x**2  -1.00y  = 0

 Press return to continue.