Mathc matrices/c12a2

Un livre de Wikilivres.


Application


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


cgn2.c
/* ------------------------------------ */
/*  Save as :   cgn2.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 **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_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);  
    
  f_mR(B_T);
  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+R2);

} while(stop_w());

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



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


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

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


 Press return to continue. 


 ------------------------------------ 
 U :
-0.40288 +0.62176 +0.61771 +0.01959 
+0.62771 +0.04994 +0.13227 +0.26016 
-0.43030 -0.04785 -0.35711 +0.79389 
-0.13459 -0.52493 +0.15695 -0.24204 
+0.28979 -0.26108 +0.57773 +0.49226 
+0.39550 +0.51470 -0.33912 +0.02774 

 S :
+19.20771 
+17.24848 
+8.58162 
+2.98489 

 V:
+0.27362 -0.78072 -0.33409 -0.45165 
+0.67911 +0.55451 -0.41802 -0.23789 
+0.62151 -0.28396 +0.24074 +0.68931 
+0.27870 +0.04856 +0.80975 -0.51408 


 Press return to continue
 Press X      to stop