head_matrix function

head and tail for matrices