def tensorproduct(*args):
 if (len(args) == 0):
  return S.One
 if (len(args) == 1):
  return _arrayfy(args[0])
 if (len(args) > 2):
  return tensorproduct(tensorproduct(args[0], args[1]), *args[2:])
 (a, b) = map(_arrayfy, args)
 if ((not isinstance(a, NDimArray)) or (not isinstance(b, NDimArray))):
  return (a * b)
 al = list(a)
 bl = list(b)
 product_list = [(i * j) for i in al for j in bl]
 return ImmutableDenseNDimArray(product_list, (a.shape + b.shape))

def tensorproduct ( * args ) : if ( len ( args ) == 0 ) : return S . One if ( len ( args ) == 1 ) : return _arrayfy ( args [ 0 ] ) if ( len ( args ) > 2 ) : return tensorproduct ( tensorproduct ( args [ 0 ] , args [ 1 ] ) , * args [ 2 : ] ) ( a , b ) = map ( _arrayfy , args ) if ( ( not isinstance ( a , NDimArray ) ) or ( not isinstance ( b , NDimArray ) ) ) : return ( a * b ) al = list ( a ) bl = list ( b ) product_list = [ ( i * j ) for i in al for j in bl ] return ImmutableDenseNDimArray ( product_list , ( a . shape + b . shape ) )
tensor product among scalars or array-like objects .