Mathc matrices/c12a6

Un livre de Wikilivres.
Aller à la navigation Aller à la recherche


Sommaire


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


Crystal Clear mimetype source c.png cgn6.c
'
/* ------------------------------------ */
/*  Save as :   cgn6.c                    */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
void fun(int r,int c)
{
double **B     = r_mR(i_mR(c,r),9.);

double **A     = transpose_mR(B,i_mR(r,c));

double **S = i_mR(r,C1);
double **U = i_mR(c,r);
double **V = i_mR(r,r);


  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_uv_mR(A,U);    
  svd_V_Rn_uv_mR(A,V); 
  svd_value_uv_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);  
    
  f_mR(A);
  f_mR(B);

  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+R6);

} while(stop_w());

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



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


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

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


 Press return to continue. 


 ------------------------------------ 
 U :
+0.17895 +0.03992 
+0.09639 +0.22832 
+0.03222 +0.67359 
-0.06430 -0.45095 
+0.64695 -0.13144 
+0.24326 +0.49087 
+0.38999 -0.14280 
-0.56895 +0.10288 

 S :
+17.39353 
+13.98088 

 V:
+0.47870 +0.87798 
+0.87798 -0.47870 


 Press return to continue
 Press X      to stop