10 #ifndef EPETRA_TSQRADAPTOR_HPP
11 #define EPETRA_TSQRADAPTOR_HPP
25 #include "Tpetra_ConfigDefs.hpp"
27 #if defined(TPETRA_ENABLE_DEPRECATED_CODE)
28 #if defined(TPETRA_DEPRECATED_DECLARATIONS)
29 #warning This file is deprecated due to Epetra removal and will be removed
32 #error This file is deprecated due to Epetra removal and will be removed
35 #if defined(TPETRA_ENABLE_DEPRECATED_CODE) && defined(HAVE_TPETRA_EPETRA) && defined(HAVE_TPETRA_TSQR)
37 #include "Tsqr_NodeTsqrFactory.hpp"
39 #include "Tsqr_DistTsqr.hpp"
40 #include "Epetra_Comm.h"
44 #include "Epetra_MultiVector.h"
45 #include "Teuchos_ParameterListAcceptorDefaultBase.hpp"
74 TPETRA_DEPRECATED_MSG(
"epetra removal")
75 class TsqrAdaptor : public Teuchos::ParameterListAcceptorDefaultBase {
77 typedef Epetra_MultiVector MV;
85 typedef double scalar_type;
93 typedef int ordinal_type;
101 Kokkos::Device<Kokkos::DefaultHostExecutionSpace,
112 using dense_matrix_type =
113 Teuchos::SerialDenseMatrix<ordinal_type, scalar_type>;
120 using magnitude_type = double;
123 using matview_type = TSQR::MatView<ordinal_type, scalar_type>;
124 using node_tsqr_factory_type =
125 TSQR::NodeTsqrFactory<scalar_type, ordinal_type, device_type>;
128 using node_tsqr_type = TSQR::NodeTsqr<ordinal_type, scalar_type>;
129 using dist_tsqr_type = TSQR::DistTsqr<ordinal_type, scalar_type>;
130 using tsqr_type = TSQR::Tsqr<ordinal_type, scalar_type>;
139 TsqrAdaptor (
const Teuchos::RCP<Teuchos::ParameterList>& plist) :
140 nodeTsqr_ (node_tsqr_factory_type::getNodeTsqr ()),
141 distTsqr_ (new dist_tsqr_type),
142 tsqr_ (new tsqr_type (nodeTsqr_, distTsqr_)),
145 setParameterList (plist);
150 nodeTsqr_ (node_tsqr_factory_type::getNodeTsqr ()),
151 distTsqr_ (new dist_tsqr_type),
152 tsqr_ (new tsqr_type (nodeTsqr_, distTsqr_)),
155 setParameterList (Teuchos::null);
158 Teuchos::RCP<const Teuchos::ParameterList>
159 getValidParameters ()
const
163 using Teuchos::ParameterList;
164 using Teuchos::parameterList;
166 if (defaultParams_.is_null()) {
167 RCP<ParameterList> params = parameterList (
"TSQR implementation");
168 params->set (
"NodeTsqr", *(nodeTsqr_->getValidParameters ()));
169 params->set (
"DistTsqr", *(distTsqr_->getValidParameters ()));
170 defaultParams_ = params;
172 return defaultParams_;
176 setParameterList (
const Teuchos::RCP<Teuchos::ParameterList>& plist)
178 using Teuchos::ParameterList;
179 using Teuchos::parameterList;
181 using Teuchos::sublist;
183 RCP<ParameterList> params = plist.is_null() ?
184 parameterList (*getValidParameters ()) : plist;
185 nodeTsqr_->setParameterList (sublist (params,
"NodeTsqr"));
186 distTsqr_->setParameterList (sublist (params,
"DistTsqr"));
188 this->setMyParamList (params);
213 factorExplicit (MV& A,
215 dense_matrix_type& R,
216 const bool forceNonnegativeDiagonal=
false)
220 scalar_type*
const A_ptr = A.Values ();
221 scalar_type*
const Q_ptr = Q.Values ();
222 scalar_type*
const R_ptr = R.values ();
223 const ordinal_type numRows = A.MyLength ();
224 const ordinal_type numCols = A.NumVectors ();
225 const ordinal_type lda = A.Stride ();
226 const ordinal_type ldq = Q.Stride ();
227 const ordinal_type ldr = R.stride ();
229 const bool contiguousCacheBlocks =
false;
230 tsqr_->factorExplicitRaw (numRows, numCols, A_ptr, lda,
231 Q_ptr, ldq, R_ptr, ldr,
232 contiguousCacheBlocks,
233 forceNonnegativeDiagonal);
268 dense_matrix_type& R,
269 const magnitude_type& tol)
271 TEUCHOS_TEST_FOR_EXCEPTION
272 (! Q.ConstantStride (), std::invalid_argument,
"TsqrAdaptor::"
273 "revealRank: Input MultiVector Q must have constant stride.");
278 return tsqr_->revealRankRaw (Q.MyLength (), Q.NumVectors (),
279 Q.Values (), Q.Stride (),
280 R.values (), R.stride (), tol,
false);
285 Teuchos::RCP<node_tsqr_type> nodeTsqr_;
288 Teuchos::RCP<dist_tsqr_type> distTsqr_;
291 Teuchos::RCP<tsqr_type> tsqr_;
294 mutable Teuchos::RCP<const Teuchos::ParameterList> defaultParams_;
318 prepareTsqr (
const MV& mv)
321 prepareDistTsqr (mv);
333 prepareDistTsqr (
const MV& mv)
337 using TSQR::Epetra::makeTsqrMessenger;
338 typedef TSQR::MessengerBase<scalar_type> base_mess_type;
343 RCP<const Epetra_Comm> comm = rcp (mv.Comm().Clone());
344 RCP<base_mess_type> messBase = makeTsqrMessenger<scalar_type> (comm);
345 distTsqr_->init (messBase);
351 #endif // defined(TPETRA_ENABLE_DEPRECATED_CODE) && defined(HAVE_TPETRA_EPETRA) && defined(HAVE_TPETRA_TSQR)
353 #endif // EPETRA_TSQRADAPTOR_HPP
Function for wrapping Epetra_Comm in a communicator wrapper that TSQR can use.