This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This function, MATrix2LaTeX, converts any matrix in MATLAB's format(s) to AMS's LaTeX-format. | |
One example of the former is " | |
[ 0.53730, 0.33377, 0.53773; 0.34990, 0.38121, 0.16256 ] | |
". | |
Another example of the former is " | |
A = 0.53730 0.33377 0.53773 | |
0.34990 0.38121 0.16256 | |
". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This is a small tool that I used myself while teaching Linear Algebra classes over the years. I frequently found myself in the following situation: | |
- I want a "random-looking" diagonalizable matrix with eigenvalues of my choice (including multiplicities), because I want to illustrate certain behavior in class or test certain ideas on an exam. | |
- But I also want the matrix to have small integer entries, and I possibly want to know eigenvectors in advance. | |
Fundamentally, all you need to do is conjugate (= "similarity transformation") a given diagonal matrix by a "small" integral matrix g whose inverse is also integral and "small". | |
A source of most, but not all, such g is GL(Z), the group of integer matrices whose determinants are either +1 or -1. The subgroup SL(Z) of those with determinant +1 is essentially the same thing, and the function rSLZ below produces random elements g of SL(Z). A typical call for classroom/exam use might be rSLZ(3,9) or rSLZ(4,5). | |
Besides the size of the matrix, you also provide |