Mathc matrices/c05a
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
c00c.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
void fun(int r,int rn)
{
double **A = r_mR(i_mR(r+rn,r),9.);
double **Q = i_mR(r+rn,r);
double **R = i_mR(r,r);
clrscrn();
printf(" A :");
P_mR(A,S3,P0,C6);
printf(" Copy/Past into the octave windows \n\n");
p_Octave_mR(A,"a",P0);
printf(" [Q, R] = qr (a,0) \n\n");
stop();
clrscrn();
QR_mR(A,Q,R);
printf(" Q :");
p_mR(Q,S10,P4,C6);
printf(" R :");
p_mR(R,S10,P4,C6);
stop();
clrscrn();
printf(" A :");
p_mR(A,S3,P0,C6);
printf(" A = Q * R :");
mul_mR(Q,R, A);
p_mR(A,S10,P4,C6);
f_mR(A);
f_mR(Q);
f_mR(R);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R3),rp_I(C3));
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
La matrice A doit avoir plus de lignes que de colonnes ou être carrée Exemple de sortie écran :
-----------------------------------
A :
+9, +5, -5,
+4, +3, -8,
+2, +4, -6,
-3, -3, -3,
+1, +6, +7,
-5, +4, -5
Copy/Past into the octave windows
a=[
+9,+5,-5;
+4,+3,-8;
+2,+4,-6;
-3,-3,-3;
+1,+6,+7;
-5,+4,-5]
[Q, R] = qr (a,0)
Press return to continue.
-----------------------------------
Q :
+0.7717 +0.1120 -0.1151
+0.3430 +0.1344 -0.4608
+0.1715 +0.3391 -0.3319
-0.2572 -0.1823 -0.3280
+0.0857 +0.6046 +0.6397
-0.4287 +0.6750 -0.3840
R :
+11.6619 +5.1450 -4.1160
+0.0000 +9.1940 -2.2649
-0.0000 +0.0000 +13.6356
Press return to continue.
-----------------------------------
A :
+9 +5 -5
+4 +3 -8
+2 +4 -6
-3 -3 -3
+1 +6 +7
-5 +4 -5
A = Q * R :
+9.0000 +5.0000 -5.0000
+4.0000 +3.0000 -8.0000
+2.0000 +4.0000 -6.0000
-3.0000 -3.0000 -3.0000
+1.0000 +6.0000 +7.0000
-5.0000 +4.0000 -5.0000
Press return to continue
Press X to stop