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

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" /* ------------------------------------ */ #define RCA R2 /* ------------------------------------ */ int main(void) { double a[RCA*RCA]={ +2,-2, -2,+5};; double R = 6; double Ev1Ev2 = 0; double **A = ca_A_mR(a, i_mR(RCA,RCA)); double **EVector = eigs_V_mR(A, i_mR(RCA,RCA)); double **EVectorT = transpose_mR(EVector, i_mR(RCA,RCA)); double **T1 = i_mR(RCA,RCA); double **T2 = i_mR(RCA,RCA); clrscrn(); printf(" If %+.0fx^2 %+.0fy^2 %+.0fxy = %+.0f \n\n" " Can you give a description of the curve in the plan?\n\n", A[R1][C1], A[R2][C2], 2*(A[R1][C2]), R); printf(" A:"); p_mR(A,S10,P4,C6); printf(" EVector:"); p_mR(EVector,S10,P4,C6); printf(" EValue: EVectorT A EVector"); mul_mR(EVectorT,A,T1); mul_mR(T1,EVector,T2); p_mR(T2,S10,P4,C6); Ev1Ev2 = (T2[R1][C1])*(T2[R2][C2]); if(Ev1Ev2 > 0) printf(" The product of the eigenvalues = %+.3f > 0" " give an ellipse or a circle.\n\n\n", Ev1Ev2); else printf(" The product of the eigenvalues = %+.3f < 0" " give an hyperbola.\n\n\n", Ev1Ev2); printf(" %+.3f x^2 %+.3f y^2 = %+.3f \n\n", T2[R1][C1], T2[R2][C2], R); stop(); f_mR(A); f_mR(EVector); f_mR(EVectorT); f_mR(T1); f_mR(T2); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: If +2x^2 +5y^2 -4xy = +6 Can you give a description of the curve in the plan? A: +2.0000 -2.0000 -2.0000 +5.0000 EVector: -0.4472 +0.8944 +0.8944 +0.4472 EValue: EVectorT A EVector +6.0000 +0.0000 +0.0000 +1.0000 The product of the eigenvalues = +6.000 > 0 give an ellipse or a circle. +6.000 x^2 +1.000 y^2 = +6.000 Press return to continue.