Application


Installer ce fichier dans votre répertoire de travail.


c00a.c
/* ------------------------------------ */
/*  Save as :   c00a.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r,int c)
{
double **A    = r_mR( i_mR(r,c),9.);
double **A_T  =       i_mR(c,r);

double **U    =       i_mR(r,r);
double **U_T  =       i_mR(r,r);
double **U_TA =       i_mR(r,c); /* rr rc     U_TA  */
double **V    =       i_mR(c,c);

double **S    =       i_mR(r,C1);
double **S_2  =       i_mR(r,c); /* rr rc cc  U_TAV */

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

  clrscrn(); 
  transpose_mR(A,A_T);
   
  svd_U_Cn_mR(A,U);   
  svd_V_Cn_mR(A,V); 
  svds_mR(A_T,S);
  
  printf(" U :");
  p_mR(U,S5,P5,C10);   
    
  printf(" S :");
  p_mR(S,S5,P5,C10);
   
  printf(" V:");
  p_mR(V,S5,P5,C10); 
  stop();

  clrscrn();   
  printf(" S :");
  p_mR(S,S5,P5,C10);
  
  printf(" S = U_T * A * V :");
  transpose_mR(U,U_T);
        mul_mR(U_T,A,U_TA);
        mul_mR(U_TA,V,S_2);
          p_mR(S_2,S10,P5,C10);  
    
  f_mR(A);
  f_mR(A_T);
  f_mR(U);
  f_mR(U_T);
  f_mR(U_TA);  
  f_mR(V); 
  f_mR(S); 
  f_mR(S_2); 
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

int i;

do
{
  i = rp_I(R3)+R1;
  
  fun(i,i+C3);

} while(stop_w());

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


Cet version fonctionne quand il y a plus de colonnes que de lignes..

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


Si on ne tient pas compte des signes négatifs cela semble marcher correctement. Les valeurs singulières nulles sont présentes sous la forme de colonnes nulles (S = U_T * A * V :)


Exemple de sortie écran :

 Copy/Past into the octave windows 


 A=[
+2.00,+2.00,+2.00,+6.00,+4.00,+6.00,+4.00;
+2.00,-3.00,-9.00,+8.00,-3.00,-9.00,-9.00;
-7.00,-9.00,-3.00,-1.00,-3.00,+6.00,+2.00;
+8.00,-9.00,-1.00,+8.00,+2.00,-3.00,-7.00]

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


 Press return to continue. 

 
 U :
-0.12841 -0.26184 +0.68591 +0.66669 
+0.75678 +0.10231 -0.34789 +0.54386 
-0.10281 +0.95947 +0.23641 +0.11379 
+0.63263 -0.01961 +0.59381 -0.49678 

 S :
+22.64855 
+13.75998 
+12.43346 
+7.00822 

 V:
+0.31073 +0.52269 +0.30334 -0.33527 -0.46718 -0.54520 +0.05036 
-0.32212 +0.67510 -0.40669 +0.44928 -0.12869 -0.08575 -0.25869 
-0.32638 +0.31274 +0.25735 -0.48599 +0.00000 +0.63283 +0.00000 
+0.46130 +0.13582 +0.47021 +0.60829 -0.00520 +0.38370 +0.12133 
-0.05344 +0.31046 +0.34308 -0.04277 +0.80808 +0.00000 -0.00000 
-0.44578 -0.24156 +0.55363 +0.18243 -0.33490 -0.38433 -0.56622 
-0.52801 -0.00640 +0.17620 +0.21076 +0.00000 +0.00000 +0.77150 

 Press return to continue. 


 S :
+22.64855 
+13.75998 
+12.43346 
+7.00822 

 U_T * A * V :
 +22.64855   -0.00000   -0.00000   +0.00000   +0.00000   +0.00000   +0.00000 
  -0.00000  -13.75998   -0.00000   +0.00000   +0.00000   +0.00000   -0.00000 
  +0.00000   -0.00000  +12.43346   +0.00000   -0.00000   -0.00000   +0.00000 
  +0.00000   +0.00000   -0.00000   +7.00822   +0.00000   -0.00000   +0.00000 


 Press return to continue
 Press X      to stop