Mathc matrices/a79
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00c.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA RC4
/* ------------------------------------ */
double **Exp_mR(
double **A,
double **ExpA
)
{
double **A_n = i_mR(RCA,RCA);
double **sA = i_mR(RCA,RCA);
double **NewExpA = i_mR(RCA,RCA);
int n = 10;
int i = 0;
for(i = 0; i <= n; i++)
{
pow_mR(i, A, A_n);
smul_mR(1./factorial(i), A_n, sA);
add_mR(ExpA,sA,NewExpA);
c_mR(NewExpA,ExpA);
}
f_mR(A_n);
f_mR(sA);
f_mR(NewExpA);
return (ExpA);
}
/* ------------------------------------ */
void fun(void)
{
double **A = rE_mR(i_mR(RCA,RCA),999,+1.E-3);
double **ExpA = i_mR(RCA,RCA);
clrscrn();
printf(" Copy/Past into the octave window. \n");
p_Octave_mR(A, "A", P4);
printf(" expm (A)\n\n");
Exp_mR(A, ExpA);
printf(" ExpA :");
p_mR(ExpA,S8,P6,C6);
f_mR(A);
f_mR(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.3230,+0.4220,+0.4330,+0.4660;
+0.4080,+0.9810,-0.8480,+0.7700;
+0.9930,+0.1970,-0.7240,-0.4430;
-0.2110,-0.7220,-0.8730,-0.7070]
expm (A)
ExpA :
+1.534408 +0.620268 +0.022490 +0.571371
-0.019000 +2.058830 -1.292284 +1.109739
+0.997799 +0.608442 +0.508767 +0.105784
-0.577654 -1.040181 -0.126381 +0.171784
Press return to continue
Press X to stop