Aller au contenu

Mathc matrices/024

Un livre de Wikilivres.


Matrices triangulaires


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

c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **B    =    rlower_mR(   i_mR(r,r),9.);
double **B_T  = transpose_mR(B, i_mR(r,r));

double **S    =                 i_mR(r,r);
double **U    =                 i_mR(r,r);
double **U_T  =                 i_mR(r,r);
double **V    =                 i_mR(r,r);
double **V_T  =                 i_mR(r,r);

double **T  =                   i_mR(r,r);

  clrscrn();  
  printf(" B :");
  p_mR(B,S10,P5,C10); 
  
  printf(" U :");
  svd_U_Rn_mR(B_T,U);
         p_mR(U,S10,P5,C10);   

  printf(" V:");
  svd_V_Rn_mR(B_T,V);
         p_mR(V, S10,P5,C10);
      
  printf(" S : U_T * B * V");
  transpose_mR(U,U_T);
        mul_mR(U_T,B,T);
        mul_mR(T,V,S);  
          p_mR(S, S10,P5,C10);
  stop();
     
  clrscrn(); 
  printf(" B :");
  p_mR(B, S10,P3,C10);
   
  printf(" B = U * S * V_T ");
  transpose_mR(V,V_T);
        mul_mR(U,S,T);
        mul_mR(T,V_T,B);
          p_mR(B,  S10,P3,C10);   
  
  f_mR(B);
  f_mR(B_T);  
  f_mR(V);
  f_mR(V_T);
  f_mR(U); 
  f_mR(U_T);  
  f_mR(S);
  f_mR(T);  
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

do
{
  
  fun(rp_I(R2)+R1);

} while(stop_w());

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


Exemple de sortie écran :

 B :
  +1.00000   +0.00000   +0.00000 
  -2.00000   -6.00000   +0.00000 
  -8.00000   -6.00000   +8.00000 

 U :
  -0.04495   +0.04165   +0.99812 
  +0.34134   +0.93964   -0.02384 
  +0.93886   -0.33963   +0.05645 

 V:
  +0.60853   -0.19138   +0.77011 
  +0.56737   +0.78343   -0.25364 
  -0.55478   +0.59128   +0.58532 

 S : U_T * B * V
 -13.53842   +0.00000   +0.00000 
  -0.00000   -4.59521   +0.00000 
  +0.00000   -0.00000   +0.77156 

 Press return to continue. 


 B :
    +1.000     +0.000     +0.000 
    -2.000     -6.000     +0.000 
    -8.000     -6.000     +8.000 

 B = U * S * V_T 
    +1.000     -0.000     +0.000 
    -2.000     -6.000     -0.000 
    -8.000     -6.000     +8.000 


 Press   return to continue
 Press X return to stop