#include <AbstractLinAlgPack_Vector.hpp>
Inheritance diagram for AbstractLinAlgPack::Vector:
Pure virtual methods (must be overridden by subclass)  
virtual const VectorSpace &  space () const =0 
Return the vector space that this vector belongs to.  
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[nv1],z[0]...z[nz1]),(*reduct_obj)) > z[0]...z[nz1],(*reduct_obj) .  
Miscellaneous virtual methods with default implementations  
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 std::ostream &  output (std::ostream &out, bool print_dim=true, bool newline=true, index_type global_offset=0) const 
Virtual output function.  
virtual vec_mut_ptr_t  clone () const 
Create a clone of this vector objet.  
virtual value_type  get_ele (index_type i) const 
Fetch an element in the vector.  
virtual vec_ptr_t  sub_view (const Range1D &rng) const 
Create an abstract view of a vector object .  
Vector norms  
virtual value_type  norm_1 () const 
One norm. v_1 = sum( v(i), i = 1,,,this>dim() ) .  
virtual value_type  norm_2 () const 
Two norm. v_2 = sqrt( sum( v(i)^2, i = 1,,,this>dim() ) ) .  
virtual value_type  norm_inf () const 
Infinity norm. v_inf = max( v(i), i = 1,,,this>dim() ) .  
Inner product  
virtual value_type  inner_product (const Vector &v) const 
Return the inner product of *this with v .  
Explicit subvector access  
virtual void  get_sub_vector (const Range1D &rng, RTOpPack::SubVector *sub_vec) const 
Get a nonmutable explicit view of a subvector.  
virtual void  free_sub_vector (RTOpPack::SubVector *sub_vec) const 
Free an explicit view of a subvector.  
Protected helper functions  
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 implementation to insure that has_changed() is called on the transformed vector objects.  
Public Types  
typedef Teuchos::RefCountPtr< const Vector >  vec_ptr_t 
 
typedef Teuchos::RefCountPtr< VectorMutable >  vec_mut_ptr_t 
 
Public Member Functions  
Vector ()  
 
virtual  ~Vector () 
 
vec_ptr_t  sub_view (const index_type &l, const index_type &u) const 
Inline member function that simply calls this>sub_view(Range1D(l,u)) .  
virtual void  has_changed () const 
Must be called by any vector subclass that modifies this vector object!  
Private Attributes  
index_type  num_nonzeros_ 
< 0 == not initialized, > 0 == already calculated  
value_type  norm_1_ 
value_type  norm_2_ 
value_type  norm_inf_ 
< 0 == not initialized, > 0 == already calculated  
Friends  
void  AbstractLinAlgPack::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) 

This interface contains a mimimal set of operations. The main feature of this interface is the operation apply_op()
. Almost every standard (i.e. BLAS) and nonstandard elementwise operation that can be performed on a set of coordinate vectors without changing (mutating) the vectors can be performed through reduction operators. More standard vector operations could be included in this interface and allow for specialized implementations but in general, assuming the subvectors are large enough, such implementations would not be significantly faster than those implemented through reduction/transformation operators. There are some operations however that can not always be efficiently with reduction/transforamtion operators and a few of these important methods are included in this interface. The apply_op()
method allows to client to specify a subset of the vector elements to include in reduction/transformation operation. This greatly increases the generality of this vector interface as vector objects can be used as sub objects in larger composite vectors and subviews of a vector can be created.
This interface allows clients to create subviews of a vector using sub_view()
that in turn are fully functional Vector
objects. This functionality is supported by default by using a default vector subclass VectorSubView
which in turn calls apply_op()
but the client need not ever worry about how this is done.
This interface also allows a client to extract a subset of elements in an explicit form as an RTOpPack::SubVector object using the method
in order to extract the needed elements.get_sub_vector()
. In general, this is very bad thing to do and should be avoided at all costs. However, there are some applications where this is needed and therefore it is supported. The default implementation of this method uses a reduction/transformation operator with <tt>apply_op()
In order to create a concreate subclass of this interface, only two methods must be overridden. The space()
method must be overridden which in turn requires defining a concreate VectorSpace
class (which has only two pure virtual methods). And, as mentioned above, the apply_op()
method must be overridden as well.
The fact that this interface defines space()
which returns a VectorSpace
object (which in turn can create mutable vectors) implies that for every possible vector object, it is possible to associate with it a mutable vector object that can be the target of transformation operations. This is not a serious limitation. For any application area, mutable vectors should be able to defined and should be usable with the nonmutable vectors.
This interface includes methods for the common vector norms: norm_1()
, norm_2()
, norm_inf()
. The default implementation of this class uses reduction operator classes (See RTOp_ROp_norms.h) and caches away the values of the norms that are computed since it is common that the norms will be accessed many times before a vector is changed. The operations in any subclass that modifies the underlying vector must call the method this>
has_changed() in order to alert this implementation that the norms are no longer valid.
ToDo: Add example code!
Definition at line 174 of file AbstractLinAlgPack_Vector.hpp.

Definition at line 178 of file AbstractLinAlgPack_Vector.hpp. 

Definition at line 180 of file AbstractLinAlgPack_Vector.hpp. 

Definition at line 101 of file AbstractLinAlgPack_Vector.cpp. 

Definition at line 199 of file AbstractLinAlgPack_Vector.hpp. 

Return the vector space that this vector belongs to.
Note that the vectors space object returned is specifically bound to this vector object. The vector space object returned should only be considered to be transient and may become invalid if Implemented in AbstractLinAlgPack::VectorSubView, AbstractLinAlgPack::VectorMutableBlocked, AbstractLinAlgPack::VectorMutableDense, and AbstractLinAlgPack::VectorMutableThyra. 

