Fixed small bugs, added documentation, and added accuracy tests.

Everything up to neural network is accurate to around 10 or more
significant digits when compared to Octave.