deal.II version GIT relicensing-2287-g6548a49e0a 2024-12-20 18:30:00+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
Public Types | Public Member Functions | Private Attributes | Friends | Related Symbols | List of all members
ArrayView< ElementType, MemorySpaceType > Class Template Reference

#include <deal.II/base/array_view.h>

Inheritance diagram for ArrayView< ElementType, MemorySpaceType >:
Inheritance graph
[legend]

Public Types

using value_type = ElementType
 
using iterator = value_type *
 
using const_iterator = const ElementType *
 

Public Member Functions

 ArrayView ()
 
 ArrayView (value_type *starting_element, const std::size_t n_elements)
 
 ArrayView (const ArrayView< std::remove_cv_t< value_type >, MemorySpaceType > &view)
 
 ArrayView (value_type &element)
 
template<typename ContiguousContainer , typename = decltype(std::data(std::declval<ContiguousContainer>())), typename = decltype(std::size(std::declval<ContiguousContainer>())), typename = std::enable_if_t< std::is_same_v< std::remove_cv_t<ElementType>, std::remove_cv_t<typename ContiguousContainer::value_type>> && std::is_const_v<ElementType>>>
 ArrayView (const ContiguousContainer &container)
 
template<typename ContiguousContainer , typename = decltype(std::data(std::declval<ContiguousContainer>())), typename = decltype(std::size(std::declval<ContiguousContainer>())), typename = std::enable_if_t<std::is_same_v< std::remove_cv_t<ElementType>, std::remove_cv_t<typename ContiguousContainer::value_type>>>>
 ArrayView (ContiguousContainer &container)
 
template<std::size_t N>
 ArrayView (value_type(&array)[N])
 
 ArrayView (const std::initializer_list< std::remove_cv_t< value_type > > &initializer_list)
 
void reinit (value_type *starting_element, const std::size_t n_elements)
 
bool operator== (const ArrayView< const value_type, MemorySpaceType > &other_view) const
 
bool operator== (const ArrayView< std::remove_cv_t< value_type >, MemorySpaceType > &other_view) const
 
bool operator!= (const ArrayView< const value_type, MemorySpaceType > &other_view) const
 
bool operator!= (const ArrayView< std::remove_cv_t< value_type >, MemorySpaceType > &other_view) const
 
std::size_t size () const
 
bool empty () const
 
value_typedata () const noexcept
 
iterator begin () const
 
iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
value_typeoperator[] (const std::size_t i) const
 

Private Attributes

value_typestarting_element
 
std::size_t n_elements
 

Friends

class ArrayView< const ElementType, MemorySpaceType >
 

Related Symbols

(Note that these are not member symbols.)

template<typename Iterator , typename MemorySpaceType = MemorySpace::Host>
ArrayView< std::remove_reference_t< typename std::iterator_traits< Iterator >::reference >, 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<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)
 

Detailed Description

template<typename ElementType, typename MemorySpaceType = MemorySpace::Host>
class ArrayView< ElementType, MemorySpaceType >

A class that represents a window of memory locations of type ElementType and presents it as if it was an array. In essence, this class is nothing more than just a pointer to the first location and an integer that represents the length of the array in elements. The memory remains owned by whoever allocated it, as this class does not take over ownership.

The advantage of using this class is that you don't have to pass around pairs of pointers and that operator[] checks for the validity of the index with which you subscript this array view. Note that accessing elements is only allowed if the underlying data is stored in CPU memory.

This class can handle views to both non-constant and constant memory locations. If you want to represent a view of a constant array, then the template argument type of this class needs to be const as well. The following code snippet gives an example:

std::vector<int> array = get_data(); // a writable array
ArrayView<int> view (&array[5], 5); // a view of elements 5..9 (inclusive)
view[2] = 42; // array[7] is set to 42
ArrayView<const int> const_view (&array[5], 5); // same view, but read-only
int element_7 = const_view[2]; // set element_7 to 42
const_view[2] = 42; // this line won't compile; can't write into this view

In either case, accessing an element of a view does not change the ArrayView object itself, and consequently ArrayView::operator[] is a const function. This corresponds to the notion that a view simply represents a, well, "view" of memory that is owned by someone else. Thus, accessing elements of the view changes the memory managed by some other object, but not the view itself, allowing us to make ArrayView::operator[] a const member function. This is in contrast to, say, std::vector, which manages the memory it points to and changing an element of the std::vector therefore changes the std::vector object itself – consequently, the std::vector::operator[] is non-const.

Note
This class is similar to std::span, but the latter is only available starting in C++20.

Definition at line 87 of file array_view.h.

Member Typedef Documentation

◆ value_type

template<typename ElementType , typename MemorySpaceType = MemorySpace::Host>
using ArrayView< ElementType, MemorySpaceType >::value_type = ElementType

