Mathc matrices/c20f
Installer et compiler ces fichiers dans votre répertoire de travail.
c00c.c |
---|
/* ------------------------------------ */
/* Save as : c00c.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 **n_u = i_mR(r,C1);
clrscrn();
printf(" A :");
p_mR(A,S3,P0,C6);
printf(" u :");
p_mR(u,S3,P0,C6);
smul_mR(1./norm_Diag_R(A,u),u,n_u);
printf(" n_u = (1/||u||) u :");
p_mR(n_u,3,6,6);
printf(" ||n_u|| = %.6f \n\n",norm_Diag_R(A,n_u));
f_mR(A);
f_mR(u);
f_mR(n_u);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R2)+R1);
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
On normalise un vecteur.
Exemple de sortie écran :
------------------------------------
A :
+6 +0 +0
+0 +5 +0
+0 +0 +5
u :
-4
-1
+7
n_u = (1/||u||) u :
-0.215041
-0.053760
+0.376322
||n_u|| = 1.000000
Press return to continue
Press X to stop