Mathc matrices/067
Apparence
Installer et compiler ces fichiers dans votre répertoire de travail.
![]() |
c00a.c |
---|
/* ------------------------------------ */
/* Save as : c00a.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RA R4
#define CA C6
#define Cb C1
/* ------------------------------------ */
#define CB C2 /* B : a basis for the column space of A */
/* ------------------------------------ */
#define CbFREE Cb+C3
/* ------------------------------------ */
int main(void)
{
double ab[RA*(CA+Cb)]={
+9, -15, +21, -18, +6, +27, +0,
-18, +30, -42, +36, -12, -54, +0,
+21, -35, +49, -42, +14, +63, +0,
-6, +10, -14, +12, -4, -18, +0
};
double **Ab = ca_A_mR(ab, i_Abr_Ac_bc_mR(RA,CA,Cb));
double **A = c_Ab_A_mR(Ab, i_mR(RA,CA));
double **b = c_Ab_b_mR(Ab, i_mR(RA,Cb));
double **AT = transpose_mR(A, i_mR(CA,RA));
double **B = i_mR(RA,CB);
double **BT = i_mR(CB,RA);
double **BTb = i_Abr_Ac_bc_mR(CB,RA,Cb);
double **BTb_free = i_Abr_Ac_bc_mR(RA,RA,CbFREE);
double **b_free = i_mR(RA,CbFREE);
double **AT_bfree = i_mR(CA,CbFREE);
int r;
clrscrn();
printf("Basis for a Column Space by Row Reduction :\n\n");
printf(" A :");
p_mR(A,S6,P1,C10);
printf(" b :");
p_mR(b,S6,P1,C10);
printf(" Ab :");
p_mR(Ab,S6,P1,C10);
stop();
clrscrn();
printf(" The leading 1’s of Ab give the position \n"
" of the columns of A which form a basis \n"
" for the column space of A \n\n"
" A :");
p_mR(A,S7,P3,C10);
printf(" gj_PP_mR(Ab,NO) :");
gj_PP_mR(Ab,NO);
p_mR(Ab,S7,P3,C10);
c_c_mR(A,C1,B,C1);
printf(" B : a basis for the column space of A");
p_mR(B,S7,P3,C10);
stop();
clrscrn();
printf(" Check if the columns of B are linearly independent\n\n");
printf(" B :");
p_mR(B, S7,P3,C10);
printf(" BT :");
p_mR(transpose_mR(B,BT), S7,P3,C10);
printf(" BTb :");
p_mR(c_mR(BT,BTb), S7,P3,C10);
printf(" gj_PP_FreeV_mZ(BTb) :");
p_mR(gj_PP_mR(BTb,NO), S7,P3,C10);
stop();
clrscrn();
put_zeroR_mR(BTb,BTb_free);
printf(" BTb_free : put_zeroR_mR(BTb,BTb_free);");
p_mR(BTb_free,S7,P3,C10);
put_freeV_mR(BTb_free);
printf(" BTb_free : put_freeV_mR(BTb_free);");
p_mR(BTb_free,S7,P3,C10);
stop();
clrscrn();
r = rsize_R(BTb_free);
while(r>R1)
zero_below_pivot_gj1Ab_mR(BTb_free,r--);
printf(" Ab_free : zero_below_pivot_gj1Ab_mR(Ab_free,r--);");
p_mR(BTb_free,S7,P3,C10);
c_Ab_b_mR(BTb_free,b_free);
printf(" b_free : A basis for the null space of AT");
p_mR(b_free,S10,P3,C7);
printf(" b_free : ");
p_freeV(b_free,S6,P3);
stop();
clrscrn();
printf(" AT :");
p_mR(AT, S7,P3,C10);
printf(" b_free :");
p_mR(b_free, S7,P3,C10);
printf(" AT * bfree :");
p_mR(mul_mR(AT,b_free,AT_bfree), S7,P3,C10);
stop();
f_mR(Ab);
f_mR(A);
f_mR(b);
f_mR(AT);
f_mR(B);
f_mR(BT);
f_mR(BTb);
f_mR(BTb_free);
f_mR(b_free);
f_mR(AT_bfree);
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Si B une base de l'espace colonnes de A,
les vecteurs libres du système BTb, seront une base pour le complément orthogonal de AT.
Exemple de sortie écran :
Basis for a Column Space by Row Reduction :
A :
+9.0 -15.0 +21.0 -18.0 +6.0 +27.0
-18.0 +30.0 -42.0 +36.0 -12.0 -54.0
+21.0 -35.0 +49.0 -42.0 +14.0 +63.0
-6.0 +10.0 -14.0 +12.0 -4.0 -18.0
b :
+0.0
+0.0
+0.0
+0.0
Ab :
+9.0 -15.0 +21.0 -18.0 +6.0 +27.0 +0.0
-18.0 +30.0 -42.0 +36.0 -12.0 -54.0 +0.0
+21.0 -35.0 +49.0 -42.0 +14.0 +63.0 +0.0
-6.0 +10.0 -14.0 +12.0 -4.0 -18.0 +0.0
Press return to continue.
The leading 1’s of Ab give the position
of the columns of A which form a basis
for the column space of A
A :
+9.000 -15.000 +21.000 -18.000 +6.000 +27.000
-18.000 +30.000 -42.000 +36.000 -12.000 -54.000
+21.000 -35.000 +49.000 -42.000 +14.000 +63.000
-6.000 +10.000 -14.000 +12.000 -4.000 -18.000
gj_PP_mR(Ab,NO) :
+1.000 -1.667 +2.333 -2.000 +0.667 +3.000 +0.000
+0.000 +0.000 -0.000 +0.000 +0.000 +0.000 +0.000
+0.000 -0.000 +0.000 +0.000 +0.000 +0.000 +0.000
+0.000 +0.000 -0.000 +0.000 +0.000 +0.000 +0.000
B : a basis for the column space of A
+9.000 +0.000
-18.000 +0.000
+21.000 +0.000
-6.000 +0.000
Press return to continue.
Check if the columns of B are linearly independent
B :
+9.000 +0.000
-18.000 +0.000
+21.000 +0.000
-6.000 +0.000
BT :
+9.000 -18.000 +21.000 -6.000
+0.000 +0.000 +0.000 +0.000
BTb :
+9.000 -18.000 +21.000 -6.000 +0.000
+0.000 +0.000 +0.000 +0.000 +0.000
gj_PP_FreeV_mZ(BTb) :
+1.000 -2.000 +2.333 -0.667 +0.000
+0.000 +0.000 +0.000 +0.000 +0.000
Press return to continue.
BTb_free : put_zeroR_mR(BTb,BTb_free);
+1.000 -2.000 +2.333 -0.667 +0.000 +0.000 +0.000 +0.000
+0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000
+0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000
+0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000
BTb_free : put_freeV_mR(BTb_free);
+1.000 -2.000 +2.333 -0.667 +0.000 +0.000 +0.000 +0.000
+0.000 +1.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000
+0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +1.000 +0.000
+0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +1.000
Press return to continue.
Ab_free : zero_below_pivot_gj1Ab_mR(Ab_free,r--);
+1.000 +0.000 +0.000 +0.000 +0.000 +2.000 -2.333 +0.667
+0.000 +1.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000
+0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +1.000 +0.000
+0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +1.000
b_free : A basis for the null space of AT
+0.000 +2.000 -2.333 +0.667
+0.000 +1.000 +0.000 +0.000
+0.000 +0.000 +1.000 +0.000
+0.000 +0.000 +0.000 +1.000
b_free :
x1 = +0.000 +2.000*u -2.333*v +0.667*w
x2 = +0.000 +1.000*u +0.000*v +0.000*w
x3 = +0.000 +0.000*u +1.000*v +0.000*w
x4 = +0.000 +0.000*u +0.000*v +1.000*w
Press return to continue.
AT :
+9.000 -18.000 +21.000 -6.000
-15.000 +30.000 -35.000 +10.000
+21.000 -42.000 +49.000 -14.000
-18.000 +36.000 -42.000 +12.000
+6.000 -12.000 +14.000 -4.000
+27.000 -54.000 +63.000 -18.000
b_free :
+0.000 +2.000 -2.333 +0.667
+0.000 +1.000 +0.000 +0.000
+0.000 +0.000 +1.000 +0.000
+0.000 +0.000 +0.000 +1.000
AT * bfree :
+0.000 +0.000 +0.000 +0.000
+0.000 +0.000 -0.000 +0.000
+0.000 +0.000 +0.000 +0.000
+0.000 +0.000 -0.000 +0.000
+0.000 +0.000 +0.000 +0.000
+0.000 +0.000 +0.000 +0.000
Press return to continue.