Mathc complexes/a335
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00b.c |
---|
/* ------------------------------------ */
/* Save as : c00b.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_TwocosA_2mns1_mZ(
double **M_Value,
double **TwocosA_2mns1_Value
)
{
int r;
int c;
nb_Z cosa;
nb_Z mns1 = {1,0};
nb_Z TwocosA_2mns1;
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)
{
cosa = cos_Z(i_Z( M_Value[r][c], M_Value[r][c+C1]));
TwocosA_2mns1 = sub_Z(smul_Z(2., mul_Z(cosa,cosa)),mns1);
TwocosA_2mns1_Value[r][c ] = TwocosA_2mns1.r;
TwocosA_2mns1_Value[r][c+C1] = TwocosA_2mns1.i;
}
return(TwocosA_2mns1_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 **cos2A = i_mZ(c,c);
double **TwocosA_2mns1 = 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(" 2 cosA**2 - 1 :");
X_TwocosA_2mns1_mZ(X,TwocosA_2mns1);
mul_mZ(V,TwocosA_2mns1,T1);
mul_mZ(T1,U_T,TwocosA_2mns1);
pE_mZ(TwocosA_2mns1, 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(TwocosA_2mns1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
A :
-0.0912 +0.0008i +0.0996 +0.0048i -0.0803 +0.0598i
+0.0712 -0.0344i -0.0132 -0.0850i -0.0474 -0.0765i
+0.0572 -0.0606i +0.0784 +0.0034i -0.0217 +0.0016i
U :
+0.0389 -0.8078i +0.3893 -0.0044i -0.3382 +0.2829i
+0.2729 +0.4535i +0.3358 -0.5936i -0.3745 +0.3384i
+0.2566 +0.0000i +0.6191 +0.0000i +0.7422 +0.0000i
V :
+0.2819 -0.6269i -0.0959 -0.2867i -0.2121 +0.6254i
-0.0710 +0.3477i -0.2218 -0.8987i +0.1290 -0.0217i
+0.6337 +0.0000i +0.2273 -0.0000i +0.7394 +0.0000i
X = U_T * A * V :
-0.1651 -0.0971i +0.0000 +0.0000i +0.0000 -0.0000i
-0.0000 +0.0000i -0.0680 -0.1315i -0.0000 -0.0000i
-0.0000 -0.0000i -0.0000 -0.0000i +0.0268 +0.0654i
Press return to continue.
cos(2*A) :
+7.1989e-01-1.0476e-01i +2.0906e-01-6.0268e-01i -1.6300e-01+1.2913e-01i
-4.2368e-01-4.0998e-01i +5.3998e-01-3.8267e-01i -7.6474e-02-4.9525e-01i
-1.0637e-01+2.8071e-01i -4.9008e-02-4.0239e-01i +8.5373e-01-1.9242e-02i
2 cosA**2 - 1 :
+7.1989e-01-1.0476e-01i +2.0906e-01-6.0268e-01i -1.6300e-01+1.2913e-01i
-4.2368e-01-4.0998e-01i +5.3998e-01-3.8267e-01i -7.6474e-02-4.9525e-01i
-1.0637e-01+2.8071e-01i -4.9008e-02-4.0239e-01i +8.5373e-01-1.9242e-02i
Press return to continue
Press X return to stop