def kronsum(A, B, format=None):
 A = coo_matrix(A)
 B = coo_matrix(B)
 if (A.shape[0] != A.shape[1]):
  raise ValueError('A is not square')
 if (B.shape[0] != B.shape[1]):
  raise ValueError('B is not square')
 dtype = upcast(A.dtype, B.dtype)
 L = kron(eye(B.shape[0], dtype=dtype), A, format=format)
 R = kron(B, eye(A.shape[0], dtype=dtype), format=format)
 return (L + R).asformat(format)

def kronsum ( A , B , format = None ) : A = coo_matrix ( A ) B = coo_matrix ( B ) if ( A . shape [ 0 ] != A . shape [ 1 ] ) : raise ValueError ( 'A is not square' ) if ( B . shape [ 0 ] != B . shape [ 1 ] ) : raise ValueError ( 'B is not square' ) dtype = upcast ( A . dtype , B . dtype ) L = kron ( eye ( B . shape [ 0 ] , dtype = dtype ) , A , format = format ) R = kron ( B , eye ( A . shape [ 0 ] , dtype = dtype ) , format = format ) return ( L + R ) . asformat ( format )
kronecker sum of sparse matrices a and b kronecker sum of two sparse matrices is a sum of two kronecker products kron + kron where a has shape and b has shape and i_m and i_n are identity matrices of shape and respectively .