Shortcuts

pypose.bvmv

class pypose.bvmv(lvec, mat, rvec)[source]

Performs batched vector-matrix-vector product.

\[\text{out}_i = \mathbf{v}_i^{l\text{T}} \times \mathbf{M}_i \times \mathbf{v}_i^r \]

where \(\text{out}_i\) is a scalar and \(\mathbf{v}_i^l, \mathbf{M}_i, \mathbf{v}_i^r\) are the i-th batched tensors with shape (n), (n, m), and (m), respectively.

Parameters:
  • lvec (Tensor) – left vectors to be multiplied.

  • mat (Tensor) – matrices to be multiplied.

  • rvec (Tensor) – right vectors to be multiplied.

Returns:

the output tensor.

Return type:

Tensor

Note

the lvec has to be a (\(\cdots\times n\)) tensor, The mat has to be a (\(\cdots\times n \times m\)) tensor, the rvec has to be a (\(\cdots\times m\)) tensor, and out will be a (\(\cdots\)) or at least a 1D tensor.

Example

>>> v1 = torch.randn(4)
>>> mat = torch.randn(4, 5)
>>> v2 = torch.randn(5)
>>> out = pp.bvmv(v1, mat, v2)
>>> out.shape
torch.Size([1])
>>> v1 = torch.randn(1, 2, 4)
>>> mat = torch.randn(2, 2, 4, 5)
>>> v2 = torch.randn(2, 1, 5)
>>> out = pp.bvmv(v1, mat, v2)
>>> out.shape
torch.Size([2, 2])

Docs

Access documentation for PyPose

View Docs

Tutorials

Get started with tutorials and examples

View Tutorials

Get Started

Find resources and how to start using pypose

View Resources