ROL
Public Member Functions | Private Types | Private Attributes | List of all members
ROL::StdVector< Real, Element > Class Template Reference

Provides the std::vector implementation of the ROL::Vector interface. More...

#include <ROL_StdVector.hpp>

+ Inheritance diagram for ROL::StdVector< Real, Element >:

Public Member Functions

 StdVector (const Teuchos::RCP< std::vector< Element > > &std_vec)
 
void set (const Vector< Real > &x)
 Set \(y \leftarrow x\) where \(y = \mathtt{*this}\). More...
 
void plus (const Vector< Real > &x)
 Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\). More...
 
void axpy (const Real alpha, const Vector< Real > &x)
 Compute \(y \leftarrow \alpha x + y\) where \(y = \mathtt{*this}\). More...
 
void scale (const Real alpha)
 Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\). More...
 
virtual Real dot (const Vector< Real > &x) const
 Compute \( \langle y,x \rangle \) where \(y = \mathtt{*this}\). More...
 
Real norm () const
 Returns \( \| y \| \) where \(y = \mathtt{*this}\). More...
 
virtual Teuchos::RCP< Vector< Real > > clone () const
 Clone to make a new (uninitialized) vector. More...
 
Teuchos::RCP< const std::vector< Element > > getVector () const
 
Teuchos::RCP< std::vector< Element > > getVector ()
 
Teuchos::RCP< Vector< Real > > basis (const int i) const
 Return i-th basis vector. More...
 
int dimension () const
 Return dimension of the vector space. More...
 
void applyUnary (const Elementwise::UnaryFunction< Real > &f)
 
void applyBinary (const Elementwise::BinaryFunction< Real > &f, const Vector< Real > &x)
 
Real reduce (const Elementwise::ReductionOp< Real > &r) const
 
- Public Member Functions inherited from ROL::Vector< Real >
virtual ~Vector ()
 
virtual void zero ()
 Set to zero vector. More...
 
virtual const Vectordual () const
 Return dual representation of \(\mathtt{*this}\), for example, the result of applying a Riesz map, or change of basis, or change of memory layout. More...
 
virtual std::vector< Real > checkVector (const Vector< Real > &x, const Vector< Real > &y, const bool printToStream=true, std::ostream &outStream=std::cout) const
 Verify vector-space methods. More...
 

Private Types

typedef std::vector< Real >::size_type uint
 

Private Attributes

Teuchos::RCP< std::vector< Element > > std_vec_
 

Detailed Description

template<class Real, class Element = Real>
class ROL::StdVector< Real, Element >

Provides the std::vector implementation of the ROL::Vector interface.

Definition at line 60 of file ROL_StdVector.hpp.

Member Typedef Documentation

◆ uint

template<class Real, class Element = Real>
typedef std::vector<Real>::size_type ROL::StdVector< Real, Element >::uint
private

Definition at line 62 of file ROL_StdVector.hpp.

Constructor & Destructor Documentation

◆ StdVector()

template<class Real, class Element = Real>
ROL::StdVector< Real, Element >::StdVector ( const Teuchos::RCP< std::vector< Element > > &  std_vec)
inline

Member Function Documentation

◆ set()

template<class Real, class Element = Real>
void ROL::StdVector< Real, Element >::set ( const Vector< Real > &  x)
inlinevirtual

Set \(y \leftarrow x\) where \(y = \mathtt{*this}\).

Parameters
[in]xis a vector.
   On return \form#18.
   Uses #zero and #plus methods for the computation.
   Please overload if a more efficient implementation is needed.

   ---

Reimplemented from ROL::Vector< Real >.

Definition at line 72 of file ROL_StdVector.hpp.

Referenced by main().

◆ plus()

template<class Real, class Element = Real>
void ROL::StdVector< Real, Element >::plus ( const Vector< Real > &  x)
inlinevirtual

Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\).

Parameters
[in]xis the vector to be added to \(\mathtt{*this}\).
   On return \form#9.

   ---

Implements ROL::Vector< Real >.

Definition at line 83 of file ROL_StdVector.hpp.

◆ axpy()

template<class Real, class Element = Real>
void ROL::StdVector< Real, Element >::axpy ( const Real  alpha,
const Vector< Real > &  x 
)
inlinevirtual

