def blockCombine(l):
 l = [list(map(mat, row)) for row in l]
 hdims = [m.shape[1] for m in l[0]]
 hs = sum(hdims)
 vdims = [row[0].shape[0] for row in l]
 vs = sum(vdims)
 res = zeros((hs, vs))
 vindex = 0
 for (i, row) in enumerate(l):
  hindex = 0
  for (j, m) in enumerate(row):
   res[vindex:(vindex + vdims[i]), hindex:(hindex + hdims[j])] = m
   hindex += hdims[j]
  vindex += vdims[i]
 return res

def blockCombine ( l ) : l = [ list ( map ( mat , row ) ) for row in l ] hdims = [ m . shape [ 1 ] for m in l [ 0 ] ] hs = sum ( hdims ) vdims = [ row [ 0 ] . shape [ 0 ] for row in l ] vs = sum ( vdims ) res = zeros ( ( hs , vs ) ) vindex = 0 for ( i , row ) in enumerate ( l ) : hindex = 0 for ( j , m ) in enumerate ( row ) : res [ vindex : ( vindex + vdims [ i ] ) , hindex : ( hindex + hdims [ j ] ) ] = m hindex += hdims [ j ] vindex += vdims [ i ] return res
produce a matrix from a list of lists of its components .