Mathc complexes/a132
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00c.c |
---|
/* ------------------------------------ */
/* Save as : c00d.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define RCA RC3
/* ------------------------------------ */
double **Exp_mZ(
double **A,
double **ExpA
)
{
double **A_n = i_mZ(RCA,RCA);
double **sA = i_mZ(RCA,RCA);
double **NewExpA = i_mZ(RCA,RCA);
int n = 10;
int i = 0;
for(i = 0; i <= n; i++)
{
pow_mZ(i, A, A_n);
smul_mZ(1./factorial(i), A_n, sA);
add_mZ(ExpA,sA,NewExpA);
c_mZ(NewExpA,ExpA);
}
f_mZ(A_n);
f_mZ(sA);
f_mZ(NewExpA);
return (ExpA);
}
/* ------------------------------------ */
void fun(void)
{
double **A = i_mZ(RCA,RCA) ;
double **B = i_mZ(RCA,RCA) ;
double **ExpA = i_mZ(RCA,RCA);
double **ExpB = i_mZ(RCA,RCA);
double **AplsB = i_mZ(RCA,RCA);
double **ExpAplsB = i_mZ(RCA,RCA);
r_commute2_mZ(A,B,9);
add_mZ(A,B,AplsB);
clrscrn();
printf(" Copy/Past into the octave window. \n\n");
p_Octave_mZ(A, "A", P12, P12);
printf(" expm (A)\n\n");
p_Octave_mZ(B, "B", P12, P12);
printf(" expm (B)\n\n");
stop();
clrscrn();
p_Octave_mZ(AplsB, "AplsB", P12, P12);
printf(" expm (AplsB)\n\n");
printf(" expm (A)*expm (B)\n");
printf(" expm (B)*expm (A)\n\n");
stop();
clrscrn();
Exp_mZ(A, ExpA);
Exp_mZ(B, ExpB);
Exp_mZ(AplsB, ExpAplsB);
printf(" ExpA :");
p_mZ(ExpA,S8,P6,S8,P6,C6);
printf(" ExpB :");
p_mZ(ExpB,S8,P6,S8,P6,C6);
stop();
clrscrn();
printf(" ExpAplsB=:");
p_mZ( ExpAplsB,S8,P6,S8,P6,C6);
printf(" ExpA * ExpB:");
mul_mZ(ExpA,ExpB,A);
p_mZ(A,S8,P6,S8,P6,C6);
printf(" ExpB * ExpA:");
mul_mZ(ExpB,ExpA,A);
p_mZ(A,S8,P6,S8,P6,C6);
f_mZ(A);
f_mZ(ExpA);
f_mZ(B);
f_mZ(ExpB);
f_mZ(AplsB);
f_mZ(ExpAplsB);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
ExpA = Ide + A + (1/2) A**2 + (1/6) A**3 + ... + 1/(n-1)! A**(n-1)
Exemple de sortie écran :
------------------------------------
Copy/Past into the octave window.
A=[
-0.757-0.090*i,-0.012+0.864*i,+0.123+0.562*i;
-0.247-0.225*i,+0.054-0.504*i,+0.601-0.484*i;
+0.217-0.277*i,+0.610+1.058*i,-0.434+0.594*i]
expm (A)
B=[
-0.059-0.034*i,-0.004+0.324*i,+0.046+0.210*i;
-0.093-0.084*i,+0.245-0.189*i,+0.225-0.181*i;
+0.081-0.104*i,+0.229+0.396*i,+0.062+0.223*i]
expm (B)
Press return to continue.
------------------------------------
AplsB=[
-0.816-0.123*i,-0.016+1.187*i,+0.169+0.772*i;
-0.339-0.309*i,+0.300-0.693*i,+0.825-0.666*i;
+0.298-0.381*i,+0.839+1.455*i,-0.372+0.817*i]
expm (AplsB)
expm (A)*expm (B)
expm (B)*expm (A)
Press return to continue.
------------------------------------
ExpA :
+0.618709-0.095516i -0.012391+0.919091i +0.130450+0.597692i
-0.262755-0.238964i +1.482159-0.536585i +0.638961-0.515155i
+0.231006-0.294612i +0.649513+1.126009i +0.962539+0.632100i
ExpB :
+0.972568-0.041773i -0.005419+0.401962i +0.057052+0.261399i
-0.114915-0.104510i +1.350196-0.234674i +0.279448-0.225302i
+0.101030-0.128848i +0.284063+0.492457i +1.122941+0.276447i
Press return to continue.
------------------------------------
ExpAplsB=:
+0.785416-0.179487i -0.023285+1.727098i +0.245133+1.123145i
-0.493753-0.449046i +2.407956-1.008317i +1.200695-0.968046i
+0.434093-0.553616i +1.220525+2.115925i +1.431519+1.187804i
ExpA * ExpB:
+0.785416-0.179487i -0.023285+1.727099i +0.245133+1.123146i
-0.493753-0.449046i +2.407957-1.008317i +1.200695-0.968047i
+0.434093-0.553616i +1.220525+2.115926i +1.431519+1.187804i
ExpB * ExpA:
+0.785416-0.179487i -0.023285+1.727099i +0.245133+1.123146i
-0.493753-0.449046i +2.407957-1.008317i +1.200695-0.968047i
+0.434093-0.553616i +1.220525+2.115926i +1.431519+1.187804i
Press return to continue
Press X to stop