42#ifndef __Thyra_TsqrAdaptor_hpp
43#define __Thyra_TsqrAdaptor_hpp
45#include "BelosConfigDefs.hpp"
50#include "Thyra_MultiVectorBase.hpp"
51#include "Thyra_SpmdVectorSpaceBase.hpp"
54# include "Teuchos_DefaultMpiComm.hpp"
56#include "Teuchos_DefaultSerialComm.hpp"
57#include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
85 template<
class Scalar>
86 class TsqrAdaptor :
public Teuchos::ParameterListAcceptorDefaultBase {
88 typedef Thyra::MultiVectorBase<Scalar>
MV;
92 typedef typename Teuchos::ScalarTraits<scalar_type>::magnitudeType
magnitude_type;
102 throw std::logic_error (
"Thyra adaptor for TSQR not implemented");
108 throw std::logic_error (
"Thyra adaptor for TSQR not implemented");
111 Teuchos::RCP<const Teuchos::ParameterList>
114 throw std::logic_error (
"Thyra adaptor for TSQR not implemented");
120 throw std::logic_error (
"Thyra adaptor for TSQR not implemented");
150 throw std::logic_error (
"Thyra adaptor for TSQR not implemented");
188 throw std::logic_error (
"Thyra adaptor for TSQR not implemented");
202 static Teuchos::RCP<const Teuchos::Comm<int> >
207 using Teuchos::rcp_dynamic_cast;
208 using Teuchos::rcp_implicit_cast;
209 typedef Thyra::VectorSpaceBase<Scalar> space_base_type;
210 typedef Thyra::SpmdVectorSpaceBase<Scalar> space_type;
214 RCP<const space_base_type> rangeBase = X.range ();
215 TEUCHOS_TEST_FOR_EXCEPTION(rangeBase.is_null (), std::runtime_error,
"X.range() is null.");
216 RCP<const space_type> range = rcp_dynamic_cast<const space_type> (rangeBase);
217 TEUCHOS_TEST_FOR_EXCEPTION(range.is_null (), std::runtime_error,
"X.range() is not an SpmdVectorSpaceBase.");
228 RCP<const Teuchos::Comm<Thyra::Ordinal> > thyraComm = range->getComm ();
230 RCP<const Teuchos::MpiComm<Thyra::Ordinal> > thyraMpiComm =
231 rcp_dynamic_cast<const Teuchos::MpiComm<Thyra::Ordinal> > (thyraComm);
232 if (thyraMpiComm.is_null ()) {
233 RCP<const Teuchos::SerialComm<Thyra::Ordinal> > thyraSerialComm =
234 rcp_dynamic_cast<const Teuchos::SerialComm<Thyra::Ordinal> > (thyraComm);
235 TEUCHOS_TEST_FOR_EXCEPTION(
236 thyraSerialComm.is_null (), std::runtime_error,
237 "Thyra's communicator is neither an MpiComm nor a SerialComm. "
238 "Sorry, I have no idea what to do with it in that case.");
242 return rcp_implicit_cast<const Teuchos::Comm<int> > (rcp (
new Teuchos::SerialComm<int>));
245 RCP<const Teuchos::OpaqueWrapper<MPI_Comm> > rawMpiComm = thyraMpiComm->getRawMpiComm ();
249 return rcp_implicit_cast<const Teuchos::Comm<int> > (rcp (
new Teuchos::MpiComm<int> (rawMpiComm)));
253 RCP<const Teuchos::SerialComm<Thyra::Ordinal> > thyraSerialComm =
254 rcp_dynamic_cast<const Teuchos::SerialComm<Thyra::Ordinal> > (thyraComm);
255 TEUCHOS_TEST_FOR_EXCEPTION(
256 thyraSerialComm.is_null (), std::runtime_error,
257 "Thyra's communicator is not a SerialComm, and MPI is not enabled, so "
258 "it can't be an MpiComm either. That means it must be some other "
259 "subclass of Comm, about which I don't know. "
260 "Sorry, I have no idea what to do with it in that case.");
264 return rcp_implicit_cast<const Teuchos::Comm<int> > (rcp (
new Teuchos::SerialComm<int>));
Stub adaptor from Thyra::MultiVectorBase to TSQR.
static Teuchos::RCP< const Teuchos::Comm< int > > getComm(const MV &X)
Attempt to get a communicator out of the given multivector.
Teuchos::SerialDenseMatrix< ordinal_type, scalar_type > dense_matrix_type
int revealRank(MV &, dense_matrix_type &, const magnitude_type &)
Rank-revealing decomposition.
Thyra::MultiVectorBase< Scalar > MV
TsqrAdaptor()
Constructor (that uses default parameters).
void setParameterList(const Teuchos::RCP< Teuchos::ParameterList > &)
Teuchos::ScalarTraits< scalar_type >::magnitudeType magnitude_type
void prepareDistTsqr(const MV &)
Finish interprocess TSQR initialization.
TsqrAdaptor(const Teuchos::RCP< Teuchos::ParameterList > &)
Constructor (that accepts a parameter list).
void prepareTsqr(const MV &)
Finish TSQR initialization.
Teuchos::RCP< const Teuchos::ParameterList > getValidParameters() const
void factorExplicit(MV &, MV &, dense_matrix_type &, const bool=false)
Compute QR factorization [Q,R] = qr(A,0).