matrix to array