Mathc complexes/Fichiers h : wel piv


Bibliothèque


Installer ce fichier dans votre répertoire de travail.

wepivot.h
/* ------------------------------------ */
/*  Save as :   wepivot.h               */
/* ------------------------------------ */
/* ------------------------------------
   pivotbest = |a+bI|^2 =  = a^2+b^2
   ------------------------------------ */
double pivotbest_mZ(
double **A,
int pivot_r,
int pivot_c
)
{
double pivotbest = A[pivot_r][pivot_c]   *A[pivot_r][pivot_c]
                                     +
                   A[pivot_r][pivot_c+C1]*A[pivot_r][pivot_c+C1];
double sign = 1.;
int best_r = pivot_r;
int best_c = pivot_c;

double value;
int r;
int c;

  for( r=pivot_r; r<A[R_SIZE][C0]; r++)

    for( c=pivot_c; c<A[C_SIZE][C0]; c+=C2)
         {
          value = A[r][c]*A[r][c] + A[r][c+C1]*A[r][c+C1]; 

          if(value>pivotbest)
             {
               pivotbest=value;  
               best_r = r;
               best_c = c;
             }
         }

 if(best_r!=pivot_r){ sign*=-1; swapR_mZ(A,pivot_r,best_r); }
 if(best_c!=pivot_c){ sign*=-1; swapC_mZ(A,pivot_c,best_c); }

 return(sign);
}
/* ------------------------------------ */
nb_Z zero_under_pivot_mZ(
double **A,
int pivot_r,
int pivot_c
)
{
double abspivot = A[pivot_r][pivot_c]   *A[pivot_r][pivot_c]
                                     +
                  A[pivot_r][pivot_c+C1]*A[pivot_r][pivot_c+C1];
nb_Z pivot;
int r;

    
  if(abspivot>ERROR_E)
    {
      pivot = i_Z( A[pivot_r][pivot_c],A[pivot_r][pivot_c+C1]);

      mulR_mZ( A,
               inv_Z(pivot),
               pivot_r);

     for( r=(pivot_r+C1); r<A[R_SIZE][C0]; r++)

         addR_mZ( A,
                  sym_Z(i_Z( A[r][pivot_c],A[r][pivot_c+C1])),
                  pivot_r,
                  r);
    }
    else pivot = i_Z(0,0);

 return(pivot);
}
/* ------------------------------------ */
/* ------------------------------------ */


L'algorithme utilisé est le total pivoting. Le coefficient de la matrice avec la plus grande norme et mis dans la position du pivot.


Cette fonction va travailler sur le déterminant. Si il y a eu un changement de ligne ou de colonne, il faudra multiplier par -1, c'est une propriété du déterminant.