BLAS 1级例程 (矢量操作)

一、BLAS例程的命名约定:

其结构为: < character > < name > < mod > ()

1、<character> 表示精度类型:

符号描述
s单精度实数
c单精度复数
d双精度实数
z双精度复数

2、<name> 在BLAS 级别2中表示操作类型,在级别2和3中反映的是矩阵参数类型

  • BLAS 1级: 
?dot点乘
?rot向量旋转
?swap向量交换
  • BLAS 2、3级:
符号描述
gegeneral matrix
gbgeneral band matrix
sysymmetric matrix
spsymmetric matrix (packed storage)
sbsymmetric band matrix
heHermitian matrix
hpHermitian matrix (packed storage)
hbHermitian band matrix
trtriangular matrix
tptriangular matrix (packed storage)
tbtriangular band matrix.

3、<mod>字段(如果存在)提供操作的其他详细信息。

  • BLAS 1级在字段中可以包含以下字符:
c共轭载体
u非共轭载体
gGivens rotation construction
mmodified Givens rotation
mgmodified Givens rotation construction
  • BLAS 2级在字段中可以包含以下字符:
mv矩阵向量积
sv用单个未知矢量解线性方程组
rrank-1 update of a matrix
r2rank-2 update of a matrix
  • BLAS 3级在字段中可以包含以下字符:
mm矩阵矩阵乘积
sm用多个未知向量求解线性方程组
rkrank- k update of a matrix
r2krank-2 k update of a matrix

二、BLAS 1级例程概述

函数形式

参数类型(?位置)

描述

cblas_?asum

s,d,sc,dz

向量幅度之和(函数)

cblas_?axpy

s,d,c,z

标量向量乘积(例程)

cblas_?copy

s,d,c,z

复制向量(例程)

cblas_?dot

d

 

点积(功能)

cblas_?sdot

d,d

点精度为双精度(功能)

cblas_?dotc

c,z

点积共轭(函数)

cblas_?dotu

c,z

点积未共轭(功能)

cblas_?nrm2

s,d,sc,dz

向量2范数(欧几里得范数)(函数)

cblas_?rot

s,d,cs,zd

点的平面旋转(例程)

cblas_?rotg

s,d,c,z

生成点的旋转旋转(例程)

cblas_?rotm

d

修改点的给定平面旋转(例程)

cblas_?rotmg

d

生成点的修改的Givens平面旋转(例程)

cblas_?scal

s,d,c,z,cs,zd

向量标量积(例程)

cblas_?swap

s,d,c,z

向量-向量交换(例程)

cblas_i?amax

s,d,c,z

向量的最大绝对值元素的索引(函数)

cblas_i?amin

s,d,c,z

向量的最小绝对值元素的索引(函数)

cblas_?cabs1

d

辅助函数,计算复数个单精度或双精度的绝对值

 三、BLAS 1级例程函数介绍

1、cblas_?asum

  • 函数功能:计算实矢量元素的大小之和,或复矢量元素的实部和虚部的大小之和。
  • 使用方法:
float cblas_sasum ( const MKL_INT n , const float *x , const MKL_INT incx );
float cblas_scasum ( const MKL_INT n , const void *x , const MKL_INT incx );
double cblas_dasum ( const MKL_INT n , const double *x , const MKL_INT incx );
double cblas_dzasum ( const MKL_INT n , const void *x , const MKL_INT incx );
  • 输入参数解析:

       其中x是一个具有n个元素的向量

n指定向量 x 中的元素数量
x数组,大小至少为(1 +(n -1)* abs(incx))
incx指定索引向量x的增量。
  • 输出参数 : 包含向量中所有元素的实部和虚部的大小之和。
  • 返回值 : 包含向量所有元素的实部和虚部的大小总和。

2、cblas_?axpy

  • 函数功能:计算向量标量积并将结果添加到向量。
  • 使用方法:
void cblas_saxpy ( const MKL_INT n , const float a , const float *x , const MKL_INT incx , float *y , const MKL_INT incy );
void cblas_daxpy ( const MKL_INT n , const double a , const double *x , const MKL_INT incx , double *y , const MKL_INT incy );
void cblas_caxpy ( const MKL_INT n , const void *a , const void *x , const MKL_INT incx , void *y , const MKL_INT incy );
void cblas_zaxpy ( const MKL_INT n , const void *a , const void *x , const MKL_INT incx , void *y , const MKL_INT incy );
  • 输入参数解析

a是标量;

x和y是向量,每个向量具有等于n的元素数量。

n指定向量x和y中的元素数
a指定标量a
x数组,大小至少为(1 +(n -1)* abs(incx))
incx指定x元素的增量。
y数组,大小至少为(1 +(n -1)* abs(incy))
incy指定y元素的增量
  • 输出参数 y: 包含更新的向量y

3、cblas_?copy

  • 函数功能:将一个向量复制到另一个向量。
  • 使用方法:
