Mathc matrices/c21z

Un livre de Wikilivres.


Application


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


c00b.c
/* ------------------------------------ */
/*  Save as :   c00c.c                  */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
int main(void)
{
double ab[R4*C7]={
     1,     -5,     3,     -8,    2,   +2,    0,
     5,     -9,     6,     -9,    6,    2,    0,
     5,     -9,     6,     -9,    6,    7,    0, 
    -1,      5,    -3,      8,   -2,   -2,    0,  
};

double **Ab = ca_A_mR(ab,i_Abr_Ac_bc_mR(R4,C6,C1));
double **A  = c_Ab_A_mR(Ab,i_mR(R4,C6));
double **b  = c_Ab_b_mR(Ab,i_mR(R4,C1));

double **B  =              i_mR(R4,C3);
double **BT  =             i_mR(C3,R4);
double **BTb =   i_Abr_Ac_bc_mR(C3,R4,C1); 

  clrscrn();
  printf("Basis for a Column Space by Row Reduction :\n\n");
  printf(" A :");
  p_mR(A,S6,P1,C10);
  printf(" b :");
  p_mR(b,S6,P1,C10);
  printf(" Ab :");
  p_mR(Ab,S6,P1,C10);
  stop();

  clrscrn();
  
  printf(" The leading 1’s of Ab give the position \n"
         " of the columns of  A which form a basis \n"
         " for the column space of A \n\n"
         " A :");
  p_mR(A,S7,P3,C10);
  printf(" gj_PP_mR(Ab,NO) :");
  gj_PP_mR(Ab,NO);
  p_mR(Ab,S7,P3,C10); 
  
  c_c_mR(A,C1,B,C1);
  c_c_mR(A,C2,B,C2);
  c_c_mR(A,C6,B,C3);
  
  printf(" B :  A basis for the column space of A");
  p_mR(B,S7,P3,C10); 
  stop();      
   
  clrscrn();   
  printf(" Check if the columns of B are linearly independent\n\n"
         " BT :");
  p_mR(transpose_mR(B,BT), S4,P0, C8);  
  printf(" BTb :");
  p_mR(c_mR(BT,BTb), S4,P0, C8); 
  printf(" gj_PP_FreeV_mZ(BTb) :");
  p_mR(gj_PP_mR(BTb,NO), S8,P4, C8);   

  stop();
     
  f_mR(Ab);
  f_mR(b);
  f_mR(A);
  f_mR(B);
  f_mR(BT);
  f_mR(BTb);
      
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */


La position des pivots de Ab donne la position des colonnes de A qui forment une base pour l'espace colonnes de A.


Exemple de sortie écran :
 ------------------------------------ 
Basis for a Column Space by Row Reduction :

 A :
  +1.0   -5.0   +3.0   -8.0   +2.0   +2.0 
  +5.0   -9.0   +6.0   -9.0   +6.0   +2.0 
  +5.0   -9.0   +6.0   -9.0   +6.0   +7.0 
  -1.0   +5.0   -3.0   +8.0   -2.0   -2.0 

 b :
  +0.0 
  +0.0 
  +0.0 
  +0.0 

 Ab :
  +1.0   -5.0   +3.0   -8.0   +2.0   +2.0   +0.0 
  +5.0   -9.0   +6.0   -9.0   +6.0   +2.0   +0.0 
  +5.0   -9.0   +6.0   -9.0   +6.0   +7.0   +0.0 
  -1.0   +5.0   -3.0   +8.0   -2.0   -2.0   +0.0 

 Press return to continue. 

 ------------------------------------ 
 The leading 1s of Ab give the position 
 of the columns of  A which form a basis 
 for the column space of A 

 A :
 +1.000  -5.000  +3.000  -8.000  +2.000  +2.000 
 +5.000  -9.000  +6.000  -9.000  +6.000  +2.000 
 +5.000  -9.000  +6.000  -9.000  +6.000  +7.000 
 -1.000  +5.000  -3.000  +8.000  -2.000  -2.000 

 gj_PP_mR(Ab,NO) :
 +1.000  -1.800  +1.200  -1.800  +1.200  +0.400  +0.000 
 -0.000  +1.000  -0.562  +1.938  -0.250  -0.500  -0.000 
 +0.000  +0.000  -0.000  +0.000  -0.000  +1.000  +0.000 
 +0.000  +0.000  +0.000  +0.000  +0.000  +0.000  +0.000 

 B :  A basis for the column space of A
 +1.000  -5.000  +2.000 
 +5.000  -9.000  +2.000 
 +5.000  -9.000  +7.000 
 -1.000  +5.000  -2.000 

 Press return to continue. 

 ------------------------------------ 
 Check if the columns of B are linearly independent

 BT :
  +1   +5   +5   -1 
  -5   -9   -9   +5 
  +2   +2   +7   -2 

 BTb :
  +1   +5   +5   -1   +0 
  -5   -9   -9   +5   +0 
  +2   +2   +7   -2   +0 

 gj_PP_FreeV_mZ(BTb) :
 +1.0000  +1.8000  +1.8000  -1.0000  -0.0000 
 +0.0000  +1.0000  +1.0000  +0.0000  +0.0000 
 +0.0000  +0.0000  +1.0000  +0.0000  +0.0000 

 Press return to continue.