89 class init_rtop_server_t {
91 init_rtop_server_t() {
94 sum_targ = sum_op.reduct_obj_create();
97 num_nonzeros_targ = num_nonzeros_op.reduct_obj_create();
100 norm_1_targ = norm_1_op.reduct_obj_create();
103 norm_2_targ = norm_2_op.reduct_obj_create();
106 norm_inf_targ = norm_inf_op.reduct_obj_create();
114 init_rtop_server_t init_rtop_server;
120 namespace AbstractLinAlgPack {
124 :num_nonzeros_(-1), norm_1_(-1.0), norm_2_(-1.0), norm_inf_(-1.0)
136 #ifdef ALAP_VECTOR_IGNORE_CACHE_DATA
141 num_nonzeros_op.reduct_obj_reinit(num_nonzeros_targ.ptr());
142 const Vector *vecs[1] = {
this };
151 std::ostream& out_arg,
bool print_dim,
bool newline,
177 sum_op.reduct_obj_reinit(sum_targ.ptr());
178 const Vector *vecs[1] = {
this };
180 sum_op,1,vecs,0,NULL,&*sum_targ
189 #ifdef ALAP_VECTOR_IGNORE_CACHE_DATA
194 norm_1_op.reduct_obj_reinit(norm_1_targ.ptr());
195 const Vector *vecs[1] = {
this };
205 #ifdef ALAP_VECTOR_IGNORE_CACHE_DATA
210 norm_2_op.reduct_obj_reinit(norm_2_targ.ptr());
211 const Vector *vecs[1] = {
this };
221 #ifdef ALAP_VECTOR_IGNORE_CACHE_DATA
226 norm_inf_op.reduct_obj_reinit(norm_inf_targ.ptr());
227 const Vector *vecs[1] = {
this };
243 namespace rcp = MemMngPack;
249 ,
"Vector::sub_view(rng): Error, rng = ["<<rng.
lbound()<<
","<<rng.
ubound()<<
"] "
250 "is not in the range [1,this->dim()] = [1,"<<dim<<
"]" );
267 ,
"Vector::get_sub_vector(rng,...): Error, rng = ["<<rng.
lbound()<<
","<<rng.
ubound()
268 <<
"] is not in range = [1,"<<this->
space().
dim()<<
"]" );
271 if( sub_vec_inout->
values() ) {
272 std::free( (
void*)sub_vec_inout->
values() );
280 const size_t num_vecs = 1;
281 const Vector* sub_vecs[num_vecs] = {
this };
283 get_sub_vector_op,num_vecs,sub_vecs,0,NULL,&*reduct_obj
292 reduct_obj.release();
293 std::free(reduct_obj_raw);
301 std::free( (
void*)sub_vec->
values() );
320 for(
size_t k = 0; k < num_targ_vecs; ++k )
333 ,
const size_t num_vecs
335 ,
const size_t num_targ_vecs
337 ,RTOpPack::ReductTarget *reduct_obj
344 vecs[0]->
apply_op(op,num_vecs,vecs,num_targ_vecs,targ_vecs,reduct_obj,first_ele,sub_dim,global_offset);
345 else if (num_targ_vecs)
346 targ_vecs[0]->
apply_op(op,num_vecs,vecs,num_targ_vecs,targ_vecs,reduct_obj,first_ele,sub_dim,global_offset);
virtual vec_ptr_t sub_view(const Range1D &rng) const
Create an abstract view of a vector object .
int RTOp_ROp_norm_inf_construct(struct RTOp_RTOp *op)
int RTOp_ROp_num_nonzeros_construct(struct RTOp_RTOp *op)
RTOp_value_type RTOp_ROp_norm_2_val(RTOp_ReductTarget targ_obj)
virtual const VectorSpace & space() const =0
Return the vector space that this vector belongs to.
virtual void get_sub_vector(const Range1D &rng, RTOpPack::SubVector *sub_vec) const
Get a non-mutable explicit view of a sub-vector.
Adapter subclass that uses a RTOp_RTOp object.
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
RTOp_index_type index_type
virtual value_type norm_1() const
One norm. ||v||_1 = sum( |v(i)|, i = 1,,,this->dim() )
virtual void finalize_apply_op(const size_t num_targ_vecs, VectorMutable **targ_vecs) const
This method usually needs to be called by subclasses at the end of the apply_op() method implementati...
Concrete subclass for a default sub-view implementation for a Vector object.
virtual vec_mut_ptr_t clone() const
Create a clone of this vector objet.
virtual value_type norm_inf() const
Infinity norm. ||v||_inf = max( |v(i)|, i = 1,,,this->dim() )
RTOp_index_type global_offset
RTOp_value_type value_type
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Index size() const
Return the size of the range (ubound() - lbound() + 1)
Teuchos::RCP< const Vector > vec_ptr_t
Index ubound() const
Return upper bound of the range.
const Scalar * values() const
virtual value_type norm_2() const
Two norm. ||v||_2 = sqrt( sum( v(i)^2, i = 1,,,this->dim() ) )
RTOp_index_type RTOp_ROp_num_nonzeros_val(RTOp_ReductTarget targ_obj)
value_type norm_inf_
< 0 == not initialized, > 0 == already calculated
int RTOp_ROp_get_sub_vector_construct(RTOp_index_type l, RTOp_index_type u, struct RTOp_RTOp *op)
index_type num_nonzeros_
< 0 == not initialized, > 0 == already calculated
const RTOp_value_type * values
int RTOp_ROp_norm_2_construct(struct RTOp_RTOp *op)
const InnerProduct * inner_prod
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
. One-based subregion index range class.
virtual void has_changed() const
Must be called by any vector subclass that modifies this vector object!
RTOpT< RTOp_value_type > RTOp
Teuchos_Ordinal subDim() const
virtual std::ostream & output(std::ostream &out, bool print_dim=true, bool newline=true, index_type global_offset=0) const
Virtual output function.
bool full_range() const
Returns true if the range represents the entire region (constructed from Range1D()) ...
RTOp_value_type RTOp_ROp_sum_val(RTOp_ReductTarget targ_obj)
virtual void free_sub_vector(RTOpPack::SubVector *sub_vec) const
Free an explicit view of a sub-vector.
Teuchos_Ordinal globalOffset() const
struct RTOp_SubVector RTOp_ROp_get_sub_vector_val(RTOp_ReductTarget targ_obj)
int RTOp_ROp_sum_construct(struct RTOp_RTOp *op)
RTOp_value_type RTOp_ROp_norm_1_val(RTOp_ReductTarget targ_obj)
virtual index_type dim() const =0
Return the dimmension of the vector space.
Index lbound() const
Return lower bound of the range.
virtual index_type dim() const
Return the dimension of this vector.
virtual index_type nz() const
Return the number of nonzero elements in the vector.
virtual value_type get_ele(index_type i) const
Fetch an element in the vector.
Abstract interface for mutable coordinate vectors {abstract}.
friend void apply_op(const RTOpPack::RTOp &op, const size_t num_vecs, const Vector *vecs[], const size_t num_targ_vecs, VectorMutable *targ_vecs[], RTOpPack::ReductTarget *reduct_obj, const index_type first_ele, const index_type sub_dim, const index_type global_offset)
virtual void apply_op(const RTOpPack::RTOp &op, const size_t num_vecs, const Vector *vecs[], const size_t num_targ_vecs, VectorMutable *targ_vecs[], RTOpPack::ReductTarget *reduct_obj, const index_type first_ele, const index_type sub_dim, const index_type global_offset) const =0
Apply a reduction/transformation,operation over a set of vectors: op(op(v[0]...v[nv-1],z[0]...z[nz-1]),(*reduct_obj)) -> z[0]...z[nz-1],(*reduct_obj).
void apply_op(EApplyBy apply_by, const RTOpPack::RTOp &primary_op, const size_t num_multi_vecs, const MultiVector *multi_vecs[], const size_t num_targ_multi_vecs, MultiVectorMutable *targ_multi_vecs[], RTOpPack::ReductTarget *reduct_objs[]=NULL, const index_type primary_first_ele=1, const index_type primary_sub_dim=0, const index_type primary_global_offset=0, const index_type secondary_first_ele=1, const index_type secondary_sub_dim=0)
Apply a reduction/transformation operator column by column and return an array of the reduction objec...
std::ostream & output(std::ostream &o, const SubVector &v, bool print_dim, bool newline)
Print an RTOp_SubVector.
virtual vec_mut_ptr_t create_member() const =0
Create a vector member from the vector space.
RTOp_value_type RTOp_ROp_norm_inf_val(RTOp_ReductTarget targ_obj)
int RTOp_ROp_norm_1_construct(struct RTOp_RTOp *op)
virtual value_type inner_product(const Vector &v) const
Return the inner product of *this with v.
void initialize(Teuchos_Ordinal globalOffset, Teuchos_Ordinal subDim, const Scalar *values, ptrdiff_t stride)
RangePack::Range1D Range1D
#define TEUCHOS_TEST_FOR_EXCEPT(throw_exception_test)
Class for a non-mutable sub-vector.
virtual value_type inner_prod(const Vector &v1, const Vector &v2) const =0
Compute the inner product of two vectors.