42 #include "Thyra_VectorBase.hpp" 44 #ifndef THYRA_EXPLICIT_VECTOR_VIEW_HPP 45 #define THYRA_EXPLICIT_VECTOR_VIEW_HPP 71 template<
class Scalar>
112 ,
const Range1D &rng =
Range1D(),
const bool forceUnitStride =
false 115 this->initialize(v,rng,forceUnitStride);
154 const Range1D &rng =
Range1D(),
const bool forceUnitStride =
false )
156 this->initialize(Teuchos::rcp(&v,
false),rng,forceUnitStride);
164 if( sv_s_.stride() != sv_.stride() )
165 delete [] const_cast<Scalar*>(sv_.values().get());
166 v_->releaseDetachedView(&sv_s_);
178 Teuchos_Ordinal
subDim()
const {
return sv_.subDim(); }
183 const Scalar*
values()
const {
return sv_.values().get(); }
188 ptrdiff_t
stride()
const {
return sv_.stride(); }
193 const Scalar&
operator[](Teuchos_Ordinal i)
const {
return sv_[i]; }
198 const Scalar&
operator()(Teuchos_Ordinal i)
const {
return sv_(i); }
202 Teuchos::RCP<const VectorBase<Scalar> > v_;
208 const Range1D &rng,
const bool forceUnitStride
213 if( forceUnitStride && sv_s_.
stride() != 1 ) {
214 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"I don't think non-unit stride has ever been tested!");
228 ConstDetachedVectorView<Scalar>& operator==(
const ConstDetachedVectorView<Scalar>&);
253 template<
class Scalar>
295 ,
const Range1D &rng =
Range1D(),
const bool forceUnitStride =
false 298 this->initialize(v,rng,forceUnitStride);
336 this->initialize(Teuchos::rcp(&v,
false),rng,forceUnitStride);
345 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"I don't think non-unit stride has ever been tested!");
357 v_->commitDetachedView(&sv_s_);
384 Scalar&
operator[](Teuchos_Ordinal i)
const {
return sv_[i]; }
388 Scalar&
operator()(Teuchos_Ordinal i)
const {
return sv_(i); }
392 Teuchos::RCP<VectorBase<Scalar> > v_;
398 ,
const Range1D &rng,
const bool forceUnitStride
403 if( forceUnitStride && sv_s_.
stride() != 1 ) {
404 TEUCHOS_TEST_FOR_EXCEPT_MSG(
true,
"I don't think non-unit stride has ever been tested!");
419 DetachedVectorView<Scalar>& operator==(
const DetachedVectorView<Scalar>&);
427 #endif // THYRA_EXPLICIT_VECTOR_VIEW_HPP const RTOpPack::SubVectorView< Scalar > & sv() const
Returns the explicit view as an RTOpPack::ConstSubVectorView<Scalar> object.
Teuchos_Ordinal globalOffset() const
Returns the global offset for the explicit view.
~ConstDetachedVectorView()
Free the explicit view on the VectorBase object v passed to ConstDetachedVectorView().
void acquireDetachedView(const Range1D &rng, RTOpPack::ConstSubVectorView< Scalar > *sub_vec) const
Calls acquireDetachedVectorViewImpl().
Teuchos_Ordinal globalOffset() const
Returns the global offset for the explicit view.
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 & operator()(Teuchos_Ordinal i) const
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).
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 non-mutable (const) view of a VectorBase object.
Ordinal globalOffset() const
Scalar & operator[](Teuchos_Ordinal i) const
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).
const ArrayRCP< const Scalar > values() const
Scalar * values() const
Return a pointer to a Scalar array containing the explicit view.
Create an explicit mutable (non-const) view of a VectorBase object.
~DetachedVectorView()
Commits back the the explicit view on the VectorBase object v passed to DetachedVectorView().
const Scalar & operator[](Teuchos_Ordinal i) const
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).
Abstract interface for finite-dimensional dense vectors.
const Scalar & operator()(Teuchos_Ordinal i) const
Zero-based indexing: Preconditions: values()!=NULL && (0 <= i < subDim()-1).
DetachedVectorView(VectorBase< Scalar > &v, const Range1D &rng=Range1D(), const bool forceUnitStride=false)
Construct an explicit mutable (non-const) view of a subset of elements.
ptrdiff_t stride() const
Return the stride between elements in the array returned from this->values().
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().
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 RTOpPack::ConstSubVectorView< Scalar > & sv() const
Returns the explicit view as an RTOpPack::ConstSubVectorView<Scalar> object.
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.