Mathc complexes/00c
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 **EigsValue_cos2A_mZ(
double **EigsValue,
double **EigsValue_cos2A
)
{
int r;
int c;
nb_Z cos2A;
for ( r=R1; r<EigsValue[R_SIZE][C0]; r++)
for ( c=C1; c<EigsValue[C_SIZE][C0]; c+=C2)
if(((r-R1)*C2)==c-C1)
{
cos2A = cos_Z(i_Z(2.*EigsValue[r][c],2.*EigsValue[r][c+C1]));
EigsValue_cos2A[r][c ] = cos2A.r;
EigsValue_cos2A[r][c+C1] = cos2A.i;
}
return(EigsValue_cos2A);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **EigsValue_cosAP2_mns_sinAP2_mZ(
double **EigsValue,
double **EigsValue_cosAP2_mns_sinAP2
)
{
int r;
int c;
nb_Z cosAP2_mns_sinAP2;
nb_Z cos;
nb_Z cosP2;
nb_Z sin;
nb_Z sinP2;
for ( r=R1; r<EigsValue[R_SIZE][C0]; r++)
for ( c=C1; c<EigsValue[C_SIZE][C0]; c+=C2)
if(((r-R1)*C2)==c-C1)
{
cos = cos_Z(i_Z(EigsValue[r][c],EigsValue[r][c+C1]));
cosP2 = mul_Z(cos,cos);
sin = sin_Z(i_Z(EigsValue[r][c],EigsValue[r][c+C1]));
sinP2 = mul_Z(sin,sin);
cosAP2_mns_sinAP2 = sub_Z(cosP2,sinP2);
EigsValue_cosAP2_mns_sinAP2[r][c ] = cosAP2_mns_sinAP2.r;
EigsValue_cosAP2_mns_sinAP2[r][c+C1] = cosAP2_mns_sinAP2.i;
}
return(EigsValue_cosAP2_mns_sinAP2);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A = rE_mZ(i_mZ(RCA,RCA),999,+1.E-4);
double **V = i_mZ(RCA,RCA);
double **invV = i_mZ(RCA,RCA);
double **T = i_mZ(RCA,RCA);
double **EigsValue = i_mZ(RCA,RCA);
double **EigsValue_cos2a = i_mZ(RCA,RCA);
double **EigsValue_cosAP2_mns_sinAP2 = i_mZ(RCA,RCA);
double **cos2a = i_mZ(RCA,RCA);
double **cosAP2_mns_sinAP2 = i_mZ(RCA,RCA);
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(" EigsValue = invV * A * V");
mul_mZ(invV,A,T);
mul_mZ(T,V,EigsValue);
pE_mZ(clean_eyes_mZ(EigsValue), S12,P4, S12,P4, C3);
stop();
clrscrn();
printf(" cos(2*A) :");
EigsValue_cos2A_mZ(EigsValue,EigsValue_cos2a);
mul_mZ(V,EigsValue_cos2a,T);
mul_mZ(T,invV,cos2a);
pE_mZ(cos2a, S12,P4, S8,P4, C3);
printf(" cos(A)**2-sin(A)**2 :");
EigsValue_cosAP2_mns_sinAP2_mZ(EigsValue,EigsValue_cosAP2_mns_sinAP2);
mul_mZ(V,EigsValue_cosAP2_mns_sinAP2,T);
mul_mZ(T,invV,cosAP2_mns_sinAP2);
pE_mZ(cosAP2_mns_sinAP2, S12,P4, S8,P4, C3);
f_mZ(A);
f_mZ(V);
f_mZ(invV);
f_mZ(T);
f_mZ(EigsValue);
f_mZ(EigsValue_cos2a);
f_mZ(cos2a);
f_mZ(EigsValue_cosAP2_mns_sinAP2);
f_mZ(cosAP2_mns_sinAP2);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
A :
+0.0216 -0.0486i +0.0101 -0.0223i -0.0590 -0.0590i
+0.0929 -0.0204i -0.0217 -0.0212i -0.0877 -0.0263i
-0.0230 +0.0701i -0.0004 +0.0815i +0.0629 +0.0554i
V :
-4.0410e-01 -2.4073e-01i -1.6682e-01 +2.6271e-01i +4.3789e-01 +2.6890e-01i
-5.4576e-01 -2.8734e-01i +3.0840e-01 +6.4933e-01i -7.3734e-01 +1.3884e-01i
+6.3114e-01 +0.0000e+00i +6.2162e-01 +0.0000e+00i +4.1593e-01 +3.3608e-18i
inv(V) ... Some time the matrix is not invertible :
-5.0398e-01 +6.2192e-01i -2.3400e-01 +3.8572e-01i +6.4659e-01 +4.3296e-01i
-1.3635e-01 -3.8795e-01i +5.3994e-01 -4.0851e-01i +7.1355e-01 -4.0783e-01i
+9.6853e-01 -3.6390e-01i -4.5188e-01 +2.5237e-02i +3.5668e-01 -4.7475e-02i
EigsValue = invV * A * V
+1.4181e-01 -5.1002e-02i +0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i -4.5886e-02 +6.6883e-02i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i -3.3129e-02 -3.0281e-02i
Press return to continue.
cos(2*A) :
+9.9181e-01+1.4187e-02i -6.5742e-03+1.0902e-02i +1.1986e-02+7.4187e-03i
-4.8898e-03+2.3892e-02i +9.9459e-01+1.6904e-02i +1.8624e-02+1.6772e-02i
+1.7064e-03-2.6556e-02i +3.0163e-03-9.0526e-03i +9.8300e-01+5.7878e-03i
cos(A)**2-sin(A)**2 :
+9.9181e-01+1.4187e-02i -6.5742e-03+1.0902e-02i +1.1986e-02+7.4187e-03i
-4.8898e-03+2.3892e-02i +9.9459e-01+1.6904e-02i +1.8624e-02+1.6772e-02i
+1.7064e-03-2.6556e-02i +3.0163e-03-9.0526e-03i +9.8300e-01+5.7878e-03i
Press return to continue
Press X return to stop