Application


Installer et compiler ces fichiers dans votre répertoire de travail.


c01b.c
/* ------------------------------------ */
/*  Save as :   c01b.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A   =      i_mR(r,r);
double **Inv =      i_mR(r,r);
double **B   = r_mR(i_mR(r,C6),999.);
double **X   =      i_mR(r,C6);
double **T   =      i_mR(r,C6);

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

  clrscrn();

  printf("                                                 \n");
  printf(" Linear systems with common coefficient matrix.\n\n");
  printf("                Ax1=b1                           \n");
  printf("                Ax2=b2                           \n");
  printf("                ...                              \n");
  printf("                Axn=bn                         \n\n");
  printf(" We can write these equalities in this maner.  \n\n");
  printf("    A|x1|x2|...|xn| = b1|b2|...|bn|            \n\n");
  printf("  or simply :                                  \n\n");
  printf("              AX = B                           \n\n");
  printf("  where B = b1|b2|...|bn                       \n\n");
  printf("  and   X = x1|x2|...|xn                       \n\n");
  getchar();

  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");
  getchar();

  clrscrn();
  printf(" A :\n");
  p_mR(A,S5,P0,C6);
  printf("       b1       b2      ...      bn :\n");
  p_mR(B,S9,P0,C6);
  getchar();

  clrscrn();
  printf(" inv(A) :\n");
  pE_mR(inv_mR(A,Inv),S1,P4,C6);
  printf(" X = inv(A) * B :\n\n");
  printf("    x1       x2       ...      xn\n");
  p_mR(mul_mR(Inv,B,X),S9,P4,C6);
  getchar();

  clrscrn();
  printf("       b1       b2      ...      bn :\n");
  p_mR(B,S9,P0,C6);
  printf("      Ax1      Ax2      ...     Axn :\n");
  p_mR(mul_mR(A,X,T),S9,P0,C6);

  f_mR(T);
  f_mR(X);
  f_mR(B);
  f_mR(Inv);
  f_mR(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;

  srand(time(&t));
do
{
  fun(rp_I(RC5)+RC1);

} while(stop_w());

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


Nous résolvons un système d'équations, et nous vérifions les calculs.



Exemple de sortie écran :
--------------------------------------                                               
 Linear systems with common coefficient matrix.

                Ax1=b1                           
                Ax2=b2                           
                ...                              
                Axn=bn                         

 We can write these equalities in this maner.  

    A|x1|x2|...|xn| = b1|b2|...|bn|            

  or simply :                                  

              AX = B                           

  where B = b1|b2|...|bn                       

  and   X = x1|x2|...|xn                       


--------------------------------------
 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.  


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

 +766  -263  -339  +266 
 +646  +266  +632  -533 
 +552  -339   +56  -645 
 +320  -447  -193  +380 

       b1       b2      ...      bn :

     +886      -287      +706      +804       +94      -263 
     -673      -829       -61      +112      +710       +32 
     +640      +202      -981      -907      -401      +660 
     -279      +364      +310      -595      +188      +580 


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

+1.0589e-03 +5.0817e-04 -1.1897e-04 -2.3039e-04 
+1.4836e-03 +1.6291e-04 -8.9711e-04 -2.3327e-03 
-1.7265e-03 +1.3907e-03 -5.3580e-04 +2.2497e-03 
-2.3430e-05 +4.7002e-04 -1.2272e-03 +1.2242e-03 

 X = inv(A) * B :

    x1       x2       ...      xn

  +0.5843   -0.8331   +0.7619   +1.1533   +0.4647   -0.4744 
  +1.2815   -1.5912   +1.1944   +3.4127   +0.1763   -2.3301 
  -3.4362   +0.0533   -0.0807   -2.0850   +1.4629   +1.4498 
  -1.4641   -0.1852   +1.5382   +0.4185   +1.0538   -0.0787 

-------------------------------------- Ax = B ?
       b1       b2      ...      bn :

     +886      -287      +706      +804       +94      -263 
     -673      -829       -61      +112      +710       +32 
     +640      +202      -981      -907      -401      +660 
     -279      +364      +310      -595      +188      +580 

      Ax1      Ax2      ...     Axn :

     +886      -287      +706      +804       +94      -263 
     -673      -829       -61      +112      +710       +32 
     +640      +202      -981      -907      -401      +660 
     -279      +364      +310      -595      +188      +580 


 Press return to continue
 Press X      to stop