Implements more functions.
wrapper code from alex cuda convnet.