def _sympy_tensor_product(*matrices):
 if (not all((isinstance(m, Matrix) for m in matrices))):
  raise TypeError(('Sequence of Matrices expected, got: %s' % repr(matrices)))
 matrix_expansion = matrices[(-1)]
 for mat in reversed(matrices[:(-1)]):
  rows = mat.rows
  cols = mat.cols
  for i in range(rows):
   start = (matrix_expansion * mat[(i * cols)])
   for j in range((cols - 1)):
    start = start.row_join((matrix_expansion * mat[(((i * cols) + j) + 1)]))
   if (i == 0):
    next = start
   else:
    next = next.col_join(start)
  matrix_expansion = next
 return matrix_expansion

def _sympy_tensor_product ( * matrices ) : if ( not all ( ( isinstance ( m , Matrix ) for m in matrices ) ) ) : raise TypeError ( ( 'Sequence of Matrices expected, got: %s' % repr ( matrices ) ) ) matrix_expansion = matrices [ ( - 1 ) ] for mat in reversed ( matrices [ : ( - 1 ) ] ) : rows = mat . rows cols = mat . cols for i in range ( rows ) : start = ( matrix_expansion * mat [ ( i * cols ) ] ) for j in range ( ( cols - 1 ) ) : start = start . row_join ( ( matrix_expansion * mat [ ( ( ( i * cols ) + j ) + 1 ) ] ) ) if ( i == 0 ) : next = start else : next = next . col_join ( start ) matrix_expansion = next return matrix_expansion
compute the tensor product of a sequence of sympy matrices .