Unify the CPU, CUDA and OpenCL math functions API in the device wrapper classes

This PR wraps the math functions as suggested by both [Yangqing](https://github.com/BVLC/caffe/issues/382#issuecomment-42465152) in #382 and [jeffdonahue](https://github.com/BVLC/caffe/issues/408#issuecomment-43035934) in #408 to abstract the device type from the algorithms.
@shelhamer, I think I agree that the need to switch back and forth between devices seems doubtful.  It is possible, though, under the current architecture.  This is actually precisely the source of the problem in @kloudkl's May 15 comment above, where he talks about the order of calling `Caffe::set_mode()` and the instantiation of a layer.  The reason that problem exists is because, in this branch, the device is set for the layer when the layer is instantiated instead of being determined immediately before the computation.  I think the problem would only be exacerbated if the device was set when the `Net` is constructed, since this at is an even higher level than the layer.

In general, I think we could make it easier for future programmers by not making the order of calls to these operations matter.  That's the kind of thing that's subtle and often very hard to track down during debugging, and I can see it causing serious headaches for those unaware of the (non-obvious) ordering requirement.  This may be especially troublesome for folks who are used to the current architecture in `dev`, where it's possible to call `Caffe::set_mode()` anywhere and have your layers all still work fine.  In other-words, the change here introduces a subtle, possibly-nasty backwards incompatibility.

I see no drawbacks to architecting the code in such a way as to eliminate these problems by simply fetching the device immediately before any device-specific pointers are gotten or any device-specific functions are called.  In fact, this will be easy to do given @kloudkl's current codebase.  We essentially simply need to change every instance of `this->device_...` to `device = DeviceFactory::GetDevice(); device...`.