22 #include "ROL_Elementwise_Function.hpp"
28 #include "Teuchos_GlobalMPISession.hpp"
38 const PV eb =
dynamic_cast<const PV&
>(x);
39 size_type n = eb.numVectors();
41 for(size_type k=0; k<n; ++k) {
42 std::cout <<
"[subvector " << k <<
"]" << std::endl;
44 auto vp = ROL::dynamicPtrCast<const SV>(vec)->getVector();
45 for(size_type i=0;i<vp->size();++i) {
46 std::cout << (*vp)[i] << std::endl;
53 int main(
int argc,
char *argv[]) {
56 typedef std::vector<RealT> vector;
68 using namespace Teuchos;
70 GlobalMPISession mpiSession(&argc, &argv);
72 int iprint = argc - 1;
74 ROL::Ptr<std::ostream> outStream;
78 outStream = ROL::makePtrFromRef(std::cout);
80 outStream = ROL::makePtrFromRef(bhs);
84 RealT errtol = ROL::ROL_THRESHOLD<RealT>();
90 ROL::Ptr<vector> x1_ptr = ROL::makePtr<vector>(
dim,1.0);
91 ROL::Ptr<vector> x2_ptr = ROL::makePtr<vector>(
dim,2.0);
93 ROL::Ptr<vector> y1_ptr = ROL::makePtr<vector>(
dim,0.0);
94 ROL::Ptr<vector> y2_ptr = ROL::makePtr<vector>(
dim,0.0);
96 ROL::Ptr<vector> z1_ptr = ROL::makePtr<vector>(
dim,0.0);
97 ROL::Ptr<vector> z2_ptr = ROL::makePtr<vector>(
dim,0.0);
99 ROL::Ptr<V> x1 = ROL::makePtr<SV>( x1_ptr);
100 ROL::Ptr<V> x2 = ROL::makePtr<SV>( x2_ptr);
102 ROL::Ptr<V> y1 = ROL::makePtr<SV>( y1_ptr);
103 ROL::Ptr<V> y2 = ROL::makePtr<SV>( y2_ptr);
105 ROL::Ptr<V> z1 = ROL::makePtr<SV>( z1_ptr);
106 ROL::Ptr<V> z2 = ROL::makePtr<SV>( z2_ptr);
113 ROL::Ptr<vector> d1_ptr = ROL::makePtr<vector>(
dim,0.0);
114 ROL::Ptr<vector> d2_ptr = ROL::makePtr<vector>(
dim,0.0);
117 ROL::Ptr<vector> u_ptr = ROL::makePtr<vector>(
dim,0.0);
118 ROL::Ptr<vector> v_ptr = ROL::makePtr<vector>(
dim,1.0);
120 (*d1_ptr)[0] = 6.0; (*d2_ptr)[0] = 3.0;
121 (*d1_ptr)[1] = 5.0; (*d2_ptr)[1] = 2.0;
122 (*d1_ptr)[2] = 4.0; (*d2_ptr)[2] = 1.0;
124 (*z1_ptr)[0] = 6.0; (*z2_ptr)[0] = 6.0;
125 (*z1_ptr)[1] = 11.0; (*z2_ptr)[1] = 4.0;
126 (*z1_ptr)[2] = 4.0; (*z2_ptr)[2] = 2.0;
130 ROL::Ptr<V> d1 = ROL::makePtr<SV>(d1_ptr);
131 ROL::Ptr<V> d2 = ROL::makePtr<SV>(d2_ptr);
132 ROL::Ptr<V> u = ROL::makePtr<SV>(u_ptr);
133 ROL::Ptr<V> v = ROL::makePtr<SV>(v_ptr);
135 ROL::Ptr<LinOp> D1 = ROL::makePtr<DiagOp>(*d1);
136 ROL::Ptr<LinOp> NO = ROL::makePtr<NullOp>();
137 ROL::Ptr<LinOp> UV = ROL::makePtr<DyadOp>(u,v);
138 ROL::Ptr<LinOp> D2 = ROL::makePtr<DiagOp>(*d2);
143 D1->apply(*x1,*x1,tol);
144 D1->applyInverse(*x1,*x1,tol);
149 bkop.
apply(*y,*x,tol);
153 errorFlag +=
static_cast<int>(z->norm()>errtol);
157 catch (std::logic_error& err) {
163 std::cout <<
"End Result: TEST FAILED\n";
165 std::cout <<
"End Result: TEST PASSED\n";
PartitionedVector< Real > PV
typename PV< Real >::size_type size_type
Defines the linear algebra of vector space on a generic partitioned vector.
ROL::Ptr< Vector< Real > > CreatePartitionedVector(const ROL::Ptr< Vector< Real >> &a)
Contains definitions of custom data types in ROL.
Defines the linear algebra or vector space interface.
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
void print_vector(const ROL::Vector< Real > &x)
Provides the interface to apply a diagonal operator which acts like elementwise multiplication when a...
void apply(V &Hv, const V &v, Real &tol) const
Apply linear operator.
Interface to apply a dyadic operator to a vector.
Provides the interface to apply a linear operator.
Provides the interface to apply a 2x2 block operator to a partitioned vector.
basic_nullstream< char, char_traits< char >> nullstream
int main(int argc, char *argv[])