API

 torch / torch


torch.vdot

torch.vdot(input, other, *, out=None) → Tensor

Computes the dot product (inner product) of two tensors. The vdot(a, b) function handles complex numbers differently than dot(a, b). If the first argument is complex, the complex conjugate of the first argument is used for the calculation of the dot product.

Note

This function does not broadcast.

Parameters
  • input (Tensor) – first tensor in the dot product. Its conjugate is used if it’s complex.

  • other (Tensor) – second tensor in the dot product.

Keyword Arguments

out (Tensor, optional) – the output tensor.

Example:

>>> torch.vdot(torch.tensor([2, 3]), torch.tensor([2, 1]))
tensor(7)
>>> a = torch.tensor((1 +2j, 3 - 1j))
>>> b = torch.tensor((2 +1j, 4 - 0j))
>>> torch.vdot(a, b)
tensor([16.+1.j])
>>> torch.vdot(b, a)
tensor([16.-1.j])

此页内容是否对您有帮助