Mathc complexes/h09m
Bibliothèque
Installer ce fichier dans votre répertoire de travail.
/* Save as : wgipivot.h */
/* ------------------------------------
 pivotbest = |a+bI|^2 = = a^2+b^2
double pivotbestAId_mZ(
double **Ab,
int pivot_r,
int pivot_c
double pivotbest=Ab[pivot_r][pivot_c] *Ab[pivot_r][pivot_c]
 Ab[pivot_r][pivot_c+C1]*Ab[pivot_r][pivot_c+C1];
double pivot = pivotbest;
int best_r = pivot_r;
int best_c = pivot_c;
int r;
int c;
 for( r=pivot_r; r<Ab[R_SIZE][C0]; r++)
 for( c=pivot_c; c<Ab[C_SIZE_A][C0]; c+=C2)
 pivot = Ab[r][c] *Ab[r][c] + 
 Ab[r][c+C1]*Ab[r][c+C1];
 if(pivot>pivotbest)
 pivotbest=pivot;
 best_r = r;
 best_c = c;
 c--;
 if(best_r!=pivot_r) swapR_mZ(Ab,pivot_r,best_r);
 if(best_c!=pivot_c){swapC_mZ(Ab,pivot_c,best_c);
 swapC_mZ(Ab,pivot_c+c,best_c+c);
 return(pivotbest);
/* ------------------------------------ */
 Déclaration des fichiers h.

