Mathc matrices/a34

Un livre de Wikilivres.


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)
{
double **A  = i_mR(r,r);
double **b  = i_mR(r,r);
double **Ab = i_Abr_Ac_bc_mR(   r,  r,  r);
/*            i_Abr_Ac_bc_mR(R_Ab,C_A,C_b));  */
double **invA = i_mR(r,r);

 do
  {
   r_mR(A,999.);
   printf(".");
  }while(!det_R(A));

  clrscrn();
  printf(" A :");
  p_mR(A,S8,P0,C4);

  printf("   b : ID :");
  eye_mR(b);
  p_mR(b,S8,P0,C4);
  stop();
  
  clrscrn();  
  printf(" Ab :");
  c_A_b_Ab_mR(A,b,Ab);
  p_mR(Ab,S8,P0,C4);
  printf("  gj_TP_mR(Ab) :");  
  gj_TP_mR(Ab);
  p_mR(Ab,S8,P4,C4);
  stop();
  
  clrscrn(); 
  printf(" Copy/Past into the octave window.\n\n");
  p_Octave_mR(A,"A",P0);
  printf("format short e\n");
  printf(" inv(A)\n\n");

  printf(" invA :                      c_Inv_A_mR(Ab,invA);");  
  c_Inv_A_mR(Ab,invA);
  pE_mR(invA,S14,P4,C4);
  
  f_mR(invA);
  f_mR(Ab);
  f_mR(b);
  f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
do
{
  fun(R4);
} while(stop_w());

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


Copier la matrice inverse du système Ab dans la matrice invA :


Exemple de sortie écran :
 ------------------------------------
 A :
    +461     +953     +389     +217 
    -273     +218     -312     +389 
    +434     +256     -224     -416 
    +978     -891     +122      +23 

   b : ID :
      +1       +0       +0       +0 
      +0       +1       +0       +0 
      +0       +0       +1       +0 
      +0       +0       +0       +1 

 Press return to continue. 

 ------------------------------------
 Ab :
    +461     +953     +389     +217 
    -273     +218     -312     +389 
    +434     +256     -224     -416 
    +978     -891     +122      +23 

      +1       +0       +0       +0 
      +0       +1       +0       +0 
      +0       +0       +1       +0 
      +0       +0       +0       +1 

  gj_TP_mR(Ab) :
 +1.0000  +0.0000  +0.0000  +0.0000 
 +0.0000  +1.0000  +0.0000  +0.0000 
 -0.0000  -0.0000  +1.0000  -0.0000 
 +0.0000  +0.0000  +0.0000  +1.0000 

 +0.0004  +0.0004  +0.0006  +0.0007 
 +0.0005  +0.0002  +0.0004  -0.0004 
 +0.0006  -0.0017  -0.0013  -0.0002 
 +0.0004  +0.0014  -0.0009  +0.0006 

 Press return to continue. 


 ------------------------------------
 Copy/Past into the octave window.

 A=[
+461,+953,+389,+217;
-273,+218,-312,+389;
+434,+256,-224,-416;
+978,-891,+122,+23]

format short e
 inv(A)

 invA :                      c_Inv_A_mR(Ab,invA);
   +3.9920e-04    +3.5079e-04    +5.7373e-04    +6.7765e-04 
   +5.2663e-04    +1.9352e-04    +4.3427e-04    -3.8693e-04 
   +5.6361e-04    -1.6586e-03    -1.2662e-03    -1.6677e-04 
   +4.3707e-04    +1.3781e-03    -8.5627e-04    +5.5865e-04 


 Press return to continue
 Press X      to stop