build a matrix