Anasazi Version of the Day
TsqrFactory_SequentialTsqr.hpp
Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //                 Anasazi: Block Eigensolvers Package
00005 //                 Copyright (2010) 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 __TSQR_Trilinos_TsqrFactory_SequentialTsqr_hpp
00030 #define __TSQR_Trilinos_TsqrFactory_SequentialTsqr_hpp
00031 
00035 
00036 #include "Tsqr_SequentialTsqr.hpp"
00037 #include "Tsqr.hpp"
00038 #include "Teuchos_ParameterListExceptions.hpp"
00039 
00042 
00043 namespace TSQR {
00044   namespace Trilinos {
00045 
00050     template< class LO, class S >
00051     class SequentialTsqrFactory :
00052       public TsqrFactory< LO, S, SequentialTsqr< LO, S >, DistTsqr< LO, S > >
00053     {
00054     public:
00055       typedef TsqrFactory< LO, S, SequentialTsqr< LO, S >, DistTsqr< LO, S > > base_type;
00056 
00057       // Pull in the typedefs from the base class.  C++ doesn't do
00058       // this when both the base and the derived classes are
00059       // templated.
00060       typedef typename base_type::scalar_messenger_ptr scalar_messenger_ptr;
00061       typedef typename base_type::node_tsqr_type node_tsqr_type;
00062       typedef typename base_type::node_tsqr_ptr  node_tsqr_ptr;
00063       typedef typename base_type::dist_tsqr_type dist_tsqr_type;
00064       typedef typename base_type::dist_tsqr_ptr  dist_tsqr_ptr;
00065       typedef typename base_type::tsqr_type tsqr_type;
00066       typedef typename base_type::tsqr_ptr  tsqr_ptr;
00067 
00068       SequentialTsqrFactory () {}
00069       virtual ~SequentialTsqrFactory () {}
00070 
00071     private:
00080       virtual node_tsqr_ptr
00081       makeNodeTsqr (const Teuchos::ParameterList& plist) const
00082       {
00083   using Teuchos::Exceptions::InvalidParameter;
00084   size_t cacheBlockSize = 0;
00085 
00086   // All this try/catch stuff is because the C++ compiler can't
00087   // deduce the right two-argument get() function (second argument
00088   // would be the default).
00089   try {
00090     const std::string cacheBlockSizeParamName ("cacheBlockSize");
00091     cacheBlockSize = plist.get< size_t > (cacheBlockSizeParamName);
00092   } catch (InvalidParameter&) {
00093     cacheBlockSize = 0;
00094   }
00095   
00096   node_tsqr_ptr node_tsqr (new node_tsqr_type (cacheBlockSize));
00097   return node_tsqr;
00098       }
00099 
00100       virtual dist_tsqr_ptr
00101       makeDistTsqr (const scalar_messenger_ptr& messenger,
00102         const Teuchos::ParameterList& plist) const
00103       {
00104   return Teuchos::rcp (new dist_tsqr_type (messenger));
00105       }
00106     };
00107 
00108   } // namespace Trilinos
00109 } // namespace TSQR
00110 
00111 #endif // __TSQR_Trilinos_TsqrFactory_SequentialTsqr_hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends