56 #include "ROL_Elementwise_Function.hpp" 61 #include "Teuchos_oblackholestream.hpp" 62 #include "Teuchos_GlobalMPISession.hpp" 70 typedef typename PV::size_type size_type;
72 const PV eb = Teuchos::dyn_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;
77 Teuchos::RCP<const V> vec = eb.get(k);
78 Teuchos::RCP<const std::vector<Real> > vp =
79 Teuchos::dyn_cast<SV>(
const_cast<V&
>(*vec)).getVector();
80 for(size_type i=0;i<vp->size();++i) {
81 std::cout << (*vp)[i] << std::endl;
88 int main(
int argc,
char *argv[]) {
91 typedef std::vector<RealT> vector;
101 typedef typename vector::size_type uint;
103 using namespace Teuchos;
105 GlobalMPISession mpiSession(&argc, &argv);
107 int iprint = argc - 1;
109 RCP<std::ostream> outStream;
110 oblackholestream bhs;
113 outStream = rcp(&std::cout,
false);
115 outStream = rcp(&bhs,
false);
119 RealT errtol = ROL::ROL_THRESHOLD<RealT>();
125 RCP<vector> x1_rcp = rcp(
new vector(dim,1.0) );
126 RCP<vector> x2_rcp = rcp(
new vector(dim,2.0) );
128 RCP<vector> y1_rcp = rcp(
new vector(dim,0.0) );
129 RCP<vector> y2_rcp = rcp(
new vector(dim,0.0) );
131 RCP<vector> z1_rcp = rcp(
new vector(dim,0.0) );
132 RCP<vector> z2_rcp = rcp(
new vector(dim,0.0) );
134 RCP<V> x1 = rcp(
new SV( x1_rcp) );
135 RCP<V> x2 = rcp(
new SV( x2_rcp) );
137 RCP<V> y1 = rcp(
new SV( y1_rcp) );
138 RCP<V> y2 = rcp(
new SV( y2_rcp) );
140 RCP<V> z1 = rcp(
new SV( z1_rcp) );
141 RCP<V> z2 = rcp(
new SV( z2_rcp) );
148 RCP<vector> d1_rcp = rcp(
new vector(dim,0.0) );
149 RCP<vector> d2_rcp = rcp(
new vector(dim,0.0) );
152 RCP<vector> u_rcp = rcp(
new vector(dim,0.0) );
153 RCP<vector> v_rcp = rcp(
new vector(dim,1.0) );
155 (*d1_rcp)[0] = 6.0; (*d2_rcp)[0] = 3.0;
156 (*d1_rcp)[1] = 5.0; (*d2_rcp)[1] = 2.0;
157 (*d1_rcp)[2] = 4.0; (*d2_rcp)[2] = 1.0;
159 (*z1_rcp)[0] = 6.0; (*z2_rcp)[0] = 6.0;
160 (*z1_rcp)[1] = 11.0; (*z2_rcp)[1] = 4.0;
161 (*z1_rcp)[2] = 4.0; (*z2_rcp)[2] = 2.0;
165 RCP<V> d1 = rcp(
new SV(d1_rcp) );
166 RCP<V> d2 = rcp(
new SV(d2_rcp) );
167 RCP<V> u = rcp(
new SV(u_rcp) );
168 RCP<V> v = rcp(
new SV(v_rcp) );
170 RCP<LinOp> D1 = rcp(
new DiagOp(*d1) );
171 RCP<LinOp> NO = rcp(
new NullOp() );
172 RCP<LinOp> UV = rcp(
new DyadOp(u,v) );
173 RCP<LinOp> D2 = rcp(
new DiagOp(*d2) );
178 D1->apply(*x1,*x1,tol);
179 D1->applyInverse(*x1,*x1,tol);
184 bkop.
apply(*y,*x,tol);
188 errorFlag +=
static_cast<int>(z->norm()>errtol);
192 catch (std::logic_error err) {
198 std::cout <<
"End Result: TEST FAILED\n";
200 std::cout <<
"End Result: TEST PASSED\n";
int main(int argc, char *argv[])
PartitionedVector< Real > PV
Defines the linear algebra of vector space on a generic partitioned vector.
Contains definitions of custom data types in ROL.
Teuchos::RCP< Vector< Real > > CreatePartitionedVector(const Teuchos::RCP< Vector< Real > > &a)
Defines the linear algebra or vector space interface.
void print_vector(const ROL::Vector< Real > &x)
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.
void apply(V &Hv, const V &v, Real &tol) const
Apply linear operator.
Provides the interface to apply a 2x2 block operator to a partitioned vector.