Compute \(y \leftarrow \alpha x + y\) where \(y = \mathtt{*this}\).

Parameters
[in]alphais the scaling of x.
[in]xis a vector.
   On return \form#16.
   Uses #clone, #set, #scale and #plus for the computation.
   Please overload if a more efficient implementation is needed.

   ---

Reimplemented from ROL::Vector< Real >.

Definition at line 97 of file ROL_StdVector.hpp.

Referenced by main(), and ROL::ZOO::Objective_PoissonInversion< Real >::solve_adjoint_sensitivity_equation().

◆ scale()

template<class Real, class Element = Real>
void ROL::StdVector< Real, Element >::scale ( const Real  alpha)
inlinevirtual

Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\).

Parameters
[in]alphais the scaling of \(\mathtt{*this}\).
   On return \form#11.

   ---

Implements ROL::Vector< Real >.

Definition at line 111 of file ROL_StdVector.hpp.

Referenced by main().

◆ dot()

template<class Real, class Element = Real>
virtual Real ROL::StdVector< Real, Element >::dot ( const Vector< Real > &  x) const
inlinevirtual

Compute \( \langle y,x \rangle \) where \(y = \mathtt{*this}\).

Parameters
[in]xis the vector that forms the dot product with \(\mathtt{*this}\).
Returns
The number equal to \(\langle \mathtt{*this}, x \rangle\).

Implements ROL::Vector< Real >.

Reimplemented in ROL::DualAtomVector< Real >, ROL::DualProbabilityVector< Real >, ROL::DualScaledStdVector< Real, Element >, ROL::PrimalAtomVector< Real >, ROL::PrimalProbabilityVector< Real >, ROL::PrimalScaledStdVector< Real, Element >, and ROL::BatchStdVector< Real >.

Definition at line 118 of file ROL_StdVector.hpp.

Referenced by ROL::StdVector< Real >::norm().

◆ norm()

template<class Real, class Element = Real>
Real ROL::StdVector< Real, Element >::norm ( ) const
inlinevirtual

Returns \( \| y \| \) where \(y = \mathtt{*this}\).

Returns
A nonnegative number equal to the norm of \(\mathtt{*this}\).

Implements ROL::Vector< Real >.

Definition at line 134 of file ROL_StdVector.hpp.

Referenced by main().

◆ clone()

template<class Real, class Element = Real>
virtual Teuchos::RCP<Vector<Real> > ROL::StdVector< Real, Element >::clone ( ) const
inlinevirtual

Clone to make a new (uninitialized) vector.

Returns
A reference-counted pointer to the cloned vector.

Provides the means of allocating temporary memory in ROL.


Implements ROL::Vector< Real >.

Reimplemented in ROL::DualAtomVector< Real >, ROL::DualProbabilityVector< Real >, ROL::DualScaledStdVector< Real, Element >, ROL::PrimalAtomVector< Real >, ROL::PrimalProbabilityVector< Real >, ROL::PrimalScaledStdVector< Real, Element >, and ROL::BatchStdVector< Real >.

Definition at line 140 of file ROL_StdVector.hpp.

Referenced by main(), and ROL::ZOO::Objective_PoissonInversion< Real >::value().

◆ getVector() [1/2]

template<class Real, class Element = Real>
Teuchos::RCP<const std::vector<Element> > ROL::StdVector< Real, Element >::getVector ( ) const
inline

Definition at line 144 of file ROL_StdVector.hpp.

