42 #include "AbstractLinAlgPack_VectorMutable.hpp"
43 #include "AbstractLinAlgPack_VectorMutableSubView.hpp"
44 #include "AbstractLinAlgPack_VectorSpace.hpp"
49 #include "RTOpPack_RTOpC.hpp"
50 #include "Teuchos_Assert.hpp"
66 class init_rtop_server_t {
68 init_rtop_server_t() {
75 RTOp_sparse_sub_vector_null(&spc_sub_vec);
84 init_rtop_server_t init_rtop_server;
88 namespace AbstractLinAlgPack {
96 AbstractLinAlgPack::apply_op(assign_scalar_op,0,NULL,1,targ_vecs,NULL);
102 if( dynamic_cast<const void*>(&vec) == dynamic_cast<const void*>(
this) )
104 const Vector* vecs[1] = { &vec };
106 AbstractLinAlgPack::apply_op(assign_vec_op,1,vecs,1,targ_vecs,NULL);
112 return this->
operator=(static_cast<const Vector&>(vec));
119 AbstractLinAlgPack::apply_op(
120 assign_scalar_op,0,NULL,1,targ_vecs,NULL
128 namespace rcp = MemMngPack;
129 const index_type
dim = this->
dim();
134 ,
"VectorMutable::sub_view(rng): Error, rng = ["<<rng.
lbound()<<
","<<rng.
ubound()<<
"] "
135 "is not in the range [1,this->dim()] = [1,"<<dim<<
"]" );
156 const Vector* vecs[1] = { &x };
158 AbstractLinAlgPack::apply_op(axpy_op,1,vecs,1,targ_vecs,NULL);
172 RTOpPack::SubVector sub_vec;
174 sub_vec_inout->initialize(
175 sub_vec.globalOffset(),sub_vec.subDim(),
const_cast<value_type*
>(sub_vec.values()),sub_vec.stride());
180 RTOpPack::SparseSubVector spc_sub_vec(
181 sub_vec_inout->globalOffset(), sub_vec_inout->subDim(),
182 Teuchos::arcp(sub_vec_inout->values(), 0, sub_vec_inout->stride()*sub_vec_inout->subDim(),
false),
183 sub_vec_inout->stride()
186 RTOpPack::SubVector sub_vec(*sub_vec_inout);
188 sub_vec_inout->set_uninitialized();
194 if (!
is_null(sub_vec.indices())) {
195 RTOp_sparse_sub_vector(
196 sub_vec.globalOffset(), sub_vec.subDim(), sub_vec.subNz(),
197 sub_vec.values().get(), sub_vec.valuesStride(),
198 sub_vec.indices().get(), sub_vec.indicesStride(),
199 sub_vec.localOffset(), sub_vec.isSorted(),
206 sub_vec.globalOffset(), sub_vec.subDim(),
207 sub_vec.values().get(), sub_vec.valuesStride(),
210 RTOp_sparse_sub_vector_from_dense( &_sub_vec, &spc_sub_vec );
215 AbstractLinAlgPack::apply_op(
216 set_sub_vector_op,0,NULL,1,targ_vecs,NULL
217 ,sub_vec.globalOffset()+1,sub_vec.subDim(),sub_vec.globalOffset()
230 true, std::logic_error
231 ,
"VectorMutable::Vp_StMtV(...): Error, this function has not yet been "
232 "given a default implementation and has not been overridden for the "
233 "subclass \'" <<
typeName(*
this) <<
"\'!"
244 namespace rcp = MemMngPack;
virtual vec_mut_ptr_t sub_view(const Range1D &rng)
Create a mutable abstract view of a vector object.
virtual void set_sub_vector(const RTOpPack::SparseSubVector &sub_vec)
Set a specific sub-vector.
virtual void get_sub_vector(const Range1D &rng, RTOpPack::SubVector *sub_vec) const
Get a non-mutable explicit view of a sub-vector.
bool is_null(const boost::shared_ptr< T > &p)
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
virtual void commit_sub_vector(RTOpPack::MutableSubVector *sub_vec)
Free a mutable explicit view of a sub-vector.
void RTOp_sub_vector(RTOp_index_type global_offset, RTOp_index_type sub_dim, const RTOp_value_type values[], ptrdiff_t values_stride, struct RTOp_SubVector *sub_vec)
virtual void set_ele(index_type i, value_type val)
Set a specific element of a vector.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
virtual void zero()
Zeros this vector.
virtual void axpy(value_type alpha, const Vector &x)
Adds a linear combination of another vector to this vector object.
Concrete subclass for a sub-view of a VectorMutable object.
virtual void free_sub_vector(RTOpPack::SubVector *sub_vec) const
Free an explicit view of a sub-vector.
virtual index_type dim() const
Return the dimension of this vector.
virtual VectorMutable & operator=(value_type alpha)
Assign the elements of this vector to a scalar.
virtual void get_sub_vector(const Range1D &rng, RTOpPack::MutableSubVector *sub_vec)
Get a mutable explicit view of a sub-vector.
Abstract interface for mutable coordinate vectors {abstract}.
virtual void Vp_StMtV(value_type alpha, const GenPermMatrixSlice &P, BLAS_Cpp::Transp P_trans, const Vector &x, value_type beta)
Perform a gather or scatter operation with a vector.
int RTOp_TOp_set_sub_vector_construct(const struct RTOp_SparseSubVector *sub_vec, struct RTOp_RTOp *op)
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Concrete matrix type to represent general permutation (mapping) matrices.
std::string typeName(const T &t)