|
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 ALAP_MULTI_VECTOR_H 00030 #define ALAP_MULTI_VECTOR_H 00031 00032 #include "AbstractLinAlgPack_MatrixOp.hpp" 00033 #include "RTOpPack_RTOpT.hpp" 00034 #include "Teuchos_RCP.hpp" 00035 00036 namespace AbstractLinAlgPack { 00037 00039 enum EApplyBy { 00040 APPLY_BY_ROW 00041 ,APPLY_BY_COL 00042 }; 00043 00049 void apply_op( 00050 EApplyBy apply_by 00051 ,const RTOpPack::RTOp &primary_op 00052 ,const size_t num_multi_vecs 00053 ,const MultiVector* multi_vecs[] 00054 ,const size_t num_targ_multi_vecs 00055 ,MultiVectorMutable* targ_multi_vecs[] 00056 ,RTOpPack::ReductTarget* reduct_objs[] = NULL 00057 ,const index_type primary_first_ele = 1 00058 ,const index_type primary_sub_dim = 0 00059 ,const index_type primary_global_offset = 0 00060 ,const index_type secondary_first_ele = 1 00061 ,const index_type secondary_sub_dim = 0 00062 ); 00063 00069 void apply_op( 00070 EApplyBy apply_by 00071 ,const RTOpPack::RTOp &primary_op 00072 ,const RTOpPack::RTOp &secondary_op 00073 ,const size_t num_multi_vecs 00074 ,const MultiVector* multi_vecs[] 00075 ,const size_t num_targ_multi_vecs 00076 ,MultiVectorMutable* targ_multi_vecs[] 00077 ,RTOpPack::ReductTarget *reduct_obj 00078 ,const index_type primary_first_ele = 1 00079 ,const index_type primary_sub_dim = 0 00080 ,const index_type primary_global_offset = 0 00081 ,const index_type secondary_first_ele = 1 00082 ,const index_type secondary_sub_dim = 0 00083 ); 00084 00157 class MultiVector : virtual public MatrixOp { 00158 public: 00159 00161 using MatrixOp::clone; 00163 using MatrixOp::Mp_StMtM; 00164 00166 typedef int access_by_t; 00168 enum { 00169 ROW_ACCESS = 0x1 00170 ,COL_ACCESS = 0x2 00171 ,DIAG_ACCESS = 0x4 00172 }; 00174 typedef Teuchos::RCP<const Vector> vec_ptr_t; 00176 typedef Teuchos::RCP<const MultiVector> multi_vec_ptr_t; 00177 00180 00182 friend void apply_op( 00183 EApplyBy apply_by 00184 ,const RTOpPack::RTOp &primary_op 00185 ,const size_t num_multi_vecs 00186 ,const MultiVector* multi_vecs[] 00187 ,const size_t num_targ_multi_vecs 00188 ,MultiVectorMutable* targ_multi_vecs[] 00189 ,RTOpPack::ReductTarget* reduct_objs[] 00190 ,const index_type primary_first_ele 00191 ,const index_type primary_sub_dim 00192 ,const index_type primary_global_offset 00193 ,const index_type secondary_first_ele 00194 ,const index_type secondary_sub_dim 00195 ); 00197 friend void apply_op( 00198 EApplyBy apply_by 00199 ,const RTOpPack::RTOp &primary_op 00200 ,const RTOpPack::RTOp &secondary_op 00201 ,const size_t num_multi_vecs 00202 ,const MultiVector* multi_vecs[] 00203 ,const size_t num_targ_multi_vecs 00204 ,MultiVectorMutable* targ_multi_vecs[] 00205 ,RTOpPack::ReductTarget *reduct_obj 00206 ,const index_type primary_first_ele 00207 ,const index_type primary_sub_dim 00208 ,const index_type primary_global_offset 00209 ,const index_type secondary_first_ele 00210 ,const index_type secondary_sub_dim 00211 ); 00212 00214 00217 00222 virtual multi_vec_ptr_t mv_clone() const; 00223 00225 00228 00235 virtual access_by_t access_by() const = 0; 00236 00244 virtual vec_ptr_t col(index_type j) const = 0; 00252 virtual vec_ptr_t row(index_type i) const = 0; 00259 virtual vec_ptr_t diag(int k) const = 0; 00260 00262 00265 00273 virtual multi_vec_ptr_t mv_sub_view(const Range1D& row_rng, const Range1D& col_rng) const; 00274 00277 multi_vec_ptr_t mv_sub_view( 00278 const index_type& rl, const index_type& ru 00279 ,const index_type& cl, const index_type& cu 00280 ) const; 00281 00283 00284 protected: 00285 00288 00302 virtual void apply_op( 00303 EApplyBy apply_by, const RTOpPack::RTOp& primary_op 00304 ,const size_t num_multi_vecs, const MultiVector* multi_vecs[] 00305 ,const size_t num_targ_multi_vecs, MultiVectorMutable* targ_multi_vecs[] 00306 ,RTOpPack::ReductTarget* reduct_objs[] 00307 ,const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset 00308 ,const index_type secondary_first_ele, const index_type secondary_sub_dim 00309 ) const; 00310 00324 virtual void apply_op( 00325 EApplyBy apply_by, const RTOpPack::RTOp& primary_op, const RTOpPack::RTOp& secondary_op 00326 ,const size_t num_multi_vecs, const MultiVector* multi_vecs[] 00327 ,const size_t num_targ_multi_vecs, MultiVectorMutable* targ_multi_vecs[] 00328 ,RTOpPack::ReductTarget* reduct_obj 00329 ,const index_type primary_first_ele, const index_type primary_sub_dim, const index_type primary_global_offset 00330 ,const index_type secondary_first_ele, const index_type secondary_sub_dim 00331 ) const; 00332 00334 00335 public: 00336 00339 00342 mat_ptr_t clone() const; 00343 00346 mat_ptr_t sub_view(const Range1D& row_rng, const Range1D& col_rng) const; 00347 00361 bool Mp_StMtM( 00362 MatrixOp* mwo_lhs, value_type alpha 00363 ,const MatrixOp& mwo_rhs1, BLAS_Cpp::Transp trans_rhs1 00364 ,BLAS_Cpp::Transp trans_rhs2 00365 ,value_type beta 00366 ) const; 00367 00381 bool Mp_StMtM( 00382 MatrixOp* mwo_lhs, value_type alpha 00383 ,BLAS_Cpp::Transp trans_rhs1 00384 ,const MatrixOp& mwo_rhs2, BLAS_Cpp::Transp trans_rhs2 00385 ,value_type beta 00386 ) const; 00387 00389 00390 private: 00391 00392 #ifdef DOXYGEN_COMPILE 00393 Vector *rows; 00394 Vector *columns; 00395 Vector *diagonals; 00396 #endif 00397 00398 }; // end class MultiVector 00399 00400 // ////////////////////////////////////////////////// 00401 // Inlined functions 00402 00403 inline 00404 MultiVector::multi_vec_ptr_t 00405 MultiVector::mv_sub_view( 00406 const index_type& rl, const index_type& ru 00407 ,const index_type& cl, const index_type& cu 00408 ) const 00409 { 00410 return this->mv_sub_view(Range1D(rl,ru),Range1D(cl,cu)); 00411 } 00412 00413 } // end namespace AbstractLinAlgPack 00414 00415 #endif // ALAP_MULTI_VECTOR_H
1.7.4