29 #ifndef __TSQR_Trilinos_TsqrTpetraTest_hpp
30 #define __TSQR_Trilinos_TsqrTpetraTest_hpp
32 #include "Teuchos_Tuple.hpp"
35 #include "Kokkos_ConfigDefs.hpp"
36 #include "Kokkos_NodeHelpers.hpp"
37 #include "Kokkos_SerialNode.hpp"
38 #ifdef HAVE_KOKKOSCLASSIC_TBB
39 #include "Kokkos_TBBNode.hpp"
40 #endif // HAVE_KOKKOSCLASSIC_TBB
44 #include "Tsqr_Random_NormalGenerator.hpp"
59 template<
class S,
class LO,
class GO,
class Node >
60 class TpetraTsqrTest {
62 typedef S scalar_type;
63 typedef LO local_ordinal_type;
64 typedef GO global_ordinal_type;
65 typedef Node node_type;
67 typedef typename TSQR::ScalarTraits< S >::magnitude_type magnitude_type;
68 typedef TSQR::Trilinos::TsqrTpetraAdaptor< S, LO, GO, Node > adaptor_type;
70 TpetraTsqrTest (
const Tpetra::global_size_t nrowsGlobal,
75 results_ (magnitude_type(0), magnitude_type(0))
79 typedef typename adaptor_type::factor_output_type factor_output_type;
82 bool contiguousCacheBlocks =
false;
84 contiguousCacheBlocks = params.
get<
bool>(
"contiguousCacheBlocks");
85 }
catch (InvalidParameter&) {
86 contiguousCacheBlocks =
false;
89 triple_type testProblem =
90 makeTestProblem (nrowsGlobal, ncols, comm, node, params);
99 matrix_type R (ncols, ncols);
103 adaptor_type adaptor (*A, params);
104 if (contiguousCacheBlocks)
105 adaptor.cacheBlock (*A, *A_copy);
107 factor_output_type factorOutput =
108 adaptor.factor (*A_copy, R, contiguousCacheBlocks);
109 adaptor.explicitQ (*A_copy, factorOutput, *Q, contiguousCacheBlocks);
110 if (contiguousCacheBlocks)
115 adaptor.unCacheBlock (*A_copy, *Q);
117 results_ = adaptor.verify (*A, *Q, R);
122 std::pair< magnitude_type, magnitude_type >
129 typedef Tpetra::MultiVector< S, LO, GO, Node > MV;
132 typedef Tpetra::Map< LO, GO, Node > map_type;
134 typedef TSQR::Random::NormalGenerator< LO, S > normalgen_type;
141 std::pair< magnitude_type, magnitude_type > results_;
152 makeMap (
const Tpetra::global_size_t nrowsGlobal,
153 const comm_ptr& comm,
154 const node_ptr& node)
156 using Tpetra::createUniformContigMapWithNode;
157 return createUniformContigMapWithNode< LO, GO, Node > (nrowsGlobal,
164 makeMultiVector (
const map_ptr& map,
176 const RCP< normalgen_type >& pGen)
178 using TSQR::Trilinos::TpetraRandomizer;
179 typedef TpetraRandomizer< S, LO, GO, Node, normalgen_type > randomizer_type;
181 const LO ncols = mv->getNumVectors();
182 std::vector< S > singular_values (ncols);
185 singular_values[0] = S(1);
186 for (LO k = 1; k < ncols; ++k)
187 singular_values[k] = singular_values[k-1] / S(2);
189 randomizer_type randomizer (*mv, pGen);
190 randomizer.randomMultiVector (*mv, &singular_values[0]);
194 makeTestProblem (
const Tpetra::global_size_t nrowsGlobal,
196 const comm_ptr& comm,
197 const node_ptr& node,
200 using TSQR::Trilinos::TpetraMessenger;
201 using TSQR::MessengerBase;
203 map_ptr map = makeMap (nrowsGlobal, comm, node);
204 RCP< MV > A = makeMultiVector (map, ncols);
205 RCP< MV > A_copy = makeMultiVector (map, ncols);
206 RCP< MV > Q = makeMultiVector (map, ncols);
209 RCP< normalgen_type > pGen (
new normalgen_type);
210 fillMultiVector (A, pGen);
212 return Teuchos::tuple (A, A_copy, Q);
220 #endif // __TSQR_Trilinos_TsqrTpetraTest_hpp
T & get(const std::string &name, T def_value)
Adaptor between Anasazi and Tpetra::{MultiVector,Operator}.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)