|
Anasazi Version of the Day
|
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_TsqrAdaptor_Tpetra_MultiVector_SerialNode_hpp 00030 #define __TSQR_Trilinos_TsqrAdaptor_Tpetra_MultiVector_SerialNode_hpp 00031 00036 00037 #include "TsqrTypeAdaptor_Tpetra_MultiVector_SerialNode.hpp" 00038 #ifdef HAVE_KOKKOS_TBB 00039 # include "TsqrTypeAdaptor_Tpetra_MultiVector_TBBNode.hpp" 00040 #endif // HAVE_KOKKOS_TBB 00041 #include "TsqrCommFactory_Tpetra.hpp" 00042 00045 00046 namespace TSQR { 00047 namespace Trilinos { 00048 00049 template< class S, class LO, class GO, class Node > 00050 class TsqrTpetraAdaptor : 00051 public TsqrAdaptor< S, LO, GO, Tpetra::MultiVector< S, LO, GO, Node > > 00052 { 00053 public: 00054 typedef Node node_type; 00055 // The MV typedef is just shorthand to make the base_type 00056 // typedef fit on one line. It's not a circular definition, 00057 // because C++ doesn't inherit typedefs from base to derived 00058 // class, when both the base and the derived classes are 00059 // templated. 00060 typedef Tpetra::MultiVector< S, LO, GO, Node > MV; 00061 typedef TsqrAdaptor< S, LO, GO, MV > base_type; 00062 typedef typename base_type::comm_ptr comm_ptr; 00063 typedef typename base_type::multivector_type multivector_type; 00064 typedef typename base_type::scalar_type scalar_type; 00065 typedef typename base_type::local_ordinal_type local_ordinal_type; 00066 typedef typename base_type::scalar_messenger_ptr scalar_messenger_ptr; 00067 typedef typename base_type::ordinal_messenger_ptr ordinal_messenger_ptr; 00068 00082 TsqrTpetraAdaptor (const multivector_type& mv, 00083 const Teuchos::ParameterList& plist) 00084 { 00085 init (mv, plist); 00086 } 00087 00088 private: 00089 virtual void 00090 fetchDims (const multivector_type& A, 00091 local_ordinal_type& nrowsLocal, 00092 local_ordinal_type& ncols, 00093 local_ordinal_type& LDA) const 00094 { 00095 nrowsLocal = A.getLocalLength(); 00096 ncols = A.getNumVectors(); 00097 if (nrowsLocal < ncols) 00098 { 00099 std::ostringstream os; 00100 os << "TSQR: The local component of the input matrix has fewer row" 00101 "s (" << nrowsLocal << ") than columns (" << ncols << "). TSQR " 00102 "does not support this case."; 00103 throw std::runtime_error (os.str()); 00104 } 00105 if (! A.isConstantStride()) 00106 { 00107 // FIXME (mfh 14 June 2010) Storage of A uses nonconstant 00108 // stride internally, but that doesn't necessarily mean we 00109 // can't run TSQR. It depends on what get1dViewNonConst() 00110 // returns. If it's copied and packed into a matrix with 00111 // constant stride, then we are free to run TSQR. 00112 std::ostringstream os; 00113 os << "TSQR does not support Tpetra::MultiVector inputs that do no" 00114 "t have constant stride."; 00115 throw std::runtime_error (os.str()); 00116 } 00117 LDA = A.getStride(); 00118 } 00119 00120 virtual Teuchos::ArrayRCP< scalar_type > 00121 fetchNonConstView (multivector_type& A) const 00122 { 00123 return A.get1dViewNonConst(); 00124 } 00125 00126 virtual Teuchos::ArrayRCP< const scalar_type > 00127 fetchConstView (const multivector_type& A) const 00128 { 00129 return A.get1dView(); 00130 } 00131 00132 virtual void 00133 fetchMessengers (const multivector_type& mv, 00134 scalar_messenger_ptr& pScalarMessenger, 00135 ordinal_messenger_ptr& pOrdinalMessenger) const 00136 { 00137 typedef TpetraCommFactory< S, LO, GO, Node > comm_factory_type; 00138 comm_ptr pComm = mv.getMap()->getComm(); 00139 comm_factory_type factory; 00140 factory.makeMessengers (pComm, pScalarMessenger, pOrdinalMessenger); 00141 } 00142 }; 00143 00144 } // namespace Trilinos 00145 } // namespace TSQR 00146 00147 #endif // __TSQR_Trilinos_TsqrAdaptor_Tpetra_MultiVector_SerialNode_hpp
1.7.4