|
AbstractLinAlgPack: C++ Interfaces For Vectors, Matrices And Related Linear Algebra Objects Version of the Day
|
00001 // @HEADER 00002 // *********************************************************************** 00003 // 00004 // Moocho: Multi-functional Object-Oriented arCHitecture for Optimization 00005 // Copyright (2003) Sandia Corporation 00006 // 00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive 00008 // license for use of this work by or on behalf of the U.S. Government. 00009 // 00010 // This library is free software; you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as 00012 // published by the Free Software Foundation; either version 2.1 of the 00013 // License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, but 00016 // WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00023 // USA 00024 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00025 // 00026 // *********************************************************************** 00027 // @HEADER 00028 00029 #ifndef VECTOR_WITH_OP_MUTABLE_BLOCK_STD_H 00030 #define VECTOR_WITH_OP_MUTABLE_BLOCK_STD_H 00031 00032 #include <vector> 00033 00034 #include "AbstractLinAlgPack_VectorMutable.hpp" 00035 #include "AbstractLinAlgPack_VectorSpaceBlocked.hpp" 00036 00037 namespace AbstractLinAlgPack { 00038 00068 class VectorMutableBlocked : virtual public VectorMutable 00069 { 00070 public: 00071 00073 typedef Teuchos::RCP<const VectorSpaceBlocked> vec_space_comp_ptr_t; 00074 00077 VectorMutableBlocked( 00078 VectorMutable::vec_mut_ptr_t* vecs 00079 ,const vec_space_comp_ptr_t& vec_space 00080 ); 00081 00098 void initialize( 00099 VectorMutable::vec_mut_ptr_t* vecs 00100 ,const vec_space_comp_ptr_t& vec_space 00101 ); 00102 00105 const VectorSpaceBlocked& block_space() const; 00106 00109 const Vector& get_vector(int k) const; 00110 00113 VectorMutable& get_vector(int k); 00114 00116 00119 00121 index_type dim() const; 00123 const VectorSpace& space() const; 00125 void apply_op( 00126 const RTOpPack::RTOp& op 00127 ,const size_t num_vecs, const Vector* vecs[] 00128 ,const size_t num_targ_vecs, VectorMutable* targ_vecs[] 00129 ,RTOpPack::ReductTarget *reduct_obj 00130 ,const index_type first_ele, const index_type sub_dim, const index_type global_offset 00131 ) const; 00133 index_type nz() const; 00135 std::ostream& output( 00136 std::ostream& out, bool print_dim, bool newline 00137 ,index_type global_offset 00138 ) const; 00140 value_type get_ele(index_type i) const; 00142 value_type norm_1() const; 00144 value_type norm_inf() const; 00146 value_type inner_product( const Vector& ) const; 00148 void get_sub_vector( const Range1D& rng, RTOpPack::SubVector* sub_vec ) const; 00150 void free_sub_vector( RTOpPack::SubVector* sub_vec ) const; 00151 00153 00156 00158 vec_mut_ptr_t sub_view( const Range1D& rng ); 00160 void axpy( value_type alpha, const Vector& x ); 00162 VectorMutable& operator=(value_type); 00164 VectorMutable& operator=(const Vector&); 00166 void set_ele( index_type i, value_type val ); 00168 void set_sub_vector( const RTOpPack::SparseSubVector& sub_vec ); 00169 00171 00172 protected: 00173 00177 void has_changed() const; 00179 00180 private: 00181 00182 // //////////////////////////////////// 00183 // Private types 00184 00185 typedef std::vector<VectorMutable::vec_mut_ptr_t> vecs_t; 00186 00187 // //////////////////////////////////// 00188 // Private data members 00189 00190 #ifdef DOXYGEN_COMPILE 00191 VectorMutable *vectors; 00192 VectorSpaceBlocked *block_vector_space; 00193 #else 00194 vecs_t vecs_; 00195 vec_space_comp_ptr_t vec_space_; 00196 #endif 00197 mutable index_type nz_; 00198 mutable value_type norm_1_, norm_inf_; 00199 00200 // //////////////////////////////////// 00201 // Private member functions 00202 00204 void assert_in_range(int k) const; 00205 00207 void assert_initialized() const; 00208 00209 // not defined and not to be called! 00210 VectorMutableBlocked(); 00211 VectorMutableBlocked(const VectorMutableBlocked&); 00212 VectorMutableBlocked& operator=(const VectorMutableBlocked&); 00213 00214 }; // end class VectorMutableBlocked 00215 00216 // //////////////////////////////////// 00217 // Inline members 00218 00219 inline 00220 const VectorSpaceBlocked& 00221 VectorMutableBlocked::block_space() const 00222 { 00223 assert_initialized(); 00224 return *vec_space_; 00225 } 00226 00227 inline 00228 const Vector& 00229 VectorMutableBlocked::get_vector(int k) const 00230 { 00231 assert_in_range(k); 00232 return *vecs_[k]; 00233 } 00234 00235 inline 00236 VectorMutable& 00237 VectorMutableBlocked::get_vector(int k) 00238 { 00239 assert_in_range(k); 00240 return *vecs_[k]; 00241 } 00242 00243 } // end namespace AbstractLinAlgPack 00244 00245 #endif // VECTOR_WITH_OP_MUTABLE_BLOCK_STD_H
1.7.4