46 #ifndef ROL_PARTITIONED_VECTOR_H 47 #define ROL_PARTITIONED_VECTOR_H 61 typedef Teuchos::RCP<V>
RCPV;
65 Teuchos::RCP<std::vector<RCPV> >
vecs_;
70 typedef typename std::vector<PV>::size_type
size_type;
74 for( size_type i=0; i<vecs_->size(); ++i ) {
75 dual_vecs_.push_back(((*vecs_)[i]->
dual()).
clone());
79 void set(
const V &x ) {
80 using Teuchos::dyn_cast;
81 const PV &xs = dyn_cast<
const PV>(dyn_cast<
const V>(x));
83 for( size_type i=0; i<vecs_->size(); ++i ) {
84 (*vecs_)[i]->set(*xs.
get(i));
89 using Teuchos::dyn_cast;
90 const PV &xs = dyn_cast<
const PV>(dyn_cast<
const V>(x));
92 for( size_type i=0; i<vecs_->size(); ++i ) {
93 (*vecs_)[i]->plus(*xs.
get(i));
97 void scale(
const Real alpha ) {
98 for( size_type i=0; i<vecs_->size(); ++i ) {
99 (*vecs_)[i]->scale(alpha);
103 void axpy(
const Real alpha,
const V &x ) {
104 using Teuchos::dyn_cast;
105 const PV &xs = dyn_cast<
const PV>(x);
106 for( size_type i=0; i<vecs_->size(); ++i ) {
107 (*vecs_)[i]->axpy(alpha,*xs.
get(i));
111 Real
dot(
const V &x )
const {
112 using Teuchos::dyn_cast;
113 const PV &xs = dyn_cast<
const PV>(x);
115 for( size_type i=0; i<vecs_->size(); ++i ) {
116 result += (*vecs_)[i]->dot(*xs.
get(i));
123 for( size_type i=0; i<vecs_->size(); ++i ) {
124 result += std::pow((*vecs_)[i]->
norm(),2);
126 return std::sqrt(result);
133 RCP<std::vector<RCPV> > clonevec = rcp(
new std::vector<RCPV> );
135 for( size_type i=0; i<vecs_->size(); ++i ) {
136 clonevec->push_back((*vecs_)[i]->
clone());
138 return rcp(
new PV(clonevec) );
145 for( size_type i=0; i<vecs_->size(); ++i ) {
146 dual_vecs_[i]->
set((*vecs_)[i]->
dual());
148 dual_pvec_ = rcp(
new PV( rcp( &dual_vecs_,
false ) ) );
155 using Teuchos::dyn_cast;
160 PV &eb = dyn_cast<PV>(*bvec);
166 for( size_type j=0; j<vecs_->size(); ++j ) {
168 end += (*vecs_)[j]->dimension();
170 if( begin<= i && i<end ) {
171 eb.
set(j, *((*vecs_)[j]->
basis(i-begin)) );
185 for( size_type j=0; j<vecs_->size(); ++j ) {
186 total_dim += (*vecs_)[j]->dimension();
192 for( size_type j=0; j<vecs_->size(); ++j ) {
199 Teuchos::RCP<const Vector<Real> >
get(size_type i)
const {
203 Teuchos::RCP<Vector<Real> >
get(size_type i) {
207 void set(size_type i,
const V &x) {
216 return vecs_->size();
226 typedef RCP<Vector<Real> >
RCPV;
230 return rcp(
new PV( rcp(
new std::vector<RCPV>(temp, temp+1) ) ) );
237 typedef RCP<const Vector<Real> >
RCPV;
241 return rcp(
new PV( rcp(
new std::vector<RCPV>(temp, temp+1) ) ) );
249 typedef RCP<Vector<Real> >
RCPV;
253 return rcp(
new PV( rcp(
new std::vector<RCPV>(temp, temp+2) ) ) );
261 typedef RCP<const Vector<Real> >
RCPV;
265 return rcp(
new PV( rcp(
new std::vector<RCPV>(temp, temp+2) ) ) );
272 #endif // ROL_PARTITIONED_VECTOR_H PartitionedVector(const Teuchos::RCP< std::vector< RCPV > > &vecs)
size_type numVectors() const
Real norm() const
Returns where .
Defines the linear algebra of vector space on a generic partitioned vector.
const V & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Teuchos::RCP< Vector< Real > > CreatePartitionedVector(Teuchos::RCP< Vector< Real > > &a)
Defines the linear algebra or vector space interface.
Real dot(const V &x) const
Compute where .
void zero()
Set to zero vector.
PartitionedVector< Real > PV
void scale(const Real alpha)
Compute where .
int dimension() const
Return dimension of the vector space.
Teuchos::RCP< const Vector< Real > > get(size_type i) const
RCPV basis(const int i) const
Return i-th basis vector.
Teuchos::RCP< std::vector< RCPV > > vecs_
std::vector< RCPV > dual_vecs_
void set(const V &x)
Set where .
RCPV clone() const
Clone to make a new (uninitialized) vector.
std::vector< PV >::size_type size_type
virtual void set(const Vector &x)
Set where .
Teuchos::RCP< PV > dual_pvec_
void plus(const V &x)
Compute , where .
void axpy(const Real alpha, const V &x)
Compute where .