Reference documentation for deal.II version GIT relicensing-439-g5fda5c893d 2024-04-20 06:50:02+00:00
\(\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\}}\)
Loading...
Searching...
No Matches
Classes | Functions
array_view.h File Reference
#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
#include <deal.II/base/memory_space.h>
#include <deal.II/base/symmetric_tensor.h>
#include <deal.II/base/template_constraints.h>
#include <deal.II/base/tensor.h>
#include <boost/container/small_vector.hpp>
#include <array>
#include <type_traits>
#include <vector>

Go to the source code of this file.

Classes

class  ArrayView< ElementType, MemorySpaceType >
 
class  StridedArrayView< ElementType, stride >
 

Functions

template<typename Iterator , typename MemorySpaceType = MemorySpace::Host>
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view (const Iterator begin, const Iterator end)
 
template<typename ElementType , typename MemorySpaceType = MemorySpace::Host>
ArrayView< ElementType, MemorySpaceType > make_array_view (ElementType *const begin, ElementType *const end)
 
template<typename Number , typename MemorySpaceType >
ArrayView< const Number, MemorySpaceType > make_array_view (const ArrayView< Number, MemorySpaceType > &array_view)
 
template<typename Number , typename MemorySpaceType >
ArrayView< Number, MemorySpaceType > make_array_view (ArrayView< Number, MemorySpaceType > &array_view)
 
template<int rank, int dim, typename Number >
ArrayView< const Number > make_array_view (const Tensor< rank, dim, Number > &tensor)
 
template<int rank, int dim, typename Number >
ArrayView< Number > make_array_view (Tensor< rank, dim, Number > &tensor)
 
template<int rank, int dim, typename Number >
ArrayView< const Number > make_array_view (const SymmetricTensor< rank, dim, Number > &tensor)
 
template<int rank, int dim, typename Number >
ArrayView< Number > make_array_view (SymmetricTensor< rank, dim, Number > &tensor)
 
template<typename ElementType , int N>
ArrayView< ElementType > make_array_view (ElementType(&array)[N])
 
template<typename ElementType >
ArrayView< ElementType > make_array_view (Vector< ElementType > &vector)
 
template<typename ElementType >
ArrayView< const ElementType > make_array_view (const Vector< ElementType > &vector)
 
template<typename ElementType >
ArrayView< ElementType > make_array_view (std::vector< ElementType > &vector)
 
template<typename ElementType >
ArrayView< const ElementType > make_array_view (const std::vector< ElementType > &vector)
 
template<typename ElementType >
ArrayView< ElementType > make_array_view (std::vector< ElementType > &vector, const std::size_t starting_index, const std::size_t size_of_view)
 
template<typename ElementType >
ArrayView< const ElementType > make_array_view (const std::vector< ElementType > &vector, const std::size_t starting_index, const std::size_t size_of_view)
 
template<typename ElementType >
ArrayView< ElementType > make_array_view (AlignedVector< ElementType > &vector)
 
template<typename ElementType >
ArrayView< const ElementType > make_array_view (const AlignedVector< ElementType > &vector)
 
template<typename ElementType >
ArrayView< ElementType > make_array_view (AlignedVector< ElementType > &vector, const std::size_t starting_index, const std::size_t size_of_view)
 
template<typename ElementType >
ArrayView< const ElementType > make_array_view (const AlignedVector< ElementType > &vector, const std::size_t starting_index, const std::size_t size_of_view)
 
template<typename ElementType , std::size_t N>
ArrayView< ElementType > make_array_view (std::array< ElementType, N > &array)
 
template<typename ElementType , std::size_t N>
ArrayView< const ElementType > make_array_view (const std::array< ElementType, N > &array)
 
template<typename ElementType >
ArrayView< ElementType > make_array_view (Table< 2, ElementType > &table, const typename Table< 2, ElementType >::size_type row)
 
template<typename ElementType >
ArrayView< ElementType > make_array_view (Table< 2, ElementType > &table)
 
template<typename ElementType >
ArrayView< const ElementType > make_array_view (const Table< 2, ElementType > &table)
 
template<typename ElementType >
ArrayView< ElementType > make_array_view (LAPACKFullMatrix< ElementType > &matrix)
 
