int main() { /* eigenvalues of a symmtrical matrix are always real numbers */ array double a1[3][3] = {0.8, 0.2, 0.1, 0.2, 0.7, 0.3, 0.1, 0.3, 0.6}; /* eigenvalues of a non-symmtrical matrix can be either real numbers or complex numbers */ /* this non-symmtrical matrix has real eigenvalues */ array double a2[3][3] = {0.8, 0.2, 0.1, 0.1, 0.7, 0.3, 0.1, 0.1, 0.6}; /* this non-symmtrical matrix has complex eigenvalues */ array double a3[3][3] = {3, 9, 23, 2, 2, 1, -7, 1, -9}; array double complex a4[2][2] = {complex(1,2), 4, 3, 7}; array double charpolynomial[4]; array double complex zcharpolynomial[4]; array double complex zcharpolynomial2[3]; charpolycoef(charpolynomial, a1); printf("charpolynomial from charpolycoef(a1) =\n%f\n", charpolynomial); charpolycoef(charpolynomial, a2); printf("charpolynomial from charpolycoef(a2) =\n%f\n", charpolynomial); charpolycoef(charpolynomial, a3); printf("charpolynomial from charpolycoef(a3) =\n%f\n", charpolynomial); charpolycoef(zcharpolynomial, a3); printf("zcharpolynomial from charpolycoef(zcharpolynomial, a3) =\n%f\n", zcharpolynomial); charpolycoef(zcharpolynomial2, a4); printf("zcharpolynomial2 from charpolycoef(zcharpolynomial2, a4) =\n%f\n", zcharpolynomial2); }
charpolynomial from charpolycoef(a1) = 1.000000 -2.100000 1.320000 -0.245000 charpolynomial from charpolycoef(a2) = 1.000000 -2.100000 1.400000 -0.300000 charpolynomial from charpolycoef(a3) = 1.000000 4.000000 103.000000 -410.000000 zcharpolynomial from charpolycoef(zcharpolynomial, a3) = complex(1.000000,0.000000) complex(4.000000,0.000000) complex(103.000000,0.000000) complex(-410.000000,0.000000) zcharpolynomial2 from charpolycoef(zcharpolynomial2, a4) = complex(1.000000,0.000000) complex(-8.000000,-2.000000) complex(-5.000000,14.000000)