Application


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


cgn0f.c
/* ------------------------------------ */
/*  Save as :   cgn0f.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_TB    = i_mR(r,r);             /* rc cr*/
double **U       = i_mR(c,r);
double **V       = i_mR(r,r);

double **S       = i_mR(r,r);
double **S_T     = i_mR(r,r);
double **invS_T  = i_mR(r,r);

double **U_T     = i_mR(r,c);
double **VS_T    = i_mR(r,r);          /* rr rr    */

double **Pinv    = i_mR(r,c);          /* rr rr rc */
double **PinvB   = i_mR(r,r);          /* rr rr rc cr */

  clrscrn();
  printf(" Copy/Past into the octave windows \n\n\n");
  p_Octave_mR(B,"B",P2);
  printf("pinv(B)\n\n\n");
  stop();

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

 /* S = U_T * B * V */ 
  transpose_mR( U,U_T);
  mul_mR(U_T,B,U_TB);
  mul_mR(U_TB,V,S);
 
  transpose_mR(S,S_T);
  inv_svd_mR(S_T,invS_T);
    
 /* Pinv = V * invS_T * U_T */    
  mul_mR(V,invS_T,VS_T);
  mul_mR(VS_T,U_T,Pinv);
  
  printf(" PseudoInverse = V * invS_T * U_T "); 
  p_mR(Pinv,S10,P6,C10);  
  
  printf(" Ide = PseudoInverse * B ");   
  mul_mR(Pinv,B,PinvB); 
  p_mR(PinvB,S10,P6,C10);   
    
  f_mR(B);
  f_mR(B_T);
  
  f_mR(U_TB); 
  
  f_mR(U);
  f_mR(V);
     
  f_mR(S); 
  f_mR(S_T);
  f_mR(invS_T);
  
  f_mR(U_T);  
  f_mR(VS_T);  
  
  f_mR(Pinv);
  f_mR(PinvB); 
}
/* ------------------------------------ */
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;
}
/* ------------------------------------ */
/* ------------------------------------ */



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


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

pinv(B)


 Press return to continue. 



 ------------------------------------ 
 PseudoInverse = V * invS_T * U_T 
 -0.418605  -0.569767  -0.612403  +0.267442 
 +0.034884  -0.244186  -0.143411  +0.186047 
 +0.302326  +0.383721  +0.534884  -0.220930 
 -0.267442  -0.127907  -0.344961  -0.093023 

 Ide = PseudoInverse * B 
 +1.000000  -0.000000  +0.000000  +0.000000 
 +0.000000  +1.000000  +0.000000  +0.000000 
 +0.000000  +0.000000  +1.000000  -0.000000 
 -0.000000  -0.000000  -0.000000  +1.000000 


 Press return to continue
 Press X      to stop