From: heltai Date: Wed, 23 Sep 2009 09:57:59 +0000 (+0000) Subject: Added reinit to vector_view X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fd358ce4c2310d5c20bbfbe8ac5665424afc870;p=dealii-svn.git Added reinit to vector_view git-svn-id: https://svn.dealii.org/trunk@19501 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/vector_view.h b/deal.II/lac/include/lac/vector_view.h index 7060bdefd6..6fc42ae1fa 100644 --- a/deal.II/lac/include/lac/vector_view.h +++ b/deal.II/lac/include/lac/vector_view.h @@ -234,6 +234,21 @@ class VectorView : public Vector 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::reinit(const unsigned int N, const bool fast) } +template +inline +void VectorView::reinit(const unsigned int new_size, Number * ptr) +{ + this->vec_size = new_size; + this->max_vec_size = new_size; + this->val = ptr; +} + + +template +inline +void VectorView::reinit(const unsigned int new_size, const Number * ptr) +{ + this->vec_size = new_size; + this->max_vec_size = new_size; + this->val = const_cast(ptr); +} + + template inline void VectorView::swap(Vector &) diff --git a/tests/lac/vector_view.cc b/tests/lac/vector_view.cc index 9176be9f31..ea44bcc9a3 100644 --- a/tests/lac/vector_view.cc +++ b/tests/lac/vector_view.cc @@ -73,6 +73,9 @@ int main() VectorView v4(N, v3.begin()); deallog << "const Vector View" << std::endl; print(v4); + + v4.reinit(N, v1.begin()); + v4.reinit(N, v3.begin()); }