Thyra_ExplicitMultiVectorView.hpp

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 ExplicitMultiVectorView {
00042 public:
00044   ExplicitMultiVectorView(
00045     const MultiVectorBase<Scalar>& mv, const Range1D &rowRng = Range1D(), const Range1D &colRng = Range1D()
00046     )
00047     : mv_(mv) { mv_.getSubMultiVector(rowRng,colRng,&smv_); }
00049   ~ExplicitMultiVectorView() { mv_.freeSubMultiVector(&smv_); }
00051   const RTOpPack::SubMultiVectorT<Scalar>& smv() const { return smv_; }
00053   RTOp_index_type   globalOffset() const { return smv_.globalOffset(); }
00055   RTOp_index_type   subDim()       const { return smv_.subDim();  }
00057   RTOp_index_type   colOffset()    const { return smv_.colOffset(); }
00059   RTOp_index_type   numSubCols()   const { return smv_.numSubCols();  }
00061   const Scalar*     values()       const { return smv_.values();  }
00063   RTOp_index_type   leadingDim()   const { return smv_.leadingDim();  }
00065   const Scalar& operator()(RTOp_index_type i,RTOp_index_type j) const { return smv_(i,j); }
00066 private:
00067   const MultiVectorBase<Scalar>          &mv_;
00068   RTOpPack::SubMultiVectorT<Scalar>  smv_;
00069   // Not defined and not to be called
00070   ExplicitMultiVectorView();
00071   ExplicitMultiVectorView(const ExplicitMultiVectorView<Scalar>&);
00072   ExplicitMultiVectorView<Scalar>& operator==(const ExplicitMultiVectorView<Scalar>&);
00073 };
00074  
00079 template<class Scalar>
00080 class ExplicitMutableMultiVectorView {
00081 public:
00083   ExplicitMutableMultiVectorView(
00084     MultiVectorBase<Scalar>& mv, const Range1D &rowRng = Range1D(), const Range1D &colRng = Range1D()
00085     )
00086     : mv_(mv) { mv_.getSubMultiVector(rowRng,colRng,&smv_); }
00088   ~ExplicitMutableMultiVectorView() { mv_.commitSubMultiVector(&smv_); }
00090   const RTOpPack::MutableSubMultiVectorT<Scalar>& smv() const { return smv_; }
00092   RTOp_index_type   globalOffset() const { return smv_.globalOffset(); }
00094   RTOp_index_type   subDim()       const { return smv_.subDim();  }
00096   RTOp_index_type   colOffset()    const { return smv_.colOffset(); }
00098   RTOp_index_type   numSubCols()   const { return smv_.numSubCols();  }
00100   Scalar*           values()       const { return smv_.values();  }
00102   RTOp_index_type   leadingDim()   const { return smv_.leadingDim();  }
00104   Scalar& operator()(RTOp_index_type i,RTOp_index_type j) { return smv_(i,j); }
00105 private:
00106   MultiVectorBase<Scalar>                       &mv_;
00107   RTOpPack::MutableSubMultiVectorT<Scalar>  smv_;
00108   // Not defined and not to be called
00109   ExplicitMutableMultiVectorView();
00110   ExplicitMutableMultiVectorView(const ExplicitMutableMultiVectorView<Scalar>&);
00111   ExplicitMutableMultiVectorView<Scalar>& operator==(const ExplicitMutableMultiVectorView<Scalar>&);
00112 };
00113 
00114 } // namespace Thyra
00115 
00116 #endif // THYRA_EXPLICIT_MULTI_VECTOR_VIEW_HPP

Generated on Thu Sep 18 12:39:52 2008 for Thyra ANA Operator/VectorBase Interfaces and Related Software by doxygen 1.3.9.1