Referenced by TridiagonalToeplitzOperator< Real >::apply(), ROL::ScalarLinearEqualityConstraint< Real >::applyAdjointJacobian(), ROL::StdVector< Real >::applyBinary(), TridiagonalToeplitzOperator< Real >::applyInverse(), ROL::ScalarLinearEqualityConstraint< Real >::applyJacobian(), ROL::StdVector< Real >::axpy(), ROL::BatchStdVector< Real >::clone(), ROL::PrimalScaledStdVector< Real, Element >::clone(), ROL::PrimalProbabilityVector< Real >::clone(), ROL::DualScaledStdVector< Real, Element >::clone(), ROL::DualProbabilityVector< Real >::clone(), ROL::StdObjective< Real >::dirDeriv(), ROL::BatchStdVector< Real >::dot(), ROL::PrimalScaledStdVector< Real, Element >::dot(), ROL::PrimalProbabilityVector< Real >::dot(), ROL::StdVector< Real >::dot(), ROL::PrimalAtomVector< Real >::dot(), ROL::DualScaledStdVector< Real, Element >::dot(), ROL::DualProbabilityVector< Real >::dot(), ROL::DualAtomVector< Real >::dot(), ROL::PrimalScaledStdVector< Real, Element >::dual(), ROL::PrimalProbabilityVector< Real >::dual(), ROL::PrimalAtomVector< Real >::dual(), ROL::DualScaledStdVector< Real, Element >::dual(), ROL::DualProbabilityVector< Real >::dual(), ROL::DualAtomVector< Real >::dual(), ROL::AtomVector< Real >::getAtom(), ROL::ProbabilityVector< Real >::getNumMyAtoms(), ROL::ProbabilityVector< Real >::getProbability(), ROL::StdObjective< Real >::gradient(), ROL::StdObjective< Real >::hessVec(), ROL::StdObjective< Real >::invHessVec(), ROL::StdVector< Real >::plus(), ROL::StdObjective< Real >::precond(), ROL::BatchStdVector< Real >::reduce(), ROL::StdVector< Real >::set(), ROL::AtomVector< Real >::setAtom(), ROL::ProbabilityVector< Real >::setProbability(), ROL::ScalarLinearEqualityConstraint< Real >::solveAugmentedSystem(), ROL::StdObjective< Real >::update(), ROL::StdObjective< Real >::value(), and ROL::ScalarLinearEqualityConstraint< Real >::value().

◆ getVector() [2/2]

template<class Real, class Element = Real>
Teuchos::RCP<std::vector<Element> > ROL::StdVector< Real, Element >::getVector ( )
inline

Definition at line 148 of file ROL_StdVector.hpp.

◆ basis()

template<class Real, class Element = Real>
Teuchos::RCP<Vector<Real> > ROL::StdVector< Real, Element >::basis ( const int  i) const
inlinevirtual

Return i-th basis vector.

Parameters
[in]iis the index of the basis function.
Returns
A reference-counted pointer to the basis vector with index i.

Overloading the basis is only required if the default gradient implementation is used, which computes a finite-difference approximation.


Reimplemented from ROL::Vector< Real >.

Definition at line 152 of file ROL_StdVector.hpp.

Referenced by main().

◆ dimension()

template<class Real, class Element = Real>
int ROL::StdVector< Real, Element >::dimension ( void  ) const
inlinevirtual

Return dimension of the vector space.

Returns
The dimension of the vector space, i.e., the total number of basis vectors.

Overload if the basis is overloaded.


Reimplemented from ROL::Vector< Real >.

Definition at line 163 of file ROL_StdVector.hpp.

Referenced by ROL::StdVector< Real >::applyBinary(), ROL::StdVector< Real >::axpy(), ROL::StdVector< Real >::basis(), ROL::StdVector< Real >::dot(), main(), ROL::StdVector< Real >::plus(), and ROL::StdVector< Real >::set().

◆ applyUnary()

template<class Real, class Element = Real>
void ROL::StdVector< Real, Element >::applyUnary ( const Elementwise::UnaryFunction< Real > &  f)
inlinevirtual

Reimplemented from ROL::Vector< Real >.

Definition at line 167 of file ROL_StdVector.hpp.

◆ applyBinary()

template<class Real, class Element = Real>
void ROL::StdVector< Real, Element >::applyBinary ( const Elementwise::BinaryFunction< Real > &  f,
const Vector< Real > &  x 
)
inlinevirtual

Reimplemented from ROL::Vector< Real >.

Definition at line 174 of file ROL_StdVector.hpp.

◆ reduce()

template<class Real, class Element = Real>
Real ROL::StdVector< Real, Element >::reduce ( const Elementwise::ReductionOp< Real > &  r) const
inlinevirtual

Reimplemented from ROL::Vector< Real >.

Definition at line 189 of file ROL_StdVector.hpp.

Member Data Documentation

◆ std_vec_

template<class Real, class Element = Real>
Teuchos::RCP<std::vector<Element> > ROL::StdVector< Real, Element >::std_vec_
private

The documentation for this class was generated from the following file: