|
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_MULTI_VECTOR_H 00043 #define ALAP_MULTI_VECTOR_H 00044 00045 #include "AbstractLinAlgPack_MatrixOp.hpp" 00046 #include "RTOpPack_RTOpT.hpp" 00047 #include "Teuchos_RCP.hpp" 00048 00049 namespace AbstractLinAlgPack { 00050 00052 enum EApplyBy { 00053 APPLY_BY_ROW 00054 ,APPLY_BY_COL 00055 }; 00056 00062 void apply_op( 00063 EApplyBy apply_by 00064 ,const RTOpPack::RTOp &primary_op 00065 ,const size_t num_multi_vecs 00066 ,const MultiVector* multi_vecs[] 00067 ,const size_t num_targ_multi_vecs 00068 ,MultiVectorMutable* targ_multi_vecs[] 00069 ,RTOpPack::ReductTarget* reduct_objs[] = NULL 00070 ,const index_type primary_first_ele = 1 00071 ,const index_type primary_sub_dim = 0 00072 ,const index_type primary_global_offset = 0 00073 ,const index_type secondary_first_ele = 1 00074 ,const index_type secondary_sub_dim = 0 00075 ); 00076 00082 void apply_op( 00083 EApplyBy apply_by 00084 ,const RTOpPack::RTOp &primary_op 00085 ,const RTOpPack::RTOp &secondary_op 00086 ,const size_t num_multi_vecs 00087 ,const MultiVector* multi_vecs[] 00088 ,const size_t num_targ_multi_vecs 00089 ,MultiVectorMutable* targ_multi_vecs[] 00090 ,RTOpPack::ReductTarget *reduct_obj 00091 ,const index_type primary_first_ele = 1 00092 ,const index_type primary_sub_dim = 0 00093 ,const index_type primary_global_offset = 0 00094 ,const index_type secondary_first_ele = 1 00095 ,const index_type secondary_sub_dim = 0 00096 ); 00097 00170 class MultiVector : virtual public MatrixOp { 00171 public: 00172 00174 using MatrixOp::clone; 00176 using MatrixOp::Mp_StMtM; 00177 00179 typedef int access_by_t; 00181 enum { 00182 ROW_ACCESS = 0x1 00183 ,COL_ACCESS = 0x2 00184 ,DIAG_ACCESS = 0x4 00185 }; 00187 typedef Teuchos::RCP<const Vector> vec_ptr_t; 00189 typedef Teuchos::RCP<const MultiVector> multi_vec_ptr_t; 00190 00193 00195 friend void apply_op( 00196 EApplyBy apply_by 00197 ,const RTOpPack::RTOp &primary_op 00198 ,const size_t num_multi_vecs 00199 ,const MultiVector* multi_vecs[] 00200 ,const size_t num_targ_multi_vecs 00201 ,MultiVectorMutable* targ_multi_vecs[] 00202 ,RTOpPack::ReductTarget* reduct_objs[] 00203 ,const index_type primary_first_ele 00204 ,const index_type primary_sub_dim 00205 ,const index_type primary_global_offset 00206 ,const index_type secondary_first_ele 00207 ,const index_type secondary_sub_dim 00208 ); 00210 friend void apply_op( 00211 EApplyBy apply_by 00212 ,const RTOpPack::RTOp &primary_op 00213 ,const RTOpPack::RTOp &secondary_op 00214 ,const size_t num_multi_vecs 00215 ,const MultiVector* multi_vecs[] 00216 ,const size_t num_targ_multi_vecs 00217 ,MultiVectorMutable* targ_multi_vecs[] 00218 ,RTOpPack::ReductTarget *reduct_obj 00219 ,const index_type primary_first_ele 00220 ,const index_type primary_sub_dim 00221 ,const index_type primary_global_offset 00222 ,const index_type secondary_first_ele 00223 ,const index_type secondary_sub_dim 00224 ); 00225 00227 00230 00235 virtual multi_vec_ptr_t mv_clone() const; 00236 00238 00241 00248 virtual access_by_t access_by() const = 0; 00249 00257 virtual vec_ptr_t col(index_type j) const = 0; 00265 virtual vec_ptr_t row(index_type i) const = 0; 00272 virtual vec_ptr_t diag(int k) const = 0; 00273 00275 00278 00286 virtual multi_vec_ptr_t mv_sub_view(const Range1D& row_rng, const Range1D& col_rng) const; 00287 00290 multi_vec_ptr_t mv_sub_view( 00291 const index_type& rl, const index_type& ru 00292 ,const index_type& cl, const index_type& cu 00293 ) const; 00294 00296 00297 protected: 00298 00301 00315 virtual void apply_op( 00316 EApplyBy apply_by, const RTOpPack::RTOp& primary_op 00317 ,const size_t num_multi_vecs, const MultiVector* multi_vecs[] 00318 ,const size_t num_targ_multi_vecs, MultiVectorMutable* targ_multi_vecs[] 00319 ,RTOpPack::ReductTarget* reduct_objs[] 00320 ,const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset 00321 ,const index_type secondary_first_ele, const index_type secondary_sub_dim 00322 ) const; 00323 00337 virtual void apply_op( 00338 EApplyBy apply_by, const RTOpPack::RTOp& primary_op, const RTOpPack::RTOp& secondary_op 00339 ,const size_t num_multi_vecs, const MultiVector* multi_vecs[] 00340 ,const size_t num_targ_multi_vecs, MultiVectorMutable* targ_multi_vecs[] 00341 ,RTOpPack::ReductTarget* reduct_obj 00342 ,const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset 00343 ,const index_type secondary_first_ele, const index_type secondary_sub_dim 00344 ) const; 00345 00347 00348 public: 00349 00352 00355 mat_ptr_t clone() const; 00356 00359 mat_ptr_t sub_view(const Range1D& row_rng, const Range1D& col_rng) const; 00360 00374 bool Mp_StMtM( 00375 MatrixOp* mwo_lhs, value_type alpha 00376 ,const MatrixOp& mwo_rhs1, BLAS_Cpp::Transp trans_rhs1 00377 ,BLAS_Cpp::Transp trans_rhs2 00378 ,value_type beta 00379 ) const; 00380 00394 bool Mp_StMtM( 00395 MatrixOp* mwo_lhs, value_type alpha 00396 ,BLAS_Cpp::Transp trans_rhs1 00397 ,const MatrixOp& mwo_rhs2, BLAS_Cpp::Transp trans_rhs2 00398 ,value_type beta 00399 ) const; 00400 00402 00403 private: 00404 00405 #ifdef DOXYGEN_COMPILE 00406 Vector *rows; 00407 Vector *columns; 00408 Vector *diagonals; 00409 #endif 00410 00411 }; // end class MultiVector 00412 00413 // ////////////////////////////////////////////////// 00414 // Inlined functions 00415 00416 inline 00417 MultiVector::multi_vec_ptr_t 00418 MultiVector::mv_sub_view( 00419 const index_type& rl, const index_type& ru 00420 ,const index_type& cl, const index_type& cu 00421 ) const 00422 { 00423 return this->mv_sub_view(Range1D(rl,ru),Range1D(cl,cu)); 00424 } 00425 00426 } // end namespace AbstractLinAlgPack 00427 00428 #endif // ALAP_MULTI_VECTOR_H
1.7.6.1