]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Implement CUDAWrappers::Vector::norm_sqr
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Fri, 17 Aug 2018 13:11:31 +0000 (15:11 +0200)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Wed, 22 Aug 2018 13:30:30 +0000 (15:30 +0200)
include/deal.II/lac/cuda_vector.h
source/lac/cuda_vector.cu

index 9c73d8d45d75cd43872dfd4a68b0db73cb70f54c..b6dfb083f024297c935856555d59e9272141d383 100644 (file)
@@ -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 <typename Number>
     class Vector : public VectorSpaceVector<Number>
@@ -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).
index 9ced53b14ed3c41468b2b800ae8b9515cbf9ade5..0cb54b675b05559b700a3496320d8272eadb3432 100644 (file)
@@ -597,7 +597,16 @@ namespace LinearAlgebra
     typename Vector<Number>::real_type
     Vector<Number>::l2_norm() const
     {
-      return std::sqrt((*this) * (*this));
+      return std::sqrt(norm_sqr());
+    }
+
+
+
+    template <typename Number>
+    typename Vector<Number>::real_type
+    Vector<Number>::norm_sqr() const
+    {
+      return (*this) * (*this);
     }
 
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.