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, comm);
165 makeMultiVector (
const map_ptr& map,
177 const RCP< normalgen_type >& pGen)
179 using TSQR::Trilinos::TpetraRandomizer;
180 typedef TpetraRandomizer< S, LO, GO, Node, normalgen_type > randomizer_type;
182 const LO ncols = mv->getNumVectors();
183 std::vector< S > singular_values (ncols);
186 singular_values[0] = S(1);
187 for (LO k = 1; k < ncols; ++k)
188 singular_values[k] = singular_values[k-1] / S(2);
190 randomizer_type randomizer (*mv, pGen);
191 randomizer.randomMultiVector (*mv, &singular_values[0]);
195 makeTestProblem (
const Tpetra::global_size_t nrowsGlobal,
197 const comm_ptr& comm,
198 const node_ptr& node,
201 using TSQR::Trilinos::TpetraMessenger;
202 using TSQR::MessengerBase;
204 map_ptr map = makeMap (nrowsGlobal, comm, node);
205 RCP< MV > A = makeMultiVector (map, ncols);
206 RCP< MV > A_copy = makeMultiVector (map, ncols);
207 RCP< MV > Q = makeMultiVector (map, ncols);
210 RCP< normalgen_type > pGen (
new normalgen_type);
211 fillMultiVector (A, pGen);
213 return Teuchos::tuple (A, A_copy, Q);
221 #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)