def duplication_matrix(n):
 tmp = np.eye(((n * (n + 1)) // 2))
 return np.array([unvech(x).ravel() for x in tmp]).T

def duplication_matrix ( n ) : tmp = np . eye ( ( ( n * ( n + 1 ) ) // 2 ) ) return np . array ( [ unvech ( x ) . ravel ( ) for x in tmp ] ) . T
create duplication matrix d_n which satisfies vec(s) = d_n vech(s) for symmetric matrix s returns d_n : ndarray .