Mathc complexes/c102a
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = i_mZ(r,r);
double **b = r_mZ( i_mZ(r,C1),999.);
double **X = i_mZ(r,C1);
double **Ab = i_Abr_Ac_bc_mZ(r,r,C1);
do
{
r_mZ(A,999.);
printf(".");
}while(!det_Z(A).r);
c_A_b_Ab_mZ(A,b,Ab);
clrscrn();
printf(" We want to find X such as, \n\n");
printf(" AX = b \n\n");
printf(" We can use the function, \n");
printf(" gaussjordan : gj_mZ(Ab); \n\n");
printf(" To verify the result you can \n");
printf(" multiply the matrix A by X. \n");
printf(" You must refind b. \n\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(" Ab :");
p_mZ(Ab, S5,P0, S4,P0, C6);
printf(" gj_mZ(Ab) :");
p_mZ(gj_mZ(Ab), S1,P4, S1,P4, C3);
stop();
clrscrn();
printf(" Ab :");
p_mZ(Ab, S4,P3, S4,P3, C4);
printf(" X :");
p_mZ(c_Ab_b_mZ(Ab,X), S4,P3, S4,P3, C4);
stop();
clrscrn();
printf(" b :");
p_mZ(b, S4,P0, S4,P0, C7);
printf(" AX :");
p_mZ(mul_mZ(A,X,b), S4,P0, S4,P0, C7);
f_mZ(Ab);
f_mZ(X);
f_mZ(b);
f_mZ(A);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R3)+R2);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
------------------------------------
We want to find X such as,
AX = b
We can use the function,
gaussjordan : gj_mZ(Ab);
To verify the result you can
multiply the matrix A by X.
You must refind b.
Press return to continue.
------------------------------------
A :
-507+884i -389 +68i +700-217i -15+314i
-531-461i +618+306i -777-817i +376-737i
-983-477i -257-595i +974+858i -597-145i
-451-671i -105+432i +316-105i -55+822i
b :
+170+874i
-75+960i
-263-925i
+282-903i
Press return to continue.
------------------------------------
Ab :
-507+884i -389 +68i +700-217i -15+314i +170+874i
-531-461i +618+306i -777-817i +376-737i -75+960i
-983-477i -257-595i +974+858i -597-145i -263-925i
-451-671i -105+432i +316-105i -55+822i +282-903i
gj_mZ(Ab) :
+1.000-0.000i -0.000+0.000i -0.000+0.000i +0.000+0.000i
+0.000+0.000i +1.000-0.000i -0.000+0.000i +0.000-0.000i
+0.000-0.000i -0.000-0.000i +1.000+0.000i +0.000+0.000i
-0.000-0.000i +0.000+0.000i +0.000+0.000i +1.000+0.000i
+0.541-1.405i
+3.428-6.264i
+1.563-2.511i
-2.762+1.532i
Press return to continue.
------------------------------------
gj_mZ(Ab) :
+1.000-0.000i -0.000+0.000i -0.000+0.000i +0.000+0.000i
+0.000+0.000i +1.000-0.000i -0.000+0.000i +0.000-0.000i
+0.000-0.000i -0.000-0.000i +1.000+0.000i +0.000+0.000i
-0.000-0.000i +0.000+0.000i +0.000+0.000i +1.000+0.000i
+0.541-1.405i
+3.428-6.264i
+1.563-2.511i
-2.762+1.532i
X :
+0.541-1.405i
+3.428-6.264i
+1.563-2.511i
-2.762+1.532i
Press return to continue.
------------------------------------
b :
+170+874i
-75+960i
-263-925i
+282-903i
AX :
+170+874i
-75+960i
-263-925i
+282-903i
Press return to continue
Press X to stop