Mathc matrices/c20q
Installer et compiler ces fichiers dans votre répertoire de travail.
c07d.c |
---|
/* ------------------------------------ */
/* Save as : c00k.c */
/* ------------------------------------ */
#include "v_a.h"
#include "dot_diag.h"
/* ------------------------------------ */
void fun(int r,int rn)
{
double **A = rpdiag_mR(i_mR(r+rn,r+rn),9.);
double **U = r_mR(i_mR(r+rn,r),9.);
double **Q = i_mR(r+rn,r);
double **R = i_mR(r,r);
double **QR = i_mR(r+rn,r);
clrscrn();
printf(" A :");
p_mR(A,S3,P3,C6);
printf(" U :");
p_mR(U,S3,P3,C6);
stop();
clrscrn();
QR_Diag_mR(A,U,Q,R);
printf(" Q :");
p_mR(Q,S3,P5,C6);
printf(" R :");
p_mR(R,S10,P5,C6);
stop();
clrscrn();
printf(" U :");
p_mR(U,S3,P3,C6);
printf(" U = Q * R :");
mul_mR(Q,R, QR);
p_mR(QR,S3,P3,C6);
f_mR(A);
f_mR(U);
f_mR(Q);
f_mR(R);
f_mR(QR);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R2)+R2,rp_I(R2));
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
On calcul la qr décomposition.
Exemple de sortie écran :
------------------------------------
A :
+7.000 +0.000 +0.000 +0.000 +0.000 +0.000
+0.000 +2.000 +0.000 +0.000 +0.000 +0.000
+0.000 +0.000 +5.000 +0.000 +0.000 +0.000
+0.000 +0.000 +0.000 +4.000 +0.000 +0.000
+0.000 +0.000 +0.000 +0.000 +1.000 +0.000
+0.000 +0.000 +0.000 +0.000 +0.000 +9.000
U :
+1.000 -1.000 +2.000 +6.000
-6.000 -2.000 -3.000 +5.000
-7.000 -2.000 +2.000 -8.000
+3.000 -9.000 +6.000 +5.000
+6.000 -2.000 +7.000 +4.000
+4.000 +5.000 -1.000 +9.000
Press return to continue.
------------------------------------
Q :
+0.04303 -0.05435 +0.12785 +0.19490
-0.25820 -0.01566 -0.28114 +0.49580
-0.30123 -0.00403 +0.29573 +0.02885
+0.12910 -0.41935 +0.00816 +0.08845
+0.25820 -0.15521 +0.46932 -0.12136
+0.17213 +0.16708 +0.08800 +0.14616
R :
+23.23790 +6.32587 +2.49592 +28.83221
+0.00000 +23.40904 -13.36188 +2.24747
+0.00000 -0.00000 +9.12307 -0.10222
-0.00000 -0.00000 +0.00000 +25.11259
Press return to continue.
------------------------------------
U :
+1.000 -1.000 +2.000 +6.000
-6.000 -2.000 -3.000 +5.000
-7.000 -2.000 +2.000 -8.000
+3.000 -9.000 +6.000 +5.000
+6.000 -2.000 +7.000 +4.000
+4.000 +5.000 -1.000 +9.000
U = Q * R :
+1.000 -1.000 +2.000 +6.000
-6.000 -2.000 -3.000 +5.000
-7.000 -2.000 +2.000 -8.000
+3.000 -9.000 +6.000 +5.000
+6.000 -2.000 +7.000 +4.000
+4.000 +5.000 -1.000 +9.000
Press return to continue
Press X to stop