Mathc matrices/02z
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = rdefinite_positive_mR( i_mR(r,r), 99);
double **SqrtA = i_mR(r,r);
double **invSqrtA = i_mR(r,r);
double **V = i_mR(r,r);
double **VT = i_mR(r,r);
double **EValue = i_mR(r,r);
double **f_EValue = i_mR(r,r);
double **T1 = i_mR(r,r);
clrscrn();
printf(" A :");
p_mR(A, S10,P4, C8);
eigs_V_mR(A,V);
transpose_mR(V,VT);
/* EValue : VT * A * V */
mul_mR(VT,A,T1);
mul_mR(T1,V,EValue);
printf(" sqrt(A) = V * sqrt(EValue) * VT\n");
f_eigs_mR(sqrt,EValue,f_EValue);
mul_mR(V,f_EValue,T1);
mul_mR(T1,VT,SqrtA);
p_mR(SqrtA, S10,P4, C8);
printf(" inv(sqrt(A)) ");
inv_mR(SqrtA,invSqrtA);
p_mR(invSqrtA, S10,P4, C8);
f_mR(A);
f_mR(SqrtA);
f_mR(invSqrtA);
f_mR(V);
f_mR(VT);
f_mR(EValue);
f_mR(f_EValue);
f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R3)+R1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Une matrice positive est définie positive si et seulement si sa racine carrée positive est inversible.
Exemple de sortie écran :
A :
+28.5666 -0.7486 +15.4961
-0.7486 +54.1899 +1.3398
+15.4961 +1.3398 +48.2435
sqrt(A) = V * sqrt(EValue) * VT
+5.1861 -0.0700 +1.2908
-0.0700 +7.3604 +0.1008
+1.2908 +0.1008 +6.8240
inv(sqrt(A))
+0.2024 +0.0025 -0.0383
+0.0025 +0.1359 -0.0025
-0.0383 -0.0025 +0.1538
Press return to continue
Press X return to stop