42 #ifndef __TSQR_Trilinos_TsqrTpetraTest_hpp 43 #define __TSQR_Trilinos_TsqrTpetraTest_hpp 46 #include "Tsqr_Random_NormalGenerator.hpp" 48 #include "Teuchos_Tuple.hpp" 61 template<
class S,
class LO,
class GO,
class Node >
62 class TpetraTsqrTest {
64 typedef S scalar_type;
65 typedef LO local_ordinal_type;
66 typedef GO global_ordinal_type;
67 typedef Node node_type;
69 typedef typename TSQR::ScalarTraits< S >::magnitude_type magnitude_type;
70 typedef TSQR::Trilinos::TsqrTpetraAdaptor< S, LO, GO, Node > adaptor_type;
72 TpetraTsqrTest (
const Tpetra::global_size_t nrowsGlobal,
77 results_ (magnitude_type(0), magnitude_type(0))
81 typedef typename adaptor_type::factor_output_type factor_output_type;
84 bool contiguousCacheBlocks =
false;
86 contiguousCacheBlocks = params.
get<
bool>(
"contiguousCacheBlocks");
87 }
catch (InvalidParameter&) {
88 contiguousCacheBlocks =
false;
91 triple_type testProblem =
92 makeTestProblem (nrowsGlobal, ncols, comm, node, params);
101 matrix_type R (ncols, ncols);
105 adaptor_type adaptor (*A, params);
106 if (contiguousCacheBlocks)
107 adaptor.cacheBlock (*A, *A_copy);
109 factor_output_type factorOutput =
110 adaptor.factor (*A_copy, R, contiguousCacheBlocks);
111 adaptor.explicitQ (*A_copy, factorOutput, *Q, contiguousCacheBlocks);
112 if (contiguousCacheBlocks)
117 adaptor.unCacheBlock (*A_copy, *Q);
119 results_ = adaptor.verify (*A, *Q, R);
124 std::pair< magnitude_type, magnitude_type >
131 typedef Tpetra::MultiVector< S, LO, GO, Node > MV;
134 typedef Tpetra::Map< LO, GO, Node > map_type;
136 typedef TSQR::Random::NormalGenerator< LO, S > normalgen_type;
143 std::pair< magnitude_type, magnitude_type > results_;
154 makeMap (
const Tpetra::global_size_t nrowsGlobal,
155 const comm_ptr& comm,
156 const node_ptr& node)
158 using Tpetra::createUniformContigMapWithNode;
159 return createUniformContigMapWithNode< LO, GO, Node > (nrowsGlobal,
166 makeMultiVector (
const map_ptr& map,
178 const RCP< normalgen_type >& pGen)
180 using TSQR::Trilinos::TpetraRandomizer;
181 typedef TpetraRandomizer< S, LO, GO, Node, normalgen_type > randomizer_type;
183 const LO ncols = mv->getNumVectors();
184 std::vector< S > singular_values (ncols);
187 singular_values[0] = S(1);
188 for (LO k = 1; k < ncols; ++k)
189 singular_values[k] = singular_values[k-1] / S(2);
191 randomizer_type randomizer (*mv, pGen);
192 randomizer.randomMultiVector (*mv, &singular_values[0]);
196 makeTestProblem (
const Tpetra::global_size_t nrowsGlobal,
198 const comm_ptr& comm,
199 const node_ptr& node,
202 using TSQR::Trilinos::TpetraMessenger;
203 using TSQR::MessengerBase;
205 map_ptr map = makeMap (nrowsGlobal, comm, node);
206 RCP< MV > A = makeMultiVector (map, ncols);
207 RCP< MV > A_copy = makeMultiVector (map, ncols);
208 RCP< MV > Q = makeMultiVector (map, ncols);
211 RCP< normalgen_type > pGen (
new normalgen_type);
212 fillMultiVector (A, pGen);
214 return Teuchos::tuple (A, A_copy, Q);
222 #endif // __TSQR_Trilinos_TsqrTpetraTest_hpp T & get(const std::string &name, T def_value)
Partial specialization of Anasazi::MultiVecTraits and Anasazi::OperatorTraits for Tpetra objects...
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)