Pytorch Torch Vdot
# PyTorch torch.vdot Function
* * (#)
`torch.vdot` is a function in PyTorch used to compute the dot product of two vectors (also known as vector dot product). Unlike `torch.dot`, `torch.vdot` can handle complex vectors and automatically multiplies each element of the first vector with the conjugate element of the second vector.
### Function Definition
torch.vdot(input, other)
* * *
## Usage Examples
## Example
import torch
# Real number vectors
a = torch.tensor([1,2,3])
b = torch.tensor([4,5,6])
result = torch.vdot(a, b)
print("vdot result:", result)
# 1*4 + 2*5 + 3*6 = 32
# Complex vectors
c = torch.tensor([1+2j,3+4j])
d = torch.tensor([5+6j,7+8j])
result_complex = torch.vdot(c, d)
print("Complex vdot result:", result_complex)
Output:
vdot result: tensor(32)Complex vdot result: tensor(70.-6.j)
* * (#)
YouTip