void cblas_scopy ( const MKL_INT n , const float *x , const MKL_INT incx , float *y , const MKL_INT incy );
void cblas_dcopy ( const MKL_INT n , const double *x , const MKL_INT incx , double *y , const MKL_INT incy );
void cblas_ccopy ( const MKL_INT n , const void *x , const MKL_INT incx , void *y , const MKL_INT incy );
void cblas_zcopy ( const MKL_INT n , const void *x , const MKL_INT incx , void *y , const MKL_INT incy );
  • 输入参数解析
n指定向量x和y中的元素数
x数组,大小至少为(1 +(n -1)* abs(incx))
y数组,大小至少为(1 +(n -1)* abs(incy))
incy指定y元素的增量
  • 输出参数 y:如果n为正,则包含向量x的副本。 否则,参数将保持不变。

4、cblas_?  dot

  • 函数功能:计算向量-向量点积。
  • 使用方法:
float cblas_sdot ( const MKL_INT n , const float *x , const MKL_INT incx , const float *y , const MKL_INT incy );
double cblas_ddot ( const MKL_INT n , const double *x , const MKL_INT incx , const double *y , const MKL_INT incy );
  • 输入参数解析:
n指定向量x和y中的元素数
x数组,大小至少为(1+(n -1)* abs(incx))
incx指定x元素的增量
y数组,大小至少为(1+(n -1)* abs(incy))
incy指定y元素的增量
  • 返回值:x和y的点积的结果,如果n是正的。否则,返回0。

5、cblas_? sdot

  • 函数功能:以双精度计算向量-向量点积
  • 使用方法:
float cblas_sdsdot ( const MKL_INT n , const float sb , const float *sx , const MKL_INT incx , const float *sy , const MKL_INT incy );
double cblas_dsdot ( const MKL_INT n , const float *sx , const MKL_INT incx , const float *sy , const MKL_INT incy );
  • 输入参数解析:
n指定输入向量sx和sy中的元素数
sb要添加到内部乘积的单精度标量(仅用于功能sdsdot)
sx, sy数组,大小分别至少为(1+(n -1)* abs(incx))和(1+(n -1)* abs(incy))。 包含输入单精度向量。
incx指定sx元素的增量。
incy指定sy元素的增量。
  • 输出参数 res:如果n为正,则包含sx和sy的点积结果(为sdsdot添加sb)。 否则,res对于sdsdot包含sb,对于dsdot包含0。
  • 返回值:如果n为正,则sx和sy的点积的结果(为sdsdot添加sb)。 否则,对于sdsdot返回sb,对于dsdot返回0

6、cblas_? dotc

  • 函数功能:计算共轭向量与另一个向量的点积。
  • 使用方法:
void cblas_cdotc_sub ( const MKL_INT n , const void *x , const MKL_INT incx , const void *y , const MKL_INT incy , void *dotc );
void cblas_zdotc_sub ( const MKL_INT n , const void *x , const MKL_INT incx , const void *y , const MKL_INT incy , void *dotc );
  • 输入参数解析:
n指定向量x和y中的元素数
x数组,大小至少为(1 +(n -1)* abs(incx))
inccx指定x元素的增量
y数组,大小至少为(1 +(n -1)* abs(incy))
incy指定y元素的增量
  • 输出参数 dotc:如果n为正,则包含共轭x和非共轭y的点积结果。 否则,它包含0。

7、cblas_? dotu

  • 函数功能:计算向量-向量点积。
  • 使用方法:
void cblas_cdotu_sub ( const MKL_INT n , const void *x , const MKL_INT incx , const void *y , const MKL_INT incy , void *dotu );
void cblas_zdotu_sub ( const MKL_INT n , const void *x , const MKL_INT incx , const void *y , const MKL_INT incy , void *dotu );
  • 输入参数解析:
n指定向量x和y中的元素数
x数组,大小至少为(1 +(n -1)* abs(incx))
incx指定x元素的增量
y数组,大小至少为(1 +(n -1)* abs(incy))
incy指定y元素的增量
  • 输出参数 dotu:如果n为正,则包含x和y的点积的结果。 否则,它包含0。

8、cblas_? nrm2

  • 函数功能:计算向量的欧几里得范数。
  • 使用方法:
float cblas_snrm2 ( const MKL_INT n , const float *x , const MKL_INT incx );
double cblas_dnrm2 ( const MKL_INT n , const double *x , const MKL_INT incx );
float cblas_scnrm2 ( const MKL_INT n , const void *x , const MKL_INT incx );
double cblas_dznrm2 ( const MKL_INT n , const void *x , const MKL_INT incx );
  • 输入参数解析:
n指定向量x中的元素数
x数组,大小至少为(1 +(n -1)* abs(incx))
incx指定x元素的增量
  • 返回值: 向量x的欧氏范数。

9、cblas_? rot

  • 函数功能:在平面中执行点的旋转。
  • 使用方法:
void cblas_srot ( const MKL_INT n , float *x , const MKL_INT incx , float *y , const MKL_INT incy , const float c , const float s );
void cblas_drot ( const MKL_INT n , double *x , const MKL_INT incx , double *y , const MKL_INT incy , const double c , const double s );
void cblas_csrot ( const MKL_INT n , void *x , const MKL_INT incx , void *y , const MKL_INT incy , const float c , const float s );
void cblas_zdrot ( const MKL_INT n , void *x , const MKL_INT incx , void *y , const MKL_INT incy , const double c , const double s );
  • 输入参数解析:

