From 4b90f190af3d7cc6d44a53174d51d31fc002fb12 Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Wed, 23 Sep 2009 09:57:59 +0000 Subject: [PATCH] Added reinit to vector_view git-svn-id: https://svn.dealii.org/trunk@19501 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/vector_view.h | 35 +++++++++++++++++++++++++++ tests/lac/vector_view.cc | 3 +++ 2 files changed, 38 insertions(+) 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()); } -- 2.39.5