This is simply the Kronecker product of the contact matrix C with a matrix of ones of dimension n x n.
C
n
expandC(C, n)
a square matrix with n*ncol(C) rows and columns.
n*ncol(C)
a contactmatrix.
contactmatrix
the size of the secondary dimension to expand to.
expandC(contactmatrix(), 2)
Run the code above in your browser using DataLab