From ce0105f84ef3c8864b435930e6cf2253f9d83516 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Fri, 17 Aug 2018 15:11:31 +0200 Subject: [PATCH] Implement CUDAWrappers::Vector::norm_sqr --- include/deal.II/lac/cuda_vector.h | 11 +++++++++-- source/lac/cuda_vector.cu | 11 ++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/deal.II/lac/cuda_vector.h b/include/deal.II/lac/cuda_vector.h index 9c73d8d45d..b6dfb083f0 100644 --- a/include/deal.II/lac/cuda_vector.h +++ b/include/deal.II/lac/cuda_vector.h @@ -45,8 +45,9 @@ namespace LinearAlgebra * * @note Only float and double are supported. * - * @ingroup CUDAWrappers Vectors - * @author Karl Ljungkvist, Bruno Turcksin, 2016 + * @see CUDAWrappers + * @ingroup Vectors + * @author Karl Ljungkvist, Bruno Turcksin, Daniel Arndt, 2016, 2018 */ template class Vector : public VectorSpaceVector @@ -233,6 +234,12 @@ namespace LinearAlgebra virtual real_type l2_norm() const override; + /** + * Return the square of the $l_2$-norm. + */ + real_type + norm_sqr() const; + /** * Return the maximum norm of the vector (i.e., the maximum absolute * value among all entries and among all processors). diff --git a/source/lac/cuda_vector.cu b/source/lac/cuda_vector.cu index 9ced53b14e..0cb54b675b 100644 --- a/source/lac/cuda_vector.cu +++ b/source/lac/cuda_vector.cu @@ -597,7 +597,16 @@ namespace LinearAlgebra typename Vector::real_type Vector::l2_norm() const { - return std::sqrt((*this) * (*this)); + return std::sqrt(norm_sqr()); + } + + + + template + typename Vector::real_type + Vector::norm_sqr() const + { + return (*this) * (*this); } -- 2.39.5