template<typename ElementType >
ArrayView< const ElementType > make_array_view (const LAPACKFullMatrix< ElementType > &matrix)
 
template<typename ElementType >
ArrayView< const ElementType > make_array_view (const Table< 2, ElementType > &table, const typename Table< 2, ElementType >::size_type row)
 
template<typename ElementType >
ArrayView< ElementType > make_array_view (Table< 2, ElementType > &table, const typename Table< 2, ElementType >::size_type row, const typename Table< 2, ElementType >::size_type starting_column, const std::size_t size_of_view)
 
template<typename ElementType >
ArrayView< const ElementType > make_array_view (const Table< 2, ElementType > &table, const typename Table< 2, ElementType >::size_type row, const typename Table< 2, ElementType >::size_type starting_column, const std::size_t size_of_view)
 
template<typename Container >
auto make_const_array_view (const Container &container) -> decltype(make_array_view(container))
 

Function Documentation

◆ make_array_view() [1/29]

template<typename Iterator , typename MemorySpaceType = MemorySpace::Host>
ArrayView< typename std::remove_reference< typename std::iterator_traits< Iterator >::reference >::type, MemorySpaceType > make_array_view ( const Iterator  begin,
const Iterator  end 
)

Create an ArrayView that takes a pair of iterators as arguments. The type of the ArrayView is inferred from the value type of the iterator (e.g., the view created from two const iterators will have a const type).

Warning
The iterators begin and end must bound (in the usual half-open way) a contiguous in memory range of values. This function is intended for use with iterators into containers like boost::container::small_vector or std::vector and will not work correctly with, e.g., boost::container::stable_vector or std::deque. In debug mode, we check that the provided iterators represent contiguous memory indeed.

Definition at line 949 of file array_view.h.

◆ make_array_view() [2/29]

template<typename ElementType , typename MemorySpaceType = MemorySpace::Host>
ArrayView< ElementType, MemorySpaceType > make_array_view ( ElementType *const  begin,
ElementType *const  end 
)

Create a view from a pair of pointers. ElementType may be const-qualified.

Warning
The pointers begin and end must bound (in the usual half-open way) a contiguous in memory range of values.

Definition at line 985 of file array_view.h.

◆ make_array_view() [3/29]

template<typename Number , typename MemorySpaceType >
ArrayView< const Number, MemorySpaceType > make_array_view ( const ArrayView< Number, MemorySpaceType > &  array_view)
inline

Create a view from an ArrayView itself.

This function is used for const references to objects of ArrayView type. It only exists for compatibility purposes.

Parameters
[in]array_viewThe ArrayView that we wish to make a copy of.

Definition at line 1007 of file array_view.h.

◆ make_array_view() [4/29]

template<typename Number , typename MemorySpaceType >
ArrayView< Number, MemorySpaceType > make_array_view ( ArrayView< Number, MemorySpaceType > &  array_view)
inline

Create a view from an ArrayView itself.

This function is used for non-const references to objects of ArrayView type. It only exists for compatibility purposes.

Parameters
[in]array_viewThe ArrayView that we wish to make a copy of.

Definition at line 1026 of file array_view.h.

◆ make_array_view() [5/29]

template<int rank, int dim, typename Number >
ArrayView< const Number > make_array_view ( const Tensor< rank, dim, Number > &  tensor)
inline

Create a view to an entire Tensor object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for const references to objects of Tensor type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]tensorThe Tensor for which we want to have an array view object. The array view corresponds to the entire object but the order in which the entries are presented in the array is an implementation detail and should not be relied upon.
Deprecated:
This function suggests that the elements of a Tensor object are stored as a contiguous array, but this is not in fact true and one should not pretend that this so. As a consequence, this function is deprecated.

Definition at line 1056 of file array_view.h.

◆ make_array_view() [6/29]

template<int rank, int dim, typename Number >
ArrayView< Number > make_array_view ( Tensor< rank, dim, Number > &  tensor)
inline

Create a view to an entire Tensor object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for non-const references to objects of Tensor type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.

Parameters
[in]tensorThe Tensor for which we want to have an array view object. The array view corresponds to the entire object but the order in which the entries are presented in the array is an implementation detail and should not be relied upon.
Deprecated:
This function suggests that the elements of a Tensor object are stored as a contiguous array, but this is not in fact true and one should not pretend that this so. As a consequence, this function is deprecated.

