Aller au contenu

Mathc matrices/c12b4

Un livre de Wikilivres.


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 **S   =       i_mR(r,C1);
double **U   =       i_mR(r,r);
double **V   =       i_mR(c,c);

  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(); 
  svd_U_Cn_mR(A,U); 
  svd_V_Cn_mR(A,V); 
  
  transpose_mR(A,A_T);
  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);  
    
  f_mR(A);
  f_mR(A_T); 
  f_mR(S); 
  f_mR(U);
  f_mR(V); 
}
/* ------------------------------------ */
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); 


Exemple de sortie écran :

 Copy/Past into the octave windows 


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

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


 Press return to continue. 


 U :
+0.15236 +0.85847 -0.41399 -0.26160 
+0.68789 -0.41853 -0.28672 -0.51907 
+0.40914 +0.28869 +0.85060 -0.16041 
+0.57982 +0.06724 -0.15127 +0.79775 

 S :
+23.44620 
+15.98080 
+15.19912 
+11.74207 

 V:
+0.42487 +0.36866 +0.55758 -0.30982 -0.20204 +0.44117 +0.35129 
-0.09904 +0.30818 -0.07215 +0.69266 +0.00000 +0.00000 +0.62441 
+0.24966 +0.04770 +0.14044 +0.53591 -0.57263 +0.28786 -0.56534 
-0.33861 +0.21595 +0.69053 +0.16835 +0.44040 -0.44698 -0.28543 
+0.55534 -0.28782 -0.01846 +0.30974 +0.61929 -0.00000 -0.00000 
+0.14665 +0.79735 -0.42945 -0.09349 +0.23194 -0.13574 -0.29263 
-0.55025 +0.03997 -0.05077 +0.06334 +0.00000 +0.71014 +0.00000 


 Press return to continue
 Press X      to stop