44 #ifndef ROL_STDVECTOR_H 45 #define ROL_STDVECTOR_H 59 template <
class Real,
class Element=Real>
62 typedef typename std::vector<Real>::size_type
uint;
70 StdVector(
const Teuchos::RCP<std::vector<Element> > & std_vec) : std_vec_(std_vec) {}
74 const std::vector<Element>& xval = *ex.
getVector();
75 std::copy(xval.begin(),xval.end(),std_vec_->begin());
80 const std::vector<Element>& xval = *ex.
getVector();
83 (*std_vec_)[i] += xval[i];
89 const std::vector<Element>& xval = *ex.
getVector();
92 (*std_vec_)[i] += alpha*xval[i];
96 void scale(
const Real alpha ) {
99 (*std_vec_)[i] *= alpha;
105 const std::vector<Element>& xval = *ex.
getVector();
109 val += (*std_vec_)[i]*xval[i];
116 val = std::sqrt(
dot(*
this) );
120 Teuchos::RCP<Vector<Real> >
clone()
const {
121 return Teuchos::rcp(
new StdVector( Teuchos::rcp(
new std::vector<Element>(std_vec_->size())) ));
124 Teuchos::RCP<const std::vector<Element> >
getVector()
const {
132 Teuchos::RCP<Vector<Real> >
basis(
const int i )
const {
133 Teuchos::RCP<StdVector> e = Teuchos::rcp(
new StdVector( Teuchos::rcp(
new std::vector<Element>(std_vec_->size(), 0.0)) ));
134 (*e->getVector())[i] = 1.0;
139 return static_cast<int>(std_vec_->size());
142 void applyUnary(
const Elementwise::UnaryFunction<Real> &f ) {
145 (*std_vec_)[i] = f.apply((*std_vec_)[i]);
152 const std::vector<Element>& xval = *ex.
getVector();
155 (*std_vec_)[i] = f.apply((*std_vec_)[i],xval[i]);
160 Real
reduce(
const Elementwise::ReductionOp<Real> &r )
const {
161 Real result = r.initialValue();
164 r.reduce((*std_vec_)[i],result);
void axpy(const Real alpha, const Vector< Real > &x)
Compute where .
void scale(const Real alpha)
Compute where .
Teuchos::RCP< const std::vector< Element > > getVector() const
Real dot(const Vector< Real > &x) const
Compute where .
StdVector(const Teuchos::RCP< std::vector< Element > > &std_vec)
void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector< Real > &x)
Teuchos::RCP< Vector< Real > > basis(const int i) const
Return i-th basis vector.
Defines the linear algebra or vector space interface.
Teuchos::RCP< std::vector< Element > > getVector()
Teuchos::RCP< Vector< Real > > clone() const
Clone to make a new (uninitialized) vector.
Real norm() const
Returns where .
Provides the std::vector implementation of the ROL::Vector interface.
void plus(const Vector< Real > &x)
Compute , where .
Real reduce(const Elementwise::ReductionOp< Real > &r) const
Teuchos::RCP< std::vector< Element > > std_vec_
int dimension() const
Return dimension of the vector space.
std::vector< Real >::size_type uint
void applyUnary(const Elementwise::UnaryFunction< Real > &f)