Just For Fun


Inkscape with textext on Windows, problem with texlive

leave a comment »

Inkscape + textext is a very cool tool for scientific graphics. It works well on my windows xp machine with Miktex2.7. But recently I got some weird problems after switching to texlive2010 (I didn’t uninstall Miktex, but just put texlive2010 before Miktex in the PATH environment.) I fixed this problem by changing the line:
paths += glob.glob(os.path.join(program_files, 'miktex*/miktex/bin'))
paths = paths + glob.glob(os.path.join(program_files, 'miktex*/miktex/bin'))
in the file “textext.py” .

It seems that textext works better with miktex, so I put miktex in front of texlive in the PATH.

Written by Jerry

November 23, 2010 at 1:23 pm

Posted in Uncategorized

These guys shapes the modern matrix theory

leave a comment »

I copied this post from Dan Simon’s book “Optimal State Estimation”, section 1.1.4. It’s interesting to see that most of the main framework of matrix theory was built in relative recent time.

In spite of this very early beginning (the use of matrices by Babylonians and ancient Chinese) it was not until the end of 17th century that serious investigation of matrix algebra began. In 1683, the Japanese mathematician Takakazu Seki Kowa wrote a book called “Method of Solving the Dissimulated Problems”. This book gives general methods for calculating determinants and presents examples for matrices as large as 5×5. Coincidentally, in the same year (1683) Gottfried Leibniz in Europe also first used determinants to solve systems of linear equations. Leibniz also discovered that a determinant could be expanded using any of the matrix columns.

In the middle of the 1700s, Colin Maclaurin and Gabriel Cramer published some major contributions to matrix theory. After that point, work on matrices became rather regular, with significant contributions by Etienne Bezout, Alexandre Vandermonde, Pierre Laplace, Joseph Lagrange, and Carl Gauss. The term “determinant” was first used in the modern sense by Augustin Cauchy in 1812 (although the word was used earlier by Gauss in a different sense). Cauchy also discovered matrix eigenvalues and diagonalization, and introduced the idea of similar matrices. He was the first to prove that every real symmetric matrix is diagonalizable.

James Sylvester (in 1850) was the first to use the term “matrix”. Sylvester moved to England in 1851 to became a lawyer and met Arthur Cayley, a fellow lawyer who was also interested in mathematics. Cayley saw the importance of the idea of matrices and in 1853 he invented matrix inversion. Cayley also proved that 2×2 and 3×3 matrices satisfy their own characteristic equations. The facet that a matrix satisfies its own characterization equation is now called Cayley-Hamilton theorem. The theorem has William Hamilton’s name associated with it because he proved the theorem for 4×4 matrices during the course of his work on quaternions.

Camille Jordan invented the Jordan canonical form of a matrix in 1870. Georg Frobenius proved in 1878 that all matrices satisfy their own characteristic equation (the Cayley Hamilton theorem). He also introduced the definition of the rank of a matrix. The nullity of a square matrix was defined by Sylvester in 1884. Karl Weierstrass’s and Leopold Kronecker’s publication in 1903 were instrumental in establishing matrix theory as an important branch of mathematics. Leon Mirsky’s book in 1955 helped solidify matrix theory as a fundamentally important topic in university mathematics.

Written by Jerry

October 20, 2010 at 1:44 pm

Posted in Uncategorized

Plan to modify Emacs org-mode

leave a comment »

Emacs org-mode is a nice tool for me to write notes. For me the most attractive feature is that I can write LaTex equations and export to html files.

However, the html file with equations look ugly, because the equation images are not properly aligned. I can’t tolerate a beautiful LaTex equation makes such an ugly webpage:

There is another light markup tool called jemdoc written in python, which also supports LaTex equations in html, but BEAUTIFULLY aligned. So I plan to study the codes for jemdoc, and immigrate the nice equation alignment to Emacs org-mode. I know a little bit python, and nothing on elisp, so I hope it won’t be too hard and take too much time.

Here is the idea in jemdoc:
1. Use a variable called “baseline”, whose value is the hight of equation $0123456789xxxXXxX$.
2. After generating each equation image, record the “height”.
3. offset = height – baseline + 1
4. In the generated html code for the equation image, set: style=”vertical-align: -height px”

If someone implement this idea before me, please let me know. I’ll be glad to try it.

Written by Jerry

June 10, 2010 at 3:58 pm

Posted in techniclick

Python under Win is really a pain!

leave a comment »

For English users, please ignore the next paragraph and jump to the process part directly.


process: python2.6(enthought)+networkx(1.0 rc1)+pygraphviz(0.99.1) under windows xp sp3

When you proceed, please first try to install without my modification, because some bugs might have been fixed when you see this post.

1. Have python2.6 and mingw32 installed. I’m using enthought, which is the company that sponsors scipy. The academic version is FREE. For beginners like me, creating python tool chain from scratch (download python, scipy, numpy, matplotlib … separately) is really a frustrating process.

2. Install the “setuptools”(0.6c11.1) here http://pypi.python.org/pypi/setuptools#files, so that you can use easy_install. You can skip this step if you want to install networkx manually.

