37 template <
typename DataType>
39 cublasHandle_t cublas_handle,
40 const DataType* input_vector,
42 DataType* output_vector)
48 cublas_handle, vector_size, input_vector, incx, output_vector,
51 assert(status == CUBLAS_STATUS_SUCCESS);
72 template <
typename DataType>
74 cublasHandle_t cublas_handle,
75 const DataType* input_vector,
78 DataType* output_vector)
80 cublasStatus_t status;
89 assert(status == CUBLAS_STATUS_SUCCESS);
95 assert(status == CUBLAS_STATUS_SUCCESS);
125 template <
typename DataType>
127 cublasHandle_t cublas_handle,
128 const DataType* input_vector,
130 const DataType scale,
131 DataType* output_vector)
141 DataType neg_scale = -scale;
143 cublas_handle, vector_size, &neg_scale, input_vector, incx,
144 output_vector, incy);
146 assert(status == CUBLAS_STATUS_SUCCESS);
165 template <
typename DataType>
167 cublasHandle_t cublas_handle,
168 const DataType* vector1,
169 const DataType* vector2,
177 cublas_handle, vector_size, vector1, incx, vector2, incy,
180 assert(status == CUBLAS_STATUS_SUCCESS);
200 template <
typename DataType>
202 cublasHandle_t cublas_handle,
203 const DataType* vector,
210 cublas_handle, vector_size, vector, incx, &norm);
212 assert(status == CUBLAS_STATUS_SUCCESS);
233 template <
typename DataType>
235 cublasHandle_t cublas_handle,
241 cublas_handle, vector, vector_size);
244 DataType scale = 1.0 / norm;
247 cublas_handle, vector_size, &scale, vector, incx);
249 assert(status == CUBLAS_STATUS_SUCCESS);
272 template <
typename DataType>
274 cublasHandle_t cublas_handle,
275 const DataType* vector,
277 DataType* output_vector)
281 cublas_handle, vector, vector_size);
284 DataType scale = 1.0 / norm;
A static class for vector operations, similar to level-1 operations of the BLAS library....
static void copy_vector(cublasHandle_t cublas_handle, const DataType *input_vector, const LongIndexType vector_size, DataType *output_vector)
Copies a vector to a new vector. Result is written in-place.
static void copy_scaled_vector(cublasHandle_t cublas_handle, const DataType *input_vector, const LongIndexType vector_size, const DataType scale, DataType *output_vector)
Scales a vector and stores to a new vector.
static void subtract_scaled_vector(cublasHandle_t cublas_handle, const DataType *input_vector, const LongIndexType vector_size, const DataType scale, DataType *output_vector)
Subtracts the scaled input vector from the output vector.
static DataType normalize_vector_in_place(cublasHandle_t cublas_handle, DataType *vector, const LongIndexType vector_size)
Normalizes a vector based on Euclidean 2-norm. The result is written in-place.
static DataType inner_product(cublasHandle_t cublas_handle, const DataType *vector1, const DataType *vector2, const LongIndexType vector_size)
Computes Euclidean inner product of two vectors.
static DataType normalize_vector_and_copy(cublasHandle_t cublas_handle, const DataType *vector, const LongIndexType vector_size, DataType *output_vector)
Normalizes a vector based on Euclidean 2-norm. The result is written into another vector.
static DataType euclidean_norm(cublasHandle_t cublas_handle, const DataType *vector, const LongIndexType vector_size)
Computes the Euclidean 2-norm of a 1D array.
cublasStatus_t cublasXdot(cublasHandle_t handle, int n, const DataType *x, int incx, const DataType *y, int incy, DataType *result)
cublasStatus_t cublasXscal(cublasHandle_t handle, int n, const DataType *alpha, DataType *x, int incx)
cublasStatus_t cublasXnrm2(cublasHandle_t handle, int n, const DataType *x, int incx, DataType *result)
cublasStatus_t cublasXcopy(cublasHandle_t handle, int n, const DataType *x, int incx, DataType *y, int incy)
cublasStatus_t cublasXaxpy(cublasHandle_t handle, int n, const DataType *alpha, const DataType *x, int incx, DataType *y, int incy)