An alias that denotes the "value_type" of this container-like class, i.e., the type of the element it "stores" or points to.

Definition at line 94 of file array_view.h.

◆ iterator

template<typename ElementType , typename MemorySpaceType = MemorySpace::Host>
using ArrayView< ElementType, MemorySpaceType >::iterator = value_type *

An alias for iterators pointing into the array.

Definition at line 99 of file array_view.h.

◆ const_iterator

template<typename ElementType , typename MemorySpaceType = MemorySpace::Host>
using ArrayView< ElementType, MemorySpaceType >::const_iterator = const ElementType *

An alias for const iterators pointing into the array.

Definition at line 104 of file array_view.h.

Constructor & Destructor Documentation

◆ ArrayView() [1/8]

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::ArrayView ( )
inline

Default constructor.

Definition at line 497 of file array_view.h.

◆ ArrayView() [2/8]

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::ArrayView ( value_type starting_element,
const std::size_t  n_elements 
)
inline

Constructor.

Parameters
[in]starting_elementA pointer to the first element of the array this object should represent. The value of this argument is only evaluated if n_elements is larger than zero. Otherwise, the value of this argument is ignored as if the ArrayView object used a nullptr to point to the first element of the array.
[in]n_elementsThe length (in elements) of the chunk of memory this object should represent.
Note
The object that is constructed from these arguments has no knowledge how large the object into which it points really is. As a consequence, whenever you call ArrayView::operator[], the array view can check that the given index is within the range of the view, but it can't check that the view is indeed a subset of the valid range of elements of the underlying object that allocated that range. In other words, you need to ensure that the range of the view specified by the two arguments to this constructor is in fact a subset of the elements of the array into which it points. The appropriate way to do this is to use the make_array_view() functions.

Definition at line 505 of file array_view.h.

◆ ArrayView() [3/8]

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::ArrayView ( const ArrayView< std::remove_cv_t< value_type >, MemorySpaceType > &  view)
inline

Copy constructor from array views that point to non-const elements. If the current object will point to non-const elements, then this is a straight forward copy constructor. On the other hand, if the current type's ElementType template argument is a const qualified type, then the current constructor is a conversion constructor that converts a non-const view to a const view, akin to converting a non-const pointer to a const pointer.

Definition at line 546 of file array_view.h.

◆ ArrayView() [4/8]

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::ArrayView ( value_type element)
inlineexplicit

A constructor that automatically creates a view from a single value_type object. The view so created then has length one.

Definition at line 538 of file array_view.h.

◆ ArrayView() [5/8]

template<typename ElementType , typename MemorySpaceType >
template<typename ContiguousContainer , typename , typename , typename >
ArrayView< ElementType, MemorySpaceType >::ArrayView ( const ContiguousContainer &  container)
inline

A constructor that automatically creates a view from a container object that requires a contiguous array of elements (such as std::vector, std::array, boost::container::small_vector, and the like). The view encompasses all elements of the given container.

This implicit conversion constructor is particularly useful when calling a function that takes an ArrayView object as argument, and passing in a container.

Note
This constructor takes a reference to a const container as argument. It can only be used to initialize ArrayView objects that point to const memory locations, such as ArrayView<const double>. You cannot initialize ArrayView objects to non-const memory with such arguments, such as ArrayView<double>.

Definition at line 587 of file array_view.h.

◆ ArrayView() [6/8]

template<typename ElementType , typename MemorySpaceType >
template<typename ContiguousContainer , typename , typename , typename >
ArrayView< ElementType, MemorySpaceType >::ArrayView ( ContiguousContainer &  container)
inline

A constructor that automatically creates a view from a container object that requires a contiguous array of elements (such as std::vector, std::array, boost::container::small_vector, and the like). The view encompasses all elements of the given container.

This implicit conversion constructor is particularly useful when calling a function that takes an ArrayView object as argument, and passing in a container.

Note
This constructor takes a reference to a non-const container as argument. It can be used to initialize ArrayView objects that point to either const memory locations, such as ArrayView<const double>, or to non-const memory, such as ArrayView<double>.

Definition at line 597 of file array_view.h.

◆ ArrayView() [7/8]

template<typename ElementType , typename MemorySpaceType >
template<std::size_t N>
ArrayView< ElementType, MemorySpaceType >::ArrayView ( value_type(&)  array[N])
inline

A constructor that automatically creates a view for a given C-style array. This constructor can be used as follows:

get_data_table ()
{
static const int my_data[7] = { 1, 1, 2, 3, 5, 8, 13 };
return {my_data};
}

The object so returned is then a view of the array, with the size 7 correctly deduced.

Definition at line 609 of file array_view.h.

◆ ArrayView() [8/8]

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::ArrayView ( const std::initializer_list< std::remove_cv_t< value_type > > &  initializer_list)
inline

