Mathc matrices/c05b
Installer et compiler ces fichiers dans votre répertoire de travail.
c00b.c |
---|
/* ------------------------------------ */
/* Save as : c00b.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RA R5
#define CA C3
/* ------------------------------------ */
void fun(void)
{
double a[RA*CA]={
+2, +7, +4,
-9, -3, +2,
-4, -4, +2,
-7, +8, -9,
+2, -2, -1
};
double **A = ca_A_mR(a,i_mR(RA,CA));
double **Q = i_mR(RA,CA);
double **R = i_mR(CA,CA);
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);
stop();
f_mR(A);
f_mR(Q);
f_mR(R);
}
/* ------------------------------------ */
int main(void)
{
fun();
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
La matrice A doit avoir plus de lignes que de colonnes ou être carrée Exemple de sortie écran :
-----------------------------------
A :
+2 +7 +4
-9 -3 +2
-4 -4 +2
-7 +8 -9
+2 -2 -1
Copy/Past into the octave windows
a=[
+2,+7,+4;
-9,-3,+2;
-4,-4,+2;
-7,+8,-9;
+2,-2,-1]
[Q, R] = qr (a,0)
Press return to continue.
-----------------------------------
Q :
+0.1612 +0.5908 +0.7252
-0.7252 -0.2665 +0.3849
-0.3223 -0.3423 +0.1799
-0.5641 +0.6600 -0.4684
+0.1612 -0.1646 -0.2724
R :
+12.4097 -0.2417 +3.4650
+0.0000 +11.9139 -4.6301
-0.0000 -0.0000 +8.5180
Press return to continue.
-----------------------------------
A :
+2 +7 +4
-9 -3 +2
-4 -4 +2
-7 +8 -9
+2 -2 -1
A = Q * R :
+2.0000 +7.0000 +4.0000
-9.0000 -3.0000 +2.0000
-4.0000 -4.0000 +2.0000
-7.0000 +8.0000 -9.0000
+2.0000 -2.0000 -1.0000
Press return to continue.