]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Added reinit to vector_view
authorheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Sep 2009 09:57:59 +0000 (09:57 +0000)
committerheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 23 Sep 2009 09:57:59 +0000 (09:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@19501 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/vector_view.h
tests/lac/vector_view.cc

index 7060bdefd60e808547db0958ad5661f9f82c7b2d..6fc42ae1fa1e3c6bf73ab14c6abd4060bd3ec80a 100644 (file)
@@ -234,6 +234,21 @@ class VectorView : public Vector<Number>
     virtual void reinit (const unsigned int N,
                         const bool         fast=false);
     
+                                    /** This reinit function is
+                                        equivalent to constructing a
+                                        new object with the given
+                                        size, starting from the
+                                        pointer ptr. */
+    void reinit(const unsigned int N, Number * ptr);
+    
+                                    /** This reinit function is
+                                        equivalent to constructing a
+                                        new object with the given
+                                        size, starting from the
+                                        pointer ptr. The same
+                                        considerations made for the
+                                        constructor apply here. */
+    void reinit(const unsigned int N, const Number * ptr);
     
                                     /**
                                      * This function is here to prevent
@@ -303,6 +318,26 @@ void VectorView<Number>::reinit(const unsigned int N, const bool fast)
 }
 
 
+template<typename Number>
+inline
+void VectorView<Number>::reinit(const unsigned int new_size, Number * ptr)
+{
+    this->vec_size     = new_size;
+    this->max_vec_size = new_size;
+    this->val          = ptr;
+}
+
+
+template<typename Number>
+inline
+void VectorView<Number>::reinit(const unsigned int new_size, const Number * ptr) 
+{
+    this->vec_size     = new_size;
+    this->max_vec_size = new_size;
+    this->val          = const_cast<Number*>(ptr);
+}
+
+
 template<typename Number>
 inline
 void VectorView<Number>::swap(Vector<Number> &)
index 9176be9f319a00bb16c4c15e7e64ad01627d29bd..ea44bcc9a398d1b833b8e899604f0c01fdb517d5 100644 (file)
@@ -73,6 +73,9 @@ int main()
   VectorView<double> v4(N, v3.begin());
   deallog << "const Vector View" << std::endl;
   print(v4); 
+
+  v4.reinit(N, v1.begin());
+  v4.reinit(N, v3.begin());
 }
 
   

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.