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.
@kloudkl, is there a reason the device needs to be a member of each layer?  This seems like it's inflexible, in that it fixes each layer to only use a single mode.  What if instead of making `device_` a member, the device was simply fetched with `DeviceFactory::GetDevice()` before performing any device-specific operations (e.g. at the beginning of the `Forward()` and `Backward()` functions, etc.)?  This would make things more flexible by allowing dynamic mode switching, which may or may not be nice, but it would be more in line with the original architecture, which essentially waited until the last minute to make a decision about whether to use, e.g. `Forward_cpu()` or `Forward_gpu()` instead of baking that decision into the layer itself upon instantiation.