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

Function complex_conj

monai/apps/reconstruction/complex_utils.py:208–233  ·  view source on GitHub ↗

Compute complex conjugate of an/a array/tensor. Supports Ndim inputs with last dim equal to 2 (real/imaginary channels) Args: x: Input array/tensor with 2 channels in the last dimension representing real and imaginary parts. Returns: Complex conjugate of x Example

(x: NdarrayOrTensor)

Source from the content-addressed store, hash-verified

206
207
208def complex_conj(x: NdarrayOrTensor) -> NdarrayOrTensor:
209 """
210 Compute complex conjugate of an/a array/tensor. Supports Ndim inputs with last dim equal to 2 (real/imaginary channels)
211
212 Args:
213 x: Input array/tensor with 2 channels in the last dimension representing real and imaginary parts.
214
215 Returns:
216 Complex conjugate of x
217
218 Example:
219 .. code-block:: python
220
221 import numpy as np
222 x = np.array([[1,2],[3,4]])
223 # the following line prints array([[ 1, -2], [ 3, -4]])
224 print(complex_conj(x))
225 """
226 if x.shape[-1] != 2:
227 raise ValueError(f"last dim must be 2, but x.shape[-1] is {x.shape[-1]}.")
228
229 if isinstance(x, Tensor):
230 return complex_conj_t(x)
231 else:
232 np_conj: np.ndarray = np.stack((x[..., 0], -x[..., 1]), axis=-1)
233 return np_conj

Callers 1

test_complex_conjMethod · 0.90

Calls 1

complex_conj_tFunction · 0.85

Tested by 1

test_complex_conjMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…