Application


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


c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RB R3
#define   CB C5
/* ------------------------------------ */
int main(void)
{
double b[RB*CB]={
+8.00,-1.00,+5.00,+8.00,-3.00,
-2.00,+5.00,-9.00,+2.00,-9.00,
+1.00,+1.00,-8.00,-7.00,+6.00
};

double **B   =      ca_A_mR(b, i_mR(RB,CB));
double **B_T = transpose_mR(B, i_mR(CB,RB));

double **U    =                 i_mR(RB,RB);
double **US   =                 i_mR(RB,CB); /* rr rc    US = U S     */
double **U_T  =                 i_mR(RB,RB);
double **U_TB =                 i_mR(RB,CB); /* rr rc          U_T B  */
double **V    =                 i_mR(CB,CB);
double **V_T  =                 i_mR(CB,CB); 

double **S    =                 i_mR(RB,CB); /* rr rc cc  S = U_T B V */

  clrscrn();  
  printf(" Copy/Past into the octave windows \n\n\n");
  p_Octave_mR(B,"B",P2);
  printf(" [U, S, V] =svd (B,10)\n\n\n");
  stop();

  clrscrn(); 
  svd_U_Cn_mR(B,U);   
  svd_V_Cn_mR(B,V); 
  
  printf(" U :");
  smul_c1_mR(-1.,C1,U); 
  smul_c1_mR(-1.,C3,U); 
        p_mR(U, S5,P5,C10);   
        
  printf(" V:");
  smul_c1_mR(-1.,C1,V); 
  smul_c1_mR(-1.,C2,V);
  smul_c1_mR(-1.,C3,V);  
        p_mR(V, S5,P5,C10);  
          
  printf(" S = U_T * B * V :");
  transpose_mR( U,U_T);
        mul_mR(U_T,B,U_TB);
        mul_mR(U_TB,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,US);
        mul_mR(US,V_T,B);
          p_mR(B, S10,P3,C10);  
  stop();
      
  f_mR(B);
  f_mR(B_T);
  f_mR(U);
  f_mR(US);
  f_mR(U_T);
  f_mR(U_TB);
  f_mR(V); 
  f_mR(V_T);
  f_mR(S);  
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


Cet version fonctionne quand le nombre de colonnes est strictement supérieur au nombre de lignes..

 svd_U_Cn_mR(B,U); 
 svd_V_Cn_mR(B,V); 

C'est la fonction "smul_c1_mR(-1.,C1,V);" qui me permet de corriger les signes d'une colonne.


Exemple de sortie écran :
 Copy/Past into the octave windows 


 B=[
+8.00,-1.00,+5.00,+8.00,-3.00;
-2.00,+5.00,-9.00,+2.00,-9.00;
+1.00,+1.00,-8.00,-7.00,+6.00]

 [U, S, V] =svd (B,10)


 Press return to continue. 


 U :
-0.70749 +0.15051 -0.69051 
+0.27636 +0.95818 -0.07430 
+0.65045 -0.24339 -0.71950 

 V:
-0.33828 -0.06940 -0.87041 -0.34954 +0.02092 
+0.16662 +0.31932 -0.05719 +0.00000 +0.93075 
-0.68288 -0.43021 +0.42444 -0.28451 +0.28759 
-0.58752 +0.35034 -0.09086 +0.72346 +0.00000 
+0.21517 -0.76511 -0.22517 +0.52295 +0.22484 

 S = U_T * B * V :
 +16.44255   +0.00000   -0.00000   +0.00000   +0.00000 
  -0.00000  +13.76986   -0.00000   -0.00000   -0.00000 
  +0.00000   +0.00000   +7.00240   +0.00000   -0.00000 

 Press return to continue. 


 B :
    +8.000     -1.000     +5.000     +8.000     -3.000 
    -2.000     +5.000     -9.000     +2.000     -9.000 
    +1.000     +1.000     -8.000     -7.000     +6.000 

 B = U * S * V_T 
    +8.000     -1.000     +5.000     +8.000     -3.000 
    -2.000     +5.000     -9.000     +2.000     -9.000 
    +1.000     +1.000     -8.000     -7.000     +6.000 

 Press return to continue.