MOOCHO (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AbstractLinAlgPack_VectorMutableBlocked.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 VECTOR_WITH_OP_MUTABLE_BLOCK_STD_H
43 #define VECTOR_WITH_OP_MUTABLE_BLOCK_STD_H
44 
45 #include <vector>
46 
49 
50 namespace AbstractLinAlgPack {
51 
81 class VectorMutableBlocked : virtual public VectorMutable
82 {
83 public:
84 
87 
92  ,const vec_space_comp_ptr_t& vec_space
93  );
94 
111  void initialize(
113  ,const vec_space_comp_ptr_t& vec_space
114  );
115 
118  const VectorSpaceBlocked& block_space() const;
119 
122  const Vector& get_vector(int k) const;
123 
126  VectorMutable& get_vector(int k);
127 
129 
132 
134  index_type dim() const;
136  const VectorSpace& space() const;
138  void apply_op(
139  const RTOpPack::RTOp& op
140  ,const size_t num_vecs, const Vector* vecs[]
141  ,const size_t num_targ_vecs, VectorMutable* targ_vecs[]
142  ,RTOpPack::ReductTarget *reduct_obj
143  ,const index_type first_ele, const index_type sub_dim, const index_type global_offset
144  ) const;
146  index_type nz() const;
148  std::ostream& output(
149  std::ostream& out, bool print_dim, bool newline
150  ,index_type global_offset
151  ) const;
153  value_type get_ele(index_type i) const;
155  value_type norm_1() const;
157  value_type norm_inf() const;
159  value_type inner_product( const Vector& ) const;
161  void get_sub_vector( const Range1D& rng, RTOpPack::SubVector* sub_vec ) const;
163  void free_sub_vector( RTOpPack::SubVector* sub_vec ) const;
164 
166 
169 
171  vec_mut_ptr_t sub_view( const Range1D& rng );
173  void axpy( value_type alpha, const Vector& x );
177  VectorMutable& operator=(const Vector&);
179  void set_ele( index_type i, value_type val );
181  void set_sub_vector( const RTOpPack::SparseSubVector& sub_vec );
182 
184 
185 protected:
186 
190  void has_changed() const;
192 
193 private:
194 
195  // ////////////////////////////////////
196  // Private types
197 
198  typedef std::vector<VectorMutable::vec_mut_ptr_t> vecs_t;
199 
200  // ////////////////////////////////////
201  // Private data members
202 
203 #ifdef DOXYGEN_COMPILE
206 #else
207  vecs_t vecs_;
208  vec_space_comp_ptr_t vec_space_;
209 #endif
210  mutable index_type nz_;
212 
213  // ////////////////////////////////////
214  // Private member functions
215 
217  void assert_in_range(int k) const;
218 
220  void assert_initialized() const;
221 
222  // not defined and not to be called!
226 
227 }; // end class VectorMutableBlocked
228 
229 // ////////////////////////////////////
230 // Inline members
231 
232 inline
233 const VectorSpaceBlocked&
235 {
237  return *vec_space_;
238 }
239 
240 inline
241 const Vector&
243 {
244  assert_in_range(k);
245  return *vecs_[k];
246 }
247 
248 inline
251 {
252  assert_in_range(k);
253  return *vecs_[k];
254 }
255 
256 } // end namespace AbstractLinAlgPack
257 
258 #endif // VECTOR_WITH_OP_MUTABLE_BLOCK_STD_H
void set_sub_vector(const RTOpPack::SparseSubVector &sub_vec)
Abstract interface for immutable, finite dimensional, coordinate vectors {abstract}.
value_type norm_inf_
< 0, not initialized, > 0 already calculated
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
void get_sub_vector(const Range1D &rng, RTOpPack::SubVector *sub_vec) const
Teuchos::RCP< const VectorSpaceBlocked > vec_space_comp_ptr_t
. One-based subregion index range class.
RTOpT< RTOp_value_type > RTOp
Abstract interface for objects that represent a space for mutable coordinate vectors.
std::ostream * out
VectorSpace subclass for the composite of one or more VectorSpace objects.
const VectorSpaceBlocked & block_space() const
Return the underlying block vector space.
std::ostream & output(std::ostream &out, bool print_dim, bool newline, index_type global_offset) const
Abstract interface for mutable coordinate vectors {abstract}.
SparseSubVectorT< RTOp_value_type > SparseSubVector
void initialize(VectorMutable::vec_mut_ptr_t *vecs, const vec_space_comp_ptr_t &vec_space)
Initialize given a list of constituent vectors.
std::vector< VectorMutable::vec_mut_ptr_t > vecs_t
Type for list of constituent vectors.
Class for a non-mutable sub-vector.
index_type nz_
dim() not initalized, < dim() already initialized!
const Vector & get_vector(int k) const
Get the kth (zero based) constituent vector.