A constructor that creates a view of the array that underlies a std::initializer_list. This constructor allows for cases such as where one has a function that takes an ArrayView object:

void f(const ArrayView<const int> &a);

and then to call this function with a list of integers:

f({1,2,3});

This also works with an empty list:

f({});
@encode
@note This constructor only works if the template type is `const`
qualified. That is, you can initialize an `ArrayView<const int>`
object from a `std::initializer_list<int>`, but not an
`ArrayView<int>` object. This is because the elements of initializer
lists are `const`.
@note `std::initializer_list` objects are temporary. They are constructed
where the compiler finds a brace-enclosed list, and so they only live
for at most the time it takes to execute the current statement. As a
consequence, creating an ArrayView object of such a `std::initializer_list`
also results in a view object that points to valid memory only for as long
as the current statement is executed. You shouldn't expect that the
resulting ArrayView can be used to point to useful memory content past
that point. In other words, while this code...
@code
std::vector<int> v(10);
ArrayView<int> a(v);
f(a);

...works because the array v pointed to exists until after the call to f(), the following code will not likely work as expected:

ArrayView<int> a({1,2,3});
f(a);

Definition at line 616 of file array_view.h.

Member Function Documentation

◆ reinit()

template<typename ElementType , typename MemorySpaceType >
void ArrayView< ElementType, MemorySpaceType >::reinit ( value_type starting_element,
const std::size_t  n_elements 
)
inline

Reinitialize a view.

Parameters
[in]starting_elementA pointer to the first element of the array this object should represent.
[in]n_elementsThe length (in elements) of the chunk of memory this object should represent.
Note
The object that is constructed from these arguments has no knowledge how large the object into which it points really is. As a consequence, whenever you call ArrayView::operator[], the array view can check that the given index is within the range of the view, but it can't check that the view is indeed a subset of the valid range of elements of the underlying object that allocated that range. In other words, you need to ensure that the range of the view specified by the two arguments to this constructor is in fact a subset of the elements of the array into which it points. The appropriate way to do this is to use the make_array_view() functions.

Definition at line 521 of file array_view.h.

◆ operator==() [1/2]

template<typename ElementType , typename MemorySpaceType >
bool ArrayView< ElementType, MemorySpaceType >::operator== ( const ArrayView< const value_type, MemorySpaceType > &  other_view) const
inline

Compare two ArrayView objects of the same type. Two objects are considered equal if they have the same size and the same starting pointer.

Note that this means that the operation tests that the views are the same. If they are, then of course the elements represented by the view are also the same. But the converse is not true: Two ArrayView objects may point to different parts of the memory space and in that case the comparison for equality will return false even if the elements the views point to are the same.

This version always compares with the const value_type.

Definition at line 627 of file array_view.h.

◆ operator==() [2/2]

template<typename ElementType , typename MemorySpaceType >
bool ArrayView< ElementType, MemorySpaceType >::operator== ( const ArrayView< std::remove_cv_t< value_type >, MemorySpaceType > &  other_view) const
inline

Compare two ArrayView objects of the same type. Two objects are considered equal if they have the same size and the same starting pointer.

Note that this means that the operation tests that the views are the same. If they are, then of course the elements represented by the view are also the same. But the converse is not true: Two ArrayView objects may point to different parts of the memory space and in that case the comparison for equality will return false even if the elements the views point to are the same.

This version always compares with the non-const value_type.

Definition at line 638 of file array_view.h.

◆ operator!=() [1/2]

template<typename ElementType , typename MemorySpaceType >
bool ArrayView< ElementType, MemorySpaceType >::operator!= ( const ArrayView< const value_type, MemorySpaceType > &  other_view) const
inline

Compare two ArrayView objects of the same type. Two objects are considered equal if they have the same size and the same starting pointer, and the current operation therefore returns true if the two views being compared point to different memory locations, or if they point to the same memory location but represent different sizes.

Note that this means that the operation tests that the views are the not the same. But this does not mean that the elements pointed to by the view are not equal: Two ArrayView objects may point to different parts of the memory space and in that case the comparison for inequality will return true even if the elements the views point to are the same.

This version always compares with the const value_type.

Definition at line 650 of file array_view.h.

◆ operator!=() [2/2]

template<typename ElementType , typename MemorySpaceType >
bool ArrayView< ElementType, MemorySpaceType >::operator!= ( const ArrayView< std::remove_cv_t< value_type >, MemorySpaceType > &  other_view) const
inline

Compare two ArrayView objects of the same type. Two objects are considered equal if they have the same size and the same starting pointer.

Note that this means that the operation tests that the views are the not the same. But this does not mean that the elements pointed to by the view are not equal: Two ArrayView objects may point to different parts of the memory space and in that case the comparison for inequality will return true even if the elements the views point to are the same.

This version always compares with the non-const value_type.

