本文簡要介紹 python 語言中 scipy.linalg.pascal
的用法。
用法:
scipy.linalg.pascal(n, kind='symmetric', exact=True)#
返回 n x n 帕斯卡矩陣。
帕斯卡矩陣是包含二項式係數作為其元素的矩陣。
- n: int
要創建的矩陣的大小;也就是說,結果是一個 n x n 矩陣。
- kind: str,可選
必須是 ‘symmetric’, ‘lower’ 或 ‘upper’ 之一。默認為‘symmetric’。
- exact: 布爾型,可選
如果精確的為 True 時,結果是 numpy.uint64 類型的數組(如果 n < 35)或 Python 長整數的對象數組。如果精確的為假,矩陣中的係數使用計算scipy.special.comb和準確=假。結果將是一個浮點數組,數組中的值不會是精確的係數,但這個版本比精確=真實.
- p: (n, n) 數組
帕斯卡矩陣。
參數 ::
返回 ::
注意:
有關 Pascal 矩陣的更多信息,請參閱https://en.wikipedia.org/wiki/Pascal_matrix。
例子:
>>> from scipy.linalg import pascal >>> pascal(4) array([[ 1, 1, 1, 1], [ 1, 2, 3, 4], [ 1, 3, 6, 10], [ 1, 4, 10, 20]], dtype=uint64) >>> pascal(4, kind='lower') array([[1, 0, 0, 0], [1, 1, 0, 0], [1, 2, 1, 0], [1, 3, 3, 1]], dtype=uint64) >>> pascal(50)[-1, -1] 25477612258980856902730428600 >>> from scipy.special import comb >>> comb(98, 49, exact=True) 25477612258980856902730428600
相關用法
- Python SciPy linalg.polar用法及代碼示例
- Python SciPy linalg.pinv用法及代碼示例
- Python SciPy linalg.pinvh用法及代碼示例
- Python SciPy linalg.eigvalsh_tridiagonal用法及代碼示例
- Python SciPy linalg.cdf2rdf用法及代碼示例
- Python SciPy linalg.LaplacianNd用法及代碼示例
- Python SciPy linalg.solve_circulant用法及代碼示例
- Python SciPy linalg.clarkson_woodruff_transform用法及代碼示例
- Python SciPy linalg.rsf2csf用法及代碼示例
- Python SciPy linalg.hessenberg用法及代碼示例
- Python SciPy linalg.tril用法及代碼示例
- Python SciPy linalg.triu用法及代碼示例
- Python SciPy linalg.svd用法及代碼示例
- Python SciPy linalg.ishermitian用法及代碼示例
- Python SciPy linalg.invhilbert用法及代碼示例
- Python SciPy linalg.factorized用法及代碼示例
- Python SciPy linalg.lu_factor用法及代碼示例
- Python SciPy linalg.SuperLU用法及代碼示例
- Python SciPy linalg.lsqr用法及代碼示例
- Python SciPy linalg.cho_factor用法及代碼示例
- Python SciPy linalg.fractional_matrix_power用法及代碼示例
- Python SciPy linalg.eig_banded用法及代碼示例
- Python SciPy linalg.tanhm用法及代碼示例
- Python SciPy linalg.orthogonal_procrustes用法及代碼示例
- Python SciPy linalg.use_solver用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.linalg.pascal。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。