📜  numpy.real_if_close()函数– Python

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

numpy.real_if_close()函数– Python

在这个numpy.real_if_close()函数中,如果复数输入返回一个实数数组,则复数部分接近于零。

代码#1:

# Python program explaining
# numpy.real_if_close() function
       
# importing numpy as geek 
import numpy as geek 
   
arr = [3.6 + 4e-14j]
tol = 1000
   
gfg = geek.real_if_close(arr, tol)
  
print (gfg)

输出 :

[3.6]


代码#2:

# Python program explaining
# numpy.real_if_close() function
       
# importing numpy as geek 
import numpy as geek 
   
arr = [3.6 + 2e-11j]
tol = 1000
   
gfg = geek.real_if_close(arr, tol)
  
print (gfg)

输出 :

[3.6+2.e-11j]