Application


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,int c)
{
double **B    =         r_mR(   i_mR(c,r),9.);
double **B_T  = transpose_mR(B, i_mR(r,c));

double **U    =                 i_mR(c,r);
double **U_T  =                 i_mR(r,c);
double **U_TB =                 i_mR(r,r);   /* rc cr         U_T*B   */
double **V    =                 i_mR(r,r);

double **S    =                 i_mR(r,C1);
double **SD   =                 i_mR(r,r);   /* rc cr rr  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_Rn_mR(B_T,U);    
  svd_V_Rn_mR(B_T,V); 
  svds_mR(B,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);
  
/* S = U_T * B * V :   */
  transpose_mR( U,U_T);
  mul_mR(U_T,B,U_TB);
  mul_mR(U_TB,V,SD);
  
  printf(" S = U_T * B * V :");
  p_mR(SD,S10,P5,C10);  
    
  f_mR(B);
  f_mR(B_T); 
  f_mR(U);
  f_mR(U_T);
  f_mR(U_TB);
  f_mR(V); 
  f_mR(S);  
  f_mR(SD);  
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));

int i;

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

} while(stop_w());

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


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

 svd_U_Rn_mR(B_T,U);    
 svd_V_Rn_mR(B_T,V); 


Exemple de sortie écran :

 Copy/Past into the octave windows 


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

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


 Press return to continue. 


 U :
-0.49076 +0.55217 -0.16100 +0.65448 
+0.55771 -0.38132 -0.01109 +0.73718 
-0.45346 -0.36696 +0.79525 +0.16520 
+0.49244 +0.64423 +0.58441 -0.03052 

 S :
+24.04363 
+9.59674 
+3.23992 
+1.81920 

 V:
+0.45739 -0.32830 +0.82323 +0.07284 
-0.62417 -0.16527 +0.21608 +0.73240 
+0.09994 +0.92713 +0.29589 +0.20708 
+0.62547 -0.07298 -0.43365 +0.64452 

 Press return to continue. 


 S :
+24.04363 
+9.59674 
+3.23992 
+1.81920 

 S = U_T * B * V :
 -24.04363   -0.00000   -0.00000   -0.00000 
  +0.00000   +9.59674   +0.00000   -0.00000 
  -0.00000   +0.00000   -3.23992   +0.00000 
  +0.00000   +0.00000   +0.00000   -1.81920 


 Press return to continue
 Press X      to stop