]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add LinearAlgebra::distributed::Vector::add() with pointers
authorDenis Davydov <davydden@gmail.com>
Thu, 27 Oct 2016 12:50:48 +0000 (14:50 +0200)
committerDenis Davydov <davydden@gmail.com>
Thu, 27 Oct 2016 12:50:48 +0000 (14:50 +0200)
include/deal.II/lac/la_parallel_vector.h

index 6c1c2a1582354f918f2816506efd94f2a110b3a1..22723a5c15e365979c207dd806d424f549a2f093 100644 (file)
@@ -694,6 +694,15 @@ namespace LinearAlgebra
       void add (const std::vector<size_type>        &indices,
                 const ::dealii::Vector<OtherNumber> &values);
 
+      /**
+       * Take an address where n_elements are stored contiguously and add them
+       * into the vector.
+       */
+      template <typename OtherNumber>
+      void add (const size_type n_elements,
+                const size_type *indices,
+                const OtherNumber *values);
+
       /**
        * Scaling and simple vector addition, i.e.  <tt>*this =
        * s*(*this)+V</tt>.
@@ -1391,6 +1400,24 @@ namespace LinearAlgebra
 
 
 
+    template <typename Number>
+    template <typename OtherNumber>
+    inline
+    void
+    Vector<Number>::add (const size_type n_elements,
+                         const size_type *indices,
+                         const OtherNumber *values)
+    {
+      for (size_type i=0; i<n_elements; ++i, ++indices, ++values)
+        {
+          Assert (numbers::is_finite(*values),
+                  ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)"));
+          this->operator()(*indices) += *values;
+        }
+    }
+
+
+
     template <typename Number>
     inline
     const MPI_Comm &

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.