Optmized Chuyuan's algorithm and create examples for IPython Notebook.
Merge pull request #3 from shaohu/master

Optmized Chuyuan's algorithm and create examples for IPython Notebook.