Reference documentation for deal.II version 9.2.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
vector_slice.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2020 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_vector_slice_h
17 #define dealii_vector_slice_h
18 
19 #include <deal.II/base/config.h>
20 
23 
25 
50 template <typename VectorType>
52  : public ArrayView<
53  typename std::conditional<std::is_const<VectorType>::value,
54  const typename VectorType::value_type,
55  typename VectorType::value_type>::type>
56 {
57 public:
69  VectorSlice(VectorType &v, unsigned int start, unsigned int length);
70 
71 protected:
75  using ArrayViewType =
77  const typename VectorType::value_type,
78  typename VectorType::value_type>::type>;
79 };
80 
81 
89 template <typename VectorType>
92 {
94  return r;
95 }
96 
97 
98 
106 template <typename VectorType>
108 make_slice(VectorType &v, const unsigned int start, const unsigned int length)
109 {
110  const VectorSlice<const VectorType> r(v, start, length);
111  return r;
112 }
113 
114 
115 
116 //---------------------------------------------------------------------------
117 
118 template <typename VectorType>
120  : ArrayViewType(make_array_view(std::begin(v), std::end(v)))
121 {}
122 
123 
124 
125 template <typename VectorType>
127  unsigned int start,
128  unsigned int length)
129  : ArrayViewType(
130  make_array_view(std::begin(v) + start, std::begin(v) + start + length))
131 {
132  AssertIndexRange(length, v.size() - start + 1);
133 }
134 
136 
137 #endif
array_view.h
ArrayView
Definition: array_view.h:77
VectorSlice::make_slice
const VectorSlice< const VectorType > make_slice(VectorType &v)
Definition: vector_slice.h:91
VectorType
AssertIndexRange
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
TrilinosWrappers::internal::begin
VectorType::value_type * begin(VectorType &V)
Definition: trilinos_sparse_matrix.cc:51
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
TrilinosWrappers::internal::end
VectorType::value_type * end(VectorType &V)
Definition: trilinos_sparse_matrix.cc:65
DEAL_II_DEPRECATED
#define DEAL_II_DEPRECATED
Definition: config.h:98
exceptions.h
ArrayView::make_array_view
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view(const Iterator begin, const Iterator end)
Definition: array_view.h:607
VectorSlice
Definition: vector_slice.h:51
VectorSlice::VectorSlice
VectorSlice(VectorType &v)
Definition: vector_slice.h:119
config.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359