155int main(
int argc,
char *argv[]) {
160 typedef std::vector<RealT> vector;
163 typedef typename vector::size_type uint;
165 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
167 int iprint = argc - 1;
168 ROL::Ptr<std::ostream> outStream;
171 outStream = ROL::makePtrFromRef(std::cout);
173 outStream = ROL::makePtrFromRef(bhs);
179 ROL::ParameterList parlist;
180 ROL::ParameterList &gList = parlist.sublist(
"General");
181 ROL::ParameterList &kList = gList.sublist(
"Krylov");
183 kList.set(
"Type",
"GMRES");
184 kList.set(
"Iteration Limit",20);
185 kList.set(
"Absolute Tolerance",1.e-8);
186 kList.set(
"Relative Tolerance",1.e-6);
187 kList.set(
"Use Initial Guess",
false);
191 ROL::Ptr<vector> xp = ROL::makePtr<vector>(
dim,0.0);
192 ROL::Ptr<vector> yp = ROL::makePtr<vector>(
dim,0.0);
193 ROL::Ptr<vector> zp = ROL::makePtr<vector>(
dim,0.0);
194 ROL::Ptr<vector> bp = ROL::makePtr<vector>(
dim,0.0);
220 ROL::Ptr<ROL::Krylov<RealT> > krylov = ROL::KrylovFactory<RealT>( parlist );
225 krylov->run(z,T,b,I,iter,flag);
227 *outStream << std::setw(10) <<
"Exact"
228 << std::setw(10) <<
"LAPACK"
229 << std::setw(10) <<
"GMRES " << std::endl;
230 *outStream <<
"---------------------------------" << std::endl;
232 for(uint k=0;k<
dim;++k) {
233 *outStream << std::setw(10) << (*xp)[k] <<
" "
234 << std::setw(10) << (*yp)[k] <<
" "
235 << std::setw(10) << (*zp)[k] <<
" " << std::endl;
238 *outStream <<
"GMRES performed " << iter <<
" iterations." << std::endl;
242 if( z.norm() > std::sqrt(ROL::ROL_EPSILON<RealT>()) ) {
247 catch (std::logic_error& err) {
248 *outStream << err.what() <<
"\n";
253 std::cout <<
"End Result: TEST FAILED\n";
255 std::cout <<
"End Result: TEST PASSED\n";
void RandomizeVector(Vector< Real > &x, const Real &lower=0.0, const Real &upper=1.0)
Fill a ROL::Vector with uniformly-distributed random numbers in the interval [lower,...