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

} 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=[
+6.00,-9.00,+6.00;
+6.00,-3.00,-1.00;
+8.00,-3.00,+2.00;
-3.00,+2.00,+8.00;
+8.00,+8.00,-9.00]

pinv(B)


 Press return to continue. 


 PseudoInverse = V * invS_T * U_T 
 +0.026280  +0.021775  +0.049295  +0.026483  +0.049595 
 -0.036176  -0.021542  +0.016123  +0.088165  +0.060228 
 +0.017345  -0.012610  +0.033799  +0.103693  +0.001535 

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


 Press return to continue
 Press X      to stop