MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / complex_mul_t

Function complex_mul_t

monai/apps/reconstruction/complex_utils.py:138–155  ·  view source on GitHub ↗

Compute complex-valued multiplication. Supports Ndim inputs with last dim equal to 2 (real/imaginary channels) Args: x: Input tensor with 2 channels in the last dimension representing real and imaginary parts. y: Input tensor with 2 channels in the last dimension representi

(x: Tensor, y: Tensor)

Source from the content-addressed store, hash-verified

136
137
138def complex_mul_t(x: Tensor, y: Tensor) -> Tensor:
139 """
140 Compute complex-valued multiplication. Supports Ndim inputs with last dim equal to 2 (real/imaginary channels)
141
142 Args:
143 x: Input tensor with 2 channels in the last dimension representing real and imaginary parts.
144 y: Input tensor with 2 channels in the last dimension representing real and imaginary parts.
145
146 Returns:
147 Complex multiplication of x and y
148 """
149 if x.shape[-1] != 2 or y.shape[-1] != 2:
150 raise ValueError(f"last dim must be 2, but x.shape[-1] is {x.shape[-1]} and y.shape[-1] is {y.shape[-1]}.")
151
152 real_part = x[..., 0] * y[..., 0] - x[..., 1] * y[..., 1]
153 imag_part = x[..., 0] * y[..., 1] + x[..., 1] * y[..., 0]
154
155 return torch.stack((real_part, imag_part), dim=-1)
156
157
158def complex_mul(x: NdarrayOrTensor, y: NdarrayOrTensor) -> NdarrayOrTensor:

Callers 3

sensitivity_map_reduceFunction · 0.90
sensitivity_map_expandFunction · 0.90
complex_mulFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…