Linear Algebra and the C Language/a0bx
Install and compile this file in your working directory.
/* ------------------------------------ */
/* Save as : c00c.c */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
#define RCA RC5
/* ------------------------------------ */
/* ------------------------------------ */
double f(
double x)
{
return((x)*(x)*(x));
}
char feq[] = "(x)*(x)*(x)";
/* ------------------------------------ */
/* ------------------------------------ */
void fun(void)
{
double **A = rsymmetric_mR(i_mR(RCA,RCA),999.);
double **A_p3 = i_mR(RCA,RCA);
double **EigsVector = i_mR(RCA,RCA);
double **T_EigsVector = i_mR(RCA,RCA);
double **EigsValue = i_mR(RCA,RCA);
double **f_EigsValue = i_mR(RCA,RCA);
double **T1 = i_mR(RCA,RCA);
clrscrn();
printf(" Copy/Paste into the octave windows \n");
p_Octave_mR(A,"A",P0);
printf(" A*A*A\n\n");
stop();
clrscrn();
eigs_V_mR(A,EigsVector);
transpose_mR(EigsVector,T_EigsVector);
/* EigsValue : T_EigsVector * A * EigsVector */
mul_mR(T_EigsVector,A,T1);
mul_mR(T1,EigsVector,EigsValue);
printf(" A**3 : EigsVector * EigsValue**3 * T_EigsVector\n");
f_eigs_mR(f,EigsValue,f_EigsValue);
mul_mR(EigsVector,f_EigsValue,T1);
mul_mR(T1,T_EigsVector,A_p3);
pE_mR(A_p3,S10,P4,C6);
printf(" A**3");
pow_mR(3,A,T1);
pE_mR(T1,S10,P4,C6);
f_mR(A);
f_mR(A_p3);
f_mR(EigsVector);
f_mR(T_EigsVector);
f_mR(EigsValue);
f_mR(f_EigsValue);
f_mR(T1);
}
/* ------------------------------------ */
int main(void)
{
time_t t;
srand(time(&t));
do
{
fun();
} while(stop_w());
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
Screen output example:
Copy/Paste into the octave windows
A=[
+561,+543,-450,-862,-178;
+543,-61,-385,-423,+404;
-450,-385,+211,-406,+367;
-862,-423,-406,+673,+109;
-178,+404,+367,+109,+707]
A*A*A
Press return to continue.
A**3 : EigsVector * EigsValue**3 * T_EigsVector
+2.4343e+09 +1.2921e+09 -6.9393e+08 -2.3589e+09 -3.9512e+08
+1.2921e+09 +5.5885e+08 -4.2649e+08 -1.3336e+09 +1.2032e+08
-6.9393e+08 -4.2649e+08 +2.4760e+08 +1.2436e+08 +4.8944e+08
-2.3589e+09 -1.3336e+09 +1.2436e+08 +2.1453e+09 +2.3129e+08
-3.9512e+08 +1.2032e+08 +4.8944e+08 +2.3129e+08 +7.1071e+08
A**3
+2.4343e+09 +1.2921e+09 -6.9393e+08 -2.3589e+09 -3.9512e+08
+1.2921e+09 +5.5885e+08 -4.2649e+08 -1.3336e+09 +1.2032e+08
-6.9393e+08 -4.2649e+08 +2.4760e+08 +1.2436e+08 +4.8944e+08
-2.3589e+09 -1.3336e+09 +1.2436e+08 +2.1453e+09 +2.3129e+08
-3.9512e+08 +1.2032e+08 +4.8944e+08 +2.3129e+08 +7.1071e+08
Press return to continue
Press X return to stop