42 #ifndef __Thyra_TsqrAdaptor_hpp 43 #define __Thyra_TsqrAdaptor_hpp 45 #include <BelosConfigDefs.hpp> 50 #include <Tsqr_NodeTsqrFactory.hpp> 52 #include <Tsqr_DistTsqr.hpp> 55 #include <Tsqr_TeuchosMessenger.hpp> 56 #include <Kokkos_SerialNode.hpp> 59 #include <Thyra_MultiVectorBase.hpp> 61 #include <Thyra_SpmdVectorSpaceBase.hpp> 95 template<
class Scalar>
98 typedef Thyra::MultiVectorBase<Scalar>
MV;
109 typedef TSQR::Tsqr<ordinal_type, scalar_type, node_tsqr_type>
tsqr_type;
124 throw std::logic_error (
"Thyra adaptor for TSQR not implemented");
134 throw std::logic_error (
"Thyra adaptor for TSQR not implemented");
143 using Teuchos::parameterList;
147 params->set (
"NodeTsqr", *(
nodeTsqr_->getValidParameters ()));
148 params->set (
"DistTsqr", *(
distTsqr_->getValidParameters ()));
158 using Teuchos::parameterList;
160 using Teuchos::sublist;
164 nodeTsqr_->setParameterList (sublist (params,
"NodeTsqr"));
165 distTsqr_->setParameterList (sublist (params,
"DistTsqr"));
194 dense_matrix_type& R,
195 const bool forceNonnegativeDiagonal=
false)
197 typedef Kokkos::MultiVector<scalar_type, node_type> KMV;
202 tsqr_->factorExplicit (A_view, Q_view, R,
false,
203 forceNonnegativeDiagonal);
238 dense_matrix_type& R,
239 const magnitude_type& tol)
241 typedef Kokkos::MultiVector<scalar_type, node_type> KMV;
249 return tsqr_->revealRank (Q_view, R, tol,
false);
286 using Teuchos::rcp_dynamic_cast;
287 using Teuchos::rcp_implicit_cast;
288 typedef Thyra::VectorSpaceBase<Scalar> space_base_type;
289 typedef Thyra::SpmdVectorSpaceBase<Scalar> space_type;
315 thyraSerialComm.
is_null (), std::runtime_error,
316 "Thyra's communicator is neither an MpiComm nor a SerialComm. " 317 "Sorry, I have no idea what to do with it in that case.");
330 #else // NOT HAVE_MPI 335 thyraSerialComm.is_null (), std::runtime_error,
336 "Thyra's communicator is not a SerialComm, and MPI is not enabled, so " 337 "it can't be an MpiComm either. That means it must be some other " 338 "subclass of Comm, about which I don't know. " 339 "Sorry, I have no idea what to do with it in that case.");
358 node_tsqr_factory_type::prepareNodeTsqr (nodeTsqr_, node_);
376 using Teuchos::rcp_implicit_cast;
377 typedef TSQR::TeuchosMessenger<scalar_type> mess_type;
378 typedef TSQR::MessengerBase<scalar_type> base_mess_type;
383 distTsqr_->init (messBase);
427 Kokkos::MultiVector<scalar_type, node_type>
433 return Kokkos::MultiVector<scalar_type, node_type> (
node_);
449 #endif // __Thyra_TsqrAdaptor_hpp Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
int revealRank(MV &Q, dense_matrix_type &R, const magnitude_type &tol)
Rank-revealing decomposition.
void prepareNodeTsqr(const MV &X)
Finish intranode TSQR initialization.
Thyra::MultiVectorBase< Scalar > MV
TsqrAdaptor(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Constructor (that accepts a parameter list).
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &plist)
Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > dense_matrix_type
Stub adaptor from Thyra::MultiVectorBase to TSQR.
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Teuchos::RCP< node_tsqr_type > nodeTsqr_
The intranode TSQR implementation instance.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
Teuchos::RCP< tsqr_type > tsqr_
The (full) TSQR implementation instance.
Kokkos::SerialNode node_type
TSQR::Tsqr< ordinal_type, scalar_type, node_tsqr_type > tsqr_type
static Teuchos::RCP< const Teuchos::Comm< int > > getComm(const MV &X)
Attempt to get a communicator out of the given multivector.
node_tsqr_factory_type::node_tsqr_type node_tsqr_type
void factorExplicit(MV &A, MV &Q, dense_matrix_type &R, const bool forceNonnegativeDiagonal=false)
Compute QR factorization [Q,R] = qr(A,0).
void prepareDistTsqr(const MV &X)
Finish internode TSQR initialization.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool is_null(const RCP< T > &p)
TSQR::NodeTsqrFactory< node_type, scalar_type, ordinal_type > node_tsqr_factory_type
bool ready_
Whether TSQR has been fully initialized.
void setMyParamList(const RCP< ParameterList > ¶mList)
TsqrAdaptor()
Constructor (that uses default parameters).
Kokkos::MultiVector< scalar_type, node_type > getNonConstView(MV &X)
Extract a nonconstant view of X's data.
Teuchos::RCP< node_type > node_
Kokkos Node instance.
Teuchos::RCP< dist_tsqr_type > distTsqr_
The internode TSQR implementation instance.
void prepareTsqr(const MV &X)
Finish TSQR initialization.
Teuchos::RCP< const Teuchos::ParameterList > defaultParams_
Default parameter list. Initialized by getValidParameters().
TSQR::DistTsqr< ordinal_type, scalar_type > dist_tsqr_type