|
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 // Redistribution and use in source and binary forms, with or without 00011 // modification, are permitted provided that the following conditions are 00012 // met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. Neither the name of the Corporation nor the names of the 00022 // contributors may be used to endorse or promote products derived from 00023 // this software without specific prior written permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY 00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE 00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00036 // 00037 // Questions? Contact Roscoe A. Bartlett (rabartl@sandia.gov) 00038 // 00039 // *********************************************************************** 00040 // @HEADER 00041 00042 #ifndef ALAP_VECTOR_HPP 00043 #define ALAP_VECTOR_HPP 00044 00045 #include <iosfwd> 00046 00047 #include "AbstractLinAlgPack_Types.hpp" 00048 #include "RTOpPack_RTOpT.hpp" 00049 00050 namespace AbstractLinAlgPack { 00051 00119 void apply_op( 00120 const RTOpPack::RTOp &op 00121 ,const size_t num_vecs 00122 ,const Vector* vecs[] 00123 ,const size_t num_targ_vecs 00124 ,VectorMutable* targ_vecs[] 00125 ,RTOpPack::ReductTarget *reduct_obj 00126 ,const index_type first_ele = 1 00127 ,const index_type sub_dim = 0 00128 ,const index_type global_offset = 0 00129 ); 00130 00187 class Vector { 00188 public: 00189 00191 typedef Teuchos::RCP<const Vector> vec_ptr_t; 00193 typedef Teuchos::RCP<VectorMutable> vec_mut_ptr_t; 00194 00196 friend 00197 void apply_op( 00198 const RTOpPack::RTOp &op 00199 ,const size_t num_vecs 00200 ,const Vector* vecs[] 00201 ,const size_t num_targ_vecs 00202 ,VectorMutable* targ_vecs[] 00203 ,RTOpPack::ReductTarget *reduct_obj 00204 ,const index_type first_ele 00205 ,const index_type sub_dim 00206 ,const index_type global_offset 00207 ); 00208 00210 Vector(); 00212 virtual ~Vector() {} 00213 00216 00224 virtual const VectorSpace& space() const = 0; 00225 00226 protected: 00227 00240 virtual void apply_op( 00241 const RTOpPack::RTOp &op 00242 ,const size_t num_vecs 00243 ,const Vector* vecs[] 00244 ,const size_t num_targ_vecs 00245 ,VectorMutable* targ_vecs[] 00246 ,RTOpPack::ReductTarget *reduct_obj 00247 ,const index_type first_ele 00248 ,const index_type sub_dim 00249 ,const index_type global_offset 00250 ) const = 0; 00251 00253 00254 public: 00255 00258 00266 virtual index_type dim() const; 00267 00274 virtual index_type nz() const; 00275 00292 virtual std::ostream& output( 00293 std::ostream& out, bool print_dim = true, bool newline = true 00294 ,index_type global_offset = 0 00295 ) const; 00296 00306 virtual vec_mut_ptr_t clone() const; 00307 00319 virtual value_type get_ele(index_type i) const; 00320 00361 virtual vec_ptr_t sub_view( const Range1D& rng ) const; 00362 00364 00367 vec_ptr_t sub_view( const index_type& l, const index_type& u ) const; 00368 00371 00374 virtual value_type norm_1() const; 00377 virtual value_type norm_2() const; 00380 virtual value_type norm_inf() const; 00381 00383 00386 00391 virtual value_type inner_product( const Vector& v ) const; 00392 00394 00397 00439 virtual void get_sub_vector( const Range1D& rng, RTOpPack::SubVector* sub_vec ) const; 00440 00455 virtual void free_sub_vector( RTOpPack::SubVector* sub_vec ) const; 00456 00458 00480 virtual void has_changed() const; 00481 00482 protected: 00483 00486 00492 virtual void finalize_apply_op( 00493 const size_t num_targ_vecs, VectorMutable** targ_vecs 00494 ) const; 00495 00497 00498 private: 00499 00500 mutable index_type num_nonzeros_; 00501 mutable value_type norm_1_, norm_2_, norm_inf_; 00502 00503 }; // end class Vector 00504 00505 // //////////////////////////////////////////////// 00506 // Inline functions 00507 00508 inline 00509 Vector::vec_ptr_t 00510 Vector::sub_view( const index_type& l, const index_type& u ) const 00511 { 00512 return this->sub_view(Range1D(l,u)); 00513 } 00514 00515 } // end namespace AbstractLinAlgPack 00516 00517 #endif // ALAP_VECTOR_HPP
1.7.6.1