lib.scimath.
sqrt
计算x的平方根。
对于负输入元素,将返回一个复杂值(与 numpy.sqrt 返回NaN)。
numpy.sqrt
输入值。
平方根 x .如果 x 是标量,也是标量 out ,否则返回数组。
参见
实例
对于真正的非负输入,这就像 numpy.sqrt :
>>> np.lib.scimath.sqrt(1) 1.0 >>> np.lib.scimath.sqrt([1, 4]) array([1., 2.])
它自动处理负输入:
>>> np.lib.scimath.sqrt(-1) 1j >>> np.lib.scimath.sqrt([-1,4]) array([0.+1.j, 2.+0.j])
numpy.emath