Over the past couple of years, a lot of my "numerical experimentation" work has moved from Octave to python/numpy.
I incorporate a lot of this work into my classes and presentations (made using beamer), and having a script to translate vectors and matrices to LaTeX format is handy.
In the past, I shared a Matlab/Octave script which does this.
Here is a python/numpy script which does something similar. The script
I incorporate a lot of this work into my classes and presentations (made using beamer), and having a script to translate vectors and matrices to LaTeX format is handy.
In the past, I shared a Matlab/Octave script which does this.
Here is a python/numpy script which does something similar. The script
- autodetects integers and floats
- allows you to control the number of decimals for floats
- allows you optionally render floats in scientific format
- right-justify using the bmatrix* environment (good for -ve numbers)
- suppress small values near zero (~ 1e-16)
The link for the python script is the same as the link for the Matlab/Octave script
ReplyDeleteThanks for pointing that out. I fixed the link.
ReplyDeleteI ran into trouble where large matrices would not be converted correctly because of extra line breaks.
ReplyDeleteAdding
np.set_printoptions(linewidth=np.inf)
before line 76 fixed the problem.
Thanks for the pointer!
ReplyDelete