Thyra_DetachedMultiVectorView.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //    Thyra: Interfaces and Support for Abstract Numerical Algorithms
00005 //                 Copyright (2004) 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 Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #include "Thyra_MultiVectorBase.hpp"
00030 
00031 #ifndef THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP
00032 #define THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP
00033 
00034 namespace Thyra {
00035 
00040 template<class Scalar>
00041 class ConstDetachedMultiVectorView {
00042 public:
00044   ConstDetachedMultiVectorView(
00045     const MultiVectorBase<Scalar>& mv, const Range1D &rowRng = Range1D(), const Range1D &colRng = Range1D()
00046     )
00047     : mv_(mv) { mv_.acquireDetachedView(rowRng,colRng,&smv_); }
00049   ~ConstDetachedMultiVectorView() { mv_.releaseDetachedView(&smv_); }
00051   const RTOpPack::ConstSubMultiVectorView<Scalar>& smv() const { return smv_; }
00053   Teuchos_Index   globalOffset() const { return smv_.globalOffset(); }
00055   Teuchos_Index   subDim()       const { return smv_.subDim();  }
00057   Teuchos_Index   colOffset()    const { return smv_.colOffset(); }
00059   Teuchos_Index   numSubCols()   const { return smv_.numSubCols();  }
00061   const Scalar*     values()       const { return smv_.values();  }
00063   Teuchos_Index   leadingDim()   const { return smv_.leadingDim();  }
00065   const Scalar& operator()(Teuchos_Index i,Teuchos_Index j) const { return smv_(i,j); }
00066 private:
00067   const MultiVectorBase<Scalar>          &mv_;
00068   RTOpPack::ConstSubMultiVectorView<Scalar>  smv_;
00069   // Not defined and not to be called
00070   ConstDetachedMultiVectorView();
00071   ConstDetachedMultiVectorView(const ConstDetachedMultiVectorView<Scalar>&);
00072   ConstDetachedMultiVectorView<Scalar>& operator==(const ConstDetachedMultiVectorView<Scalar>&);
00073 };
00074  
00079 template<class Scalar>
00080 class DetachedMultiVectorView {
00081 public:
00083   DetachedMultiVectorView(
00084     MultiVectorBase<Scalar>& mv, const Range1D &rowRng = Range1D(), const Range1D &colRng = Range1D()
00085     )
00086     : mv_(mv) { mv_.acquireDetachedView(rowRng,colRng,&smv_); }
00088   ~DetachedMultiVectorView() { mv_.commitDetachedView(&smv_); }
00090   const RTOpPack::SubMultiVectorView<Scalar>& smv() const { return smv_; }
00092   Teuchos_Index   globalOffset() const { return smv_.globalOffset(); }
00094   Teuchos_Index   subDim()       const { return smv_.subDim();  }
00096   Teuchos_Index   colOffset()    const { return smv_.colOffset(); }
00098   Teuchos_Index   numSubCols()   const { return smv_.numSubCols();  }
00100   Scalar*           values()       const { return smv_.values();  }
00102   Teuchos_Index   leadingDim()   const { return smv_.leadingDim();  }
00104   Scalar& operator()(Teuchos_Index i,Teuchos_Index j) { return smv_(i,j); }
00105 private:
00106   MultiVectorBase<Scalar>                   &mv_;
00107   RTOpPack::SubMultiVectorView<Scalar>  smv_;
00108   // Not defined and not to be called
00109   DetachedMultiVectorView();
00110   DetachedMultiVectorView(const DetachedMultiVectorView<Scalar>&);
00111   DetachedMultiVectorView<Scalar>& operator==(const DetachedMultiVectorView<Scalar>&);
00112 };
00113 
00114 } // namespace Thyra
00115 
00116 #endif // THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP

Generated on Thu Sep 18 12:33:02 2008 for Thyra Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1