Definition at line 1091 of file array_view.h.

◆ make_array_view() [7/29]

template<int rank, int dim, typename Number >
ArrayView< const Number > make_array_view ( const SymmetricTensor< rank, dim, Number > &  tensor)
inline

Create a view to an entire SymmetricTensor object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for const references to objects of SymmetricTensor type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]tensorThe SymmetricTensor for which we want to have an array view object. The array view corresponds to the entire object but the order in which the entries are presented in the array is an implementation detail and should not be relied upon.
Deprecated:
This function suggests that the elements of a SymmetricTensor object are stored as a contiguous array, but this is not in fact true and one should not pretend that this so. As a consequence, this function is deprecated.

Definition at line 1126 of file array_view.h.

◆ make_array_view() [8/29]

template<int rank, int dim, typename Number >
ArrayView< Number > make_array_view ( SymmetricTensor< rank, dim, Number > &  tensor)
inline

Create a view to an entire SymmetricTensor object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for non-const references to objects of SymmetricTensor type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.

Parameters
[in]tensorThe SymmetricTensor for which we want to have an array view object. The array view corresponds to the entire object but the order in which the entries are presented in the array is an implementation detail and should not be relied upon.
Deprecated:
This function suggests that the elements of a SymmetricTensor object are stored as a contiguous array, but this is not in fact true and one should not pretend that this so. As a consequence, this function is deprecated.

Definition at line 1157 of file array_view.h.

◆ make_array_view() [9/29]

template<typename ElementType , int N>
ArrayView< ElementType > make_array_view ( ElementType(&)  array[N])
inline

Create a view to an entire C-style array. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

Whether the resulting ArrayView is writable or not depends on the ElementType being a const type or not.

Parameters
[in]arrayThe C-style array for which we want to have an ArrayView object. The ArrayView corresponds to the entire vector.

Definition at line 1179 of file array_view.h.

◆ make_array_view() [10/29]

template<typename ElementType >
ArrayView< ElementType > make_array_view ( Vector< ElementType > &  vector)
inline

Create a view to an entire Vector object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for non-const references to objects of Vector type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.

Parameters
[in]vectorThe Vector for which we want to have an array view object. The array view corresponds to the entire Vector.

Definition at line 1202 of file array_view.h.

◆ make_array_view() [11/29]

template<typename ElementType >
ArrayView< const ElementType > make_array_view ( const Vector< ElementType > &  vector)
inline

Create a view to an entire Vector object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for const references to objects of Vector type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]vectorThe Vector for which we want to have an array view object. The array view corresponds to the entire Vector.

Definition at line 1225 of file array_view.h.

◆ make_array_view() [12/29]

template<typename ElementType >
ArrayView< ElementType > make_array_view ( std::vector< ElementType > &  vector)
inline

Create a view to an entire std::vector object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for non-const references to objects of vector type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.

Parameters
[in]vectorThe vector for which we want to have an array view object. The array view corresponds to the entire vector.

Definition at line 1248 of file array_view.h.

◆ make_array_view() [13/29]

template<typename ElementType >
ArrayView< const ElementType > make_array_view ( const std::vector< ElementType > &  vector)
inline

Create a view to an entire std::vector object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for const references to objects of vector type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]vectorThe vector for which we want to have an array view object. The array view corresponds to the entire vector.

Definition at line 1271 of file array_view.h.

◆ make_array_view() [14/29]

template<typename ElementType >
ArrayView< ElementType > make_array_view ( std::vector< ElementType > &  vector,
const std::size_t  starting_index,
const std::size_t  size_of_view 
)
inline

Create a view to a part of a std::vector object. This is equivalent to initializing the ArrayView object with a pointer to the starting_index-th element and the size_of_view as the length of the view.

This function is used for non-const references to objects of vector type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.

Parameters
[in]vectorThe vector for which we want to have an array view object.
[in]starting_indexThe index of the first element of the vector that will be part of this view.
[in]size_of_viewNumber of elements in the new ArrayView.
Precondition
starting_index + size_of_view <= vector.size()

Definition at line 1299 of file array_view.h.

◆ make_array_view() [15/29]

