Mathc complexes/a131
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00c.c |
---|
/* ------------------------------------ */
/* Save as : c00c.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
#define RCA RC4
/* ------------------------------------ */
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 = rE_mZ(i_mZ(RCA,RCA),999999999,+1.E-9);
double **ExpA = i_mZ(RCA,RCA);
clrscrn();
printf(" Copy/Past into the octave window. \n");
p_Octave_mZ(A, "A", P9, P9);
printf(" expm (A)\n\n");
Exp_mZ(A, ExpA);
printf(" ExpA :");
p_mZ(ExpA,S8,P6,S8,P6,C6);
f_mZ(A);
f_mZ(ExpA);
}
/* ------------------------------------ */
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.9800+0.1960*i,+0.9130+0.5030*i,+0.5290-0.6070*i,+0.6290+0.9570*i;
+0.3980-0.4720*i,+0.7180-0.0890*i,-0.7170+0.6740*i,+0.3950+0.3900*i;
+0.9690-0.0360*i,+0.0040+0.3800*i,-0.2380-0.6130*i,-0.4090+0.6630*i;
-0.0190+0.1890*i,+0.3230-0.4630*i,+0.2750-0.3880*i,+0.3600+0.4820*i]
expm (A)
ExpA :
+3.539701-0.246861i +3.511082+1.461404i +0.160950-0.663128i +1.251337+3.424947i
+0.477610-0.566795i +2.517752-0.638068i -0.539014+0.958794i +0.977770+0.471292i
+1.734940-0.403141i +1.445311+1.053302i +0.565714-0.732940i +0.108221+1.816247i
+0.067336-0.116619i +0.800798-0.593310i +0.353656-0.060909i +1.480073+0.886323i
Press return to continue
Press X to stop