Mathc complexes/00l
Apparence
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_cosh2A_mZ(
double **EV,
double **EV_cosh2A
)
{
int r;
int c;
nb_Z cosh2A;
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)
{
cosh2A = cosh_Z(i_Z(2.*EV[r][c],2.*EV[r][c+C1]));
EV_cosh2A[r][c ] = cosh2A.r;
EV_cosh2A[r][c+C1] = cosh2A.i;
}
return(EV_cosh2A);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **EV_TwocoshAP2mns1_mZ(
double **EV,
double **EV_TwocoshAP2mns1
)
{
int r;
int c;
nb_Z cosha;
nb_Z mns1 = {1,0};
nb_Z TwocoshAP2mns1;
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]));
TwocoshAP2mns1 = sub_Z(smul_Z(2., mul_Z(cosha,cosha)),mns1);
EV_TwocoshAP2mns1[r][c ] = TwocoshAP2mns1.r;
EV_TwocoshAP2mns1[r][c+C1] = TwocoshAP2mns1.i;
}
return(EV_TwocoshAP2mns1);
}
/* ------------------------------------ */
/* ------------------------------------ */
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_cosh2a = i_mZ(RCA,RCA);
double **EV_TwocoshAP2mns1 = i_mZ(RCA,RCA);
double **cosh2a = i_mZ(RCA,RCA);
double **TwocoshAP2mns1 = 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(" cosh(2*A) :");
EV_cosh2A_mZ(EV,EV_cosh2a);
mul_mZ(V,EV_cosh2a,T);
mul_mZ(T,invV,cosh2a);
pE_mZ(cosh2a, S12,P4, S8,P4, C3);
printf(" 2cosh(A)**2-1 :");
EV_TwocoshAP2mns1_mZ(EV,EV_TwocoshAP2mns1);
mul_mZ(V,EV_TwocoshAP2mns1,T);
mul_mZ(T,invV,TwocoshAP2mns1);
pE_mZ(TwocoshAP2mns1, S12,P4, S8,P4, C3);
f_mZ(A);
f_mZ(V);
f_mZ(invV);
f_mZ(T);
f_mZ(EV);
f_mZ(EV_cosh2a);
f_mZ(cosh2a);
f_mZ(EV_TwocoshAP2mns1);
f_mZ(TwocoshAP2mns1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
A :
+0.0225 +0.0051i +0.0779 +0.0138i -0.0945 -0.0217i
-0.0923 +0.0011i -0.0101 -0.0281i +0.0311 +0.0265i
-0.0476 +0.0727i -0.0818 +0.0970i -0.0647 +0.0755i
V :
+3.8851e-01 +3.1281e-01i -2.4670e-01 -5.7185e-01i -6.2073e-01 +1.8526e-01i
+1.5785e-02 +6.6124e-02i -4.2367e-01 +5.3807e-01i +1.8555e-01 -5.3566e-01i
+8.6405e-01 +0.0000e+00i +3.7831e-01 +0.0000e+00i +5.0894e-01 +0.0000e+00i
inv(V) ... Some time the matrix is not invertible :
+5.7288e-01 -2.8106e-01i +3.3068e-01 -2.7999e-01i +7.7053e-01 -1.0121e-01i
-4.5662e-01 +3.8366e-01i -7.0829e-01 -4.5720e-01i +3.2216e-01 +5.5354e-02i
-6.3318e-01 +1.9199e-01i -3.4921e-02 +8.1520e-01i +4.1723e-01 +1.3068e-01i
EigsValue = invV * A * V
-1.2134e-01 +8.6469e-02i +0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +2.9878e-02 -1.2493e-01i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i +3.9161e-02 +9.0963e-02i
Press return to continue.
cosh(2*A) :
+9.9863e-01-1.3628e-02i +2.2062e-02-1.8013e-02i +1.5567e-02-8.5442e-03i
-8.9704e-03+6.2120e-03i +9.7408e-01+4.7939e-04i +1.0280e-02+2.7482e-03i
+6.9753e-03-3.1922e-02i -6.4808e-03-1.2306e-02i +9.9872e-01-2.9622e-02i
2cosh(A)**2-1 :
+9.9863e-01-1.3628e-02i +2.2062e-02-1.8013e-02i +1.5567e-02-8.5442e-03i
-8.9704e-03+6.2120e-03i +9.7408e-01+4.7939e-04i +1.0280e-02+2.7482e-03i
+6.9753e-03-3.1922e-02i -6.4808e-03-1.2306e-02i +9.9872e-01-2.9622e-02i
Press return to continue
Press X return to stop