def rep_innerproduct(expr, **options):
 if (not isinstance(expr, (KetBase, BraBase))):
  raise TypeError('expr passed is not a Bra or Ket')
 basis = get_basis(expr, **options)
 if (not isinstance(basis, StateBase)):
  raise NotImplementedError("Can't form this representation!")
 if (not ('index' in options)):
  options['index'] = 1
 basis_kets = enumerate_states(basis, options['index'], 2)
 if isinstance(expr, BraBase):
  bra = expr
  ket = (basis_kets[1] if (basis_kets[0].dual == expr) else basis_kets[0])
 else:
  bra = (basis_kets[1].dual if (basis_kets[0] == expr) else basis_kets[0].dual)
  ket = expr
 prod = InnerProduct(bra, ket)
 result = prod.doit()
 format = options.get('format', 'sympy')
 return expr._format_represent(result, format)

def rep_innerproduct ( expr , ** options ) : if ( not isinstance ( expr , ( KetBase , BraBase ) ) ) : raise TypeError ( 'expr passed is not a Bra or Ket' ) basis = get_basis ( expr , ** options ) if ( not isinstance ( basis , StateBase ) ) : raise NotImplementedError ( "Can't form this representation!" ) if ( not ( 'index' in options ) ) : options [ 'index' ] = 1 basis_kets = enumerate_states ( basis , options [ 'index' ] , 2 ) if isinstance ( expr , BraBase ) : bra = expr ket = ( basis_kets [ 1 ] if ( basis_kets [ 0 ] . dual == expr ) else basis_kets [ 0 ] ) else : bra = ( basis_kets [ 1 ] . dual if ( basis_kets [ 0 ] == expr ) else basis_kets [ 0 ] . dual ) ket = expr prod = InnerProduct ( bra , ket ) result = prod . doit ( ) format = options . get ( 'format' , 'sympy' ) return expr . _format_represent ( result , format )
returns an innerproduct like representation for the given state .