ROL
|
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraints. More...
#include <ROL_StdVector.hpp>
Public Member Functions | |
StdVector (const Ptr< std::vector< Element > > &std_vec) | |
StdVector (const int dim, const Element val=0.0) | |
StdVector (std::initializer_list< Element > ilist) | |
Real & | operator[] (int i) |
const Real & | operator[] (int i) const |
void | set (const Vector< Real > &x) |
Set \(y \leftarrow x\) where \(y = \mathtt{*this}\). | |
void | plus (const Vector< Real > &x) |
Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\). | |
void | axpy (const Real alpha, const Vector< Real > &x) |
Compute \(y \leftarrow \alpha x + y\) where \(y = \mathtt{*this}\). | |
void | scale (const Real alpha) |
Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\). | |
virtual Real | dot (const Vector< Real > &x) const |
Compute \( \langle y,x \rangle \) where \(y = \mathtt{*this}\). | |
Real | norm () const |
Returns \( \| y \| \) where \(y = \mathtt{*this}\). | |
virtual Ptr< Vector< Real > > | clone () const |
Clone to make a new (uninitialized) vector. | |
Ptr< const std::vector< Element > > | getVector () const |
Ptr< std::vector< Element > > | getVector () |
Ptr< Vector< Real > > | basis (const int i) const |
Return i-th basis vector. | |
int | dimension () const |
Return dimension of the vector space. | |
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 |
void | setScalar (const Real C) |
Set \(y \leftarrow C\) where \(C\in\mathbb{R}\). | |
void | randomize (const Real l=0.0, const Real u=1.0) |
Set vector to be uniform random between [l,u]. | |
virtual void | print (std::ostream &outStream) const |
![]() | |
virtual | ~Vector () |
virtual void | plus (const Vector &x)=0 |
Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\). | |
virtual void | scale (const Real alpha)=0 |
Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\). | |
virtual Real | dot (const Vector &x) const =0 |
Compute \( \langle y,x \rangle \) where \(y = \mathtt{*this}\). | |
virtual Real | norm () const =0 |
Returns \( \| y \| \) where \(y = \mathtt{*this}\). | |
virtual ROL::Ptr< Vector > | clone () const =0 |
Clone to make a new (uninitialized) vector. | |
virtual void | axpy (const Real alpha, const Vector &x) |
Compute \(y \leftarrow \alpha x + y\) where \(y = \mathtt{*this}\). | |
virtual void | zero () |
Set to zero vector. | |
virtual ROL::Ptr< Vector > | basis (const int i) const |
Return i-th basis vector. | |
virtual int | dimension () const |
Return dimension of the vector space. | |
virtual void | set (const Vector &x) |
Set \(y \leftarrow x\) where \(y = \mathtt{*this}\). | |
virtual const Vector & | dual () 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. | |
virtual Real | apply (const Vector< Real > &x) const |
Apply \(\mathtt{*this}\) to a dual vector. This is equivalent to the call \(\mathtt{this->dot(x.dual())}\). | |
virtual void | applyUnary (const Elementwise::UnaryFunction< Real > &f) |
virtual void | applyBinary (const Elementwise::BinaryFunction< Real > &f, const Vector &x) |
virtual Real | reduce (const Elementwise::ReductionOp< Real > &r) const |
virtual void | print (std::ostream &outStream) const |
virtual void | setScalar (const Real C) |
Set \(y \leftarrow C\) where \(C\in\mathbb{R}\). | |
virtual void | randomize (const Real l=0.0, const Real u=1.0) |
Set vector to be uniform random between [l,u]. | |
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. | |
Private Types | |
using | size_type = typename std::vector< Real >::size_type |
Private Attributes | |
Ptr< std::vector< Element > > | std_vec_ |
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraints.
Provides the std::vector implementation of the ROL::Vector interface.
Definition at line 61 of file ROL_StdVector.hpp.
|
private |
Definition at line 63 of file ROL_StdVector.hpp.
|
inline |
Definition at line 67 of file ROL_StdVector.hpp.
|
inline |
Definition at line 69 of file ROL_StdVector.hpp.
References dim, and ROL::StdVector< Real, Element >::std_vec_.
|
inline |
Definition at line 73 of file ROL_StdVector.hpp.
|
inline |
Definition at line 76 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
|
inline |
Definition at line 77 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
|
inlinevirtual |
Set \(y \leftarrow x\) where \(y = \mathtt{*this}\).
@param[in] x is a vector. On return \f$\mathtt{*this} = x\f$. Uses #zero and #plus methods for the computation. Please overload if a more efficient implementation is needed. ---
Reimplemented from ROL::Vector< Real >.
Reimplemented in L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, and H1VectorDual< Real >.
Definition at line 79 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::dimension(), ROL::Vector< Real >::dimension(), ROL::StdVector< Real, Element >::getVector(), and ROL::StdVector< Real, Element >::std_vec_.
Referenced by main(), and testRandomInputs().
|
inlinevirtual |
Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\).
@param[in] x is the vector to be added to \f$\mathtt{*this}\f$. On return \f$\mathtt{*this} = \mathtt{*this} + x\f$. ---
Implements ROL::Vector< Real >.
Reimplemented in L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, and H1VectorDual< Real >.
Definition at line 90 of file ROL_StdVector.hpp.
References dim, ROL::StdVector< Real, Element >::dimension(), ROL::Vector< Real >::dimension(), ROL::StdVector< Real, Element >::getVector(), and ROL::StdVector< Real, Element >::std_vec_.
|
inlinevirtual |
Compute \(y \leftarrow \alpha x + y\) where \(y = \mathtt{*this}\).
@param[in] alpha is the scaling of @b x. @param[in] x is a vector. On return \f$\mathtt{*this} = \mathtt{*this} + \alpha x \f$. 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 104 of file ROL_StdVector.hpp.
References dim, ROL::StdVector< Real, Element >::dimension(), ROL::Vector< Real >::dimension(), ROL::StdVector< Real, Element >::getVector(), and ROL::StdVector< Real, Element >::std_vec_.
Referenced by main(), ROL::ZOO::Objective_PoissonInversion< Real >::solve_adjoint_sensitivity_equation(), and testRandomInputs().
|
inlinevirtual |
Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\).
@param[in] alpha is the scaling of \f$\mathtt{*this}\f$. On return \f$\mathtt{*this} = \alpha (\mathtt{*this}) \f$. ---
Implements ROL::Vector< Real >.
Reimplemented in L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, and H1VectorDual< Real >.
Definition at line 118 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
Referenced by main(), and testRandomInputs().
|
inlinevirtual |
Compute \( \langle y,x \rangle \) where \(y = \mathtt{*this}\).
@param[in] x is the vector that forms the dot product with \f$\mathtt{*this}\f$. @return The number equal to \f$\langle \mathtt{*this}, x \rangle\f$. ---
Implements ROL::Vector< Real >.
Reimplemented in L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, ROL::PrimalAtomVector< Real >, ROL::DualAtomVector< Real >, ROL::BatchStdVector< Real >, ROL::PrimalProbabilityVector< Real >, ROL::DualProbabilityVector< Real >, ROL::PrimalScaledStdVector< Real, Element >, and ROL::DualScaledStdVector< Real, Element >.
Definition at line 126 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::dimension(), ROL::Vector< Real >::dimension(), ROL::StdVector< Real, Element >::getVector(), and ROL::StdVector< Real, Element >::std_vec_.
Referenced by ROL::PrimalScaledStdVector< Real, Element >::apply(), ROL::DualScaledStdVector< Real, Element >::apply(), and ROL::StdVector< Real, Element >::norm().
|
inlinevirtual |
Returns \( \| y \| \) where \(y = \mathtt{*this}\).
@return A nonnegative number equal to the norm of \f$\mathtt{*this}\f$. ---
Implements ROL::Vector< Real >.
Reimplemented in L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, and H1VectorDual< Real >.
Definition at line 143 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::dot().
Referenced by main().
|
inlinevirtual |
Clone to make a new (uninitialized) vector.
@return A reference-counted pointer to the cloned vector. Provides the means of allocating temporary memory in ROL. ---
Implements ROL::Vector< Real >.
Reimplemented in L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, ROL::PrimalScaledStdVector< Real, Element >, ROL::DualScaledStdVector< Real, Element >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, ROL::PrimalAtomVector< Real >, ROL::DualAtomVector< Real >, ROL::BatchStdVector< Real >, ROL::ProbabilityVector< Real >, ROL::PrimalProbabilityVector< Real >, and ROL::DualProbabilityVector< Real >.
Definition at line 149 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
Referenced by ROL::StdVector< Real, Element >::basis(), main(), and ROL::ZOO::Objective_PoissonInversion< Real >::value().
|
inline |
Definition at line 153 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
Referenced by TridiagonalToeplitzOperator< Real >::apply(), ROL::StdConstraint< Real >::applyAdjointHessian(), ROL::StdConstraint< Real >::applyAdjointJacobian(), ROL::StdVector< Real, Element >::applyBinary(), TridiagonalToeplitzOperator< Real >::applyInverse(), ROL::StdConstraint< Real >::applyJacobian(), ROL::StdConstraint< Real >::applyPreconditioner(), ROL::StdVector< Real, Element >::axpy(), ROL::PrimalScaledStdVector< Real, Element >::clone(), ROL::DualScaledStdVector< Real, Element >::clone(), L2VectorPrimal< Real >::clone(), L2VectorDual< Real >::clone(), H1VectorPrimal< Real >::clone(), H1VectorDual< Real >::clone(), ROL::BatchStdVector< Real >::clone(), ROL::ProbabilityVector< Real >::clone(), ROL::PrimalProbabilityVector< Real >::clone(), ROL::DualProbabilityVector< Real >::clone(), ROL::StdObjective< Real >::dirDeriv(), L2VectorPrimal< Real >::dot(), L2VectorDual< Real >::dot(), H1VectorPrimal< Real >::dot(), H1VectorDual< Real >::dot(), ROL::PrimalAtomVector< Real >::dot(), ROL::DualAtomVector< Real >::dot(), ROL::BatchStdVector< Real >::dot(), ROL::PrimalProbabilityVector< Real >::dot(), ROL::DualProbabilityVector< Real >::dot(), ROL::PrimalScaledStdVector< Real, Element >::dot(), ROL::DualScaledStdVector< Real, Element >::dot(), ROL::StdVector< Real, Element >::dot(), ROL::PrimalScaledStdVector< Real, Element >::dual(), ROL::DualScaledStdVector< Real, Element >::dual(), L2VectorPrimal< Real >::dual(), L2VectorDual< Real >::dual(), H1VectorPrimal< Real >::dual(), H1VectorDual< Real >::dual(), ROL::PrimalAtomVector< Real >::dual(), ROL::DualAtomVector< Real >::dual(), ROL::PrimalProbabilityVector< Real >::dual(), ROL::DualProbabilityVector< 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, Element >::plus(), ROL::StdObjective< Real >::precond(), ROL::BatchStdVector< Real >::reduce(), ROL::StdVector< Real, Element >::set(), ROL::AtomVector< Real >::setAtom(), ROL::ProbabilityVector< Real >::setProbability(), ROL::StdConstraint< Real >::solveAugmentedSystem(), ROL::StdConstraint< Real >::update(), ROL::StdObjective< Real >::update(), ROL::StdObjective< Real >::value(), and ROL::StdConstraint< Real >::value().
|
inline |
Definition at line 157 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
|
inlinevirtual |
Return i-th basis vector.
@param[in] i is the index of the basis function. @return A reference-counted pointer to the basis vector with index @b 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 >.
Reimplemented in L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, and H1VectorDual< Real >.
Definition at line 161 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::clone(), and ROL::StdVector< Real, Element >::dimension().
Referenced by main().
|
inlinevirtual |
Return dimension of the vector space.
@return 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 >.
Reimplemented in L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, L2VectorPrimal< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, and ROL::BatchStdVector< Real >.
Definition at line 171 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
Referenced by ROL::StdVector< Real, Element >::applyBinary(), ROL::StdVector< Real, Element >::axpy(), ROL::StdVector< Real, Element >::basis(), ROL::PrimalScaledStdVector< Real, Element >::clone(), ROL::DualScaledStdVector< Real, Element >::clone(), ROL::PrimalScaledStdVector< Real, Element >::dot(), ROL::DualScaledStdVector< Real, Element >::dot(), ROL::StdVector< Real, Element >::dot(), L2VectorPrimal< Real >::dual(), L2VectorDual< Real >::dual(), H1VectorPrimal< Real >::dual(), H1VectorDual< Real >::dual(), main(), ROL::StdVector< Real, Element >::plus(), and ROL::StdVector< Real, Element >::set().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 175 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
Referenced by testRandomInputs().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 183 of file ROL_StdVector.hpp.
References dim, ROL::StdVector< Real, Element >::dimension(), ROL::Vector< Real >::dimension(), ROL::StdVector< Real, Element >::getVector(), and ROL::StdVector< Real, Element >::std_vec_.
Referenced by testCases().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Reimplemented in ROL::BatchStdVector< Real >.
Definition at line 198 of file ROL_StdVector.hpp.
References dim, and ROL::StdVector< Real, Element >::std_vec_.
|
inlinevirtual |
Set \(y \leftarrow C\) where \(C\in\mathbb{R}\).
@param[in] C is a scalar. On return \f$\mathtt{*this} = C\f$. Uses #applyUnary methods for the computation. Please overload if a more efficient implementation is needed. ---
Reimplemented from ROL::Vector< Real >.
Definition at line 207 of file ROL_StdVector.hpp.
References dim, and ROL::StdVector< Real, Element >::std_vec_.
Referenced by testRandomInputs().
|
inlinevirtual |
Set vector to be uniform random between [l,u].
@param[in] l is a the lower bound. @param[in] u is a the upper bound. On return the components of \f$\mathtt{*this}\f$ are uniform random numbers on the interval \f$[l,u]\f$. The default implementation uses #applyUnary methods for the computation. Please overload if a more efficient implementation is needed. ---
Reimplemented from ROL::Vector< Real >.
Definition at line 212 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
Referenced by main(), and testRandomInputs().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 228 of file ROL_StdVector.hpp.
References ROL::StdVector< Real, Element >::std_vec_.
|
private |
Definition at line 239 of file ROL_StdVector.hpp.
Referenced by ROL::StdVector< Real, Element >::applyBinary(), ROL::StdVector< Real, Element >::applyUnary(), ROL::StdVector< Real, Element >::axpy(), ROL::StdVector< Real, Element >::clone(), ROL::StdVector< Real, Element >::dimension(), ROL::StdVector< Real, Element >::dot(), ROL::StdVector< Real, Element >::getVector(), ROL::StdVector< Real, Element >::operator[](), ROL::StdVector< Real, Element >::plus(), ROL::StdVector< Real, Element >::print(), ROL::StdVector< Real, Element >::randomize(), ROL::StdVector< Real, Element >::reduce(), ROL::StdVector< Real, Element >::scale(), ROL::StdVector< Real, Element >::set(), ROL::StdVector< Real, Element >::setScalar(), and ROL::StdVector< Real, Element >::StdVector().