Aller au contenu

Mathc matrices/c12b16

Un livre de Wikilivres.


Application


Installer ce fichier dans votre répertoire de travail.


c00b.c
/* ------------------------------------ */
/*  Save as :   c00b.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define   RA R3
#define   CA C5
/* ------------------------------------ */
#define FACTOR_E        +1.E-0         
/* ------------------------------------ */
void fun(void)
{
double tA[RA*CA]={
  +8.00,   -5.00,   +1.00,   +3.00,   +8.00, 
  -2.00,   +6.00,   -2.00,   -8.00,   -2.00, 
  +3.00,   -9.00,   +9.00,   +7.00,   -7.00  
};

double **A    = ca_A_mR(tA,i_mR(RA,CA));
double **Pinv =            i_mR(CA,RA);     
double **Ide  =            i_mR(RA,RA);    

  clrscrn();
  printf(" A :");
  p_mR(A,S7,P2,C7);   
  
  printf(" PseudoInverse = V * invS_T * U_T ");
  pseudo_Cn_mR(A,Pinv,FACTOR_E); 
  pE_mR(Pinv,S12,P4,C10);
  
  printf(" Ide =  A * Pinv ");
  mul_mR(A,Pinv,Ide); 
  p_mR(Ide,S7,P2,C10); 
  stop();
    
  f_mR(A); 
  f_mR(Pinv); 
  f_mR(Ide); 
}
/* ------------------------------------ */
int main(void)
{
  fun();

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


Cet version fonctionne quand il y a plus de colonnes que de lignes.

pseudo_Cn_mR(A,Pinv,FACTOR_E);

Exemple de sortie écran :
 ------------------------------------ 
 A :
  +8.00   -5.00   +1.00   +3.00   +8.00 
  -2.00   +6.00   -2.00   -8.00   -2.00 
  +3.00   -9.00   +9.00   +7.00   -7.00 

 PseudoInverse = V * invS_T * U_T 
 +8.9736e-02  +9.4303e-02  +3.8876e-02 
 -1.6303e-02  +1.4763e-02  -2.4265e-02 
 +2.5728e-02  +6.4743e-02  +5.8226e-02 
 -5.1374e-02  -1.4389e-01  -2.9953e-02 
 +4.1124e-02  -3.9211e-02  -5.0088e-02 

 Ide =  A * Pinv 
  +1.00   -0.00   -0.00 
  -0.00   +1.00   +0.00 
  +0.00   +0.00   +1.00 

 Press return to continue.