Mathc complexes/00k
Fonctions matricielles dans C. Matrices Non symétriques conjugués
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define FACTOR_E +1.E-0
#define RCA RC3
/* ------------------------------------ */
/* ------------------------------------ */
double **EV_sinh2A_mZ(
double **EV,
double **EV_sinh2A
)
{
int r;
int c;
nb_Z sinh2A;
for ( r=R1; r<EV[R_SIZE][C0]; r++)
for ( c=C1; c<EV[C_SIZE][C0]; c+=C2)
if(((r-R1)*C2)==c-C1)
{
sinh2A = sinh_Z(i_Z(2.*EV[r][c],2.*EV[r][c+C1]));
EV_sinh2A[r][c ] = sinh2A.r;
EV_sinh2A[r][c+C1] = sinh2A.i;
}
return(EV_sinh2A);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **EV_TwocoshAsinhA_mZ(
double **EV,
double **EV_TwocoshAsinhA
)
{
int r;
int c;
nb_Z cosha;
nb_Z sinha;
nb_Z TwocoshAsinhA;
for ( r=R1; r<EV[R_SIZE][C0]; r++)
for ( c=C1; c<EV[C_SIZE][C0]; c+=C2)
if(((r-R1)*C2)==c-C1)
{
cosha = cosh_Z(i_Z( EV[r][c], EV[r][c+C1]));
sinha = sinh_Z(i_Z( EV[r][c], EV[r][c+C1]));
TwocoshAsinhA = smul_Z(2., mul_Z(cosha,sinha) );
EV_TwocoshAsinhA[r][c ] = TwocoshAsinhA.r;
EV_TwocoshAsinhA[r][c+C1] = TwocoshAsinhA.i;
}
return(EV_TwocoshAsinhA);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A = i_mZ(RCA,RCA);
double **V = i_mZ(RCA,RCA);
double **invV = i_mZ(RCA,RCA);
double **T = i_mZ(RCA,RCA);
double **EV = i_mZ(RCA,RCA);
double **EV_sinh2A = i_mZ(RCA,RCA);
double **EV_TwocoshAsinhA = i_mZ(RCA,RCA);
double **sinh2A = i_mZ(RCA,RCA);
double **TwocoshAsinhA = i_mZ(RCA,RCA);
do
{
rE_mZ(A,999,+1.E-4);
eigs_V_mZ(A,V,FACTOR_E);
}while(!det_Z(V).r);
clrscrn();
printf(" A :");
p_mZ(A, S9,P4, S8,P4, C3);
printf(" V :");
eigs_V_mZ(A,V,FACTOR_E);
pE_mZ(V, S12,P4, S12,P4, C3);
printf(" inv(V) ... Some time the matrix is not invertible :");
inv_mZ(V,invV);
pE_mZ(invV, S12,P4, S12,P4, C3);
printf(" EV = invV * A * V");
mul_mZ(invV,A,T);
mul_mZ(T,V,EV);
pE_mZ(clean_eyes_mZ(EV), S12,P4, S12,P4, C3);
stop();
clrscrn();
printf(" sinh(2*A) :");
EV_sinh2A_mZ(EV,EV_sinh2A);
mul_mZ(V,EV_sinh2A,T);
mul_mZ(T,invV,sinh2A);
pE_mZ(sinh2A, S12,P4, S8,P4, C3);
printf(" 2 cosh(A)sinh(A) :");
EV_TwocoshAsinhA_mZ(EV,EV_TwocoshAsinhA);
mul_mZ(V,EV_TwocoshAsinhA,T);
mul_mZ(T,invV,TwocoshAsinhA);
pE_mZ(TwocoshAsinhA, S12,P4, S8,P4, C3);
f_mZ(A);
f_mZ(V);
f_mZ(invV);
f_mZ(T);
f_mZ(EV);
f_mZ(EV_sinh2A);
f_mZ(sinh2A);
f_mZ(EV_TwocoshAsinhA);
f_mZ(TwocoshAsinhA);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
A :
+0.0255 -0.0832i -0.0272 +0.0408i -0.0747 -0.0754i
+0.0269 -0.0200i +0.0518 +0.0331i +0.0874 -0.0067i
+0.0746 +0.0486i -0.0223 +0.0870i +0.0712 +0.0577i
V :
-1.8265e-01 +1.3961e-01i -4.0748e-01 -7.9646e-01i -4.2445e-01 +5.2710e-01i
+3.3651e-01 -5.4931e-01i +1.2439e-01 +5.5202e-02i -5.5288e-01 +8.8787e-03i
+7.2950e-01 +0.0000e+00i +4.2554e-01 +1.1811e-17i +4.8606e-01 +1.4041e-17i
inv(V) ... Some time the matrix is not invertible :
+3.0616e-01 -2.6567e-01i +6.1174e-01 +5.6963e-01i +6.8549e-01 +7.2765e-02i
-2.7774e-01 +8.1404e-01i -9.6267e-02 -5.1873e-01i +5.2125e-01 +4.2376e-01i
-2.1633e-01 -3.1395e-01i -8.3384e-01 -4.0079e-01i +5.7219e-01 -4.8021e-01i
EigsValue = invV * A * V
+9.8446e-02 +1.1673e-01i +0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +7.2925e-02 -1.0592e-01i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i -2.2870e-02 -3.2085e-03i
Press return to continue.
sinh(2*A) :
+4.8685e-02-1.6702e-01i -5.2362e-02+8.0674e-02i -1.4977e-01-1.4993e-01i
+5.4865e-02-3.9233e-02i +1.0172e-01+6.8204e-02i +1.7448e-01-1.1565e-02i
+1.4930e-01+9.7654e-02i -4.7449e-02+1.7400e-01i +1.3972e-01+1.1573e-01i
2 cosh(A)sinh(A) :
+4.8685e-02-1.6702e-01i -5.2362e-02+8.0674e-02i -1.4977e-01-1.4993e-01i
+5.4865e-02-3.9233e-02i +1.0172e-01+6.8204e-02i +1.7448e-01-1.1565e-02i
+1.4930e-01+9.7654e-02i -4.7449e-02+1.7400e-01i +1.3972e-01+1.1573e-01i
Press return to continue
Press X return to stop