给定两个复数向量x和y,将替换这些向量的每个向量元素,如下所示:

x i = c * x i + s * y i  

y i = c * y i-s * x i

n指定向量x和y中的元素数
x数组,大小至少为(1 +(n -1)* abs(incx))
incx指定x元素的增量
y数组,大小至少为(1 +(n -1)* abs(incy))
incy指定y元素的增量
c标量
a标量
  • 输出参数 x:每个元素均替换为c * x + s * y
  • 输出参数 y:每个元素均替换为c * y-s * x

10、cblas_? rotg

  • 函数功能:计算Givens旋转的参数
  • 使用方法:
void cblas_srotg ( float *a , float *b , float *c , float *s );
void cblas_drotg ( double *a , double *b , double *c , double *s );
void cblas_crotg ( void *a , const void *b , float *c , void *s );
void cblas_zrotg ( void *a , const void *b , double *c , void *s );
  • 输入参数解析:
a提供点p的x坐标
b提供点p的y坐标
  • 输出参数:
a包含与Givens旋转关联的参数r
b包含与Givens旋转关联的参数z
c包含与Givens旋转关联的参数c
s包含与Givens旋转关联的参数s

11、cblas_? scal

  • 函数功能:用标量计算向量的乘积。
  • 使用方法:
void cblas_sscal ( const MKL_INT n , const float a , float *x , const MKL_INT incx );
void cblas_dscal ( const MKL_INT n , const double a , double *x , const MKL_INT incx );
void cblas_cscal ( const MKL_INT n , const void *a , void *x , const MKL_INT incx );
void cblas_zscal ( const MKL_INT n , const void *a , void *x , const MKL_INT incx );
void cblas_csscal ( const MKL_INT n , const float a , void *x , const MKL_INT incx );
void cblas_zdscal ( const MKL_INT n , const double a , void *x , const MKL_INT incx );
  • 输入参数解析:
n指定向量x中的元素数
a指定标量a
x数组,大小至少为(1 +(n -1)* abs(incx))
incx指定x元素的增量
  • 输出参数 x:更新的向量x

12、cblas_? swap

  • 函数功能:用另一个向量交换该向量
  • 使用方法:
void cblas_sswap ( const MKL_INT n , float *x , const MKL_INT incx , float *y , const MKL_INT incy );
void cblas_dswap ( const MKL_INT n , double *x , const MKL_INT incx , double *y , const MKL_INT incy );
void cblas_cswap ( const MKL_INT n , void *x , const MKL_INT incx , void *y , const MKL_INT incy );
void cblas_zswap ( const MKL_INT n , void *x , const MKL_INT incx , void *y , const MKL_INT incy );
  • 输入参数解析:
n指定向量x和y中的元素数
x数组,大小至少为(1 +(n -1)* abs(incx))
incx指定x元素的增量
y数组,大小至少为(1 +(n -1)* abs(incy))
incy指定y元素的增量
  • 输出参数:
x包含结果向量x,即输入向量y
y包含结果向量y,即输入向量x

15、cblas_? amax

  • 函数功能:查找具有最大绝对值的元素的索引。
  • 使用方法:
CBLAS_INDEX cblas_isamin ( const MKL_INT n , const float *x , const MKL_INT incx );
CBLAS_INDEX cblas_idamin ( const MKL_INT n , const double *x , const MKL_INT incx );
CBLAS_INDEX cblas_icamin ( const MKL_INT n , const void *x , const MKL_INT incx );
CBLAS_INDEX cblas_izamin ( const MKL_INT n , const void *x , const MKL_INT incx );
  • 输入参数解析:
n指定向量中的元素数 X
x数组,大小至少为(1 +(n -1)* abs(incx))
incx指定x元素的增量
  • 返回值: 返回具有最大绝对值的向量元素的位置,以使x [index -1]具有最大绝对值。 返回的索引从零开始。

15、cblas_? amin

目录

一、BLAS例程的命名约定:

二、BLAS 1级例程概述

 三、BLAS 1级例程个函数介绍

1、cblas_?asum

2、cblas_?axpy

3、cblas_?copy

4、cblas_?  dot

5、cblas_? sdot

6、cblas_? dotc

7、cblas_? dotu

8、cblas_? nrm2

9、cblas_? rot

10、cblas_? rotg

11、cblas_? scal

12、cblas_? swap

15、cblas_? amax

15、cblas_? amin

16、cblas_? cabs1


  • 函数功能:查找具有最小绝对值的元素的索引。

同上。

16、cblas_? cabs1

  • 函数功能:计算复数的绝对值。
  • 使用方法:
float cblas_scabs1 ( const void *z );
double cblas_dcabs1 ( const void *z );
  • 输入参数解析 z :  复标量
  • 返回值:复数z的绝对值

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部