Aller au contenu

Mathc matrices/c25a2

Un livre de Wikilivres.


Application


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


c02.c
/* ------------------------------------ */
/*  Save as :   c02.c                   */
/* ------------------------------------ */
#include "v_a.h"
#include   "d.h"
/* --------------------------------- */
int main(void)
{
double   p[R2*C2] ={ 0,  1,       
                     1, -1};

double **Ap =     ca_A_mR(p,  i_mR(R2,C2));
double **A  = m_line_A_mR(Ap, i_mR(R3,C3));

int r;

  clrscrn();
  printf(" Theorem.\n\n");
  printf(" A homogeneous linear system with as many equations\n");
  printf(" as unknowns has a nontrivial  solution if and only\n");
  printf(" if the determinant  of the  coefficient  matrix is\n");
  printf(" zero.\n\n");
  
  printf(" Equation of a line:   \n\n");
  printf(" c1 x  + c2 y  + c3 = 0\n\n");    
  
  printf(" The same equation with the values of the two points:\n\n");
  printf(" c1 x1 + c2 y1 + c3 = 0\n");
  printf(" c1 x2 + c2 y2 + c3 = 0\n\n");
  
  printf(" The three equation:\n\n");
  printf(" c1 x  + c2 y  + c3 = 0\n");
  printf(" c1 x1 + c2 y1 + c3 = 0\n");
  printf(" c1 x2 + c2 y2 + c3 = 0\n\n");
  stop();
  
  clrscrn();
  printf(" The two points:\n\n");
  printf(" P1(%+.0f,%+.0f)  ",  Ap[R1][C1],Ap[R1][C2]);
  printf(" P2(%+.0f,%+.0f)\n\n",Ap[R2][C1],Ap[R2][C2]);

  printf(" The determinant :\n\n (cofactor expansion along the first row)\n\n");
  
  printf("     x     y     1");
  p_Det_mR(A,6,0);
  
  printf(" The equation of the line : \n\n");
  
  printf(" eq = %+.0f x %+.0f y %+.0f = 0\n\n",
           cofactor_R(A,R1,C1),
           cofactor_R(A,R1,C2),
           cofactor_R(A,R1,C3));
           
  printf(" Verify the result : \n\n");           
  for(r=R1;r<Ap[R_SIZE][C0];r++)
      verify_eq_line_mR(A, Ap[r][C1],
                           Ap[r][C2]);
           
  stop();
  
  f_mR(A);
  f_mR(Ap);

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



Exemple de sortie écran :
 ------------------------------------ 
 Theorem.

 A homogeneous linear system with as many equations
 as unknowns has a nontrivial  solution if and only
 if the determinant  of the  coefficient  matrix is
 zero.

 Equation of a line:   

 c1 x  + c2 y  + c3 = 0

 The same equation with the values of the two points:

 c1 x1 + c2 y1 + c3 = 0
 c1 x2 + c2 y2 + c3 = 0

 The three equation:

 c1 x  + c2 y  + c3 = 0
 c1 x1 + c2 y1 + c3 = 0
 c1 x2 + c2 y2 + c3 = 0

 Press return to continue. 



 The two points:

 P1(+0,+1)   P2(+1,-1)

 The determinant :

 (cofactor expansion along the first row)

     x     y     1
    +0    +1    +1
    +1    -1    +1

 The equation of the line : 

 eq = +2 x +1 y -1 = 0

 Verify the result : 

 With x= +0.0 y= +1.0  eq=+0.00000
 With x= +1.0 y= -1.0  eq=+0.00000
 Press return to continue.