12 #ifndef _CU_BASIC_ALGEBRA_CU_VECTOR_OPERATIONS_H_
13 #define _CU_BASIC_ALGEBRA_CU_VECTOR_OPERATIONS_H_
19 #include <cublas_v2.h>
20 #include "../_definitions/types.h"
35 template <
typename DataType>
42 cublasHandle_t cublas_handle,
43 const DataType* input_vector,
45 DataType* output_vector);
49 cublasHandle_t cublas_handle,
50 const DataType* input_vector,
53 DataType* output_vector);
57 cublasHandle_t cublas_handle,
58 const DataType* input_vector,
61 DataType* output_vector);
65 cublasHandle_t cublas_handle,
66 const DataType* vector1,
67 const DataType* vector2,
72 cublasHandle_t cublas_handle,
73 const DataType* vector,
78 cublasHandle_t cublas_handle,
84 cublasHandle_t cublas_handle,
85 const DataType* vector,
87 DataType* output_vector);
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.