fn

t

Tensor
t(x: Tensor)
source

Short-form transpose for tensors of rank at most 2.

A convenience analogue of MATLAB's A' or the reference framework's Tensor.t(): returns the transpose of a 2-D matrix, or the input unchanged for 0-D and 1-D tensors.

Parameters

xTensor
Input tensor with at most 2 dimensions.

Returns

Tensor

For ndim <= 1, returns x unchanged. For ndim == 2, returns the 2-D transpose.

Raises

RuntimeError
If x has 3 or more dimensions.

Notes

Defined as

t(x)={x,ndim(x)1,xT,ndim(x)=2.\text{t}(x) = \begin{cases} x, & \text{ndim}(x) \leq 1, \\ x^{T}, & \text{ndim}(x) = 2. \end{cases}

Use adjoint or lucid.transpose for batched / higher rank inputs.

Examples

>>> import lucid
>>> A = lucid.tensor([[1., 2.], [3., 4.], [5., 6.]])
>>> lucid.t(A).shape
(2, 3)