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

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 : c00b.c */ /* ------------------------------------ */ #include "v_a.h" #include "dline.h" /* --------------------------------- */ int main(void) { double p[R2*C2] ={ 0, 1, 1, -1}; double **Ap = ca_A_mR(p, i_mR(R2,C2)); double **A = m_line_A_mR(Ap, i_mR(R3,C3)); int r; clrscrn(); printf(" A homogeneous linear system with as many equations\n"); printf(" as unknowns has a nontrivial solution if and only\n"); printf(" if the determinant of the matrix is zero. \n\n"); printf(" Equation of a line: \n\n"); printf(" c1 x + c2 y + c3 = 0\n\n"); printf(" The same equation with the values of the two points:\n\n"); printf(" c1 x1 + c2 y1 + c3 = 0\n"); printf(" c1 x2 + c2 y2 + c3 = 0\n\n"); printf(" The three equation:\n\n"); printf(" c1 x + c2 y + c3 = 0\n"); printf(" c1 x1 + c2 y1 + c3 = 0\n"); printf(" c1 x2 + c2 y2 + c3 = 0\n\n"); stop(); clrscrn(); printf(" The two points:\n\n"); printf(" P1(%+.0f,%+.0f) ", Ap[R1][C1],Ap[R1][C2]); printf(" P2(%+.0f,%+.0f)\n\n",Ap[R2][C1],Ap[R2][C2]); printf("\n\nCofactor expansion along the first row\n\n"); printf(" x y 1"); p_Det_mR(A,6,0); printf(" The equation of the line : \n\n"); printf(" eq = %+.0f x %+.0f y %+.0f = 0\n\n", cofactor_R(A,R1,C1), cofactor_R(A,R1,C2), cofactor_R(A,R1,C3)); printf(" Verify the result : \n\n"); for(r=R1;r<Ap[R_SIZE][C0];r++) verify_eq_line_mR(A, Ap[r][C1], Ap[r][C2]); stop(); f_mR(A); f_mR(Ap); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: A homogeneous linear system with as many equations as unknowns has a nontrivial solution if and only if the determinant of the matrix is zero. Equation of a line: c1 x + c2 y + c3 = 0 The same equation with the values of the two points: c1 x1 + c2 y1 + c3 = 0 c1 x2 + c2 y2 + c3 = 0 The three equation: c1 x + c2 y + c3 = 0 c1 x1 + c2 y1 + c3 = 0 c1 x2 + c2 y2 + c3 = 0 Press return to continue. The two points: P1(+0,+1) P2(+1,-1) Cofactor expansion along the first row x y 1 +0 +1 +1 +1 -1 +1 The equation of the line : eq = +2 x +1 y -1 = 0 Verify the result : With x= +0.0 y= +1.0 eq=+0.00000 With x= +1.0 y= -1.0 eq=+0.00000 Press return to continue.