@@ -691,4 +691,76 @@ void vector_div_vector(const int& dim, T* result, const T* vector1, const T* vec
691691 hsolver::vector_div_vector_op<T, base_device::DEVICE_GPU>()(gpu_ctx, dim, result, vector1, vector2);
692692#endif
693693 }
694+ }
695+
696+ void vector_add_vector (const int & dim, float *result, const float *vector1, const float constant1, const float *vector2, const float constant2, base_device::AbacusDevice_t device_type)
697+ {
698+ if (device_type == base_device::CpuDevice){
699+ #ifdef _OPENMP
700+ #pragma omp parallel for schedule(static, 8192 / sizeof(float))
701+ #endif
702+ for (int i = 0 ; i < dim; i++)
703+ {
704+ result[i] = vector1[i] * constant1 + vector2[i] * constant2;
705+ }
706+ }
707+ else if (device_type == base_device::GpuDevice){
708+ #ifdef __CUDA
709+ hsolver::constantvector_addORsub_constantVector_op<float , base_device::DEVICE_GPU>()(gpu_ctx, dim, result, vector1, constant1, vector2, constant2);
710+ #endif
711+ }
712+ }
713+
714+ void vector_add_vector (const int & dim, double *result, const double *vector1, const double constant1, const double *vector2, const double constant2, base_device::AbacusDevice_t device_type)
715+ {
716+ if (device_type == base_device::CpuDevice){
717+ #ifdef _OPENMP
718+ #pragma omp parallel for schedule(static, 8192 / sizeof(double))
719+ #endif
720+ for (int i = 0 ; i < dim; i++)
721+ {
722+ result[i] = vector1[i] * constant1 + vector2[i] * constant2;
723+ }
724+ }
725+ else if (device_type == base_device::GpuDevice){
726+ #ifdef __CUDA
727+ hsolver::constantvector_addORsub_constantVector_op<double , base_device::DEVICE_GPU>()(gpu_ctx, dim, result, vector1, constant1, vector2, constant2);
728+ #endif
729+ }
730+ }
731+
732+ void vector_add_vector (const int & dim, std::complex <float > *result, const std::complex <float > *vector1, const float constant1, const std::complex <float > *vector2, const float constant2, base_device::AbacusDevice_t device_type)
733+ {
734+ if (device_type == base_device::CpuDevice){
735+ #ifdef _OPENMP
736+ #pragma omp parallel for schedule(static, 8192 / sizeof(std::complex<float>))
737+ #endif
738+ for (int i = 0 ; i < dim; i++)
739+ {
740+ result[i] = vector1[i] * constant1 + vector2[i] * constant2;
741+ }
742+ }
743+ else if (device_type == base_device::GpuDevice){
744+ #ifdef __CUDA
745+ hsolver::constantvector_addORsub_constantVector_op<std::complex <float >, base_device::DEVICE_GPU>()(gpu_ctx, dim, result, vector1, constant1, vector2, constant2);
746+ #endif
747+ }
748+ }
749+
750+ void vector_add_vector (const int & dim, std::complex <double > *result, const std::complex <double > *vector1, const double constant1, const std::complex <double > *vector2, const double constant2, base_device::AbacusDevice_t device_type)
751+ {
752+ if (device_type == base_device::CpuDevice){
753+ #ifdef _OPENMP
754+ #pragma omp parallel for schedule(static, 8192 / sizeof(std::complex<double>))
755+ #endif
756+ for (int i = 0 ; i < dim; i++)
757+ {
758+ result[i] = vector1[i] * constant1 + vector2[i] * constant2;
759+ }
760+ }
761+ else if (device_type == base_device::GpuDevice){
762+ #ifdef __CUDA
763+ hsolver::constantvector_addORsub_constantVector_op<std::complex <double >, base_device::DEVICE_GPU>()(gpu_ctx, dim, result, vector1, constant1, vector2, constant2);
764+ #endif
765+ }
694766}
0 commit comments