49 #include "Teuchos_oblackholestream.hpp" 50 #include "Teuchos_GlobalMPISession.hpp" 54 int main(
int argc,
char *argv[]) {
56 using Teuchos::RCP;
using Teuchos::rcp;
62 using vector = std::vector<RealT>;
65 Teuchos::GlobalMPISession mpiSession(&argc, &argv);
68 int iprint = argc - 1;
69 Teuchos::RCP<std::ostream> outStream;
70 Teuchos::oblackholestream bhs;
72 outStream = Teuchos::rcp(&std::cout,
false);
74 outStream = Teuchos::rcp(&bhs,
false);
77 Teuchos::oblackholestream oldFormatState;
78 oldFormatState.copyfmt(std::cout);
82 RealT tol = ROL::ROL_EPSILON<RealT>();
90 RCP<vector> m_rcp = rcp(
new vector({ 3.0, 1.0, 0.0, -2.0, 6.0, 2.0, 0.0, -1.0, 3.0 }) );
91 RCP<vector> a_rcp = rcp(
new vector({ 3.0, 6.0, 3.0} ) );
92 RCP<vector> b_rcp = rcp(
new vector({ -2.0,-1.0 } ) );
93 RCP<vector> c_rcp = rcp(
new vector({ 1.0, 2.0 } ) );
96 TRI T(a_rcp,b_rcp,c_rcp);
98 SV xm( rcp(
new vector( {1.0, 2.0,-1.0} ) ) );
99 SV ym( rcp(
new vector( dim ) ) );
100 SV zm( rcp(
new vector( dim ) ) );
102 SV xt( rcp(
new vector( dim ) ) );
103 SV yt( rcp(
new vector( dim ) ) );
104 SV zt( rcp(
new vector( dim ) ) );
106 SV error( rcp(
new vector(dim) ) );
112 M.applyInverse(zm,ym,tol);
114 *outStream <<
"\nUsing StdLinearOperator - A is full matrix representation" << std::endl;
115 *outStream <<
"x = "; xm.print(*outStream);
116 *outStream <<
"y = Ax = "; ym.print(*outStream);
117 *outStream <<
"z = inv(A)y = "; zm.print(*outStream);
119 *outStream <<
"\nUsing StdTridiagonalOperator - T is tridiagonal representation" << std::endl;
121 *outStream <<
"y = Tx = "; yt.print(*outStream);
125 errorFlag +=
static_cast<int>(nerr>tol);
126 *outStream <<
"apply() error = " << nerr <<std::endl;
128 T.applyInverse(zt,yt,tol);
129 *outStream <<
"z = inv(T)y = "; yt.print(*outStream);
133 errorFlag +=
static_cast<int>(nerr>tol);
134 *outStream <<
"applyInverse() error = " << nerr <<std::endl;
136 M.applyAdjoint(ym,xm,tol);
137 M.applyAdjointInverse(zm,ym,tol);
138 *outStream <<
"\nUsing StdLinearOperator - A is full matrix representation" << std::endl;
139 *outStream <<
"x = "; xm.print(*outStream);
140 *outStream <<
"y = A'x = "; ym.print(*outStream);
141 *outStream <<
"z = inv(A')y = "; zm.print(*outStream);
143 *outStream <<
"\nUsing StdTridiagonalOperator - T is tridiagonal representation" << std::endl;
144 T.applyAdjoint(yt,xt,tol);
145 *outStream <<
"y = T'x = "; yt.print(*outStream);
149 errorFlag +=
static_cast<int>(nerr>tol);
150 *outStream <<
"applyAdjoint() error = " << nerr <<std::endl;
152 T.applyAdjointInverse(zt,yt,tol);
153 *outStream <<
"z = inv(T')y = "; yt.print(*outStream);
157 errorFlag +=
static_cast<int>(nerr>tol);
158 *outStream <<
"applyAdjointInverse() error = " << nerr <<std::endl;
164 catch (std::logic_error err) {
165 *outStream << err.what() <<
"\n";
170 std::cout <<
"End Result: TEST FAILED\n";
172 std::cout <<
"End Result: TEST PASSED\n";
175 std::cout.copyfmt(oldFormatState);
Provides the std::vector implementation to apply a linear operator, which is a std::vector representa...
Provides the std::vector implementation of the ROL::Vector interface.
Provides the std::vector implementation to apply a linear operator, which encapsulates a tridiagonal ...
int main(int argc, char *argv[])