科學計算庫(BLAS,LAPACK,MKL,EIGEN)


  • 函數庫接口標准:BLAS (Basic Linear Algebra Subprograms)和LAPACK (Linear Algebra PACKage)
1979年,Netlib首先用Fortran實現基本的 向量乘法、矩陣乘法的函數庫(該庫沒有對運算做過多優化)。后來該代碼庫對應的接口規范被稱為BLAS。
(注:NetLib是一個古老的代碼社區, https://en.wikipedia.org/wiki/Netlib

LAPACK也是Netlib用Fortan編寫的代碼庫,實現了高級的線性運算功能,例如矩陣分解,求逆等,底層是調用的BLAS代碼庫。后來LAPACK也變成一套代碼接口標准。

后來,Netlib還在BLAS/LAPACK的基礎上,增加了C語言的調用方式,稱為CBLAS/CLAPACK

因此,BLAS/LAPACK都有兩個含義,一個是Netlib通過Fortran或C實現的代碼庫,一個是這個兩個代碼庫對應的接口標准

http://www.icl.utk.edu/~mgates3/docs/
 
現在大多數函數庫都是基於BLAS/LAPACK接口標准實現
https://en.wikipedia.org/wiki/List_of_numerical_libraries
  • 開源函數庫
開源社區對對BLAS/LAPACK的實現,比較著名是 ATLAS(Automatically Tuned Linear Algebra Software)和OpenBLAS。它們都實現了BLAS的全部功能,以及LAPACK的部分功能,並且他們都對計算過程進行了優化。
 
  • 商業函數庫

商業公司對BLAS/LAPACK的實現,有Intel的MKL,AMD的ACML。他們對自己的cpu架構,進行了相關計算過程的優化,實現算法效率也很高。

NVIDIA針對其GPU,也推出了cuBLAS,用以在GPU上做矩陣運行。

 
 

Matlab用的是MKL庫,可以用version –lapack來查看函數庫的版本

Octave 默認用的是OpenBLAS庫,  version -blas



附錄:Lapack中的函數命名規則
============================================================================
lapack naming: x-yy-zzz, or x-yy-zz
 
x (data type)
------------------------------ 
s float
d double
c float-complex
z double-complex
ds input data is double, internal use float
zc input data is double-complex, internal use float-complex
 
 
Matrix type (yy) | full | packed | RFP | banded | tridiag | generalized problem
================================================================================
general          | ge                    gb       gt        gg
symmetric        | sy     sp       sf    sb       st
Hermitian        | he     hp       hf    hb
positive definite| po     pp       pf    pb       pt
--------------------------------------------------------------------------------
triangular       | tr     tp       tf    tb                 tg
upper Hessenberg | hs                                       hg
trapezoidal      | tz
--------------------------------------------------------------------------------
orthogonal       | or    op
unitary          | un    up
--------------------------------------------------------------------------------
diagonal         |                                di
bidiagonal       |                                bd
 
 
(zzz) algorithm
------------------------------
* Triangular factorization
-trf — factorize: General LU, Cholesky decomposition
-tri — calculate the inverse matrix
 
* Orthogonal factorization
-qp3 — QR factorization, with pivoting
-qrf — QR factorization
 
* Eigenvalue
-ev — all eigenvalues, [eigenvectors]
-evx — expert; also subset
-evd — divide-and-conquer; faster but more memory
-evr — relative robust; fastest and least memory
 
* SVD singular value decomposition
-svd — singular values
 
* Linear system, solve Ax = b
-sv — solve
-sdd — divide-and-conquer; faster but more memory
 
* Linear least squares, minimize ||b?Ax||2
-ls — full rank, rank(A) = min(m,n), uses QR.
-lsy — rank deficient, uses complete orthogonal factorization.
-lsd — rank deficient, uses SVD.
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM