|
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 MATRIX_WITH_OP_GET_GMS_MUTABLE_H 00030 #define MATRIX_WITH_OP_GET_GMS_MUTABLE_H 00031 00032 #include "AbstractLinAlgPack_MatrixOpGetGMS.hpp" 00033 00034 namespace AbstractLinAlgPack { 00035 00052 class MatrixOpGetGMSMutable : virtual public MatrixOpGetGMS { 00053 public: 00054 00056 using MatrixOpGetGMS::get_gms_view; 00057 00073 virtual DMatrixSlice get_gms_view() = 0; 00074 00090 virtual void commit_gms_view(DMatrixSlice* gms_view) = 0; 00091 00092 }; // end class MatrixOpGetGMSMutable 00093 00113 class MatrixDenseMutableEncap { 00114 public: 00115 00118 MatrixDenseMutableEncap( MatrixOpGetGMSMutable* mat_get ); 00124 MatrixDenseMutableEncap( MatrixOp* mat ); 00126 ~MatrixDenseMutableEncap(); 00128 DMatrixSlice operator()(); 00130 const DMatrixSlice operator()() const; 00131 00132 private: 00133 00134 MatrixOpGetGMSMutable *mat_get_; 00135 DMatrixSlice gms_view_; 00136 MatrixDenseMutableEncap(); // Not defined and not to be called! 00137 MatrixDenseMutableEncap(const MatrixDenseMutableEncap&); // "" 00138 MatrixDenseMutableEncap& operator=(const MatrixDenseMutableEncap&); // "" 00139 00140 }; // end class MatrixDenseMutableEncap 00141 00142 // /////////////////////////////////////////// 00143 // Inline members 00144 00145 // MatrixDenseMutableEncap 00146 00147 inline 00148 MatrixDenseMutableEncap::MatrixDenseMutableEncap( MatrixOpGetGMSMutable* mat_get ) 00149 :mat_get_(mat_get) 00150 ,gms_view_(mat_get_->get_gms_view()) 00151 {} 00152 00153 inline 00154 MatrixDenseMutableEncap::MatrixDenseMutableEncap( MatrixOp* mat ) 00155 :mat_get_(&Teuchos::dyn_cast<MatrixOpGetGMSMutable>(*mat)) 00156 ,gms_view_(mat_get_->get_gms_view()) 00157 {} 00158 00159 inline 00160 MatrixDenseMutableEncap::~MatrixDenseMutableEncap() 00161 { 00162 mat_get_->commit_gms_view(&gms_view_); 00163 } 00164 00165 inline 00166 DMatrixSlice MatrixDenseMutableEncap::operator()() 00167 { 00168 return gms_view_; 00169 } 00170 00171 inline 00172 const DMatrixSlice MatrixDenseMutableEncap::operator()() const 00173 { 00174 return gms_view_; 00175 } 00176 00177 } // end namespace AbstractLinAlgPack 00178 00179 #endif // MATRIX_WITH_OP_GET_GMS_MUTABLE_H
1.7.4