Numpy MaskedArray.conjugate() function | Python
numpy.MaskedArray.conjugate()
function is used to return the complex conjugate, element-wise.The conjugate of a complex number is obtained by changing the sign of its imaginary part.
Syntax : numpy.ma.conjugate(arr, out=None, where=True, casting='same_kind', order='K', dtype=None, subok=True)
Parameters:
arr :[ array_like] Input masked array which we want to conjugate.
out : [ndarray, optional] A location into which the result is stored.
-> If provided, it must have a shape that the inputs broadcast to.
-> If not provided or None, a freshly-allocated array is returned.
where : [array_like, optional] Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone.
casting :[ ‘no’, ‘equiv’, ‘safe’, ‘same_kind’, or ‘unsafe’] Provides a policy for what kind of casting is permitted.
order : The elements of a are read using this index order.
dtype :[dtype, optional] Type of the returned array, as well as of the accumulator in which the elements are multiplied.
subok : Defaults to true. If set to false, the output will always be a strict array, not a subtype.
Return : [ ndarray] The complex conjugate of arr.
Code #1 :
import numpy as geek
import numpy.ma as ma
in_arr = geek.array([[ 1 + 2j , 2 + 3j ], [ 3 - 2j , - 1 + 2j ], [ 5 - 4j , - 3 - 3j ]])
print ( "Input array : " , in_arr)
mask_arr = ma.masked_array(in_arr, mask = [[ 1 , 0 ], [ 1 , 0 ], [ 0 , 0 ]])
print ( "Masked array : " , mask_arr)
out_arr = ma.conjugate(mask_arr)
print ( "conjugate of masked array : " , out_arr)
|
Output:
Input array : [[ 1.+2.j 2.+3.j]
[ 3.-2.j -1.+2.j]
[ 5.-4.j -3.-3.j]]
Masked array : [[-- (2+3j)]
[-- (-1+2j)]
[(5-4j) (-3-3j)]]
conjugate of masked array : [[-- (2-3j)]
[-- (-1-2j)]
[(5+4j) (-3+3j)]
Last Updated :
13 Oct, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...