Aller au contenu

Mathc matrices/a110

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"
/* ------------------------------------ */
#define   RA R3
#define   CA C3
#define   Cb C1
/* ------------------------------------ */
int main(void)
{
double at[RA*CA]={
     +10,     -150,     -148, 
    +207,     -215,     +997, 
    -858,     +803,     +289  
};

double bt[RA*Cb]={
    +437,  
    -233,     
    +444 
};

double **A  = ca_A_mR(at,i_mR(RA,CA));
double **B  = ca_A_mR(bt,i_mR(RA,Cb));

double **Inv =      i_mR(RA,C3);
double **X   =      i_mR(RA,Cb);
double **T   =      i_mR(RA,Cb);

  clrscrn();
  printf(" We want to find X such as,   \n\n");
  printf("         AX = B               \n\n");
  printf(" If A is a square matrix and, \n\n");
  printf(" If A has an inverse matrix,  \n\n");
  printf(" you can find X by this method\n\n");
  printf("         X = inv(A) B       \n\n\n");
  printf(" To verify the result you can \n\n");
  printf(" multiply the matrix A by X.  \n\n");
  printf(" You must refind B.  \n\n");
  stop();

  clrscrn();
  printf(" A :\n");
  p_mR(A,S5,P0,C7);
  printf(" B :\n");
  p_mR(B,S5,P0,C7);
  stop();

  clrscrn();
  printf(" inv(A) :\n");
  pE_mR(invgj_mR(A,Inv),S1,P3,C7);
  printf(" X = inv(A) * B :\n");
  p_mR(mul_mR(Inv,B,X),S13,P4,C7);
  stop();

  clrscrn();
  printf(" B :\n");
  p_mR(B,S5,P0,C7);
  printf("  AX :\n");
  p_mR(mul_mR(A,X,T),S5,P0,C7);
  stop();

  f_mR(T);
  f_mR(X);
  f_mR(B);
  f_mR(Inv);
  f_mR(A);

  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
 ------------------------------------ 
 We want to find X such as,   

         AX = B               

 If A is a square matrix and, 

 If A has an inverse matrix,  

 you can find X by this method

         X = inv(A) B       


 To verify the result you can 

 multiply the matrix A by X.  

 You must refind B.  

 Press return to continue. 


 ------------------------------------ 
 A :

  +10  -150  -148 
 +207  -215  +997 
 -858  +803  +289 

 B :

 +437 
 -233 
 +444 

 Press return to continue. 


 ------------------------------------ 
 inv(A) :

-6.568e-03 -5.747e-04 -1.381e-03 
-6.967e-03 -9.447e-04 -3.091e-04 
-1.389e-04 +9.186e-04 +2.200e-04 

 X = inv(A) * B :

      -3.3492 
      -2.9619 
      -0.1771 

 Press return to continue. 


 ------------------------------------ 
 B :

 +437 
 -233 
 +444 

  AX :

 +437 
 -233 
 +444 

 Press return to continue.