Contrastive loss layer for training siamese nets

Hi All,

I've started work on a contrastive loss layer that, when combined with weight sharing #546, can be used to train siamese nets. 

The layer implements:
loss = 1/2 (y d + (1-y) \max(margin-d, 0))
d = \sum_i (a_i - b_i)^2
where d is the distance between two features a and b, and y is binary, indicating if the two features are similar or dissimilar.

This loss function was proposed in:
Raia Hadsell, Sumit Chopra, Yann LeCun "Dimensionality Reduction by Learning an Invariant Mapping"

I still need to implement the GPU version and flesh out the tests, but before I go too far, is this something that you would be interested in merging? I can also add a small example based on MNIST for documentation if that is of interest.

Thanks, 
Nick
@nickcarlevaris @shelhamer Isn't it safer to recast the data to int type before doing this comparison? I'm not really sure how it will be interpreted by the compiler, but I think this is one of those situations where you should be explicit. This also applies to other locations where you make comparison based on the label. Look at the SoftMax loss for instance. They always say something like
```c++
bottom_diff[i * dim + static_cast<int>(label[i * spatial_dim + j])
```