22#include "ROL_Elementwise_Function.hpp"
28#include "ROL_GlobalMPISession.hpp"
38 const PV eb =
dynamic_cast<const PV&
>(x);
42 std::cout <<
"[subvector " << k <<
"]" << std::endl;
44 auto vp = ROL::dynamicPtrCast<const SV>(vec)->getVector();
46 std::cout << (*vp)[i] << std::endl;
53int main(
int argc,
char *argv[]) {
56 typedef std::vector<RealT> vector;
66 typedef typename vector::size_type luint;
68 ROL::GlobalMPISession mpiSession(&argc, &argv);
70 int iprint = argc - 1;
72 ROL::Ptr<std::ostream> outStream;
76 outStream = ROL::makePtrFromRef(std::cout);
78 outStream = ROL::makePtrFromRef(bhs);
82 RealT errtol = ROL::ROL_THRESHOLD<RealT>();
88 ROL::Ptr<vector> x1_ptr = ROL::makePtr<vector>(
dim,1.0);
89 ROL::Ptr<vector> x2_ptr = ROL::makePtr<vector>(
dim,2.0);
91 ROL::Ptr<vector> y1_ptr = ROL::makePtr<vector>(
dim,0.0);
92 ROL::Ptr<vector> y2_ptr = ROL::makePtr<vector>(
dim,0.0);
94 ROL::Ptr<vector> z1_ptr = ROL::makePtr<vector>(
dim,0.0);
95 ROL::Ptr<vector> z2_ptr = ROL::makePtr<vector>(
dim,0.0);
97 ROL::Ptr<V> x1 = ROL::makePtr<SV>( x1_ptr);
98 ROL::Ptr<V> x2 = ROL::makePtr<SV>( x2_ptr);
100 ROL::Ptr<V> y1 = ROL::makePtr<SV>( y1_ptr);
101 ROL::Ptr<V> y2 = ROL::makePtr<SV>( y2_ptr);
103 ROL::Ptr<V> z1 = ROL::makePtr<SV>( z1_ptr);
104 ROL::Ptr<V> z2 = ROL::makePtr<SV>( z2_ptr);
111 ROL::Ptr<vector> d1_ptr = ROL::makePtr<vector>(
dim,0.0);
112 ROL::Ptr<vector> d2_ptr = ROL::makePtr<vector>(
dim,0.0);
115 ROL::Ptr<vector> u_ptr = ROL::makePtr<vector>(
dim,0.0);
116 ROL::Ptr<vector> v_ptr = ROL::makePtr<vector>(
dim,1.0);
118 (*d1_ptr)[0] = 6.0; (*d2_ptr)[0] = 3.0;
119 (*d1_ptr)[1] = 5.0; (*d2_ptr)[1] = 2.0;
120 (*d1_ptr)[2] = 4.0; (*d2_ptr)[2] = 1.0;
122 (*z1_ptr)[0] = 6.0; (*z2_ptr)[0] = 6.0;
123 (*z1_ptr)[1] = 11.0; (*z2_ptr)[1] = 4.0;
124 (*z1_ptr)[2] = 4.0; (*z2_ptr)[2] = 2.0;
128 ROL::Ptr<V> d1 = ROL::makePtr<SV>(d1_ptr);
129 ROL::Ptr<V> d2 = ROL::makePtr<SV>(d2_ptr);
130 ROL::Ptr<V> u = ROL::makePtr<SV>(u_ptr);
131 ROL::Ptr<V> v = ROL::makePtr<SV>(v_ptr);
133 ROL::Ptr<LinOp> D1 = ROL::makePtr<DiagOp>(*d1);
134 ROL::Ptr<LinOp> NO = ROL::makePtr<NullOp>();
135 ROL::Ptr<LinOp> UV = ROL::makePtr<DyadOp>(u,v);
136 ROL::Ptr<LinOp> D2 = ROL::makePtr<DiagOp>(*d2);
141 D1->apply(*x1,*x1,tol);
142 D1->applyInverse(*x1,*x1,tol);
147 bkop.apply(*y,*x,tol);
151 errorFlag +=
static_cast<int>(z->norm()>errtol);
155 catch (std::logic_error& err) {
161 std::cout <<
"End Result: TEST FAILED\n";
163 std::cout <<
"End Result: TEST PASSED\n";
PartitionedVector< Real > PV
typename PV< Real >::size_type size_type
Defines a no-output stream class ROL::NullStream and a function makeStreamPtr which either wraps a re...
Contains definitions of custom data types in ROL.
Provides the interface to apply a 2x2 block operator to a partitioned vector.
Provides the interface to apply a diagonal operator which acts like elementwise multiplication when a...
Interface to apply a dyadic operator to a vector.
Provides the interface to apply a linear operator.
Defines the linear algebra of vector space on a generic partitioned vector.
size_type numVectors() const
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Defines the linear algebra or vector space interface.
int main(int argc, char *argv[])
ROL::Ptr< Vector< Real > > CreatePartitionedVector(const ROL::Ptr< Vector< Real > > &a)
void print_vector(const ROL::Vector< Real > &x)