10 #include "Thyra_VectorBase.hpp"
12 #ifndef THYRA_EXPLICIT_VECTOR_VIEW_HPP
13 #define THYRA_EXPLICIT_VECTOR_VIEW_HPP
39 template<
class Scalar>
80 ,
const Range1D &rng =
Range1D(),
const bool forceUnitStride =
false
83 this->initialize(v,rng,forceUnitStride);
122 const Range1D &rng =
Range1D(),
const bool forceUnitStride =
false )
124 this->initialize(
Teuchos::rcp(&v,
false),rng,forceUnitStride);
132 if( sv_s_.stride() != sv_.stride() )
133 delete [] const_cast<Scalar*>(sv_.values().get());
134 v_->releaseDetachedView(&sv_s_);
146 Teuchos_Ordinal
subDim()
const {
return sv_.subDim(); }
151 const Scalar*
values()
const {
return sv_.values().get(); }
156 ptrdiff_t
stride()
const {
return sv_.stride(); }
161 const Scalar&
operator[](Teuchos_Ordinal i)
const {
return sv_[i]; }
166 const Scalar&
operator()(Teuchos_Ordinal i)
const {
return sv_(i); }
176 const Range1D &rng,
const bool forceUnitStride
180 v_->acquireDetachedView(rng,&sv_s_);
181 if( forceUnitStride && sv_s_.stride() != 1 ) {
196 ConstDetachedVectorView<Scalar>& operator==(
const ConstDetachedVectorView<Scalar>&);
221 template<
class Scalar>
263 ,
const Range1D &rng =
Range1D(),
const bool forceUnitStride =
false
266 this->initialize(v,rng,forceUnitStride);
304 this->initialize(
Teuchos::rcp(&v,
false),rng,forceUnitStride);
312 if( sv_s_.stride() != sv_.stride() ) {
325 v_->commitDetachedView(&sv_s_);
337 Teuchos_Ordinal
subDim()
const {
return sv_.subDim(); }
342 Scalar*
values()
const {
return sv_.values().get(); }
347 ptrdiff_t
stride()
const {
return sv_.stride(); }
352 Scalar&
operator[](Teuchos_Ordinal i)
const {
return sv_[i]; }
356 Scalar&
operator()(Teuchos_Ordinal i)
const {
return sv_(i); }
366 ,
const Range1D &rng,
const bool forceUnitStride
370 v_->acquireDetachedView(rng,&sv_s_);
371 if( forceUnitStride && sv_s_.stride() != 1 ) {
387 DetachedVectorView<Scalar>& operator==(
const DetachedVectorView<Scalar>&);
395 #endif // THYRA_EXPLICIT_VECTOR_VIEW_HPP
ptrdiff_t stride() const
Return the stride between elements in the array returned from this->values().
~ConstDetachedVectorView()
Free the explicit view on the VectorBase object v passed to ConstDetachedVectorView().
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.
Scalar * values() const
Return a pointer to a Scalar array containing the explicit view.
Create an explicit non-mutable (const) view of a VectorBase object.
const RTOpPack::SubVectorView< Scalar > & sv() const
Returns the explicit view as an RTOpPack::ConstSubVectorView<Scalar> object.
const RTOpPack::ConstSubVectorView< Scalar > & sv() const
Returns the explicit view as an RTOpPack::ConstSubVectorView<Scalar> object.
TEUCHOSCORE_LIB_DLL_EXPORT void TestForTermination_terminate(const std::string &msg)
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
#define TEUCHOS_TEST_FOR_EXCEPT_MSG(throw_exception_test, msg)
Teuchos_Ordinal globalOffset() const
Returns the global offset for the explicit view.
Teuchos_Ordinal subDim() const
Returns the dimension of the explicit view.
Teuchos_Ordinal subDim() const
Returns the dimension of the explicit view.
Create an explicit mutable (non-const) view of a VectorBase object.
~DetachedVectorView()
Construct an explicit mutable (non-const) view of a subset of elements.
Abstract interface for finite-dimensional dense vectors.
ptrdiff_t stride() const
Return the stride between elements in the array returned from this->values().
Scalar & operator[](Teuchos_Ordinal i) const
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).
const Scalar & operator()(Teuchos_Ordinal i) const
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).
Scalar & operator()(Teuchos_Ordinal i) const
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).
Teuchos_Ordinal globalOffset() const
Returns the global offset for the explicit view.
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.
const Scalar & operator[](Teuchos_Ordinal i) const
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).
DetachedVectorView(const Teuchos::RCP< VectorBase< Scalar > > &v, const Range1D &rng=Range1D(), const bool forceUnitStride=false)
Construct an explicit mutable (non-const) view of a subset of elements.
const Scalar * values() const
Return a pointer to a Scalar array containing the explicit view.