cublasscal()
cublasStatus_t cublasSscal(cublasHandle_t handle, int n,
const float *alpha,
float *x, int incx)
cublasStatus_t cublasDscal(cublasHandle_t handle, int n,
const double *alpha,
double *x, int incx)
cublasStatus_t cublasCscal(cublasHandle_t handle, int n,
const cuComplex *alpha,
cuComplex *x, int incx)
cublasStatus_t cublasCsscal(cublasHandle_t handle, int n,
const float *alpha,
cuComplex *x, int incx)
cublasStatus_t cublasZscal(cublasHandle_t handle, int n,
const cuDoubleComplex *alpha,
cuDoubleComplex *x, int incx)
cublasStatus_t cublasZdscal(cublasHandle_t handle, int n,
const double *alpha,
cuDoubleComplex *x, int incx)
该函数通过标量 α 缩放向量 x 并用结果覆盖它。 因此,执行的操作是 x [ j ] = α × x [ j ] 对于 i = 1 , … , n 和 j = 1 + ( i - 1) *incx。 请注意,最后两个等式反映了用于与 Fortran 兼容的基于 1 的索引。
Param. | Memory | In/out | Meaning |
---|---|---|---|
handle | input | handle to the cuBLAS library context. | |
n | input | number of elements in the vector x. | |
x | device | input | vector with n elements. |
incx | input | stride between consecutive elements of x. |
该函数可能返回的错误值及其含义如下所列。
Error Value | Meaning |
---|---|
CUBLAS_STATUS_SUCCESS | 操作成功完成 |
CUBLAS_STATUS_NOT_INITIALIZED | 库未初始化 |
CUBLAS_STATUS_EXECUTION_FAILED | 该功能无法在 GPU 上启动 |
请参考:
sscal, dscal, csscal, cscal, zdscal, zscal
cublasswap()
cublasStatus_t cublasSswap(cublasHandle_t handle, int n, float *x,
int incx, float *y, int incy)
cublasStatus_t cublasDswap(cublasHandle_t handle, int n, double *x,
int incx, double *y, int incy)
cublasStatus_t cublasCswap(cublasHandle_t handle, int n, cuComplex *x,
int incx, cuComplex *y, int incy)
cublasStatus_t cublasZswap(cublasHandle_t handle, int n, cuDoubleComplex *x,
int incx, cuDoubleComplex *y, int incy)
此函数交换向量 x 和 y 的元素。 因此,执行的操作是 y [ j ] ⇔ x [ k ] 对于 i = 1 , … , n , k = 1 + ( i - 1 ) * incx 和 j = 1 + ( i - 1 ) * incy 。 请注意,最后两个等式反映了用于与 Fortran 兼容的基于 1 的索引。
Param. | Memory | In/out | Meaning |
---|---|---|---|
handle | input | handle to the cuBLAS library context. | |
n | input | number of elements in the vector x. | |
x | device | input | vector with n elements. |
incx | input | stride between consecutive elements of x. | |
y | device | in/out | vector with n elements. |
incy | input | stride between consecutive elements of y. |
该函数可能返回的错误值及其含义如下所列。
Error Value | Meaning |
---|---|
CUBLAS_STATUS_SUCCESS | 操作成功完成 |
CUBLAS_STATUS_NOT_INITIALIZED | 库未初始化 |
CUBLAS_STATUS_EXECUTION_FAILED | 该功能无法在 GPU 上启动 |