9 template<
class ScalarType>
16 typedef ScalarType NormType;
18 std::vector<std::pair<std::string, std::string> > solvers;
19 solvers.push_back (std::make_pair (
"A",
"1"));
20 solvers.push_back (std::make_pair (
"A",
"2"));
21 solvers.push_back (std::make_pair (
"B",
"3"));
22 solvers.push_back (std::make_pair (
"B",
"4"));
23 solvers.push_back (std::make_pair (
"C",
"5"));
24 solvers.push_back (std::make_pair (
"C",
"6"));
26 for (
size_t k = 0; k < solvers.size (); ++k) {
27 const std::string packageName = solvers[k].first;
28 const std::string solverName = solvers[k].second;
29 cout <<
"Package \"" << packageName <<
"\", solver \"" << solverName
32 Trilinos::Details::getLinearSolver<MV, OP, NormType> (packageName, solverName);
33 if (solver.
get () == NULL) {
34 std::ostringstream err;
35 err <<
"Solver \"" << solvers[k].second <<
"\" from package \""
36 << solvers[k].first <<
"\" does not exist!";
37 throw std::logic_error (err.str ());
43 solver->setMatrix (A);
51 cout <<
"Finished solver->solve(X, B)" << endl << endl;
61 int err = EXIT_SUCCESS;
63 cout <<
"Test ScalarType=float" << endl;
65 testSolvers<float> ();
66 }
catch (std::exception& e) {
67 cout <<
"testSolvers<float>() threw an exception: " << e.what () << endl;
71 cout << endl <<
"Test ScalarType=double" << endl;
73 testSolvers<double> ();
74 }
catch (std::exception& e) {
75 cout <<
"testSolvers<double>() threw an exception: " << e.what () << endl;
79 cout << endl <<
"Test ScalarType=int (should not work)" << endl;
82 cout <<
"testSolvers<int>() should not have worked!" << endl;
84 }
catch (std::exception&) {
85 cout <<
"Of course testSolvers<int>() threw an exception: "
86 "no packages registered themselves for ScalarType=int. "
87 "This is correct behavior in that case." << endl;
T * get() const
Get the raw C++ pointer to the underlying object.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
int main(int argc, char *argv[])
Smart reference counting pointer class for automatic garbage collection.