3. Install “networkx”(1.0rc1) using the command: “easy_install networkx”

4. Install “graphviz”(2.26.3) (yes, pygraphviz is just a python interface to graphviz, so you need to install graphviz first). You can’t install pygraphviz using easy_install, because it depends on graphviz, and the easy_install too can’t find the path of graphviz. So you need to download and install “graphviz” from here: http://www.graphviz.org/Download_windows.php

5. Install pygraphviz from source:

5.1 Download pygraphviz(0.99.1) from this link http://networkx.lanl.gov/pygraphviz/download.html, and extract it.

5.2 Modify “setup.py”

library_path='c:/Program Files/Graphviz2.26.3/lib/release/lib'
include_path='c:/Program Files/Graphviz2.26.3/include/graphviz'

5.3 Modify “c:\python26\lib\distutils\unixcompiler.py”, (for me it was line 282):

compiler = os.path.basename(sysconfig.get_config_var("CC"))
compiler = "gcc"

Otherwise there would be an error “TypeError: ‘NoneType’ object is unsubscriptable”, see this link “http://code.google.com/p/netcdf4-python/issues/detail?id=8”. I change it back after finishing installing pygraphviz for safety (I am a beginner).

5.4 Run command “python setup.py install” under the pygraphviz source directory. Now you should be able to install it.

6. Now the installation is done, but if you try to run the sample code such as edge_colormap, you might get an error: “close_fds is not supported on Windows platforms, balabala”. This was a bug of pygraphviz, I found it here and here. So I followed the links and modified line 1146 of site-packages/pygraphviz/agraph.py to


7. Now you should be able to run the test codes without error and begin to do your own work. Actually, my python crashes when I run the test codes “circular_tree” and “lanl_routes”. I don’t know why and really don’t want to spend time fixing it.

I hope those issues will be fixed soon so nobody have to follow this painful process. Working with python under windows is really a pain.

Written by Jerry

February 12, 2010 at 12:45 am

Posted in techniclick


leave a comment »

今天跟Evg同学聊了一会儿会儿,学了一点关于pgp encryption,public key, private key的东西,花10分钟记下来。n年前考所谓的计算机3级网络技术时就把这些名词背得烂熟,却始终没搞明白到底是怎么回事,而Evg同学画个草图,5分钟就讲得明明白白,可见国内的考试认证是多么的没用。

1. public key(公钥) 和 private key(私钥)



2 签名



上面的过程已经非常安全了: 首先,如果别人(比如C),在网络传输中截获了B发出来的消息和签名,他只能对签名进行解密,得到消息的Hash的结果”hho”,而因为Hash是不可逆的,所以他得不到消息。 第二,如果C想给A发一条消息”fuck you”,想办法让A以为是B发的,这也是不可能的,因为C他不知道B的私钥;A拿着B的公钥对签名解密,会发现得到的签名和A对消息解密后再Hash的结果不一致。

3 公钥的分配



4 结语和鸣谢
感谢知识面广阔的Evg同学给我如此通俗易懂的解释。感谢发明Public-key cryptography, digital signatures这套系统以及RSA/DSA算法,Hash算法,PGP程序的前辈。

Written by Jerry

May 5, 2009 at 9:07 pm

Posted in techniclick

jemdoc和emacs org mode

leave a comment »

还是老毛病,有了整理一些笔记的想法,首先不是着手开始干,而是找个好工具。希望写出来的笔记能够发布成html发到网上。3个备选工具:wordpress自己对latex公式支持, jemdoc, 和emacs的org-mode。

第一个算是很方便,而且人家Terry Tao都在用这个写blog,但是似乎不够灵活,因为格式要求$\latex ...$ ,这样就只能在blog上用了。


第三个顾名思义,是emacs下一个综合的笔记,日程管理的mode。方便的TODO列表,超级链接,输出各种格式,html,tex,pdf等。试了一下,很不错,如果我真的能够借助这个工具变成一个organized的人就好了。对公式和文字的对齐不太好,不知道我日后能不能参考jemdoc的代码来修改一下。奇怪的地方是不支持换行,在一个eqnarray环境里面,两行公式居然不能用回车分开,只能写成一行,不知道为什么。同样在windows下运行不成功。slackware工作在virtualbox的seamless mode实在是很爽。


Written by Jerry

March 30, 2009 at 9:53 pm

Posted in 1


leave a comment »

虽然很不想把我的blog变成我的自白书,但是每当想到自己身上的一些问题,总是不吐不快。这些问题不外乎围绕着学习方法和学习效果等等,都是我很早就应该很好的解决的了;毕竟现在已经是博士阶段,良好和高效的学习方法是最最起码的素质,本应该追求更高层次的研究上的创新与突破,考虑事业的选择和人脉培养,而我还在炒这些早就应该吃完的剩饭,心里觉得很惭愧,于是不自觉地就把blog写成了自白书。 Read the rest of this entry »

Written by Jerry

June 16, 2008 at 6:28 pm

Posted in struggle