template<typename ElementType >
ArrayView< const ElementType > make_array_view ( const std::vector< ElementType > &  vector,
const std::size_t  starting_index,
const std::size_t  size_of_view 
)
inline

Create a view to a part of a std::vector object. This is equivalent to initializing the ArrayView object with a pointer to the starting_index-th element and the size_of_view as the length of the view.

This function is used for const references to objects of vector type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]vectorThe vector for which we want to have an array view object.
[in]starting_indexThe index of the first element of the vector that will be part of this view.
[in]size_of_viewNumber of elements in the new ArrayView.
Precondition
starting_index + size_of_view <= vector.size()

Definition at line 1333 of file array_view.h.

◆ make_array_view() [16/29]

template<typename ElementType >
ArrayView< ElementType > make_array_view ( AlignedVector< ElementType > &  vector)
inline

Create a writable view to an entire AlignedVector object. See the documentation of the corresponding overload for std::vector for more information.

Definition at line 1355 of file array_view.h.

◆ make_array_view() [17/29]

template<typename ElementType >
ArrayView< const ElementType > make_array_view ( const AlignedVector< ElementType > &  vector)
inline

Create a read-only view to an entire AlignedVector object. See the documentation of the corresponding overload for std::vector for more information.

Definition at line 1371 of file array_view.h.

◆ make_array_view() [18/29]

template<typename ElementType >
ArrayView< ElementType > make_array_view ( AlignedVector< ElementType > &  vector,
const std::size_t  starting_index,
const std::size_t  size_of_view 
)
inline

Create a writable view to a part of an AlignedVector object. See the documentation of the corresponding overload for std::vector for more information.

Definition at line 1387 of file array_view.h.

◆ make_array_view() [19/29]

template<typename ElementType >
ArrayView< const ElementType > make_array_view ( const AlignedVector< ElementType > &  vector,
const std::size_t  starting_index,
const std::size_t  size_of_view 
)
inline

Create a read-only view to a part of an AlignedVector object. See the documentation of the corresponding overload for std::vector for more information.

Definition at line 1409 of file array_view.h.

◆ make_array_view() [20/29]

template<typename ElementType , std::size_t N>
ArrayView< ElementType > make_array_view ( std::array< ElementType, N > &  array)
inline

Create a view to an entire std::array object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for non-const references to objects of array type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.

Parameters
[in]arrayThe std::array object for which we want to have an array view object. The array view corresponds to the entire array.

Definition at line 1438 of file array_view.h.

◆ make_array_view() [21/29]

template<typename ElementType , std::size_t N>
ArrayView< const ElementType > make_array_view ( const std::array< ElementType, N > &  array)
inline

Create a view to an entire std::array object. This is equivalent to initializing an ArrayView object with a pointer to the first element and the size of the given argument.

This function is used for const references to objects of array type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]arrayThe std::array object for which we want to have an array view object. The array view corresponds to the entire array.

Definition at line 1461 of file array_view.h.

◆ make_array_view() [22/29]

template<typename ElementType >
ArrayView< ElementType > make_array_view ( Table< 2, ElementType > &  table,
const typename Table< 2, ElementType >::size_type  row 
)
inline

Create a view to an entire row of a Table<2> object. This is equivalent to initializing an ArrayView object with a pointer to the first element of the given row, and the length of the row as the length of the view.

This function is used for non-const references to objects of Table type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.

Parameters
[in]tableThe Table for which we want to have an array view object. The array view corresponds to an entire row.
[in]rowThe index of the row into the table to which this view should correspond.

Definition at line 1486 of file array_view.h.

◆ make_array_view() [23/29]

template<typename ElementType >
ArrayView< ElementType > make_array_view ( Table< 2, ElementType > &  table)
inline

Create a view to an entire Table<2> object. This is equivalent to initializing an ArrayView object with a pointer to the first element of the given table, and the number of table entries as the length of the view.

This function is used for non-const references to objects of Table type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.

Parameters
[in]tableThe Table for which we want to have an array view object. The array view corresponds to the entire table but the order in which the entries are presented in the array is an implementation detail and should not be relied upon.

Definition at line 1513 of file array_view.h.

◆ make_array_view() [24/29]

template<typename ElementType >
ArrayView< const ElementType > make_array_view ( const Table< 2, ElementType > &  table)
inline

