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

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 : c00a.c */ /* ------------------------------------ */ #include "v_a.h" #include "dplan.h" /* --------------------------------- */ int main(void) { double p[R3*C3] ={ 1, 1, 0, 2, 0, -1, 2, 9, 2}; double **Ap = ca_A_mR(p, i_mR(R3,C3)); double **A = m_plan_A_mR(Ap, i_mR(R4,C4)); 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 plane: \n\n"); printf(" c1 x + c2 y + c3 z + c4 = 0\n\n"); printf(" The same equation with the values of the three points:\n\n"); for(r=R1;r<Ap[R_SIZE][C0];r++) printf(" c1 x%d + c2 y%d + c3 z%d + c4 = 0\n",r,r,r); printf("\n The four equation:\n\n"); printf(" c1 x + c2 y + c3 z + c4 = 0\n"); for(r=R1;r<Ap[R_SIZE][C0];r++) printf(" c1 x%d + c2 y%d + c3 z%d + c4 = 0\n",r,r,r); stop(); clrscrn(); printf(" The three points:\n\n"); for(r=R1;r<Ap[R_SIZE][C0];r++) printf(" P%d(%+.0f,%+.0f,%+.0f)", r,Ap[r][C1],Ap[r][C2],Ap[r][C3]); printf("\n\nCofactor expansion along the first row\n\n"); printf(" x y z 1"); p_Det_mR(A,6,0); printf(" The equation of the plane : \n\n"); printf(" %+.0f x %+.0f y %+.0f z %+.0f = 0\n\n", cofactor_R(A,R1,C1), cofactor_R(A,R1,C2), cofactor_R(A,R1,C3), cofactor_R(A,R1,C4)); printf(" Verify the result : \n\n"); for(r=R1;r<Ap[R_SIZE][C0];r++) verify_eq_plan_mR(A, Ap[r][C1], Ap[r][C2], Ap[r][C3]); 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 plane: c1 x + c2 y + c3 z + c4 = 0 The same equation with the values of the three points: c1 x1 + c2 y1 + c3 z1 + c4 = 0 c1 x2 + c2 y2 + c3 z2 + c4 = 0 c1 x3 + c2 y3 + c3 z3 + c4 = 0 The four equation: c1 x + c2 y + c3 z + c4 = 0 c1 x1 + c2 y1 + c3 z1 + c4 = 0 c1 x2 + c2 y2 + c3 z2 + c4 = 0 c1 x3 + c2 y3 + c3 z3 + c4 = 0 Press return to continue. The three points: P1(+1,+1,+0) P2(+2,+0,-1) P3(+2,+9,+2) Cofactor expansion along the first row x y z 1 +1 +1 +0 +1 +2 +0 -1 +1 +2 +9 +2 +1 The equation of the plane : +6 x -3 y +9 z -3 = 0 Verify the result : With x=+1 y=+1 z=+0 eq=-0.00000 With x=+2 y=+0 z=-1 eq=+0.00000 With x=+2 y=+9 z=+2 eq=-0.00000 Press return to continue.