NumPy 的 float_power(~)
方法將輸入數組中的每個值提高指定的量。
注意
NumPy 的 power(~)
和 float_power(~)
之間存在差異。 NumPy 的 power(~)
方法使用與輸入數組相同的數據類型來執行計算;如果您的輸入數組僅包含整數,則返回的結果也將是 int
類型。另一方麵,float_power(~)
始終使用 float64
以獲得最大精度。
參數
1. x1
| array_like
輸入數組。
2. x2
| array_like
指數數組。
3. out
| Numpy array
| optional
您可以將計算的平均值放入 out
指定的數組中,而不是創建新數組。
4. where
| boolean
的array
| optional
標記為 False 的值將被忽略,即它們的原始值將未被初始化。如果指定了 out 參數,行為會略有不同 - 原始值將保持不變。
返回值
如果 x1
和 x2
是標量,則返回標量,否則返回 NumPy 數組。無論哪種方式,返回的數據類型都是 float64
。
例子
共同指數
np.float_power([1,2,3], 2)
array([1., 4., 9.])
多個指數
x = [1,2,3]
np.float_power(x, [3,2,1])
array([1., 4., 3.])
在這裏,我們正在執行 1**3=1
、 2**2=4
和 3**1=3
。
相關用法
- Python float轉exponential用法及代碼示例
- Python float.is_integer用法及代碼示例
- Python float()用法及代碼示例
- Python floating轉binary用法及代碼示例
- Python float構造函數用法及代碼示例
- Python float用法及代碼示例
- Python NumPy floor方法用法及代碼示例
- Python NumPy floor_divide方法用法及代碼示例
- Python NumPy fliplr方法用法及代碼示例
- Python NumPy flatten方法用法及代碼示例
- Python NumPy flipud方法用法及代碼示例
- Python NumPy flat屬性用法及代碼示例
- Python NumPy flatnonzero方法用法及代碼示例
- Python dict fromkeys()用法及代碼示例
- Python frexp()用法及代碼示例
- Python BeautifulSoup find_next方法用法及代碼示例
- Python functools.wraps用法及代碼示例
- Python functools.singledispatchmethod用法及代碼示例
- Python calendar firstweekday()用法及代碼示例
- Python NumPy full方法用法及代碼示例
- Python Django format_lazy用法及代碼示例
- Python format()用法及代碼示例
- Python NumPy fill_diagonal方法用法及代碼示例
- Python filecmp.cmpfiles()用法及代碼示例
注:本文由純淨天空篩選整理自Isshin Inada大神的英文原創作品 NumPy | float_power method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。