本文簡要介紹 python 語言中 numpy.sqrt
的用法。
用法:
numpy.sqrt(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True [, signature, extobj ]) = <ufunc 'sqrt'>
按元素返回數組的非負平方根。
- x: array_like
需要平方根的值。
- out: ndarray,None,或 ndarray 和 None 的元組,可選
存儲結果的位置。如果提供,它必須具有輸入廣播到的形狀。如果未提供或 None,則返回一個新分配的數組。元組(隻能作為關鍵字參數)的長度必須等於輸出的數量。
- where: 數組,可選
此條件通過輸入廣播。在條件為真的位置,out數組將設置為 ufunc 結果。在其他地方,out數組將保留其原始值。請注意,如果未初始化out數組是通過默認創建的
out=None
,其中條件為 False 的位置將保持未初始化狀態。- **kwargs:
對於其他僅關鍵字參數,請參閱 ufunc 文檔。
- y: ndarray
形狀相同的數組x,包含中每個元素的正平方根x。如果任意元素在x是複數,則返回複數數組(並計算負實數的平方根)。如果所有元素在x是真實的,也是如此y,返回負數元素
nan
.如果out提供了,y是對它的引用。這是一個標量,如果x是一個標量。
參數:
返回:
注意:
sqrt has-consistent 與共同的convention-as 它的分支切割了真正的“interval” [-inf, 0),並且從上麵連續。分支切割是複平麵中的一條曲線,在該曲線上給定的複函數不能是連續的。
例子:
>>> np.sqrt([1,4,9]) array([ 1., 2., 3.])
>>> np.sqrt([4, -1, -3+4J]) array([ 2.+0.j, 0.+1.j, 1.+2.j])
>>> np.sqrt([4, -1, np.inf]) array([ 2., nan, inf])
相關用法
- Python numpy square用法及代碼示例
- Python numpy squeeze用法及代碼示例
- Python numpy searchsorted用法及代碼示例
- Python numpy shape用法及代碼示例
- Python numpy scimath.log用法及代碼示例
- Python numpy signbit用法及代碼示例
- Python numpy setdiff1d用法及代碼示例
- Python numpy seterr用法及代碼示例
- Python numpy sort用法及代碼示例
- Python numpy scimath.logn用法及代碼示例
- Python numpy std用法及代碼示例
- Python numpy scimath.log2用法及代碼示例
- Python numpy sum用法及代碼示例
- Python numpy spacing用法及代碼示例
- Python numpy seterrobj用法及代碼示例
- Python numpy scimath.arccos用法及代碼示例
- Python numpy shares_memory用法及代碼示例
- Python numpy s_用法及代碼示例
- Python numpy swapaxes用法及代碼示例
- Python numpy sctype2char用法及代碼示例
- Python numpy show_config用法及代碼示例
- Python numpy set_printoptions用法及代碼示例
- Python numpy source用法及代碼示例
- Python numpy save用法及代碼示例
- Python numpy scimath.log10用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.sqrt。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。