Mathc matrices/c20h
Installer et compiler ces fichiers dans votre répertoire de travail.
c04b.c |
---|
/* ------------------------------------ */
/* Save as : c00d.c */
/* ------------------------------------ */
#include "v_a.h"
#include "dot_diag.h"
/* ------------------------------------ */
void fun(int r)
{
double **A = rpdiag_mR(i_mR(r,r ),9.);
double **u = r_mR(i_mR(r,C1),9.);
double **v = r_mR(i_mR(r,C1),9.);
clrscrn();
printf(" A :");
p_mR(A,S3,P0,C6);
printf(" u :");
p_mR(u,S3,P0,C6);
printf(" v :");
p_mR(v,S3,P0,C6);
printf(" d(u,v) = ||u-v||^(1/2) \n\n");
printf(" d(u,v) = %.3f \n", dist_Diag_R(A,u,v));
printf(" d(v,u) = %.3f \n\n", dist_Diag_R(A,v,u));
f_mR(A);
f_mR(u);
f_mR(v);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R2)+R1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
On calcul la distance entre deux vecteurs.
Exemple de sortie écran :
------------------------------------
A :
+9 +0
+0 +1
u :
-2
+6
v :
+1
+2
d(u,v) = ||u-v||^(1/2)
d(u,v) = 9.849
d(v,u) = 9.849
Press return to continue
Press X to stop