def hermitian_to_vector(matrix, basis):
"""
Returns a the vector representing the ``matrix`` w.r.t. the given *orthonormal* ``basis``.
"""
_assert_orthogonal(basis)
vec = tuple(
frobenius_product(matrix, b) / frobenius_product(b, b) for b in basis
)
vec = tuple(v.nsimplify() for v in vec)
# check consistency
assert matrix.equals(
sum((v * b for v, b in zip(vec, basis)), sp.zeros(*matrix.shape))
)
return vec
评论列表
文章目录