16 #include "Teuchos_GlobalMPISession.hpp"
20 int main(
int argc,
char *argv[]) {
28 using vector = std::vector<RealT>;
31 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
34 int iprint = argc - 1;
35 ROL::Ptr<std::ostream> outStream;
38 outStream = ROL::makePtrFromRef(std::cout);
40 outStream = ROL::makePtrFromRef(bhs);
44 oldFormatState.copyfmt(std::cout);
48 RealT tol = ROL::ROL_EPSILON<RealT>();
56 ROL::Ptr<vector> m_ptr = ROL::makePtr<vector>(
57 std::initializer_list<RealT>{ 3.0, 1.0, 0.0, -2.0, 6.0, 2.0, 0.0, -1.0, 3.0 } );
58 ROL::Ptr<vector> a_ptr = ROL::makePtr<vector>(
59 std::initializer_list<RealT>{ 3.0, 6.0, 3.0} );
60 ROL::Ptr<vector> b_ptr = ROL::makePtr<vector>(
61 std::initializer_list<RealT>{ -2.0, -1.0 } );
62 ROL::Ptr<vector> c_ptr = ROL::makePtr<vector>(
63 std::initializer_list<RealT>{ 1.0, 2.0 } );
66 TRI T(a_ptr,b_ptr,c_ptr);
68 SV xm( ROL::makePtr<vector>( std::initializer_list<RealT>{1.0, 2.0, -1.0} ) );
69 SV ym( ROL::makePtr<vector>( dim ) );
70 SV zm( ROL::makePtr<vector>( dim ) );
72 SV xt( ROL::makePtr<vector>( dim ) );
73 SV yt( ROL::makePtr<vector>( dim ) );
74 SV zt( ROL::makePtr<vector>( dim ) );
76 SV error( ROL::makePtr<vector>(dim) );
82 M.applyInverse(zm,ym,tol);
84 *outStream <<
"\nUsing StdLinearOperator - A is full matrix representation" << std::endl;
85 *outStream <<
"x = "; xm.print(*outStream);
86 *outStream <<
"y = Ax = "; ym.print(*outStream);
87 *outStream <<
"z = inv(A)y = "; zm.print(*outStream);
89 *outStream <<
"\nUsing StdTridiagonalOperator - T is tridiagonal representation" << std::endl;
91 *outStream <<
"y = Tx = "; yt.print(*outStream);
95 errorFlag +=
static_cast<int>(nerr>tol);
96 *outStream <<
"apply() error = " << nerr <<std::endl;
98 T.applyInverse(zt,yt,tol);
99 *outStream <<
"z = inv(T)y = "; yt.print(*outStream);
103 errorFlag +=
static_cast<int>(nerr>tol);
104 *outStream <<
"applyInverse() error = " << nerr <<std::endl;
106 M.applyAdjoint(ym,xm,tol);
107 M.applyAdjointInverse(zm,ym,tol);
108 *outStream <<
"\nUsing StdLinearOperator - A is full matrix representation" << std::endl;
109 *outStream <<
"x = "; xm.print(*outStream);
110 *outStream <<
"y = A'x = "; ym.print(*outStream);
111 *outStream <<
"z = inv(A')y = "; zm.print(*outStream);
113 *outStream <<
"\nUsing StdTridiagonalOperator - T is tridiagonal representation" << std::endl;
114 T.applyAdjoint(yt,xt,tol);
115 *outStream <<
"y = T'x = "; yt.print(*outStream);
119 errorFlag +=
static_cast<int>(nerr>tol);
120 *outStream <<
"applyAdjoint() error = " << nerr <<std::endl;
122 T.applyAdjointInverse(zt,yt,tol);
123 *outStream <<
"z = inv(T')y = "; yt.print(*outStream);
127 errorFlag +=
static_cast<int>(nerr>tol);
128 *outStream <<
"applyAdjointInverse() error = " << nerr <<std::endl;
134 catch (std::logic_error& err) {
135 *outStream << err.what() <<
"\n";
140 std::cout <<
"End Result: TEST FAILED\n";
142 std::cout <<
"End Result: TEST PASSED\n";
145 std::cout.copyfmt(oldFormatState);
Provides the std::vector implementation to apply a linear operator, which is a std::vector representa...
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Provides the std::vector implementation to apply a linear operator, which encapsulates a tridiagonal ...
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])