Mathc complexes/008
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-2
#define RCA RC3
/* ------------------------------------ */
/* ------------------------------------ */
double **invEigsValue_mZ(
double **EigsValue,
double **invEigsValue
)
{
int r;
int c;
nb_Z a;
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)
{
a = inv_Z(i_Z( EigsValue[r][c], EigsValue[r][c+C1]));
invEigsValue[r][c ] = a.r;
invEigsValue[r][c+C1] = a.i;
}
return(invEigsValue);
}
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
double a[RCA*(RCA*C2)] ={
+4,-53,-35,-14,-23,+37,
+58,+41,+65,-1,+6,+11,
+87,+6,-41,-97,+32,-63
};
double **A = ca_A_mZ(a, i_mZ(RCA,RCA));
double **invA = i_mZ(RCA,RCA);
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 **invEigsValue = i_mZ(RCA,RCA);
clrscrn();
printf(" Copy/Past into the octave windows \n\n\n");
p_Octave_mZ(A,"a",P0,P0);
printf(" [V, E] = eigs (a,%d) \n\n\n",RCA);
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);
stop();
clrscrn();
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);
printf(" invEigsValue :");
invEigsValue_mZ(EigsValue, invEigsValue);
pE_mZ(invEigsValue, S12,P4, S12,P4, C3);
stop();
clrscrn();
printf(" invA = V * invEigsValue * invV");
mul_mZ(V,invEigsValue,T);
mul_mZ(T,invV,invA);
pE_mZ(invA, S12,P4, S12,P4, C3);
printf(" Ide = A * invA ");
mul_mZ(A,invA,T);
p_mZ(T, S10,P4, S8,P4, C3);
stop();
f_mZ(A);
f_mZ(invA);
f_mZ(V);
f_mZ(invV);
f_mZ(T);
f_mZ(EigsValue);
f_mZ(invEigsValue);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Exemple de sortie écran :
Copy/Past into the octave windows
a=[
+4-53*i,-35-14*i,-23+37*i;
+58+41*i,+65-1*i,+6+11*i;
+87+6*i,-41-97*i,+32-63*i]
[V, E] = eigs (a,3)
V :
-3.4790e-01 -3.5507e-01i +3.8438e-02 +2.0039e-01i +5.0800e-01 +2.1379e-01i
+1.6384e-01 +8.1577e-02i -3.1879e-01 +4.1999e-01i -4.2139e-02 -6.3360e-01i
+8.4817e-01 +0.0000e+00i +8.2483e-01 +0.0000e+00i +5.4130e-01 +0.0000e+00i
inv(V) ... Some time the matrix is not invertible :
-5.7450e-01 +8.1654e-01i +4.3646e-01 +2.9873e-01i +5.4595e-01 -5.2619e-03i
+1.7040e-01 -7.5982e-01i -5.3195e-01 -7.8327e-01i +4.1540e-01 -3.7858e-02i
+6.4053e-01 -1.2164e-01i +1.2668e-01 +7.2545e-01i +3.5895e-01 +6.5932e-02i
Press return to continue.
EigsValue = invV * A * V
+2.3577e-01 -1.2456e+02i +0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +9.9834e+01 -2.4970e+01i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i +9.2973e-01 +3.2533e+01i
invEigsValue :
+1.5195e-05 +8.0280e-03i +0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +9.4269e-03 +2.3578e-03i +0.0000e+00 +0.0000e+00i
+0.0000e+00 +0.0000e+00i +0.0000e+00 +0.0000e+00i +8.7771e-04 -3.0713e-02i
Press return to continue.
invA = V * invEigsValue * invV
+4.7522e-03 -6.3743e-03i +1.5758e-02 +1.7958e-03i +5.1011e-03 -5.7869e-03i
-1.1342e-02 +5.1376e-03i +9.5446e-04 -1.2247e-02i -8.9346e-03 +1.1854e-03i
-4.4826e-03 -2.0184e-02i +7.4794e-03 -5.9105e-03i +4.6131e-03 -1.7054e-03i
Ide = A * invA
+1.0000 +0.0000i +0.0000 -0.0000i -0.0000 -0.0000i
+0.0000 -0.0000i +1.0000 -0.0000i -0.0000 -0.0000i
+0.0000 -0.0000i -0.0000 -0.0000i +1.0000 -0.0000i
Press return to continue.