Implemented all math - UNTESTED

Everything is implemented as I envisioned it, all that remains is to
test the monstrous trainBatch method.