Add coord2ind(), ind2coord() and sub2ind()

Implements #74.