50 #include "Teuchos_GlobalMPISession.hpp"
54 int main(
int argc,
char *argv[]) {
62 using vector = std::vector<RealT>;
65 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
68 int iprint = argc - 1;
69 ROL::Ptr<std::ostream> outStream;
72 outStream = ROL::makePtrFromRef(std::cout);
74 outStream = ROL::makePtrFromRef(bhs);
78 oldFormatState.copyfmt(std::cout);
82 RealT tol = ROL::ROL_EPSILON<RealT>();
90 ROL::Ptr<vector> m_ptr = ROL::makePtr<vector>(
91 std::initializer_list<RealT>{ 3.0, 1.0, 0.0, -2.0, 6.0, 2.0, 0.0, -1.0, 3.0 } );
92 ROL::Ptr<vector> a_ptr = ROL::makePtr<vector>(
93 std::initializer_list<RealT>{ 3.0, 6.0, 3.0} );
94 ROL::Ptr<vector> b_ptr = ROL::makePtr<vector>(
95 std::initializer_list<RealT>{ -2.0, -1.0 } );
96 ROL::Ptr<vector> c_ptr = ROL::makePtr<vector>(
97 std::initializer_list<RealT>{ 1.0, 2.0 } );
100 TRI T(a_ptr,b_ptr,c_ptr);
102 SV xm( ROL::makePtr<vector>( std::initializer_list<RealT>{1.0, 2.0, -1.0} ) );
103 SV ym( ROL::makePtr<vector>( dim ) );
104 SV zm( ROL::makePtr<vector>( dim ) );
106 SV xt( ROL::makePtr<vector>( dim ) );
107 SV yt( ROL::makePtr<vector>( dim ) );
108 SV zt( ROL::makePtr<vector>( dim ) );
110 SV error( ROL::makePtr<vector>(dim) );
116 M.applyInverse(zm,ym,tol);
118 *outStream <<
"\nUsing StdLinearOperator - A is full matrix representation" << std::endl;
119 *outStream <<
"x = "; xm.print(*outStream);
120 *outStream <<
"y = Ax = "; ym.print(*outStream);
121 *outStream <<
"z = inv(A)y = "; zm.print(*outStream);
123 *outStream <<
"\nUsing StdTridiagonalOperator - T is tridiagonal representation" << std::endl;
125 *outStream <<
"y = Tx = "; yt.print(*outStream);
129 errorFlag +=
static_cast<int>(nerr>tol);
130 *outStream <<
"apply() error = " << nerr <<std::endl;
132 T.applyInverse(zt,yt,tol);
133 *outStream <<
"z = inv(T)y = "; yt.print(*outStream);
137 errorFlag +=
static_cast<int>(nerr>tol);
138 *outStream <<
"applyInverse() error = " << nerr <<std::endl;
140 M.applyAdjoint(ym,xm,tol);
141 M.applyAdjointInverse(zm,ym,tol);
142 *outStream <<
"\nUsing StdLinearOperator - A is full matrix representation" << std::endl;
143 *outStream <<
"x = "; xm.print(*outStream);
144 *outStream <<
"y = A'x = "; ym.print(*outStream);
145 *outStream <<
"z = inv(A')y = "; zm.print(*outStream);
147 *outStream <<
"\nUsing StdTridiagonalOperator - T is tridiagonal representation" << std::endl;
148 T.applyAdjoint(yt,xt,tol);
149 *outStream <<
"y = T'x = "; yt.print(*outStream);
153 errorFlag +=
static_cast<int>(nerr>tol);
154 *outStream <<
"applyAdjoint() error = " << nerr <<std::endl;
156 T.applyAdjointInverse(zt,yt,tol);
157 *outStream <<
"z = inv(T')y = "; yt.print(*outStream);
161 errorFlag +=
static_cast<int>(nerr>tol);
162 *outStream <<
"applyAdjointInverse() error = " << nerr <<std::endl;
168 catch (std::logic_error& err) {
169 *outStream << err.what() <<
"\n";
174 std::cout <<
"End Result: TEST FAILED\n";
176 std::cout <<
"End Result: TEST PASSED\n";
179 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[])