Definition at line 673 of file array_view.h.

◆ size()

template<typename ElementType , typename MemorySpaceType >
std::size_t ArrayView< ElementType, MemorySpaceType >::size ( ) const
inline

Return the size (in elements) of the view of memory this object represents.

Definition at line 684 of file array_view.h.

◆ empty()

template<typename ElementType , typename MemorySpaceType >
bool ArrayView< ElementType, MemorySpaceType >::empty ( ) const
inline

Return a bool whether the array view is empty.

Definition at line 693 of file array_view.h.

◆ data()

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::value_type * ArrayView< ElementType, MemorySpaceType >::data ( ) const
inlinenoexcept

Return a pointer to the underlying array serving as element storage. In case the container is empty a nullptr is returned.

Definition at line 661 of file array_view.h.

◆ begin()

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::iterator ArrayView< ElementType, MemorySpaceType >::begin ( ) const
inline

Return an iterator pointing to the beginning of the array view.

Definition at line 702 of file array_view.h.

◆ end()

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::iterator ArrayView< ElementType, MemorySpaceType >::end ( ) const
inline

Return an iterator pointing to one past the end of the array view.

Definition at line 711 of file array_view.h.

◆ cbegin()

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::const_iterator ArrayView< ElementType, MemorySpaceType >::cbegin ( ) const
inline

Return a constant iterator pointing to the beginning of the array view.

Definition at line 720 of file array_view.h.

◆ cend()

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::const_iterator ArrayView< ElementType, MemorySpaceType >::cend ( ) const
inline

Return a constant iterator pointing to one past the end of the array view.

Definition at line 729 of file array_view.h.

◆ operator[]()

template<typename ElementType , typename MemorySpaceType >
ArrayView< ElementType, MemorySpaceType >::value_type & ArrayView< ElementType, MemorySpaceType >::operator[] ( const std::size_t  i) const
inline

Return a reference to the \(i\)th element of the range represented by the current object.

This function is marked as const because it does not change the view object. It may however return a reference to a non-const memory location depending on whether the template type of the class is const or not.

This function is only allowed to be called if the underlying data is indeed stored in CPU memory.

Definition at line 738 of file array_view.h.

Friends And Related Symbol Documentation

◆ ArrayView< const ElementType, MemorySpaceType >

template<typename ElementType , typename MemorySpaceType = MemorySpace::Host>
friend class ArrayView< const ElementType, MemorySpaceType >
friend

Definition at line 486 of file array_view.h.

◆ make_array_view() [1/25]

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

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/25]

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

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/25]

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

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/25]

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

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/25]

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

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 1048 of file array_view.h.

◆ make_array_view() [6/25]

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

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 1071 of file array_view.h.

◆ make_array_view() [7/25]

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

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 1094 of file array_view.h.

◆ make_array_view() [8/25]

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

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 1117 of file array_view.h.

◆ make_array_view() [9/25]

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

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 1140 of file array_view.h.

◆ make_array_view() [10/25]

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 
)
related

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 1168 of file array_view.h.

◆ make_array_view() [11/25]

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 
)
related

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 1202 of file array_view.h.

◆ make_array_view() [12/25]

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

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 1224 of file array_view.h.

◆ make_array_view() [13/25]

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

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 1240 of file array_view.h.

◆ make_array_view() [14/25]

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

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 1256 of file array_view.h.

◆ make_array_view() [15/25]

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 
)
related

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 1278 of file array_view.h.

◆ make_array_view() [16/25]

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

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 1307 of file array_view.h.

◆ make_array_view() [17/25]

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

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 1330 of file array_view.h.

◆ make_array_view() [18/25]

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

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 1355 of file array_view.h.

◆ make_array_view() [19/25]

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

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 1382 of file array_view.h.

◆ make_array_view() [20/25]

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

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 1407 of file array_view.h.

◆ make_array_view() [21/25]

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

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 1432 of file array_view.h.

◆ make_array_view() [22/25]

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

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 1457 of file array_view.h.

◆ make_array_view() [23/25]

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

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 1482 of file array_view.h.

◆ make_array_view() [24/25]

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 
)
related

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 1512 of file array_view.h.

◆ make_array_view() [25/25]

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 
)
related

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 1549 of file array_view.h.

Member Data Documentation

◆ starting_element

template<typename ElementType , typename MemorySpaceType = MemorySpace::Host>
value_type* ArrayView< ElementType, MemorySpaceType >::starting_element
private

A pointer to the first element of the range of locations in memory that this object represents.

Definition at line 481 of file array_view.h.

◆ n_elements

template<typename ElementType , typename MemorySpaceType = MemorySpace::Host>
std::size_t ArrayView< ElementType, MemorySpaceType >::n_elements
private

The length of the array this object represents.

Definition at line 486 of file array_view.h.


The documentation for this class was generated from the following file: