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); }
208 const Range1D &rng,
const bool forceUnitStride
212 v_->acquireDetachedView(rng,&sv_s_);
213 if( forceUnitStride && sv_s_.stride() != 1 ) {
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);
344 if( sv_s_.stride() != sv_.stride() ) {
357 v_->commitDetachedView(&sv_s_);
369 Teuchos_Ordinal
subDim()
const {
return sv_.subDim(); }
374 Scalar*
values()
const {
return sv_.values().get(); }
379 ptrdiff_t
stride()
const {
return sv_.stride(); }
384 Scalar&
operator[](Teuchos_Ordinal i)
const {
return sv_[i]; }
388 Scalar&
operator()(Teuchos_Ordinal i)
const {
return sv_(i); }
398 ,
const Range1D &rng,
const bool forceUnitStride
402 v_->acquireDetachedView(rng,&sv_s_);
403 if( forceUnitStride && sv_s_.stride() != 1 ) {
419 DetachedVectorView<Scalar>& operator==(
const DetachedVectorView<Scalar>&);
427 #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[[noreturn]] 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.