MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_Vector.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization
5 // Copyright (2003) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov)
38 //
39 // ***********************************************************************
40 // @HEADER
41 
42 #ifndef ALAP_VECTOR_HPP
43 #define ALAP_VECTOR_HPP
44 
45 #include <iosfwd>
46 
48 #include "RTOpPack_RTOpT.hpp"
49 
50 namespace AbstractLinAlgPack {
51 
119 void apply_op(
120  const RTOpPack::RTOp &op
121  ,const size_t num_vecs
122  ,const Vector* vecs[]
123  ,const size_t num_targ_vecs
124  ,VectorMutable* targ_vecs[]
125  ,RTOpPack::ReductTarget *reduct_obj
126  ,const index_type first_ele = 1
127  ,const index_type sub_dim = 0
128  ,const index_type global_offset = 0
129  );
130 
187 class Vector {
188 public:
189 
194 
196  friend
197  void apply_op(
198  const RTOpPack::RTOp &op
199  ,const size_t num_vecs
200  ,const Vector* vecs[]
201  ,const size_t num_targ_vecs
202  ,VectorMutable* targ_vecs[]
203  ,RTOpPack::ReductTarget *reduct_obj
204  ,const index_type first_ele
205  ,const index_type sub_dim
206  ,const index_type global_offset
207  );
208 
210  Vector();
212  virtual ~Vector() {}
213 
216 
224  virtual const VectorSpace& space() const = 0;
225 
226 protected:
227 
240  virtual void apply_op(
241  const RTOpPack::RTOp &op
242  ,const size_t num_vecs
243  ,const Vector* vecs[]
244  ,const size_t num_targ_vecs
245  ,VectorMutable* targ_vecs[]
246  ,RTOpPack::ReductTarget *reduct_obj
247  ,const index_type first_ele
248  ,const index_type sub_dim
249  ,const index_type global_offset
250  ) const = 0;
251 
253 
254 public:
255 
258 
266  virtual index_type dim() const;
267 
274  virtual index_type nz() const;
275 
292  virtual std::ostream& output(
293  std::ostream& out, bool print_dim = true, bool newline = true
294  ,index_type global_offset = 0
295  ) const;
296 
306  virtual vec_mut_ptr_t clone() const;
307 
319  virtual value_type get_ele(index_type i) const;
320 
361  virtual vec_ptr_t sub_view( const Range1D& rng ) const;
362 
364 
367  vec_ptr_t sub_view( const index_type& l, const index_type& u ) const;
368 
371 
374  virtual value_type norm_1() const;
377  virtual value_type norm_2() const;
380  virtual value_type norm_inf() const;
381 
383 
386 
391  virtual value_type inner_product( const Vector& v ) const;
392 
394 
397 
439  virtual void get_sub_vector( const Range1D& rng, RTOpPack::SubVector* sub_vec ) const;
440 
455  virtual void free_sub_vector( RTOpPack::SubVector* sub_vec ) const;
456 
458 
480  virtual void has_changed() const;
481 
482 protected:
483 
486 
492  virtual void finalize_apply_op(
493  const size_t num_targ_vecs, VectorMutable** targ_vecs
494  ) const;
495 
497 
498 private:
499 
502 
503 }; // end class Vector
504 
505 // ////////////////////////////////////////////////
506 // Inline functions
507 
508 inline
510 Vector::sub_view( const index_type& l, const index_type& u ) const
511 {
512  return this->sub_view(Range1D(l,u));
513 }
514 
515 } // end namespace AbstractLinAlgPack
516 
517 #endif // ALAP_VECTOR_HPP
virtual vec_ptr_t sub_view(const Range1D &rng) const
Create an abstract view of a vector object .
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.
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
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...
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() )
Teuchos::RCP< const Vector > vec_ptr_t
virtual value_type norm_2() const
Two norm. ||v||_2 = sqrt( sum( v(i)^2, i = 1,,,this->dim() ) )
value_type norm_inf_
< 0 == not initialized, > 0 == already calculated
Teuchos::RCP< VectorMutable > vec_mut_ptr_t
index_type num_nonzeros_
< 0 == not initialized, > 0 == already calculated
. 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
Abstract interface for objects that represent a space for mutable coordinate vectors.
virtual std::ostream & output(std::ostream &out, bool print_dim=true, bool newline=true, index_type global_offset=0) const
Virtual output function.
std::ostream * out
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 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)
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...
virtual value_type inner_product(const Vector &v) const
Return the inner product of *this with v.
const f_int f_dbl_prec const f_int f_int const f_int f_int const f_dbl_prec & u
Class for a non-mutable sub-vector.