12#ifndef _C_BASIC_ALGEBRA_C_VECTOR_OPERATIONS_H_
13#define _C_BASIC_ALGEBRA_C_VECTOR_OPERATIONS_H_
19#include "../_definitions/types.h"
23 #define RESTRICT __restrict
24#elif defined(__INTEL_COMPILER)
25 #define RESTRICT __restrict
26#elif defined(__CUDA__) || defined(__GNUC__) || defined(__clang__)
27 #define RESTRICT __restrict__
45template <
typename DataType>
52 const DataType*
RESTRICT input_vector,
58 const DataType*
RESTRICT input_vector,
65 const DataType*
RESTRICT input_vector,
A static class for vector operations, similar to level-1 operations of the BLAS library....
static void copy_scaled_vector(const DataType *RESTRICT input_vector, const LongIndexType vector_size, const DataType scale, DataType *RESTRICT output_vector)
Scales a vector and stores to a new vector.
static DataType inner_product(const DataType *RESTRICT vector1, const DataType *RESTRICT vector2, const LongIndexType vector_size)
Computes Euclidean inner product of two vectors.
static DataType normalize_vector_and_copy(const DataType *RESTRICT vector, const LongIndexType vector_size, DataType *RESTRICT output_vector)
Normalizes a vector based on Euclidean 2-norm. The result is written into another vector.
static void copy_vector(const DataType *RESTRICT input_vector, const LongIndexType vector_size, DataType *RESTRICT output_vector)
Copies a vector to a new vector. Result is written in-place.
static DataType normalize_vector_in_place(DataType *RESTRICT vector, const LongIndexType vector_size)
Normalizes a vector based on Euclidean 2-norm. The result is written in-place.
static void subtract_scaled_vector(const DataType *RESTRICT input_vector, const LongIndexType vector_size, const DataType scale, DataType *RESTRICT output_vector)
Subtracts the scaled input vector from the output vector.
static DataType euclidean_norm(const DataType *RESTRICT vector, const LongIndexType vector_size)
Computes the Euclidean norm of a 1D array.