Mathc complexes/c05a
Installer et compiler ces fichiers dans votre répertoire de travail.
c01a.c |
---|
/* ------------------------------------ */
/* Save as : c01a.c */
/* ------------------------------------ */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
void fun(int r, int rn)
{
double **A = r_mZ(i_mZ(r+rn,r),9.);
double **Q = i_mZ(r+rn,r);
double **R = i_mZ(r,r);
clrscrn();
printf(" Copy/Past into the octave windows \n\n\n");
p_Octave_mZ(A,"a",P0,P0);
printf(" [Q, R] = qr (a,0) \n\n");
QR_mZ(A,Q,R);
printf(" Q :");
p_mZ(Q, S10,P4, S10,P4, C10);
printf(" R :");
p_mZ(R, S10,P4, S10,P4, C10);
stop();
clrscrn();
printf(" A :");
p_mZ(A, S3,P0, S3,P0, C10);
printf(" A = Q * R :");
mul_mZ(Q,R, A);
p_mZ(A, S3,P0, S3,P0, C10);
f_mZ(A);
f_mZ(Q);
f_mZ(R);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun(rp_I(R2)+R1,rp_I(R2));
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Cette fonction n'est correcte que pour les matrices ayant un nombre de lignes égales ou supérieures aux nombres de colonnes. Utiliser pour calculer les valeurs propres et les valeurs singulière, elle fait bien son travail puisque dans les deux cas elle travaille sur des matrices carrées.
Exemple de sortie écran :
Copy/Past into the octave windows
a=[
-7.0-1*i,-5.0-7*i,+6.0+4*i,-5.0+2*i;
-7.0-9*i,+4.0+8*i,-3.0-1*i,-3.0-9*i;
+8.0-5*i,-5.0+4*i,-3.0-5*i,-5.0-1*i;
-1.0-3*i,-3.0+6*i,+2.0+4*i,-1.0-7*i;
+4.0-5*i,+2.0-9*i,+6.0+6*i,-9.0-1*i;
-5.0-1*i,-9.0-5*i,-1.0-9*i,-3.0+6*i;
+2.0-7*i,-7.0-5*i,-9.0-3*i,-5.0-7*i]
[Q, R] = qr (a,0)
Q :
-0.35044 -0.05006i -0.22523 -0.35644i
-0.35044 -0.45056i +0.22580 +0.30780i
+0.40050 -0.25031i -0.18625 +0.22186i
-0.05006 -0.15019i -0.11762 +0.25995i
+0.20025 -0.25031i +0.12346 -0.38464i
-0.25031 -0.05006i -0.40250 -0.25489i
+0.10013 -0.35044i -0.27006 -0.21928i
+0.19072 +0.28365i +0.05021 -0.17398i
+0.02432 -0.26812i +0.02191 -0.42605i
+0.00292 -0.15393i -0.54497 +0.17013i
+0.26921 +0.26159i -0.03948 -0.45425i
+0.23149 +0.33921i -0.29181 +0.12954i
-0.16300 -0.38686i -0.08163 +0.07634i
-0.54715 -0.04276i -0.19873 -0.31218i
R :
+19.97498 +0.00000i -0.45056 -2.65332i
-0.00000 +0.00000i +22.31047 -0.00000i
+0.00000 +0.00000i +0.00000 +0.00000i
-0.00000 +0.00000i +0.00000 +0.00000i
-0.90113 -3.30413i +6.95870 -7.15895i
+0.70940 +7.79465i -2.18999 -6.93348i
+16.94140 -0.00000i -1.22692 +2.68011i
-0.00000 -0.00000i +15.32215 -0.00000i
Press return to continue.
A :
-7 -1i -5 -7i +6 +4i -5 +2i
-7 -9i +4 +8i -3 -1i -3 -9i
+8 -5i -5 +4i -3 -5i -5 -1i
-1 -3i -3 +6i +2 +4i -1 -7i
+4 -5i +2 -9i +6 +6i -9 -1i
-5 -1i -9 -5i -1 -9i -3 +6i
+2 -7i -7 -5i -9 -3i -5 -7i
A = Q * R :
-7 -1i -5 -7i +6 +4i -5 +2i
-7 -9i +4 +8i -3 -1i -3 -9i
+8 -5i -5 +4i -3 -5i -5 -1i
-1 -3i -3 +6i +2 +4i -1 -7i
+4 -5i +2 -9i +6 +6i -9 -1i
-5 -1i -9 -5i -1 -9i -3 +6i
+2 -7i -7 -5i -9 -3i -5 -7i
Press return to continue
Press X to stop