Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Linear Algebra and the C Language/a08r

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

__NOTOC__ Install and compile this file in your working directory. /* ------------------------------------ */ /* Save as : c00c.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 */ /* ------------------------------------ */ int main(void) { double ab[RA*(CA+Cb)]={ +9, -27, +36, -18, +45, +36, +0, +14, -42, +63, -7, +56, +14, +0, +3, -9, +12, -6, +15, +12, +0, -5, +15, -20, +10, -25, -20, +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 **B = i_mR(RA,CB); double **BT = i_mR(CB,RA); double **BTb = i_Abr_Ac_bc_mR(CB,RA,Cb); 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); c_c_mR(A,C3,B,C2); 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_mR(BTb,NO); :"); p_mR(gj_PP_mR(BTb,NO), S7,P3,C10); stop(); f_mR(Ab); f_mR(b); f_mR(A); f_mR(B); f_mR(BT); f_mR(BTb); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ The position of the pivots of Ab gives the position of the columns of A which form a basis for the column space of A. Next, we check whether these columns are linearly independent. Screen output example: Basis for a Column Space by Row Reduction : A : +9.0 -27.0 +36.0 -18.0 +45.0 +36.0 +14.0 -42.0 +63.0 -7.0 +56.0 +14.0 +3.0 -9.0 +12.0 -6.0 +15.0 +12.0 -5.0 +15.0 -20.0 +10.0 -25.0 -20.0 b : +0.0 +0.0 +0.0 +0.0 Ab : +9.0 -27.0 +36.0 -18.0 +45.0 +36.0 +0.0 +14.0 -42.0 +63.0 -7.0 +56.0 +14.0 +0.0 +3.0 -9.0 +12.0 -6.0 +15.0 +12.0 +0.0 -5.0 +15.0 -20.0 +10.0 -25.0 -20.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 -27.000 +36.000 -18.000 +45.000 +36.000 +14.000 -42.000 +63.000 -7.000 +56.000 +14.000 +3.000 -9.000 +12.000 -6.000 +15.000 +12.000 -5.000 +15.000 -20.000 +10.000 -25.000 -20.000 gj_PP_mR(Ab,NO) : +1.000 -3.000 +4.500 -0.500 +4.000 +1.000 +0.000 -0.000 -0.000 +1.000 +3.000 -2.000 -6.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 +36.000 +14.000 +63.000 +3.000 +12.000 -5.000 -20.000 Press return to continue. Check if the columns of B are linearly independent B : +9.000 +36.000 +14.000 +63.000 +3.000 +12.000 -5.000 -20.000 BT : +9.000 +14.000 +3.000 -5.000 +36.000 +63.000 +12.000 -20.000 BTb : +9.000 +14.000 +3.000 -5.000 +0.000 +36.000 +63.000 +12.000 -20.000 +0.000 gj_PP_mR(BTb,NO); : +1.000 +1.750 +0.333 -0.556 +0.000 -0.000 +1.000 -0.000 -0.000 -0.000 Press return to continue.