Discontinuous Galerkin Library
#include "dg/algorithm.h"
|
A vector view class, usable in dg
functions.
More...
Public Types | |
using | iterator = std::conditional_t< std::is_const< ThrustVector >::value, typename ThrustVector::const_iterator, typename ThrustVector::iterator > |
using | const_iterator = typename ThrustVector::const_iterator |
using | pointer = std::conditional_t< std::is_const< ThrustVector >::value, typename ThrustVector::const_pointer, typename ThrustVector::pointer > |
using | const_pointer = typename ThrustVector::const_pointer |
Public Member Functions | |
View (void) | |
Initialize empty view. More... | |
template<class OtherView > | |
View (OtherView &src) | |
Construct from another View or Vector. More... | |
template<class InputIterator > | |
View (InputIterator data, unsigned size) | |
Construct view from pointer and size. More... | |
template<class InputIterator > | |
void | construct (InputIterator data, unsigned size) |
Construct view from pointer and size. More... | |
pointer | data () const |
Constant Reference of the pointer. More... | |
iterator | begin () const |
Iterator to the beginning. More... | |
const_iterator | cbegin () const |
const Iterator to the beginning More... | |
iterator | end () const |
Iterator to the end. More... | |
const_iterator | cend () const |
const Iterator to the end More... | |
unsigned | size () const |
Get the size. More... | |
void | swap (View &src) |
Swap pointer and size with another View. More... | |
A vector view class, usable in dg
functions.
The view class holds a pointer and a size. It does not own the pointer. The user is responsible for allocating and deallocating memory. The intention is to use Views in dg::blas1
functions.
The class can be used as a traditional "view" in the sense that it can view part of a larger contiguous chunk of data and thus apply operations to only part of that data. The second use would be to imitate for example a full dg::DVec
without allocating or copying memory for it. This might be useful if you want to use the dg::blas1
functions without specializing TensorTraits
for your own vector class or deep copying data, like the following example demonstrates:
dg::construct
or dg::assign
View
of an MPI_Vector
but you can have an MPI_Vector
of View
ThrustVector | TensorTraits exists for this class and the tensor_category derives from ThrustVectorTag |
using dg::View< ThrustVector >::const_iterator = typename ThrustVector::const_iterator |
using dg::View< ThrustVector >::const_pointer = typename ThrustVector::const_pointer |
using dg::View< ThrustVector >::iterator = std::conditional_t<std::is_const<ThrustVector>::value, typename ThrustVector::const_iterator, typename ThrustVector::iterator> |
using dg::View< ThrustVector >::pointer = std::conditional_t<std::is_const<ThrustVector>::value, typename ThrustVector::const_pointer, typename ThrustVector::pointer> |
|
inline |
Initialize empty view.
|
inline |
|
inline |
Construct view from pointer and size.
data | the beginning of the contiguous chunk of data |
size | the number of elements in the contiguous chunk of data |
InputIterator | pointer must be constructible from this type |
Iterator to the beginning.
|
inline |
const Iterator to the beginning
|
inline |
const Iterator to the end
|
inline |
Construct view from pointer and size.
data | the beginning of the contiguous chunk of data |
size | the number of elements in the contiguous chunk of data |
InputIterator | pointer must be constructible from this type |
Constant Reference of the pointer.
Iterator to the end.
|
inline |
Get the size.
|
inline |
Swap pointer and size with another View.
src | the source view |