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    */
double **V     =                 i_mR(r,r);
double **VS    =                 i_mR(r,r);          /* rr rr       */

double **S     =                 i_mR(r,r);
double **invS  =                 i_mR(r,r);

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);
 
  inv_svd_mR(S,invS);
    
  printf(" PseudoInverse = V * invS * U_T ");
  mul_mR(V,invS,VS);
  mul_mR(VS,U_T,Pinv); 
    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);
  f_mR(U_T);
  f_mR(U_TB); 
  f_mR(V);
  f_mR(VS);     
  f_mR(S); 
  f_mR(invS);
  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;
}
/* ------------------------------------ */
/* ------------------------------------ */


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=[
-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