Apply a reduction/transformation,operation over a set of vectors:
The vector
See the documentation for the method Implemented in AbstractLinAlgPack::VectorSubView, AbstractLinAlgPack::VectorMutableBlocked, AbstractLinAlgPack::VectorMutableDense, and AbstractLinAlgPack::VectorMutableThyra. 

Return the dimension of this vector.
It is allowed for a vector to return a dimension of Reimplemented in AbstractLinAlgPack::VectorSubView, AbstractLinAlgPack::VectorMutableBlocked, AbstractLinAlgPack::VectorMutableDense, and AbstractLinAlgPack::VectorMutableThyra. Definition at line 105 of file AbstractLinAlgPack_Vector.cpp. 

Return the number of nonzero elements in the vector.
The default implementation just uses a reduction operator with the Reimplemented in AbstractLinAlgPack::VectorMutableBlocked. Definition at line 110 of file AbstractLinAlgPack_Vector.cpp. 

Virtual output function.
The default implementation just uses get_sub_vector ToDo: Finish documentation!
Reimplemented in AbstractLinAlgPack::VectorMutableBlocked. Definition at line 125 of file AbstractLinAlgPack_Vector.cpp. 

Create a clone of this vector objet.
The vector object returned in a smart reference counted pointer to a functional copy of the current vector object. The vector object
The default implementation of this function calls on Definition at line 140 of file AbstractLinAlgPack_Vector.cpp. 

Fetch an element in the vector. Preconditions:
The default implementation uses a C reduction operator class (See RTOp_ROp_get_ele.h C).
Reimplemented in AbstractLinAlgPack::VectorSubView, AbstractLinAlgPack::VectorMutableBlocked, and AbstractLinAlgPack::VectorMutableDense. Definition at line 148 of file AbstractLinAlgPack_Vector.cpp. 

Create an abstract view of a vector object .
This is only a transient view of a subvector that is to be immediately used and then released by
It is important to understand what the minimum postconditions are for the sub vector objects returned from this method. If two vector objects Preconditions:
Postconditions:
Reimplemented in AbstractLinAlgPack::VectorMutable, AbstractLinAlgPack::VectorMutableSubView, and AbstractLinAlgPack::VectorSubView. Definition at line 210 of file AbstractLinAlgPack_Vector.cpp. 

Inline member function that simply calls
Definition at line 497 of file AbstractLinAlgPack_Vector.hpp. 

One norm.
Reimplemented in AbstractLinAlgPack::VectorMutableBlocked. Definition at line 159 of file AbstractLinAlgPack_Vector.cpp. 

Two norm.
Definition at line 174 of file AbstractLinAlgPack_Vector.cpp. 

Infinity norm.
Reimplemented in AbstractLinAlgPack::VectorMutableBlocked. Definition at line 189 of file AbstractLinAlgPack_Vector.cpp. 

Return the inner product of
Reimplemented in AbstractLinAlgPack::VectorMutableBlocked. Definition at line 204 of file AbstractLinAlgPack_Vector.cpp. 

Get a nonmutable explicit view of a subvector.
This is only a transient view of a subvector that is to be immediately used and then released with a call to
Note that calling this operation might require some internal allocations and temporary memory. Therefore, it is critical that
If Preconditions:
This method has a default implementation based on a vector reduction operator class (see RTOp_ROp_get_sub_vector.h) and calls
Reimplemented in AbstractLinAlgPack::VectorSubView, AbstractLinAlgPack::VectorMutableBlocked, AbstractLinAlgPack::VectorMutableDense, and AbstractLinAlgPack::VectorMutableThyra. Definition at line 229 of file AbstractLinAlgPack_Vector.cpp. 

Free an explicit view of a subvector. The subvector view must have been allocated by this>get_sub_vector() first.
This method has a default implementation which is a companion to the default implementation for
Reimplemented in AbstractLinAlgPack::VectorSubView, AbstractLinAlgPack::VectorMutableBlocked, AbstractLinAlgPack::VectorMutableDense, and AbstractLinAlgPack::VectorMutableThyra. Definition at line 264 of file AbstractLinAlgPack_Vector.cpp. 

Must be called by any vector subclass that modifies this vector object!
The way to use this method by subclasses is to call it when ever there is a chance that the vector may have changed. Therefore, this method should be called in every nonconst member function in every subclass. This is a little bit of a pain but overall this is a good design in that it allows for efficient cacheing of information for multiple retreval. For example, if the subclass void SomeVector::has_changed() { BaseClass::has_changed(); // Called on most direct subclass that // has overridden this method as well. ... // Reinitialize your own cached data to uninitialized! } Reimplemented in AbstractLinAlgPack::VectorMutableBlocked. Definition at line 272 of file AbstractLinAlgPack_Vector.cpp. 

This method usually needs to be called by subclasses at the end of the
Definition at line 280 of file AbstractLinAlgPack_Vector.cpp. 



< 0 == not initialized, > 0 == already calculated
Definition at line 487 of file AbstractLinAlgPack_Vector.hpp. 

Reimplemented in AbstractLinAlgPack::VectorMutableBlocked. Definition at line 488 of file AbstractLinAlgPack_Vector.hpp. 

Definition at line 488 of file AbstractLinAlgPack_Vector.hpp. 

< 0 == not initialized, > 0 == already calculated
Reimplemented in AbstractLinAlgPack::VectorMutableBlocked. Definition at line 488 of file AbstractLinAlgPack_Vector.hpp. 