Thyra
Version of the Day
|
Create an explicit non-mutable (const) view of a VectorBase
object.
More...
#include <Thyra_DetachedVectorView.hpp>
Public Member Functions | |
ConstDetachedVectorView (const Teuchos::RCP< const VectorBase< Scalar > > &v, const Range1D &rng=Range1D(), const bool forceUnitStride=false) | |
Construct an explicit non-mutable (const) view of a subset of elements. More... | |
ConstDetachedVectorView (const VectorBase< Scalar > &v, const Range1D &rng=Range1D(), const bool forceUnitStride=false) | |
Construct an explicit non-mutable (const) view of a subset of elements. More... | |
~ConstDetachedVectorView () | |
Free the explicit view on the VectorBase object v passed to ConstDetachedVectorView() . More... | |
const RTOpPack::ConstSubVectorView < Scalar > & | sv () const |
Returns the explicit view as an RTOpPack::ConstSubVectorView<Scalar> object. More... | |
Teuchos_Ordinal | globalOffset () const |
Returns the global offset for the explicit view. More... | |
Teuchos_Ordinal | subDim () const |
Returns the dimension of the explicit view. More... | |
const Scalar * | values () const |
Return a pointer to a Scalar array containing the explicit view. More... | |
ptrdiff_t | stride () const |
Return the stride between elements in the array returned from this->values() . More... | |
const Scalar & | operator[] (Teuchos_Ordinal i) const |
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1) . More... | |
const Scalar & | operator() (Teuchos_Ordinal i) const |
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1) . More... | |
Create an explicit non-mutable (const) view of a VectorBase
object.
This utility class makes it easy to explicitly access a contiguous subset of elements in any const VectorBase
object.
Warning! Creating an explicit view of an arbitrary VectorBase
object may be a very expensive operation (such as with distributed-memory vectors) and should only be done in special cases (such as when the vector is an in-core vector). There several specialized use cases where creating these types of explicit views are necessary but in most cases this should not be done.
If one wants to modify the elements in a VectorBase
object then one should use the utility class DetachedVectorView
.
The default constructor, copy constructor and assignment operators are not allowed.
Definition at line 72 of file Thyra_DetachedVectorView.hpp.
|
inline |
Construct an explicit non-mutable (const) view of a subset of elements.
v | [in] The vector that a view will be taken. This object must be maintained until *this is destroyed. |
rng | [in] the range of element indices that the explicit view will be taken. |
forceUnitStride | [in] If true then the view will have unit stride. |
Preconditions:
[rng.full_range()==false
] rng.ubound() < v.space()->dim()
Postconditions:
this->sv()
returns the created view
this->globalOffset()==rng.lbound()
this->subDim()==rng.size()
this->values()
returns a pointer to a Scalar
array
this->stride()
returns the stride between the elements pointed it in this->values()
[forceUnitStride==true
] this->stride()==1
Definition at line 110 of file Thyra_DetachedVectorView.hpp.
|
inline |
Construct an explicit non-mutable (const) view of a subset of elements.
v | [in] The vector that a view will be taken. This object must be maintained until *this is destroyed. |
rng | [in] the range of element indices that the explicit view will be taken. |
forceUnitStride | [in] If true then the view will have unit stride. |
Preconditions:
[rng.full_range()==false
] rng.ubound() < v.space()->dim()
Postconditions:
this->sv()
returns the created view
this->globalOffset()==rng.lbound()
this->subDim()==rng.size()
this->values()
returns a pointer to a Scalar
array
this->stride()
returns the stride between the elements pointed it in this->values()
[forceUnitStride==true
] this->stride()==1
Definition at line 153 of file Thyra_DetachedVectorView.hpp.
|
inline |
Free the explicit view on the VectorBase
object v
passed to ConstDetachedVectorView()
.
Definition at line 162 of file Thyra_DetachedVectorView.hpp.
|
inline |
Returns the explicit view as an RTOpPack::ConstSubVectorView<Scalar>
object.
Definition at line 172 of file Thyra_DetachedVectorView.hpp.
|
inline |
Returns the global offset for the explicit view.
Definition at line 175 of file Thyra_DetachedVectorView.hpp.
|
inline |
Returns the dimension of the explicit view.
Definition at line 178 of file Thyra_DetachedVectorView.hpp.
|
inline |
Return a pointer to a Scalar
array containing the explicit view.
Definition at line 183 of file Thyra_DetachedVectorView.hpp.
|
inline |
Return the stride between elements in the array returned from this->values()
.
Definition at line 188 of file Thyra_DetachedVectorView.hpp.
|
inline |
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1)
.
Definition at line 193 of file Thyra_DetachedVectorView.hpp.
|
inline |
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1)
.
Definition at line 198 of file Thyra_DetachedVectorView.hpp.