#include <Teuchos_GlobalMPISession.hpp>
#include <Teuchos_oblackholestream.hpp>
#include <Teuchos_CommandLineProcessor.hpp>
#include <Teuchos_Array.hpp>
#include <Tpetra_MatrixIO.hpp>
#include "Tpetra_Power_Method.hpp"
#include "Tpetra_DefaultPlatform.hpp"
#include "Tpetra_Version.hpp"
#include "Tpetra_Map.hpp"
#include "Tpetra_MultiVector.hpp"
#include "Tpetra_Vector.hpp"
#include "Tpetra_CrsMatrix.hpp"
int main(int argc, char *argv[]) {
Teuchos::oblackholestream blackhole;
Teuchos::GlobalMPISession mpiSession(&argc,&argv,&blackhole);
typedef double Scalar;
typedef Teuchos::ScalarTraits<Scalar>::magnitudeType Magnitude;
typedef int Ordinal;
using Teuchos::RCP;
using Teuchos::tuple;
RCP<const Teuchos::Comm<int> > comm = platform.getComm();
RCP<Node> node = platform.getNode();
const int myRank = comm->getRank();
bool printMatrix = false;
bool verbose = (myRank==0);
int niters = 100;
Magnitude tolerance = 1.0e-2;
std::string filename("bcsstk14.hb");
Teuchos::CommandLineProcessor cmdp(false,true);
cmdp.setOption("verbose","quiet",&verbose,"Print messages and results.");
cmdp.setOption("filename",&filename,"Filename for Harwell-Boeing test matrix.");
cmdp.setOption("tolerance",&tolerance,"Relative residual tolerance used for solver.");
cmdp.setOption("iterations",&niters,"Maximum number of iterations.");
cmdp.setOption("printMatrix","noPrintMatrix",&printMatrix,"Print the full matrix after reading it.");
if (cmdp.parse(argc,argv) != Teuchos::CommandLineProcessor::PARSE_SUCCESSFUL) {
return -1;
}
if (verbose) {
std::cout << "\n" << Tpetra::version() << std::endl << std::endl;
}
std::cout << "Comm info: " << *comm;
RCP<CrsMatrix> A;
Tpetra::Utils::readHBMatrix(filename,comm,node,A);
if (printMatrix) {
RCP<Teuchos::FancyOStream> fos = Teuchos::fancyOStream(Teuchos::rcpFromRef(std::cout));
A->describe(*fos, Teuchos::VERB_EXTREME);
}
else if (verbose) {
std::cout << std::endl << A->description() << std::endl << std::endl;
}
TpetraExamples::powerMethod<Scalar,Ordinal>(A, niters, tolerance, verbose);
if (verbose) {
std::cout << "\nEnd Result: TEST PASSED" << std::endl;
}
return 0;
}