47 #ifndef ROL_SIMULATED_VECTOR_H 48 #define ROL_SIMULATED_VECTOR_H 65 typedef Teuchos::RCP<V>
RCPV;
66 typedef Teuchos::RCP<BatchManager<Real> >
RCPBM;
71 Teuchos::RCP<BatchManager<Real> >
bman_;
76 typedef typename std::vector<PV>::size_type
size_type;
84 void set(
const V &x ) {
85 using Teuchos::dyn_cast;
86 const PV &xs = dyn_cast<
const PV>(dyn_cast<
const V>(x));
89 std::invalid_argument,
90 "Error: Vectors must have the same number of subvectors." );
98 using Teuchos::dyn_cast;
99 const PV &xs = dyn_cast<
const PV>(dyn_cast<
const V>(x));
102 std::invalid_argument,
103 "Error: Vectors must have the same number of subvectors." );
112 vecs_[i]->scale(alpha);
116 void axpy(
const Real alpha,
const V &x ) {
117 using Teuchos::dyn_cast;
118 const PV &xs = dyn_cast<
const PV>(x);
121 std::invalid_argument,
122 "Error: Vectors must have the same number of subvectors." );
130 using Teuchos::dyn_cast;
131 const PV &xs = dyn_cast<
const PV>(x);
134 std::invalid_argument,
135 "Error: Vectors must have the same number of subvectors." );
140 locresult +=
vecs_[i]->dot(*xs.
get(i));
143 bman_->sumAll(&locresult, &result, 1);
152 locresult += std::pow(
vecs_[i]->
norm(),2);
155 bman_->sumAll(&locresult, &result, 1);
157 return std::sqrt(result);
164 std::vector<RCPV> clonevec;
168 return rcp(
new PV(clonevec,
bman_) );
183 TEUCHOS_TEST_FOR_EXCEPTION( i >=
dimension() || i<0,
184 std::invalid_argument,
185 "Error: Basis index must be between 0 and vector dimension." );
189 using Teuchos::dyn_cast;
194 PV &eb = dyn_cast<
PV>(*bvec);
202 end +=
vecs_[j]->dimension();
204 if( begin<= i && i<end ) {
220 total_dim +=
vecs_[j]->dimension();
232 void applyUnary(
const Elementwise::UnaryFunction<Real> &f ) {
234 vecs_[i]->applyUnary(f);
239 void applyBinary(
const Elementwise::BinaryFunction<Real> &f,
const V &x ) {
240 const PV &xs = Teuchos::dyn_cast<
const PV>(x);
243 vecs_[i]->applyBinary(f,*xs.
get(i));
247 Real
reduce(
const Elementwise::ReductionOp<Real> &r )
const {
248 Real result = r.initialValue();
260 Teuchos::RCP<const Vector<Real> >
get(
size_type i)
const {
287 typedef RCP<Vector<Real> > RCPV;
291 return rcp(
new PV( std::vector<RCPV>(temp, temp+1), bman ) );
298 typedef RCP<const Vector<Real> > RCPV;
302 return rcp(
new PV( std::vector<RCPV>(temp, temp+1), bman ) );
311 typedef RCP<Vector<Real> > RCPV;
315 return rcp(
new PV( std::vector<RCPV>(temp, temp+2), bman ) );
324 typedef RCP<const Vector<Real> > RCPV;
328 return rcp(
new PV( std::vector<RCPV>(temp, temp+2), bman ) );
338 typedef RCP<Vector<Real> > RCPV;
341 RCPV temp[] = {a,b,c};
342 return rcp(
new PV( std::vector<RCPV>(temp, temp+3), bman ) );
352 typedef RCP<const Vector<Real> > RCPV;
355 RCPV temp[] = {a,b,c};
356 return rcp(
new PV( std::vector<RCPV>(temp, temp+3), bman ) );
367 typedef RCP<Vector<Real> > RCPV;
370 RCPV temp[] = {a,b,c,d};
371 return rcp(
new PV( std::vector<RCPV>(temp, temp+4), bman ) );
382 typedef RCP<const Vector<Real> > RCPV;
385 RCPV temp[] = {a,b,c,d};
386 return rcp(
new PV( std::vector<RCPV>(temp, temp+4), bman ) );
391 #endif // ROL_SIMULATED_VECTOR_H void set(const V &x)
Set where .
std::vector< PV >::size_type size_type
size_type numVectors() const
std::vector< RCPV > dual_vecs_
Teuchos::RCP< Vector< Real > > CreateSimulatedVector(const Teuchos::RCP< Vector< Real > > &a, const Teuchos::RCP< BatchManager< Real > > &bman)
void applyBinary(const Elementwise::BinaryFunction< Real > &f, const V &x)
Defines the linear algebra or vector space interface.
Real norm() const
Returns where .
Defines the linear algebra of a vector space on a generic partitioned vector where the individual vec...
const V & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
SimulatedVector(const std::vector< RCPV > &vecs, const RCPBM &bman)
Teuchos::RCP< PV > dual_pvec_
RCPV clone() const
Clone to make a new (uninitialized) vector.
const std::vector< RCPV > vecs_
Teuchos::RCP< BatchManager< Real > > bman_
Real dot(const V &x) const
Compute where .
int dimension() const
Return dimension of the vector space.
RCPV basis(const int i) const
Return i-th basis vector.
void zero()
Set to zero vector.
void plus(const V &x)
Compute , where .
Teuchos::RCP< BatchManager< Real > > RCPBM
SimulatedVector< Real > PV
Real reduce(const Elementwise::ReductionOp< Real > &r) const
void scale(const Real alpha)
Compute where .
void axpy(const Real alpha, const V &x)
Compute where .
void applyUnary(const Elementwise::UnaryFunction< Real > &f)
Teuchos::RCP< const Vector< Real > > get(size_type i) const