regressioninc.transform module#

Functions to implement various transforms of complex data

regressioninc.transform.complex_to_real_2d(arr: ndarray) ndarray[source]#

Convert complex array into 2-D real array

The real parts of the numbers are in the first column, the complex in the second.

Parameters:

arr (np.ndarray) – The complex array

Returns:

The real array

Return type:

np.ndarray

Examples

Convert a 1-D complex array into a 2-D real array with real numbers in the first column and imaginary numbers in the second.

>>> import numpy as np
>>> from regressioninc.transform import complex_to_real_2d
>>> arr = np.array([3 + 5j, 2 - 1j, 6 + 7j])
>>> complex_to_real_2d(arr)
array([[ 3.,  5.],
       [ 2., -1.],
       [ 6.,  7.]])

See also

real_2d_to_complex

convert 2-D real-valued array to a complex-valued array

regressioninc.transform.complex_to_real_view(arr: ndarray) ndarray[source]#

Get a 2-D view of a complex array

This returns a 2-D view of a complex array with real numbers in the first column and complex in the second column. Note that changes made in the view will also be reflected in the original array

Parameters:

arr (np.ndarray) – The complex array

Returns:

The real array

Return type:

np.ndarray

Examples

Convert a 1-D complex array into a 2-D real array with real numbers in the first column and imaginary numbers in the second.

>>> import numpy as np
>>> from regressioninc.transform import complex_to_real_view
>>> arr = np.array([3 + 5j, 2 - 1j, 6 + 7j])
>>> view = complex_to_real_view(arr)
>>> view
array([[ 3.,  5.],
       [ 2., -1.],
       [ 6.,  7.]])
>>> view[0,0] = 9
>>> view
array([[ 9.,  5.],
       [ 2., -1.],
       [ 6.,  7.]])
>>> arr
array([9.+5.j, 2.-1.j, 6.+7.j])

See also

real_view_to_complex

get a complex-valued view of a 2-D real-valued array

regressioninc.transform.real_2d_to_complex(arr: ndarray) ndarray[source]#

Convert a real-valued 2-D array to complex values

Parameters:

arr (np.ndarray) – 2-D array with real values

Returns:

Array converted to have complex values

Return type:

np.ndarray

Examples

Start by converting a complex-valued array to a 2-D real-valued array

>>> import numpy as np
>>> from regressioninc.transform import complex_to_real_2d, real_2d_to_complex
>>> arr = np.array([3 + 5j, 2 - 1j, 6 + 7j])
>>> real2d = complex_to_real_2d(arr)
>>> real2d
array([[ 3.,  5.],
       [ 2., -1.],
       [ 6.,  7.]])

Now let’s convert this back

>>> real_2d_to_complex(real2d)
array([3.+5.j, 2.-1.j, 6.+7.j])

See also

complex_to_real_2d

convert complex-valued array to 2-D real-valued array

regressioninc.transform.real_view_to_complex(arr: ndarray) ndarray[source]#

Get a complex-valued view of a 2-D real array

Parameters:

arr (np.ndarray) – 2-D array with real values

Returns:

Complex-valued view of the real-valued array

Return type:

np.ndarray

Examples

Start by converting a complex-valued array to a 2-D real-valued array

>>> import numpy as np
>>> from regressioninc.transform import complex_to_real_2d, real_view_to_complex
>>> arr = np.array([3 + 5j, 2 - 1j, 6 + 7j])
>>> real2d = complex_to_real_2d(arr)
>>> real2d
array([[ 3.,  5.],
       [ 2., -1.],
       [ 6.,  7.]])

Now let’s get a complex-valued view

>>> real_view_to_complex(real2d)
array([[3.+5.j],
       [2.-1.j],
       [6.+7.j]])

See also

complex_to_real_view

get a 2-D real-valued view of a complex-valued array