Problem solved. Against tremendous odds. I shouldn't have put too much faith in Wiki; it helps nothing this time.
The Jordan canonical form is notorious for its computational challenge, but extremely useful in dealing with defective matrices. I pieced together the information I collected from several mathematical websites, and developed my own algorithm that partially avoids the tricky Jordan chain. Now I'm confident that Jordan() can take the place of dn() in linalgcas lib.
Also, armed with jordan decomposition, I wrote an algorithm that computes the generalized functions of matrices. matfunc(A, f(var), var) can replace both expmat() and pwrmat() in the original library. What's more, now I'm able to symbolically analyze sin(A*t), cos(A*t), log(A), sinh(A), etc.
Note: 1. when handling large matrices that do not have good eigenvalues, the function would sometimes fail, because the built-in cZeros and cPolyroots are working falsely. But if you input a 11*11 matrix with eigenvalues 1,2 and 3, my functions work perfectly.
2. if the matrix is diagonalizable, Jordan() is the same as diagonalization()
Thanks for Philippe's amazing groundwork.