Thyra_DefaultProductVectorSpaceDecl.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 #ifndef THYRA_PRODUCT_VECTOR_SPACE_DECL_HPP
00030 #define THYRA_PRODUCT_VECTOR_SPACE_DECL_HPP
00031 
00032 #include "Thyra_ProductVectorSpaceBase.hpp"
00033 #include "Thyra_VectorSpaceDefaultBase.hpp"
00034 
00035 namespace Thyra {
00036 
00122 template<class Scalar>
00123 class DefaultProductVectorSpace
00124   : virtual public ProductVectorSpaceBase<Scalar>
00125   , virtual protected VectorSpaceDefaultBase<Scalar>
00126 {
00127 public:
00128 
00131 
00133   DefaultProductVectorSpace(
00134     const int                                                       numBlocks
00135     ,const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >     vecSpaces[]
00136     );
00137   
00168   virtual void initialize(
00169     const int                                                       numBlocks
00170     ,const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >     vecSpaces[]
00171     );
00172 
00179   bool hasBeenCloned() const;
00180 
00200   virtual void uninitialize(
00201     int                                                             *numBlocks  = NULL
00202     ,Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >           vecSpaces[] = NULL
00203     );
00204 
00213   virtual const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >* vecSpaces() const;
00214 
00223   virtual const Index* vecSpacesOffsets() const;
00224 
00245   void getVecSpcPoss( Index i, int* kth_vector_space, Index* kth_global_offset ) const;
00246   
00248 
00251 
00253   int numBlocks() const;
00255   Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > getBlock(const int k) const; 
00256 
00258 
00261 
00262   Index dim() const;
00264   bool isCompatible( const VectorSpaceBase<Scalar>& vecSpc ) const;
00266   Teuchos::RefCountPtr< VectorBase<Scalar> > createMember() const;
00268   Scalar scalarProd( const VectorBase<Scalar>& x, const VectorBase<Scalar>& y ) const;
00270   void scalarProds( const MultiVectorBase<Scalar>& X, const MultiVectorBase<Scalar>& Y, Scalar scalar_prods[] ) const;
00272   bool hasInCoreView(const Range1D& rng, const EViewType viewType, const EStrideType strideType) const;
00274   Teuchos::RefCountPtr< const VectorSpaceFactoryBase<Scalar> > smallVecSpcFcty() const;
00276   Teuchos::RefCountPtr< MultiVectorBase<Scalar> > createMembers(int numMembers) const;
00278   Teuchos::RefCountPtr< const VectorSpaceBase<Scalar> > clone() const;
00280 
00281 private:
00282  
00283   // ///////////////////////////////////
00284   // Private types
00285 
00286   typedef std::vector<Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> > >  vecSpaces_t;
00287   typedef std::vector<Index>                                                  vecSpacesOffsets_t;
00288  
00289   // ///////////////////////////////////
00290   // Private data members
00291 
00292   int                                        numBlocks_;
00293   Teuchos::RefCountPtr<vecSpaces_t>          vecSpaces_;
00294   Teuchos::RefCountPtr<vecSpacesOffsets_t>   vecSpacesOffsets_;
00295   // cached info
00296   Index                                      dim_;
00297   bool                                       isInCore_;
00298   
00299 protected:
00300 
00301   // ///////////////////////////////////
00302   // Protected member functions
00303 
00305   DefaultProductVectorSpace(){ numBlocks_=0; dim_=0; }
00306 
00307 };
00308 
00309 // /////////////////////////////////
00310 // Inline members
00311 
00312 template<class Scalar>
00313 inline const Teuchos::RefCountPtr<const VectorSpaceBase<Scalar> >*
00314 DefaultProductVectorSpace<Scalar>::vecSpaces() const
00315 {
00316   return ( dim_ ? &(*vecSpaces_)[0] : NULL );
00317 }
00318 
00319 template<class Scalar>
00320 inline const Index* DefaultProductVectorSpace<Scalar>::vecSpacesOffsets() const
00321 {
00322   return ( dim_ ? &(*vecSpacesOffsets_)[0] : NULL );
00323 }
00324 
00325 template<class Scalar>
00326 inline bool DefaultProductVectorSpace<Scalar>::hasBeenCloned() const
00327 {
00328   return vecSpaces_.count() > 1;
00329 }
00330 
00331 } // namespace Thyra
00332 
00333 #endif // THYRA_PRODUCT_VECTOR_SPACE_DECL_HPP

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