From: Daniel Arndt Date: Fri, 17 Aug 2018 13:11:31 +0000 (+0200) Subject: Implement CUDAWrappers::Vector::norm_sqr X-Git-Tag: v9.1.0-rc1~790^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce0105f84ef3c8864b435930e6cf2253f9d83516;p=dealii.git Implement CUDAWrappers::Vector::norm_sqr --- 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); }