Thyra Package Browser (Single Doxygen Collection) Version of the Day
Public Member Functions | Private Member Functions | Private Attributes
Thyra::ConstDetachedVectorView< Scalar > Class Template Reference

Create an explicit non-mutable (const) view of a VectorBase object. More...

#include <Thyra_DetachedVectorView.hpp>

List of all members.

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.
 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.
 ~ConstDetachedVectorView ()
 Free the explicit view on the VectorBase object v passed to ConstDetachedVectorView().
const
RTOpPack::ConstSubVectorView
< Scalar > & 
sv () const
 Returns the explicit view as an RTOpPack::ConstSubVectorView<Scalar> object.
Teuchos_Index globalOffset () const
 Returns the global offset for the explicit view.
Teuchos_Index subDim () const
 Returns the dimension of the explicit view.
const Scalar * values () const
 Return a pointer to a Scalar array containing the explicit view.
ptrdiff_t stride () const
 Return the stride between elements in the array returned from this->values().
const Scalar & operator[] (Teuchos_Index i) const
 Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).
const Scalar & operator() (Teuchos_Index i) const
 Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).

Private Member Functions

void initialize (const Teuchos::RCP< const VectorBase< Scalar > > &v, const Range1D &rng, const bool forceUnitStride)
 ConstDetachedVectorView ()
 ConstDetachedVectorView (const ConstDetachedVectorView< Scalar > &)
ConstDetachedVectorView< Scalar > & operator== (const ConstDetachedVectorView< Scalar > &)

Private Attributes

Teuchos::RCP< const VectorBase
< Scalar > > 
v_
RTOpPack::ConstSubVectorView
< Scalar > 
sv_s_
RTOpPack::ConstSubVectorView
< Scalar > 
sv_

Detailed Description

template<class Scalar>
class Thyra::ConstDetachedVectorView< Scalar >

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 59 of file Thyra_DetachedVectorView.hpp.


Constructor & Destructor Documentation

template<class Scalar>
Thyra::ConstDetachedVectorView< Scalar >::ConstDetachedVectorView ( const Teuchos::RCP< const VectorBase< Scalar > > &  v,
const Range1D rng = Range1D(),
const bool  forceUnitStride = false 
) [inline]

Construct an explicit non-mutable (const) view of a subset of elements.

Parameters:
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:

Definition at line 97 of file Thyra_DetachedVectorView.hpp.

References Thyra::ConstDetachedVectorView< Scalar >::initialize().

template<class Scalar>
Thyra::ConstDetachedVectorView< Scalar >::ConstDetachedVectorView ( const VectorBase< Scalar > &  v,
const Range1D rng = Range1D(),
const bool  forceUnitStride = false 
) [inline]

Construct an explicit non-mutable (const) view of a subset of elements.

Parameters:
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:

Definition at line 140 of file Thyra_DetachedVectorView.hpp.

References Thyra::ConstDetachedVectorView< Scalar >::initialize(), and Teuchos::rcp().

template<class Scalar>
Thyra::ConstDetachedVectorView< Scalar >::~ConstDetachedVectorView ( ) [inline]
template<class Scalar>
Thyra::ConstDetachedVectorView< Scalar >::ConstDetachedVectorView ( ) [private]
template<class Scalar>
Thyra::ConstDetachedVectorView< Scalar >::ConstDetachedVectorView ( const ConstDetachedVectorView< Scalar > &  ) [private]

Member Function Documentation

template<class Scalar>
const RTOpPack::ConstSubVectorView<Scalar>& Thyra::ConstDetachedVectorView< Scalar >::sv ( ) const [inline]

Returns the explicit view as an RTOpPack::ConstSubVectorView<Scalar> object.

Definition at line 159 of file Thyra_DetachedVectorView.hpp.

References Thyra::ConstDetachedVectorView< Scalar >::sv_.

template<class Scalar>
Teuchos_Index Thyra::ConstDetachedVectorView< Scalar >::globalOffset ( ) const [inline]

Returns the global offset for the explicit view.

Definition at line 162 of file Thyra_DetachedVectorView.hpp.

References Thyra::ConstDetachedVectorView< Scalar >::sv_.

template<class Scalar>
Teuchos_Index Thyra::ConstDetachedVectorView< Scalar >::subDim ( ) const [inline]

Returns the dimension of the explicit view.

Definition at line 165 of file Thyra_DetachedVectorView.hpp.

References Thyra::ConstDetachedVectorView< Scalar >::sv_.

Referenced by Thyra::VectorDefaultBase< Scalar >::describe().

template<class Scalar>
const Scalar* Thyra::ConstDetachedVectorView< Scalar >::values ( ) const [inline]

Return a pointer to a Scalar array containing the explicit view.

Definition at line 170 of file Thyra_DetachedVectorView.hpp.

References Thyra::ConstDetachedVectorView< Scalar >::sv_.

template<class Scalar>
ptrdiff_t Thyra::ConstDetachedVectorView< Scalar >::stride ( ) const [inline]

Return the stride between elements in the array returned from this->values().

Definition at line 175 of file Thyra_DetachedVectorView.hpp.

References Thyra::ConstDetachedVectorView< Scalar >::sv_.

template<class Scalar>
const Scalar& Thyra::ConstDetachedVectorView< Scalar >::operator[] ( Teuchos_Index  i) const [inline]

Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).

Definition at line 180 of file Thyra_DetachedVectorView.hpp.

References Thyra::ConstDetachedVectorView< Scalar >::sv_.

template<class Scalar>
const Scalar& Thyra::ConstDetachedVectorView< Scalar >::operator() ( Teuchos_Index  i) const [inline]

Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).

Definition at line 185 of file Thyra_DetachedVectorView.hpp.

References Thyra::ConstDetachedVectorView< Scalar >::sv_.

template<class Scalar>
void Thyra::ConstDetachedVectorView< Scalar >::initialize ( const Teuchos::RCP< const VectorBase< Scalar > > &  v,
const Range1D rng,
const bool  forceUnitStride 
) [inline, private]
template<class Scalar>
ConstDetachedVectorView<Scalar>& Thyra::ConstDetachedVectorView< Scalar >::operator== ( const ConstDetachedVectorView< Scalar > &  ) [private]

Member Data Documentation

template<class Scalar>
Teuchos::RCP<const VectorBase<Scalar> > Thyra::ConstDetachedVectorView< Scalar >::v_ [private]
template<class Scalar>
RTOpPack::ConstSubVectorView<Scalar> Thyra::ConstDetachedVectorView< Scalar >::sv_s_ [private]
template<class Scalar>
RTOpPack::ConstSubVectorView<Scalar> Thyra::ConstDetachedVectorView< Scalar >::sv_ [private]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines