Code for sparse coding