def overlap(*args):
'''
Calculate the overlap between two vectors or among a matrix and two vectors.
Usage:
* ``overlap(vector1,vector2)``, with
vector1,vector2: 1d ndarray
The vectors between which the overlap is to calculate.
* ``overlap(vector1,matrix,vector2)``, with
vector1,vector2: 1d ndarray
The ket and bra in the overlap.
matrix: 2d ndarray-like
The matrix between the two vectors.
'''
assert len(args) in (2,3)
if len(args)==2:
return np.vdot(args[0],args[1])
else:
return np.vdot(args[0],args[1].dot(args[2]))
评论列表
文章目录