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

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 RC4 /* ------------------------------------ */ /* ------------------------------------ */ void fun(void) { double **A = rEsymmetric_mR(i_mR(RCA,RCA),999,+1.E-3); double **ExpA_EValue = i_mR(RCA,RCA); double **ExpA = i_mR(RCA,RCA); double **Log_ExpA_EValue = i_mR(RCA,RCA); double **Log_ExpA = i_mR(RCA,RCA); double **EVector = i_mR(RCA,RCA); double **EVectorT = i_mR(RCA,RCA); double **EValue = i_mR(RCA,RCA); double **T = i_mR(RCA,RCA); /* ================================================================== */ clrscrn(); printf(" Copy/Paste into the octave window. \n\n"); p_Octave_mR(A, "A", P6); printf(" expm (A)\n\n\n"); eigs_V_mR(A,EVector); transpose_mR(EVector,EVectorT); /* EValue = EVectorT A EVector */ mul_mR(EVectorT,A,T); mul_mR(T,EVector,EValue); printf(" ExpA"); f_eigs_mR(exp,EValue, ExpA_EValue); /* ExpA = EVector Exp_EValue EVectorT */ mul_mR(EVector,ExpA_EValue,T); mul_mR(T,EVectorT,ExpA); p_mR(ExpA, S9,P4, C6); stop(); /* ================================================================== */ clrscrn(); eigs_V_mR(ExpA,EVector); transpose_mR(EVector,EVectorT); /* ExpA_EValue = EVectorT ExpA EVector */ mul_mR(EVectorT,ExpA,T); mul_mR(T,EVector,ExpA_EValue); printf(" Log_ExpA = A"); f_eigs_mR(log,ExpA_EValue, Log_ExpA_EValue); /* A = EVector Log_ExpA_EValue EVectorT */ mul_mR(EVector,Log_ExpA_EValue,T); mul_mR(T,EVectorT,Log_ExpA); p_mR(Log_ExpA, S9,P6, C6); printf(" A:"); p_mR(A, S9,P6, C6); f_mR(A); f_mR(ExpA_EValue); f_mR(ExpA); f_mR(Log_ExpA_EValue); f_mR(Log_ExpA); f_mR(EVector); f_mR(EVectorT); f_mR(EValue); f_mR(T); } /* ------------------------------------ */ int main(void) { time_t t; srand(time(&t)); do { fun(); } while(stop_w()); return 0; } /* ------------------------------------ */ /* ------------------------------------ */ Screen output example: Copy/Paste into the octave window. A=[ +1.403277,+0.847714,-1.289026,-0.416156; +0.847714,+1.528721,-1.318441,+0.605936; -1.289026,-1.318441,+2.234697,-0.011670; -0.416156,+0.605936,-0.011670,+0.892437] expm (A) ExpA +16.2907 +14.9339 -20.6188 -0.0222 +14.9339 +18.4591 -21.8879 +2.4212 -20.6188 -21.8879 +30.9132 -1.3729 -0.0222 +2.4212 -1.3729 +3.1255 Press return to continue. Log_ExpA = A +1.403277 +0.847714 -1.289026 -0.416156 +0.847714 +1.528721 -1.318441 +0.605936 -1.289026 -1.318441 +2.234697 -0.011670 -0.416156 +0.605936 -0.011670 +0.892437 A: +1.403277 +0.847714 -1.289026 -0.416156 +0.847714 +1.528721 -1.318441 +0.605936 -1.289026 -1.318441 +2.234697 -0.011670 -0.416156 +0.605936 -0.011670 +0.892437 Press return to continue Press X return to stop