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

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 RC5 /* ------------------------------------ */ /* ------------------------------------ */ double f( double x) { return(sin(x)*sin(x)); } char feq[] = "sin(x)*sin(x)"; /* ------------------------------------ */ double g( double x) { return(cos(x)*cos(x)); } char geq[] = "cos(x)*cos(x)"; /* ------------------------------------ */ /* ------------------------------------ */ void fun(void) { double **A = rsymmetric_mR( i_mR(RCA,RCA),999.); double **sinA_P2 = i_mR(RCA,RCA); double **cosA_P2 = i_mR(RCA,RCA); double **EVector = i_mR(RCA,RCA); double **EVectorT = i_mR(RCA,RCA); double **EValue = i_mR(RCA,RCA); double **sinA_P2_EValue = i_mR(RCA,RCA); double **cosA_P2_EValue = i_mR(RCA,RCA); double **T1 = i_mR(RCA,RCA); clrscrn(); printf(" A:"); p_mR(A,S10,P4,C6); stop(); clrscrn(); eigs_V_mR(A,EVector); transpose_mR(EVector,EVectorT); /* EValue = EVectorT A EVector */ mul_mR(EVectorT,A,T1); mul_mR(T1,EVector,EValue); printf(" sin(A)**2"); f_eigs_mR(f,EValue,sinA_P2_EValue); /* sinA_P2 = EVector sinA_P2_EValue EVectorT */ mul_mR(EVector,sinA_P2_EValue,T1); mul_mR(T1,EVectorT,sinA_P2); p_mR(sinA_P2,S10,P4,C6); printf(" cos(A)**2"); f_eigs_mR(g,EValue,cosA_P2_EValue); /* cosA_P2 = EVector cosA_P2_EValue EVectorT */ mul_mR(EVector,cosA_P2_EValue,T1); mul_mR(T1,EVectorT,cosA_P2); p_mR(cosA_P2,S10,P4,C6); printf(" Ide: cos(A)**2 + sin(A)**2"); add_mR(sinA_P2,cosA_P2,T1); p_mR(T1,S10,P4,C6); f_mR(A); f_mR(sinA_P2); f_mR(cosA_P2); f_mR(EVector); f_mR(EVectorT); f_mR(EValue); f_mR(cosA_P2_EValue); f_mR(sinA_P2_EValue); f_mR(T1); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: A: +20.0000 +709.0000 +498.0000 +172.0000 -394.0000 +709.0000 -221.0000 -342.0000 -931.0000 -743.0000 +498.0000 -342.0000 +206.0000 -38.0000 -587.0000 +172.0000 -931.0000 -38.0000 +55.0000 +914.0000 -394.0000 -743.0000 -587.0000 +914.0000 +753.0000 Press return to continue. sin(A)**2 +0.6255 -0.2229 +0.0451 -0.0637 -0.0215 -0.2229 +0.7666 +0.0617 +0.0720 +0.0750 +0.0451 +0.0617 +0.8170 +0.0572 +0.1250 -0.0637 +0.0720 +0.0572 +0.7974 -0.1899 -0.0215 +0.0750 +0.1250 -0.1899 +0.6702 cos(A)**2 +0.3745 +0.2229 -0.0451 +0.0637 +0.0215 +0.2229 +0.2334 -0.0617 -0.0720 -0.0750 -0.0451 -0.0617 +0.1830 -0.0572 -0.1250 +0.0637 -0.0720 -0.0572 +0.2026 +0.1899 +0.0215 -0.0750 -0.1250 +0.1899 +0.3298 Ide: cos(A)**2 + sin(A)**2 +1.0000 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 +1.0000 +0.0000 +0.0000 +0.0000 -0.0000 +0.0000 +1.0000 +0.0000 -0.0000 -0.0000 +0.0000 +0.0000 +1.0000 +0.0000 -0.0000 +0.0000 -0.0000 +0.0000 +1.0000 Press return to continue Press X return to stop