Install up-to-date scientific environment in Ubuntu 14.04 with Python 3.4

Note: I’ve created an updated page with most recent instructions for Jupyter Notebook.

I use IPython notebook for processing numerical experiments results and plotting. The default Python 3 in Ubuntu 14.04 is 3.4, so it is easier to install really up-to-date bunch of software.

Full set of commands you need to install recent ipython notebook, numpy, scipy, etc in virtual environment almost without affecting shiny-new Ubuntu 14.04.

SSH config for multiple hops in Linux

Often some hosts in corporate network are available only from several gateway machines. The scheme looks like that: you connect to gateway ssh -A and then to desired host from gateway machines ssh -A But the problem arises when you want to copy or download something from You have to do it in two hops, because is not available from your machine directly. The solution is ssh forwarding. Just add the following (edit according your network settings) lines to ~/.ssh/config:

Sort strings from file in C++

The very simple and common test program is to read bunch of strings from input file (let it be input.txt), sort them and write down to another file (output.txt). There is an implementation with small bug: it adds extra empty line. I’ve modified original code a bit, so now it works correctly (note: if have last empty line in the input, you will have an empty line in the output). Fixed code is provided below.

Randomized quicksort implementation in C++

Quicksort has $O(N\log(N))$ computational complexity in best and average cases, $O(N^{2})$ for bad case. Extremely bad cases may be avoided by using randomized Quicksort.