Package: pyblas
🔢 PyBLASPyBLAS is a python port of thenetlib reference BLAS implementation.Usagepipinstallnumpypyblasimportnumpyasnpfrompyblas.level1importdswapx=np.array([1.2,2.3,3.4],dtype=np.double)# A double-precision vector xy=np.array([5.6,7.8,9.0],dtype=np.double)# A double precision vector yN=len(x)# The length of the vectors x and yincx=1# The index spacing of the vector xincy=1# The index spacing of the vector y# Swap the values of the vectors x and ydswap(N,x,incx,y,incy)print(x,y)For more details on how to use the PyBLAS library, please consult ourdocsWhat is BLASTheBasic Linear Algebra Subprograms(BLAS) are a collection of functions which form the basis of many modern numerical computing packages, including numpy, scipy, and matlab.
They provide functions for performing basic calculations on vectors and matrices, which form the basis for more complex calculations such as solving systems of linear equations.Who is this for?Maths and computer science students who are learning about linear algebra and want to see how to implement simple operations.Algorithm developers who want to prototype their calculations in a high level language with the same APIs they will use in C or Fortran.Data scientists who want to better understand what is going on under the hood of the algorithms they use.Educators who want an easy to use BLAS implementation when teaching numerical computing courses.PerformanceOptimal performance isnota goal of the PyBLAS project.
The project aim is to have a simple and readable implementation of the BLAS standards.
As such, we often forego optimization opporunities in favour of simplicity.The project matches overall algorithmic complexity with the reference implementation for all functions.AccuracyThe project aims to match the numerical accuracy of the reference BLAS implementation.
A future goal is to have benchmarks which can be run against the system BLAS libraries to verify the numerical accuract of the functionsLevel 1single (s)double (d)single complex (c)double complex (z)scopydcopyccopyzcopyy := xsswapdswapcswapzswapx, y := ysscaldscalcscal (csscal)zscal (zdscal)x := a*xsaxpydaxpycaxpyzaxpyy := a*x + yscabs1dcabs1`=>sasumdasum`=> sum(scasumdzasum`=> sum(sdot (sdsdot, dsdot)ddotcdotuzdotu=>  <x, y>cdotczdotc=>  <x^H, y>snrm2dnrm2=> sqrt(<x, x>)scnrm2dznrm2=> sqrt(<x^H, x>)srotdrotcsrotzdrot[x_i, y_i] := [c s; -s c] * [x_i, y_i]srotgdrotgcrotgzrotgc := a/r, s:= b/r, a :=r, b := "z"srotmdrotm[x_i, y_i] := [h_1 h_2; h_3, h_4] * [x_i, y_i]srotmgdrotmgLevel 2single (s)double (d)single complex (c)double complex (z)ssyrdsyrA := a*x*x^T + A(sym)cherzherA := a*x*x^H + A(her)ssprdsprA := a*x*x^T + A(sym-packaged)chprzhprA := a*x*x^H + A(her-packaged)sgerdgercgeruzgeruA := a*x*y^T + AcgerczgercA := a*x*y^H + Assyr2dsyr2A := a*x*y^T + a*y*x^T + A(sym)cher2zher2A := a*x*y^H + a^+*y*x^H + A(her)sspr2dspr2A := a*x*y^T + a*y*x^T + A(sym-packed)chpr2zhpr2A := a*x*y^H + a*y*x^H + A(her-packed)| | |  |
| strsv  | dtrsv  | ctrsv  | ztrsv |x := A^-1*borx := A^[TH]^-1*b(tri) |
| stbsv  | dtbsv  | ctbsv  | ztbsv |x := A^-1*borx := A^[TH]^-1*b(band) |
| stpsv  | dtpsv  | ctpsv  | ztpsv |x := A^-1*borx := A^[TH]^-1*b(tri-packed) |
| | | |
| stpmv  | dtpmv  | ctpmv  | ztpmv |x := A^[1TH]*x(sym-packed)   |
| stbmv  | dtbmv  | ctbmv  | ztbmv |x := A^[1TH]*x(tri-band) |
| strmv  | dtrmv  | ctrmv  | ztrmv |x := A^[1TH]*x(tri) |
| sgemv  | dgemv  | cgemv  | zgemv |y := a*A^[1TH]*x + b*y|
|        |        | chemv  | zhemv |y := a*A*x + b*y(herm) |
| sgbmv  | dgbmv  | cgbmv  | zgbmv |y := a*A^[1TH]*x + b*y(band) |
|        |        | chbmv  | zhbmv |y := a*A*x + b*y(band-herm)   |
| ssymv  | dsymv  |                |y := a*A*x + b*y(sym)        |
| sspmv  | dspmv  |                |y := a*A*x + b*y(sym-packed) |
|        |        | chpmv  | zhpmv |y := a*A*x + b*y(her-packed) |
| ssbmv  | dsbmv  |        |       |y := a*A*x + b*y(sym-band)   |
| isamax | idamax |        |     | |=> argmax(|x_i|)|
|        |        | icamax |izamax |=> argmax(|Re(x_i)| + |Im(x_i)|)|Level 3