📜  Numpy MaskedArray.conjugate()函数| Python

📅  最后修改于: 2022-05-13 01:55:20.869000             🧑  作者: Mango

Numpy MaskedArray.conjugate()函数| Python

numpy.MaskedArray.conjugate()函数用于按元素返回复数共轭。复数的共轭是通过改变其虚部的符号来获得的。

代码#1:

# Python program explaining
# numpy.MaskedArray.conjugate() method 
    
# importing numpy as geek  
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
    
# creating input array  
in_arr = geek.array([[1 + 2j, 2 + 3j], [ 3-2j, -1 + 2j], [ 5-4j, -3-3j]])
print ("Input array : ", in_arr) 
    
# Now we are creating a masked array. 
# by making two entry as invalid.  
mask_arr = ma.masked_array(in_arr, mask =[[1, 0], [ 1, 0], [ 0, 0]]) 
print ("Masked array : ", mask_arr) 
    
# applying MaskedArray.conjugate    
# methods to masked array
out_arr = ma.conjugate(mask_arr) 
print ("conjugate of masked array : ", out_arr) 
输出:
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)]