📄 blas.texi
字号:
@cindex linear algebra, BLAS@cindex matrix, operations@cindex vector, operations@cindex BLAS@cindex CBLASThe Basic Linear Algebra Subprograms (@sc{blas}) define a set of fundamentaloperations on vectors and matrices which can be used to create optimizedhigher-level linear algebra functionality.The library provides a low-level layer which corresponds directly to theC-language @sc{blas} standard, referred to here as ``@sc{cblas}'', and ahigher-level interface for operations on GSL vectors and matrices.Users who are interested in simple operations on GSL vector and matrixobjects should use the high-level layer, which is declared in the file@code{gsl_blas.h}. This should satisfy the needs of most users. Notethat GSL matrices are implemented using dense-storage so the interfaceonly includes the corresponding dense-storage @sc{blas} functions. The full@sc{blas} functionality for band-format and packed-format matrices isavailable through the low-level @sc{cblas} interface.The interface for the @code{gsl_cblas} layer is specified in the file@code{gsl_cblas.h}. This interface corresponds the @sc{blas} TechnicalForum's draft standard for the C interface to legacy @sc{blas}implementations. Users who have access to other conforming @sc{cblas}implementations can use these in place of the version provided by thelibrary. Note that users who have only a Fortran @sc{blas} library canuse a @sc{cblas} conformant wrapper to convert it into a @sc{cblas}library. A reference @sc{cblas} wrapper for legacy Fortranimplementations exists as part of the draft @sc{cblas} standard and canbe obtained from Netlib. The complete set of @sc{cblas} functions islisted in an appendix (@pxref{GSL CBLAS Library}).There are three levels of @sc{blas} operations,@table @b@item Level 1Vector operations, e.g. @math{y = \alpha x + y}@item Level 2Matrix-vector operations, e.g. @math{y = \alpha A x + \beta y}@item Level 3Matrix-matrix operations, e.g. @math{C = \alpha A B + C}@end table@noindentEach routine has a name which specifies the operation, the type ofmatrices involved and their precisions. Some of the most commonoperations and their names are given below,@table @b@item DOTscalar product, @math{x^T y}@item AXPYvector sum, @math{\alpha x + y}@item MVmatrix-vector product, @math{A x}@item SVmatrix-vector solve, @math{inv(A) x}@item MMmatrix-matrix product, @math{A B}@item SMmatrix-matrix solve, @math{inv(A) B}@end table@noindentThe type of matrices are,@table @b@item GEgeneral@item GBgeneral band@item SYsymmetric@item SBsymmetric band@item SPsymmetric packed@item HEhermitian@item HBhermitian band@item HPhermitian packed@item TRtriangular @item TBtriangular band@item TPtriangular packed@end table@noindentEach operation is defined for four precisions,@table @b@item Ssingle real@item Ddouble real@item Csingle complex@item Zdouble complex@end table@noindentThus, for example, the name @sc{sgemm} stands for ``single-precisiongeneral matrix-matrix multiply'' and @sc{zgemm} stands for``double-precision complex matrix-matrix multiply''.@menu* GSL BLAS Interface:: * BLAS Examples:: * BLAS References and Further Reading:: @end menu@node GSL BLAS Interface@section GSL BLAS InterfaceGSL provides dense vector and matrix objects, based on the relevantbuilt-in types. The library provides an interface to the @sc{blas}operations which apply to these objects. The interface to thisfunctionality is given in the file @code{gsl_blas.h}.@comment CblasNoTrans, CblasTrans, CblasConjTrans@comment CblasUpper, CblasLower@comment CblasNonUnit, CblasUnit@comment CblasLeft, CblasRight@menu* Level 1 GSL BLAS Interface:: * Level 2 GSL BLAS Interface:: * Level 3 GSL BLAS Interface:: @end menu@node Level 1 GSL BLAS Interface@subsection Level 1 @deftypefun int gsl_blas_sdsdot (float @var{alpha}, const gsl_vector_float * @var{x}, const gsl_vector_float * @var{y}, float * @var{result})@deftypefunx int gsl_blas_dsdot (const gsl_vector_float * @var{x}, const gsl_vector_float * @var{y}, double * @var{result})@cindex DOT, Level-1 BLASThese functions compute the sum @math{\alpha + x^T y} for the vectors@var{x} and @var{y}, returning the result in @var{result}.@end deftypefun@deftypefun int gsl_blas_sdot (const gsl_vector_float * @var{x}, const gsl_vector_float * @var{y}, float * @var{result})@deftypefunx int gsl_blas_ddot (const gsl_vector * @var{x}, const gsl_vector * @var{y}, double * @var{result})These functions compute the scalar product @math{x^T y} for the vectors@var{x} and @var{y}, returning the result in @var{result}.@end deftypefun@deftypefun int gsl_blas_cdotu (const gsl_vector_complex_float * @var{x}, const gsl_vector_complex_float * @var{y}, gsl_complex_float * @var{dotu})@deftypefunx int gsl_blas_zdotu (const gsl_vector_complex * @var{x}, const gsl_vector_complex * @var{y}, gsl_complex * @var{dotu})These functions compute the complex scalar product @math{x^T y} for thevectors @var{x} and @var{y}, returning the result in @var{result}@end deftypefun@deftypefun int gsl_blas_cdotc (const gsl_vector_complex_float * @var{x}, const gsl_vector_complex_float * @var{y}, gsl_complex_float * @var{dotc})@deftypefunx int gsl_blas_zdotc (const gsl_vector_complex * @var{x}, const gsl_vector_complex * @var{y}, gsl_complex * @var{dotc})These functions compute the complex conjugate scalar product @math{x^Hy} for the vectors @var{x} and @var{y}, returning the result in@var{result}@end deftypefun@deftypefun float gsl_blas_snrm2 (const gsl_vector_float * @var{x})@deftypefunx double gsl_blas_dnrm2 (const gsl_vector * @var{x})@cindex NRM2, Level-1 BLASThese functions compute the Euclidean norm @c{$||x||_2 = \sqrt{\sum x_i^2}$}@math{||x||_2 = \sqrt @{\sum x_i^2@}} of the vector @var{x}.@end deftypefun@deftypefun float gsl_blas_scnrm2 (const gsl_vector_complex_float * @var{x})@deftypefunx double gsl_blas_dznrm2 (const gsl_vector_complex * @var{x})These functions compute the Euclidean norm of the complex vector @var{x},@tex\beforedisplay$$||x||_2 = \sqrt{\sum (\Re(x_i)^2 + \Im(x_i)^2)}.$$\afterdisplay@end tex@ifinfo@example||x||_2 = \sqrt @{\sum (\Re(x_i)^2 + \Im(x_i)^2)@}.@end example@end ifinfo@noindent@end deftypefun@deftypefun float gsl_blas_sasum (const gsl_vector_float * @var{x})@deftypefunx double gsl_blas_dasum (const gsl_vector * @var{x})@cindex ASUM, Level-1 BLASThese functions compute the absolute sum @math{\sum |x_i|} of theelements of the vector @var{x}.@end deftypefun@deftypefun float gsl_blas_scasum (const gsl_vector_complex_float * @var{x})@deftypefunx double gsl_blas_dzasum (const gsl_vector_complex * @var{x})These functions compute the absolute sum @math{\sum |\Re(x_i)| +|\Im(x_i)|} of the elements of the vector @var{x}.@end deftypefun@deftypefun CBLAS_INDEX_t gsl_blas_isamax (const gsl_vector_float * @var{x})@deftypefunx CBLAS_INDEX_t gsl_blas_idamax (const gsl_vector * @var{x})@deftypefunx CBLAS_INDEX_t gsl_blas_icamax (const gsl_vector_complex_float * @var{x})@deftypefunx CBLAS_INDEX_t gsl_blas_izamax (const gsl_vector_complex * @var{x})@cindex AMAX, Level-1 BLASThese functions return the index of the largest element of the vector@var{x}. The largest element is determined by its absolute magnitude forreal vector and by the sum of the magnitudes of the real and imaginaryparts @math{|\Re(x_i)| + |\Im(x_i)|} for complex vectors. If thelargest value occurs several times then the index of the firstoccurrence is returned.@end deftypefun@deftypefun int gsl_blas_sswap (gsl_vector_float * @var{x}, gsl_vector_float * @var{y})@deftypefunx int gsl_blas_dswap (gsl_vector * @var{x}, gsl_vector * @var{y})@deftypefunx int gsl_blas_cswap (gsl_vector_complex_float * @var{x}, gsl_vector_complex_float * @var{y})@deftypefunx int gsl_blas_zswap (gsl_vector_complex * @var{x}, gsl_vector_complex * @var{y})@cindex SWAP, Level-1 BLASThese functions exchange the elements of the vectors @var{x} and @var{y}.@end deftypefun@deftypefun int gsl_blas_scopy (const gsl_vector_float * @var{x}, gsl_vector_float * @var{y})@deftypefunx int gsl_blas_dcopy (const gsl_vector * @var{x}, gsl_vector * @var{y})@deftypefunx int gsl_blas_ccopy (const gsl_vector_complex_float * @var{x}, gsl_vector_complex_float * @var{y})@deftypefunx int gsl_blas_zcopy (const gsl_vector_complex * @var{x}, gsl_vector_complex * @var{y})@cindex COPY, Level-1 BLASThese functions copy the elements of the vector @var{x} into the vector@var{y}.@end deftypefun@deftypefun int gsl_blas_saxpy (float @var{alpha}, const gsl_vector_float * @var{x}, gsl_vector_float * @var{y})@deftypefunx int gsl_blas_daxpy (double @var{alpha}, const gsl_vector * @var{x}, gsl_vector * @var{y})@deftypefunx int gsl_blas_caxpy (const gsl_complex_float @var{alpha}, const gsl_vector_complex_float * @var{x}, gsl_vector_complex_float * @var{y})
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -