Mathc complexes/a336
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00c.c |
---|
/* ------------------------------------ */
/* Save as : c00c.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define RCA RC3
#define FACTOR_E +1.E-0
/* ------------------------------------ */
/* ------------------------------------ */
double **X_Cos2A_mZ(
double **M_Value,
double **Cos2A_Value
)
{
int r;
int c;
nb_Z Cos2A;
for ( r=R1; r<M_Value[R_SIZE][C0]; r++)
for ( c=C1; c<M_Value[C_SIZE][C0]; c+=C2)
if(((r-R1)*C2)==c-C1)
{
Cos2A = cos_Z(i_Z(2.*M_Value[r][c],2.*M_Value[r][c+C1]));
Cos2A_Value[r][c ] = Cos2A.r;
Cos2A_Value[r][c+C1] = Cos2A.i;
}
return(Cos2A_Value);
}
/* ------------------------------------ */
/* ------------------------------------ */
double **X_CosAP2_mns_SinAP2_mZ(
double **M_Value,
double **CosAP2_mns_SinAP2_Value
)
{
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<M_Value[R_SIZE][C0]; r++)
for ( c=C1; c<M_Value[C_SIZE][C0]; c+=C2)
if(((r-R1)*C2)==c-C1)
{
Cos = cos_Z(i_Z(M_Value[r][c],M_Value[r][c+C1]));
CosP2 = mul_Z(Cos,Cos);
Sin = sin_Z(i_Z(M_Value[r][c],M_Value[r][c+C1]));
SinP2 = mul_Z(Sin,Sin);
CosAP2_mns_SinAP2 = sub_Z(CosP2,SinP2);
CosAP2_mns_SinAP2_Value[r][c ] = CosAP2_mns_SinAP2.r;
CosAP2_mns_SinAP2_Value[r][c+C1] = CosAP2_mns_SinAP2.i;
}
return(CosAP2_mns_SinAP2_Value);
}
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
int r = RCA;
int c = RCA;
double **A = rE_mZ(i_mZ(r,c),999,+1.E-4);
double **A_T = ctranspose_mZ(A,i_mZ(c,r));
double **V = i_mZ(r,c);
double **V_T = i_mZ(c,r);
double **U = i_mZ(r,c);
double **U_T = i_mZ(c,r);
double **U_TA = i_mZ(c,c);
double **X = i_mZ(c,c);
double **T1 = i_mZ(c,c);
double **CosAP2_mns_SinAP2 = i_mZ(c,c);
double **Cos2A = i_mZ(c,c);
clrscrn();
printf(" A :");
p_mZ(A, S9,P4, S8,P4, C3);
printf(" U :");
X_U_mZ(A_T,U,FACTOR_E);
p_mZ(U, S9,P4, S8,P4, C3);
printf(" V :");
X_V_mZ(A_T,V,FACTOR_E);
p_mZ(V, S9,P4, S8,P4, C3);
ctranspose_mZ(U,U_T);
ctranspose_mZ(V,V_T);
printf(" X = U_T * A * V :");
mul_mZ(U_T, A, U_TA);
mul_mZ(U_TA, V, X);
p_mZ(X, S9,P4, S8,P4, C3);
stop();
clrscrn();
printf(" cos(2 A) :");
X_Cos2A_mZ(X,Cos2A);
mul_mZ(V,Cos2A,T1);
mul_mZ(T1,U_T,Cos2A);
pE_mZ(Cos2A, S12,P4, S8,P4, C3);
printf(" cos(A)**2 - sin(A)**2 :");
X_CosAP2_mns_SinAP2_mZ(X,CosAP2_mns_SinAP2);
mul_mZ(V,CosAP2_mns_SinAP2,T1);
mul_mZ(T1,U_T,CosAP2_mns_SinAP2);
pE_mZ(CosAP2_mns_SinAP2, S12,P4, S8,P4, C3);
f_mZ(A);
f_mZ(A_T);
f_mZ(V);
f_mZ(V_T);
f_mZ(U);
f_mZ(U_T);
f_mZ(U_TA);
f_mZ(X);
f_mZ(Cos2A);
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.4410 -0.0550i +0.3410 +0.4300i -0.2340 +0.1550i
-0.2760 -0.1720i -0.2020 +0.4740i +0.5480 +0.0020i
+0.5200 -0.1010i -0.4160 +0.1630i -0.2250 -0.3330i
U :
-0.4293 +0.4933i +0.1178 +0.1815i +0.3527 -0.6334i
-0.0100 +0.4074i -0.3142 -0.8074i +0.2362 +0.1657i
+0.6375 +0.0000i +0.4500 -0.0000i +0.6254 +0.0000i
V :
-0.0634 +0.6479i -0.2463 +0.0708i +0.5555 -0.4493i
+0.4347 -0.5921i -0.3568 +0.1292i +0.5626 -0.0037i
+0.1913 -0.0000i +0.8890 +0.0000i +0.4160 -0.0000i
X = U_T * A * V :
-0.3133 +0.1119i +0.0000 +0.0000i +0.0000 +0.0000i
+0.0000 +0.0000i -0.1612 +0.4154i +0.0000 +0.0000i
+0.0000 +0.0000i +0.0000 +0.0000i -0.3907 -0.0637i
Press return to continue.
cos(2 A) :
+6.4538e-01+2.2927e-05i +3.3128e-01-3.7620e-01i -1.7769e-02+1.1387e-01i
-2.7471e-01+3.0374e-01i +1.1855e-02-6.7725e-01i +3.0659e-01-2.8206e-01i
+2.5618e-01-9.2067e-02i -5.0035e-01+7.2424e-01i +8.0556e-01+1.1058e-01i
cos(A)**2 - sin(A)**2 :
+6.4538e-01+2.2927e-05i +3.3128e-01-3.7620e-01i -1.7769e-02+1.1387e-01i
-2.7471e-01+3.0374e-01i +1.1855e-02-6.7725e-01i +3.0659e-01-2.8206e-01i
+2.5618e-01-9.2067e-02i -5.0035e-01+7.2424e-01i +8.0556e-01+1.1058e-01i
Press return to continue
Press X return to stop