46 #ifndef ROL_PARTITIONED_VECTOR_H 47 #define ROL_PARTITIONED_VECTOR_H 61 typedef Teuchos::RCP<V>
RCPV;
70 typedef typename std::vector<PV>::size_type
size_type;
78 void set(
const V &x ) {
79 using Teuchos::dyn_cast;
80 const PV &xs = dyn_cast<
const PV>(dyn_cast<
const V>(x));
83 std::invalid_argument,
84 "Error: Vectors must have the same number of subvectors." );
92 using Teuchos::dyn_cast;
93 const PV &xs = dyn_cast<
const PV>(dyn_cast<
const V>(x));
96 std::invalid_argument,
97 "Error: Vectors must have the same number of subvectors." );
106 vecs_[i]->scale(alpha);
110 void axpy(
const Real alpha,
const V &x ) {
111 using Teuchos::dyn_cast;
112 const PV &xs = dyn_cast<
const PV>(x);
115 std::invalid_argument,
116 "Error: Vectors must have the same number of subvectors." );
124 using Teuchos::dyn_cast;
125 const PV &xs = dyn_cast<
const PV>(x);
128 std::invalid_argument,
129 "Error: Vectors must have the same number of subvectors." );
133 result +=
vecs_[i]->dot(*xs.
get(i));
143 return std::sqrt(result);
150 std::vector<RCPV> clonevec;
154 return rcp(
new PV(clonevec) );
169 TEUCHOS_TEST_FOR_EXCEPTION( i >=
dimension() || i<0,
170 std::invalid_argument,
171 "Error: Basis index must be between 0 and vector dimension." );
175 using Teuchos::dyn_cast;
180 PV &eb = dyn_cast<
PV>(*bvec);
188 end +=
vecs_[j]->dimension();
190 if( begin<= i && i<end ) {
206 total_dim +=
vecs_[j]->dimension();
218 void applyUnary(
const Elementwise::UnaryFunction<Real> &f ) {
220 vecs_[i]->applyUnary(f);
225 void applyBinary(
const Elementwise::BinaryFunction<Real> &f,
const V &x ) {
226 const PV &xs = Teuchos::dyn_cast<
const PV>(x);
229 vecs_[i]->applyBinary(f,*xs.
get(i));
233 Real
reduce(
const Elementwise::ReductionOp<Real> &r )
const {
234 Real result = r.initialValue();
244 Teuchos::RCP<const Vector<Real> >
get(
size_type i)
const {
271 typedef RCP<Vector<Real> > RCPV;
275 return rcp(
new PV( std::vector<RCPV>(temp, temp+1) ) );
282 typedef RCP<const Vector<Real> > RCPV;
286 return rcp(
new PV( std::vector<RCPV>(temp, temp+1) ) );
294 typedef RCP<Vector<Real> > RCPV;
298 return rcp(
new PV( std::vector<RCPV>(temp, temp+2) ) );
306 typedef RCP<const Vector<Real> > RCPV;
310 return rcp(
new PV( std::vector<RCPV>(temp, temp+2) ) );
319 typedef RCP<Vector<Real> > RCPV;
322 RCPV temp[] = {a,b,c};
323 return rcp(
new PV( std::vector<RCPV>(temp, temp+3) ) );
332 typedef RCP<const Vector<Real> > RCPV;
335 RCPV temp[] = {a,b,c};
336 return rcp(
new PV( std::vector<RCPV>(temp, temp+3) ) );
346 typedef RCP<Vector<Real> > RCPV;
349 RCPV temp[] = {a,b,c,d};
350 return rcp(
new PV( std::vector<RCPV>(temp, temp+4) ) );
360 typedef RCP<const Vector<Real> > RCPV;
363 RCPV temp[] = {a,b,c,d};
364 return rcp(
new PV( std::vector<RCPV>(temp, temp+4) ) );
369 #endif // ROL_PARTITIONED_VECTOR_H Real norm() const
Returns where .
Defines the linear algebra of vector space on a generic partitioned vector.
const std::vector< RCPV > vecs_
Teuchos::RCP< const Vector< Real > > get(size_type i) const
RCPV basis(const int i) const
Return i-th basis vector.
void applyBinary(const Elementwise::BinaryFunction< Real > &f, const V &x)
Real dot(const V &x) const
Compute where .
Teuchos::RCP< Vector< Real > > CreatePartitionedVector(const Teuchos::RCP< Vector< Real > > &a)
const V & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Defines the linear algebra or vector space interface.
int dimension() const
Return dimension of the vector space.
void zero()
Set to zero vector.
void applyUnary(const Elementwise::UnaryFunction< Real > &f)
PartitionedVector< Real > PV
PartitionedVector(const std::vector< RCPV > &vecs)
void scale(const Real alpha)
Compute where .
std::vector< RCPV > dual_vecs_
void set(const V &x)
Set where .
Real reduce(const Elementwise::ReductionOp< Real > &r) const
std::vector< PV >::size_type size_type
RCPV clone() const
Clone to make a new (uninitialized) vector.
Teuchos::RCP< PV > dual_pvec_
void plus(const V &x)
Compute , where .
void axpy(const Real alpha, const V &x)
Compute where .
size_type numVectors() const