Create a view to an entire Table<2> object. This is equivalent to initializing an ArrayView object with a pointer to the first element of the given table, and the number of table entries as the length of the view.

This function is used for const references to objects of Table type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]tableThe Table for which we want to have an array view object. The array view corresponds to the entire table but the order in which the entries are presented in the array is an implementation detail and should not be relied upon.

Definition at line 1538 of file array_view.h.

◆ make_array_view() [25/29]

template<typename ElementType >
ArrayView< ElementType > make_array_view ( LAPACKFullMatrix< ElementType > &  matrix)
inline

Create a view to an entire LAPACKFullMatrix object. This is equivalent to initializing an ArrayView object with a pointer to the first element of the given object, and the number entries as the length of the view.

This function is used for non-const references to objects of LAPACKFullMatrix type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of non-const objects.

Parameters
[in]matrixThe LAPACKFullMatrix for which we want to have an array view object. The array view corresponds to the entire object but the order in which the entries are presented in the array is an implementation detail and should not be relied upon.

Definition at line 1563 of file array_view.h.

◆ make_array_view() [26/29]

template<typename ElementType >
ArrayView< const ElementType > make_array_view ( const LAPACKFullMatrix< ElementType > &  matrix)
inline

Create a view to an entire LAPACKFullMatrix object. This is equivalent to initializing an ArrayView object with a pointer to the first element of the given object, and the number of entries as the length of the view.

This function is used for const references to objects of LAPACKFullMatrix type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]matrixThe LAPACKFullMatrix for which we want to have an array view object. The array view corresponds to the entire object but the order in which the entries are presented in the array is an implementation detail and should not be relied upon.

Definition at line 1588 of file array_view.h.

◆ make_array_view() [27/29]

template<typename ElementType >
ArrayView< const ElementType > make_array_view ( const Table< 2, ElementType > &  table,
const typename Table< 2, ElementType >::size_type  row 
)
inline

Create a view to an entire row of a Table<2> object. This is equivalent to initializing an ArrayView object with a pointer to the first element of the given row, and the length of the row as the length of the view.

This function is used for const references to objects of Table type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]tableThe Table for which we want to have an array view object. The array view corresponds to an entire row.
[in]rowThe index of the row into the table to which this view should correspond.

Definition at line 1613 of file array_view.h.

◆ make_array_view() [28/29]

template<typename ElementType >
ArrayView< ElementType > make_array_view ( Table< 2, ElementType > &  table,
const typename Table< 2, ElementType >::size_type  row,
const typename Table< 2, ElementType >::size_type  starting_column,
const std::size_t  size_of_view 
)
inline

Create a view to (a part of) a row of a Table<2> object.

This function is used for non-const references to objects of Table type. Such objects contain elements that can be written to. Consequently, the return type of this function is a view to a set of writable objects.

Parameters
[in]tableThe Table for which we want to have an array view object. The array view corresponds to an entire row.
[in]rowThe index of the row into the table to which this view should correspond.
[in]starting_columnThe index of the column into the given row of the table that corresponds to the first element of this view.
[in]size_of_viewThe number of elements this view should have. This corresponds to the number of columns in the current row to which the view should correspond.

Definition at line 1643 of file array_view.h.

◆ make_array_view() [29/29]

template<typename ElementType >
ArrayView< const ElementType > make_array_view ( const Table< 2, ElementType > &  table,
const typename Table< 2, ElementType >::size_type  row,
const typename Table< 2, ElementType >::size_type  starting_column,
const std::size_t  size_of_view 
)
inline

Create a view to (a part of) a row of a Table<2> object.

This function is used for const references to objects of Table type because they contain immutable elements. Consequently, the return type of this function is a view to a set of const objects.

Parameters
[in]tableThe Table for which we want to have an array view object. The array view corresponds to an entire row.
[in]rowThe index of the row into the table to which this view should correspond.
[in]starting_columnThe index of the column into the given row of the table that corresponds to the first element of this view.
[in]size_of_viewThe number of elements this view should have. This corresponds to the number of columns in the current row to which the view should correspond.

Definition at line 1680 of file array_view.h.

◆ make_const_array_view()

template<typename Container >
auto make_const_array_view ( const Container &  container) -> decltype(make_array_view(container))
inline

Definition at line 1709 of file array_view.h.