Mathc complexes/h09l
Bibliothèque
Installer ce fichier dans votre répertoire de travail.
/* Save as : wgpivot.h */
/* ------------------------------------
 pivotbest = |a+bI|^2 = = a^2+b^2
double pivotbestAb_mZ(
double **Ab,
int pivot_r,
int pivot_c
double pivotbest=Ab[pivot_r][pivot_c] *Ab[pivot_r][pivot_c]
 Ab[pivot_r][pivot_c+C1]*Ab[pivot_r][pivot_c+C1];
double pivot = pivotbest;
int best_r = pivot_r;
int best_c = pivot_c;
int r;
int c;
 for( r=pivot_r; r<Ab[R_SIZE][C0]; r++)
 for( c=pivot_c; c<Ab[C_SIZE_A][C0]; c+=C2)
 pivot = Ab[r][c]*Ab[r][c] + Ab[r][c+C1]*Ab[r][c+C1];
 if(pivot>pivotbest)
 pivotbest=pivot;
 best_r = r;
 best_c = c;
 if(best_r!=pivot_r) swapR_mZ(Ab,pivot_r,best_r);
 if(best_c!=pivot_c) swapC_mZ(Ab,pivot_c,best_c);
 return(pivotbest);
/* ------------------------------------ */
void zero_under_pivot_gjAb_mZ(
double **A,
int pivot_r,
int pivot_c
nb_Z pivot;
double abspivot=A[pivot_r][pivot_c] *A[pivot_r][pivot_c]
 A[pivot_r][pivot_c+C1]*A[pivot_r][pivot_c+C1];
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);
void zero_below_pivot_gj_mZ(
double **Ab,
int pivot_r,
int pivot_c
double abspivot=Ab[pivot_r][pivot_c] *Ab[pivot_r][pivot_c]
 Ab[pivot_r][pivot_c+C1]*Ab[pivot_r][pivot_c+C1];
int r;
 if(abspivot>ERROR_E)
 for( r=(pivot_r-C1); r>=R1; r--)
 addR_mZ( Ab,
 sym_Z(i_Z( Ab[r][pivot_c], 
 Ab[r][pivot_c+C1]) ),
 pivot_r,
 r);
/* ------------------------------------ */
 Déclaration des fichiers h.

Mathc complexes/h09k
Bibliothèque
Installer ce fichier dans votre répertoire de travail.
/* Save as : wgsort.h */
void sort_c_mZ(
double **Ab
double **T = i_RC_mZ(Ab[R_SIZE][C0],Ab[C_SIZE][C0]);
int c;
nb_Z c_T;
 for(c=C1; c<Ab[C_SIZE][C0]; c+=C2)
 c_T = i_Z( Ab[R0][c],Ab[R0][c+C1]); 
 cR0_c_mZ(Ab,
 c,
 T,
 ((c_T.r-C1)*C2+C1) );
 cR0_mZ(T,Ab);
 f_mZ(T);
/* ------------------------------------ */
void sort_r_mZ(
double **Ab
nb_Z pivot;
double abs_pivot = 0.;
int r_pivot = R1;
int r = R1;
int c;
 for ( c=C1; c<Ab[C_SIZE_A][C0]; c+=C2)
 r = r_pivot;
 abs_pivot = 0.;
 while((abs_pivot<ERROR_E) &&
 r<Ab[R_SIZE][C0])
 pivot = i_Z( Ab[r][c],Ab[r][c+C1]);
 abs_pivot = (pivot.r*pivot.r)+(pivot.i*pivot.i);
 if(abs_pivot>ERROR_E) {
 swapR_mZ(Ab,r,r_pivot);
 r_pivot++;
 r++;
/* ------------------------------------ */
void sort4_r_coef_r0_mZ(
double **Ab
double **Ab_T = i_RC_mZ(Ab[R_SIZE][C0],Ab[C_SIZE][C0]);
int c;
int r;
int r_T;
nb_Z T;
 for ( r=R1; r<Ab[R_SIZE][C0]; r++)
 for ( c=C1; c<Ab[C_SIZE][C0]; c+=C2)
 T= i_Z( Ab[R0][(((r-C1)*C2)+C1)],
 Ab[R0][(((r-C1)*C2)+C1)+C1]);
 r_T = T.r;
 Ab_T[r_T][c] = Ab[r][c];
 Ab_T[r_T][c+C1] = Ab[r][c+C1];
 cR0_mZ(Ab_T,Ab);
 f_mZ(Ab_T);
/* ------------------------------------ */
 Déclaration des fichiers h.

Mathc complexes/h09n
Bibliothèque
Installer ce fichier dans votre répertoire de travail.
/* Save as : wgjinv.h */
void invgj_T_mZ(
double **Ab
int r;
int c;
double pivot;
 r = c = C1;
 while((r<Ab[R_SIZE][C0]) &&
 (c<Ab[C_SIZE_A][C0])
 {
 pivot = pivotbestAId_mZ(Ab,r,c);
 if(fabs(pivot)>ERROR_E) zero_under_pivot_mZ(Ab,r,c);
 r++;
 c+=C2;
 r--;
 c-=C2;
 while( (r>R1) )
 zero_below_pivot_gj_mZ(Ab,r,c);
 r--;
 c-=C2;
double **invgj_mZ(
double **A,
double **invA
double **ID = i_RC_mZ(A[R_SIZE][C0],A[C_SIZE][C0]);
double **AID;
int r = A[R_SIZE][C0];
 --r;
 AID = i_Abr_Ac_bc_mZ(r,r,r);
 eye_mZ(ID);
 c_A_b_Ab_mZ(A,ID,AID);
 invgj_T_mZ(AID);
 sort_c_mZ(AID);
 sort_r_mZ(AID);
 c_Inv_A_mZ(AID,invA);
 f_mZ(AID);
 f_mZ(ID);
return(invA);
/* ------------------------------------ */
 Déclaration des fichiers h.

Mathc complexes/c091a
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* Save as : inv_z.c */
void fun(int r)
double **A = i_mZ(r,r);
double **Inv = i_mZ(r,r);
 clrscrn();
 printf(" A\n");
 p_mZ(r_mZ(A,99.), S5,P0, S4,P0, C6);
 stop();
 clrscrn();
 printf(" invgj_mZ(A,invA);");
 pE_mZ(invgj_mZ(A,Inv), S1,P4, S1,P4, C3);
 printf(" inv_mZ(A,Inv); :");
 pE_mZ(inv_mZ(A,Inv), S1,P4, S1,P4, C3);
 stop();
 clrscrn();
 printf(" Copy/Past into the octave window.\n\n");
 p_Octave_mZ(A,"A",P0, P0);
 printf(" inv(A)\n");
 pE_mZ(Inv, S1,P4, S1,P4, C3);
 f_mZ(Inv);
 f_mZ(A);
/* ------------------------------------ */
int main(void)
time_t t;
 srand(time(&t));
do
 fun(rp_I(R3)+R1);
} while(stop_w());
 return 0;
/* ------------------------------------ */
 Vérifier le résultat avec octave.

Exemple de sortie écran :
 A
 -39 -71i +28 -45i -67 +10i 
 +90 -17i +64 -25i -71 +52i 
 +58 -95i -77 -53i +82 -15i 
 Press return to continue. 
 ------------------------------------
 invgj_mZ(A,invA);
-3.9897e-03-3.5139e-04i +6.6885e-03+3.1050e-03i +4.5529e-03-5.2070e-04i 
+1.7498e-03+1.2785e-02i -7.3726e-03-8.5534e-03i -9.8613e-03+5.6986e-03i 
-4.8329e-03+7.8790e-03i -8.1257e-03-8.7309e-03i -4.0740e-03+3.8751e-03i 
 inv_mZ(A,Inv); :
-3.9897e-03-3.5139e-04i +6.6885e-03+3.1050e-03i +4.5529e-03-5.2070e-04i 
+1.7498e-03+1.2785e-02i -7.3726e-03-8.5534e-03i -9.8613e-03+5.6986e-03i 
-4.8329e-03+7.8790e-03i -8.1257e-03-8.7309e-03i -4.0740e-03+3.8751e-03i 
 Press return to continue. 
 Copy/Past into the octave window.
 A=[
-39-71*i,+28-45*i,-67+10*i;
+90-17*i,+64-25*i,-71+52*i;
+58-95*i,-77-53*i,+82-15*i]
 inv(A)
-3.9897e-03-3.5139e-04i +6.6885e-03+3.1050e-03i +4.5529e-03-5.2070e-04i 
+1.7498e-03+1.2785e-02i -7.3726e-03-8.5534e-03i -9.8613e-03+5.6986e-03i 
-4.8329e-03+7.8790e-03i -8.1257e-03-8.7309e-03i -4.0740e-03+3.8751e-03i 
 Press return to continue
 Press X to stop

Mathc complexes/c092a
Application
Installer et compiler ces fichiers dans votre répertoire de travail.
/* Save as : c02a.c */
void fun(int r)
double **A = i_mZ(r,r);
double **Inv = i_mZ(r,r);
double **B = r_mZ(i_mZ(r,C1),999.);
double **X = i_mZ(r,C1);
double **T = i_mZ(r,C1);
 do
 r_mZ(A,999.);
 printf(".");
 }while(!det_Z(A).r);
 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 :");
 p_mZ(A, S5,P0, S4,P0, C6);
 printf(" B :");
 p_mZ(B, S5,P0, S4,P0, C6);
 stop();
 clrscrn();
 printf(" invgj_mZ(A,Inv) :");
 pE_mZ(invgj_mZ(A,Inv), S1,P4, S1,P4, C3);
 printf(" X = invgj_mZ(A,Inv) * B :");
 p_mZ(mul_mZ(Inv,B,X), S2,P4, S2, P4, C6);
 stop();
 clrscrn();
 printf(" B :");
 p_mZ(B, S5,P0, S4,P0, C6);
 printf(" AX :");
 p_mZ(mul_mZ(A,X,T), S5,P0, S4,P0, C6);
 f_mZ(T);
 f_mZ(X);
 f_mZ(B);
 f_mZ(Inv);
 f_mZ(A);
/* ------------------------------------ */
int main(void)
time_t t;
 srand(time(&t));
do
 fun(rp_I(R5)+R1);
} while(stop_w());
 return 0;
/* ------------------------------------ */