sidpy.hdf.dtype_utils.stack_real_to_complex¶
- sidpy.hdf.dtype_utils.stack_real_to_complex(ds_real, lazy=False)[source]¶
Puts the real and imaginary sections of the provided matrix (in the last axis) together to make complex matrix
- Parameters:
ds_real (
numpy.ndarray
,dask.array.core.Array
, orh5py.Dataset
) – n dimensional real-valued numpy array or HDF5 dataset where data arranged as [instance, 2 x features], where the first half of the features are the real component and the second half contains the imaginary componentslazy (bool, optional. Default = False) – If set to True, will use lazy Dask arrays instead of in-memory numpy arrays
- Returns:
ds_compound – 2D complex array arranged as [sample, features]
- Return type:
Examples
>>> import numpy as np >>> import sidpy >>> real_val = np.hstack([5 * np.random.rand(6), >>> 7 * np.random.rand(6)]) >>> print('Real valued dataset of shape {}:'.format(real_val.shape)) >>> print(real_val) Real valued dataset of shape (12,): [3.59249723 1.05674621 4.41035214 1.84720102 1.79672691 4.7636207 3.09574246 0.76396171 3.38140637 4.97629028 0.83303717 0.32816285]
>>> comp_val = sidpy.dtype_utils.stack_real_to_complex(real_val) >>> print('Complex-valued array of shape: {}'.format(comp_val.shape)) >>> print(comp_val) Complex-valued array of shape: (6,) [3.59249723+3.09574246j 1.05674621+0.76396171j 4.41035214+3.38140637j 1.84720102+4.97629028j 1.79672691+0.83303717j 4.7636207 +0.32816285j]