def inner(mpa1, mpa2):
"""Compute the inner product `<mpa1|mpa2>`. Both have to have the same
physical dimensions. If these represent a MPS, ``inner(...)`` corresponds
to the canoncial Hilbert space scalar product. If these represent a MPO,
``inner(...)`` corresponds to the Frobenius scalar product (with Hermitian
conjugation in the first argument)
:param mpa1: MPArray with same number of physical legs on each site
:param mpa2: MPArray with same physical shape as mpa1
:returns: <mpa1|mpa2>
"""
assert len(mpa1) == len(mpa2), \
"Length is not equal: {} != {}".format(len(mpa1), len(mpa2))
ltens_new = (_local_dot(_local_ravel(l).conj(), _local_ravel(r), axes=(1, 1))
for l, r in zip(mpa1.lt, mpa2.lt))
return _ltens_to_array(ltens_new)[0, ..., 0]
评论列表
文章目录