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/a08j

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 : c00d.c */ /* ------------------------------------ */ #include "v_a.h" /* ------------------------------------ */ #define RA R4 #define CA C6 #define Cb C1 /* ------------------------------------ */ #define CbFREE Cb+C2 /* ------------------------------------ */ int main(void) { double ab[RA*(CA+Cb)]={ +34, -85, +51, -136, +34, +34, +0, +55, -99, +66, -99, +66, +22, +0, +35, -63, +42, -63, +42, +49, +0, -70, +126, -42, +112, -28, -28, +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 **Ab_free = i_Abr_Ac_bc_mR(CA,CA,CbFREE); double **b_free = i_mR(CA,CbFREE); double **A_bfree = i_mR(RA,CbFREE); int r; clrscrn(); printf("Find a basis for the orthogonal complement of A :\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(" Ab : gj_PP_mR(Ab,NO) :"); gj_PP_mR(Ab,NO); p_mR(Ab,S7,P3,C10); put_zeroR_mR(Ab,Ab_free); printf(" Ab_free : put_zeroR_mR(Ab,Ab_free);"); p_mR(Ab_free,S7,P3,C10); put_freeV_mR(Ab_free); printf(" Ab_free : put_freeV_mR(Ab_free);"); p_mR(Ab_free,S7,P3,C10); stop(); clrscrn(); r = rsize_R(Ab_free); while(r>R1) zero_above_pivot_gj1Ab_mR(Ab_free,r--); printf(" Ab_free : zero_above_pivot_gj1Ab_mR(Ab_free,r--);"); p_mR(Ab_free,S7,P3,C10); c_Ab_b_mR(Ab_free,b_free); printf(" b_free is a basis for the orthogonal complement of A"); p_mR(b_free,S10,P3,C7); stop(); clrscrn(); printf(" A :"); p_mR(A,S10,P3,C10); printf(" b_free is a basis for the orthogonal complement of A"); p_mR(b_free,S10,P3,C7); printf(" The row vectors of A" " are orthogonal to the column vectors of bfree\n\n"); printf(" A * bfree: "); p_mR(mul_mR(A,b_free,A_bfree),S10,P3,C7); stop(); f_mR(Ab); f_mR(A); f_mR(b); f_mR(Ab_free); f_mR(b_free); f_mR(A_bfree); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ We begin by calculating the free variables. The columns of b_free form a basis for the orthogonal complement of A. A * b_free = 0 This proves that the row vectors of A are orthogonal to the column vectors of b_free. Screen output example: Find a basis for the orthogonal complement of A : A : +34.0 -85.0 +51.0 -136.0 +34.0 +34.0 +55.0 -99.0 +66.0 -99.0 +66.0 +22.0 +35.0 -63.0 +42.0 -63.0 +42.0 +49.0 -70.0 +126.0 -42.0 +112.0 -28.0 -28.0 b : +0.0 +0.0 +0.0 +0.0 Ab : +34.0 -85.0 +51.0 -136.0 +34.0 +34.0 +0.0 +55.0 -99.0 +66.0 -99.0 +66.0 +22.0 +0.0 +35.0 -63.0 +42.0 -63.0 +42.0 +49.0 +0.0 -70.0 +126.0 -42.0 +112.0 -28.0 -28.0 +0.0 Press return to continue. Ab : gj_PP_mR(Ab,NO) : +1.000 -1.800 +0.600 -1.600 +0.400 +0.400 -0.000 -0.000 +1.000 -1.286 +3.429 -0.857 -0.857 -0.000 +0.000 +0.000 +1.000 -0.333 +1.333 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 -0.000 +1.000 +0.000 Ab_free : put_zeroR_mR(Ab,Ab_free); +1.000 -1.800 +0.600 -1.600 +0.400 +0.400 -0.000 +0.000 +0.000 -0.000 +1.000 -1.286 +3.429 -0.857 -0.857 -0.000 +0.000 +0.000 +0.000 +0.000 +1.000 -0.333 +1.333 +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 +1.000 +0.000 +0.000 +0.000 Ab_free : put_freeV_mR(Ab_free); +1.000 -1.800 +0.600 -1.600 +0.400 +0.400 -0.000 +0.000 +0.000 -0.000 +1.000 -1.286 +3.429 -0.857 -0.857 -0.000 +0.000 +0.000 +0.000 +0.000 +1.000 -0.333 +1.333 +0.000 +0.000 +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 +0.000 +1.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 -0.000 +1.000 +0.000 +0.000 +0.000 Press return to continue. Ab_free : zero_above_pivot_gj1Ab_mR(Ab_free,r--); +1.000 +0.000 +0.000 +0.000 +0.000 +0.000 +0.000 -4.000 -1.143 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +0.000 -3.000 -0.857 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +0.000 +0.333 -1.333 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 +1.000 +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 -0.000 +1.000 +0.000 +0.000 +0.000 b_free is a basis for the orthogonal complement of A +0.000 -4.000 -1.143 +0.000 -3.000 -0.857 +0.000 +0.333 -1.333 +0.000 +1.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 Press return to continue. A : +34.000 -85.000 +51.000 -136.000 +34.000 +34.000 +55.000 -99.000 +66.000 -99.000 +66.000 +22.000 +35.000 -63.000 +42.000 -63.000 +42.000 +49.000 -70.000 +126.000 -42.000 +112.000 -28.000 -28.000 b_free is a basis for the orthogonal complement of A +0.000 -4.000 -1.143 +0.000 -3.000 -0.857 +0.000 +0.333 -1.333 +0.000 +1.000 +0.000 +0.000 +0.000 +1.000 +0.000 +0.000 +0.000 The row vectors of A are orthogonal to the column vectors of bfree A * 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 Press return to continue.