56 #include "ROL_Elementwise_Function.hpp"
62 #include "Teuchos_GlobalMPISession.hpp"
72 const PV eb =
dynamic_cast<const PV&
>(x);
73 size_type n = eb.numVectors();
75 for(size_type k=0; k<n; ++k) {
76 std::cout <<
"[subvector " << k <<
"]" << std::endl;
78 auto vp = ROL::dynamicPtrCast<const SV>(vec)->getVector();
79 for(size_type i=0;i<vp->size();++i) {
80 std::cout << (*vp)[i] << std::endl;
87 int main(
int argc,
char *argv[]) {
90 typedef std::vector<RealT> vector;
102 using namespace Teuchos;
104 GlobalMPISession mpiSession(&argc, &argv);
106 int iprint = argc - 1;
108 ROL::Ptr<std::ostream> outStream;
112 outStream = ROL::makePtrFromRef(std::cout);
114 outStream = ROL::makePtrFromRef(bhs);
118 RealT errtol = ROL::ROL_THRESHOLD<RealT>();
124 ROL::Ptr<vector> x1_ptr = ROL::makePtr<vector>(
dim,1.0);
125 ROL::Ptr<vector> x2_ptr = ROL::makePtr<vector>(
dim,2.0);
127 ROL::Ptr<vector> y1_ptr = ROL::makePtr<vector>(
dim,0.0);
128 ROL::Ptr<vector> y2_ptr = ROL::makePtr<vector>(
dim,0.0);
130 ROL::Ptr<vector> z1_ptr = ROL::makePtr<vector>(
dim,0.0);
131 ROL::Ptr<vector> z2_ptr = ROL::makePtr<vector>(
dim,0.0);
133 ROL::Ptr<V> x1 = ROL::makePtr<SV>( x1_ptr);
134 ROL::Ptr<V> x2 = ROL::makePtr<SV>( x2_ptr);
136 ROL::Ptr<V> y1 = ROL::makePtr<SV>( y1_ptr);
137 ROL::Ptr<V> y2 = ROL::makePtr<SV>( y2_ptr);
139 ROL::Ptr<V> z1 = ROL::makePtr<SV>( z1_ptr);
140 ROL::Ptr<V> z2 = ROL::makePtr<SV>( z2_ptr);
147 ROL::Ptr<vector> d1_ptr = ROL::makePtr<vector>(
dim,0.0);
148 ROL::Ptr<vector> d2_ptr = ROL::makePtr<vector>(
dim,0.0);
151 ROL::Ptr<vector> u_ptr = ROL::makePtr<vector>(
dim,0.0);
152 ROL::Ptr<vector> v_ptr = ROL::makePtr<vector>(
dim,1.0);
154 (*d1_ptr)[0] = 6.0; (*d2_ptr)[0] = 3.0;
155 (*d1_ptr)[1] = 5.0; (*d2_ptr)[1] = 2.0;
156 (*d1_ptr)[2] = 4.0; (*d2_ptr)[2] = 1.0;
158 (*z1_ptr)[0] = 6.0; (*z2_ptr)[0] = 6.0;
159 (*z1_ptr)[1] = 11.0; (*z2_ptr)[1] = 4.0;
160 (*z1_ptr)[2] = 4.0; (*z2_ptr)[2] = 2.0;
164 ROL::Ptr<V> d1 = ROL::makePtr<SV>(d1_ptr);
165 ROL::Ptr<V> d2 = ROL::makePtr<SV>(d2_ptr);
166 ROL::Ptr<V> u = ROL::makePtr<SV>(u_ptr);
167 ROL::Ptr<V> v = ROL::makePtr<SV>(v_ptr);
169 ROL::Ptr<LinOp> D1 = ROL::makePtr<DiagOp>(*d1);
170 ROL::Ptr<LinOp> NO = ROL::makePtr<NullOp>();
171 ROL::Ptr<LinOp> UV = ROL::makePtr<DyadOp>(u,v);
172 ROL::Ptr<LinOp> D2 = ROL::makePtr<DiagOp>(*d2);
177 D1->apply(*x1,*x1,tol);
178 D1->applyInverse(*x1,*x1,tol);
183 bkop.
apply(*y,*x,tol);
187 errorFlag +=
static_cast<int>(z->norm()>errtol);
191 catch (std::logic_error& err) {
197 std::cout <<
"End Result: TEST FAILED\n";
199 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[])