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}\). 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 Ptr< Vector< Real > > | clone () const |
Clone to make a new (uninitialized) vector. More... | |
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. 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 |
void | setScalar (const Real C) |
Set \(y \leftarrow C\) where \(C\in\mathbb{R}\). More... | |
void | randomize (const Real l=0.0, const Real u=1.0) |
Set vector to be uniform random between [l,u]. More... | |
virtual void | print (std::ostream &outStream) const |
Public Member Functions inherited from ROL::Vector< Real > | |
virtual | ~Vector () |
virtual void | zero () |
Set to zero vector. More... | |
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. More... | |
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())}\). 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 | |
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 27 of file ROL_StdVector.hpp.
|
private |
Definition at line 29 of file ROL_StdVector.hpp.
|
inline |
Definition at line 33 of file ROL_StdVector.hpp.
|
inline |
Definition at line 35 of file ROL_StdVector.hpp.
|
inline |
Definition at line 39 of file ROL_StdVector.hpp.
|
inline |
Definition at line 42 of file ROL_StdVector.hpp.
|
inline |
Definition at line 43 of file ROL_StdVector.hpp.
|
inlinevirtual |
Set \(y \leftarrow x\) where \(y = \mathtt{*this}\).
[in] | x | is a vector. |
On return \(\mathtt{*this} = x\). 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 45 of file ROL_StdVector.hpp.
Referenced by main(), and testRandomInputs().
|
inlinevirtual |
Compute \(y \leftarrow y + x\), where \(y = \mathtt{*this}\).
[in] | x | is the vector to be added to \(\mathtt{*this}\). |
On return \(\mathtt{*this} = \mathtt{*this} + x\).
Implements ROL::Vector< Real >.
Definition at line 56 of file ROL_StdVector.hpp.
|
inlinevirtual |
Compute \(y \leftarrow \alpha x + y\) where \(y = \mathtt{*this}\).
[in] | alpha | is the scaling of x. |
[in] | x | is a vector. |
On return \(\mathtt{*this} = \mathtt{*this} + \alpha x \). 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 70 of file ROL_StdVector.hpp.
Referenced by main(), ROL::ZOO::Objective_PoissonInversion< Real >::solve_adjoint_sensitivity_equation(), and testRandomInputs().
|
inlinevirtual |
Compute \(y \leftarrow \alpha y\) where \(y = \mathtt{*this}\).
[in] | alpha | is the scaling of \(\mathtt{*this}\). |
On return \(\mathtt{*this} = \alpha (\mathtt{*this}) \).
Implements ROL::Vector< Real >.
Definition at line 84 of file ROL_StdVector.hpp.
Referenced by main(), and testRandomInputs().
|
inlinevirtual |
Compute \( \langle y,x \rangle \) where \(y = \mathtt{*this}\).
[in] | x | is the vector that forms the dot product with \(\mathtt{*this}\). |
Implements ROL::Vector< Real >.
Reimplemented in H1VectorDual< Real >, H1VectorDual< Real >, H1VectorDual< Real >, H1VectorPrimal< Real >, H1VectorPrimal< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, H1VectorDual< Real >, L2VectorDual< Real >, L2VectorDual< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorPrimal< Real >, L2VectorDual< Real >, L2VectorDual< Real >, L2VectorPrimal< Real >, L2VectorPrimal< Real >, L2VectorPrimal< Real >, L2VectorPrimal< Real >, L2VectorPrimal< Real >, 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 92 of file ROL_StdVector.hpp.
Referenced by ROL::PrimalScaledStdVector< Real, Element >::apply(), ROL::DualScaledStdVector< Real, Element >::apply(), and ROL::StdVector< Real >::norm().
|
inlinevirtual |
Returns \( \| y \| \) where \(y = \mathtt{*this}\).
Implements ROL::Vector< Real >.
Definition at line 109 of file ROL_StdVector.hpp.
Referenced by main().
|
inlinevirtual |
Clone to make a new (uninitialized) vector.
Provides the means of allocating temporary memory in ROL.
Implements ROL::Vector< Real >.
Reimplemented in H1VectorDual< Real >, H1VectorDual< Real >, H1VectorDual< Real >, H1VectorPrimal< Real >, H1VectorPrimal< Real >, H1VectorPrimal< Real >, H1VectorDual< Real >, H1VectorDual< Real >, L2VectorDual< Real >, L2VectorDual< Real >, L2VectorDual< Real >, H1VectorPrimal< Real >, H1VectorPrimal< Real >, L2VectorDual< Real >, L2VectorDual< Real >, L2VectorPrimal< Real >, L2VectorPrimal< Real >, L2VectorPrimal< Real >, L2VectorPrimal< Real >, L2VectorPrimal< Real >, ROL::DualAtomVector< Real >, ROL::DualProbabilityVector< Real >, ROL::DualScaledStdVector< Real, Element >, ROL::PrimalAtomVector< Real >, ROL::PrimalProbabilityVector< Real >, ROL::PrimalScaledStdVector< Real, Element >, ROL::ProbabilityVector< Real >, and ROL::BatchStdVector< Real >.
Definition at line 115 of file ROL_StdVector.hpp.
Referenced by ROL::StdVector< Real >::basis(), main(), and ROL::ZOO::Objective_PoissonInversion< Real >::value().
|
inline |
Definition at line 119 of file ROL_StdVector.hpp.
Referenced by TridiagonalToeplitzOperator< Real >::apply(), ROL::StdConstraint< Real >::applyAdjointHessian(), constraint1< Real >::applyAdjointHessian_11(), constraint2< Real >::applyAdjointHessian_11(), constraint1< Real >::applyAdjointHessian_12(), constraint2< Real >::applyAdjointHessian_12(), constraint1< Real >::applyAdjointHessian_21(), constraint2< Real >::applyAdjointHessian_21(), constraint1< Real >::applyAdjointHessian_22(), constraint2< Real >::applyAdjointHessian_22(), ROL::StdConstraint< Real >::applyAdjointJacobian(), constraint2< Real >::applyAdjointJacobian_1(), constraint1< Real >::applyAdjointJacobian_2(), constraint2< Real >::applyAdjointJacobian_2(), ROL::StdVector< Real >::applyBinary(), TridiagonalToeplitzOperator< Real >::applyInverse(), constraint1< Real >::applyInverseJacobian_1(), ROL::StdConstraint< Real >::applyJacobian(), constraint1< Real >::applyJacobian_1(), constraint2< Real >::applyJacobian_1(), constraint1< Real >::applyJacobian_2(), constraint2< Real >::applyJacobian_2(), ROL::StdConstraint< Real >::applyPreconditioner(), ROL::StdVector< Real >::axpy(), ROL::StdVector< Real >::basis(), ROL::BatchStdVector< Real >::clone(), ROL::ProbabilityVector< Real >::clone(), ROL::PrimalScaledStdVector< Real, Element >::clone(), ROL::PrimalProbabilityVector< Real >::clone(), ROL::DualScaledStdVector< Real, Element >::clone(), ROL::DualProbabilityVector< Real >::clone(), L2VectorPrimal< Real >::clone(), L2VectorDual< Real >::clone(), H1VectorPrimal< Real >::clone(), H1VectorDual< Real >::clone(), ROL::StdObjective< Real >::dirDeriv(), ROL::BatchStdVector< Real >::dot(), ROL::PrimalScaledStdVector< Real, Element >::dot(), ROL::PrimalProbabilityVector< Real >::dot(), ROL::PrimalAtomVector< Real >::dot(), ROL::StdVector< Real >::dot(), ROL::DualScaledStdVector< Real, Element >::dot(), ROL::DualProbabilityVector< Real >::dot(), ROL::DualAtomVector< Real >::dot(), L2VectorPrimal< Real >::dot(), L2VectorDual< Real >::dot(), H1VectorPrimal< Real >::dot(), H1VectorDual< 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(), L2VectorPrimal< Real >::dual(), L2VectorDual< Real >::dual(), H1VectorPrimal< Real >::dual(), H1VectorDual< 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(), constraint1< Real >::solve(), ROL::StdConstraint< Real >::solveAugmentedSystem(), ROL::StdConstraint< Real >::update(), ROL::StdObjective< Real >::update(), ROL::StdConstraint< Real >::value(), ROL::StdObjective< Real >::value(), constraint1< Real >::value(), and constraint2< Real >::value().
|
inline |
Definition at line 123 of file ROL_StdVector.hpp.
|
inlinevirtual |
Return i-th basis vector.
[in] | i | is the index of the basis function. |
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 127 of file ROL_StdVector.hpp.
Referenced by main().
|
inlinevirtual |
Return dimension of the vector space.
Overload if the basis is overloaded.
Reimplemented from ROL::Vector< Real >.
Definition at line 137 of file ROL_StdVector.hpp.
Referenced by ROL::StdVector< Real >::applyBinary(), ROL::StdVector< Real >::axpy(), ROL::StdVector< Real >::basis(), L2VectorPrimal< Real >::clone(), L2VectorDual< Real >::clone(), H1VectorPrimal< Real >::clone(), H1VectorDual< Real >::clone(), ROL::StdVector< Real >::dot(), L2VectorPrimal< Real >::dual(), L2VectorDual< Real >::dual(), H1VectorPrimal< Real >::dual(), H1VectorDual< Real >::dual(), main(), ROL::StdVector< Real >::plus(), and ROL::StdVector< Real >::set().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 141 of file ROL_StdVector.hpp.
Referenced by testRandomInputs().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 149 of file ROL_StdVector.hpp.
Referenced by testCases().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 164 of file ROL_StdVector.hpp.
|
inlinevirtual |
Set \(y \leftarrow C\) where \(C\in\mathbb{R}\).
[in] | C | is a scalar. |
On return \(\mathtt{*this} = C\). Uses applyUnary methods for the computation. Please overload if a more efficient implementation is needed.
Reimplemented from ROL::Vector< Real >.
Definition at line 173 of file ROL_StdVector.hpp.
|
inlinevirtual |
Set vector to be uniform random between [l,u].
[in] | l | is a the lower bound. |
[in] | u | is a the upper bound. |
On return the components of \(\mathtt{*this}\) are uniform random numbers on the interval \([l,u]\). 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 178 of file ROL_StdVector.hpp.
Referenced by main(), and testRandomInputs().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 194 of file ROL_StdVector.hpp.
|
private |
Definition at line 205 of file ROL_StdVector.hpp.
Referenced by ROL::StdVector< Real >::applyBinary(), ROL::StdVector< Real >::applyUnary(), ROL::StdVector< Real >::axpy(), ROL::StdVector< Real >::clone(), ROL::StdVector< Real >::dimension(), ROL::StdVector< Real >::dot(), ROL::StdVector< Real >::getVector(), ROL::StdVector< Real >::operator[](), ROL::StdVector< Real >::plus(), ROL::StdVector< Real >::print(), ROL::StdVector< Real >::randomize(), ROL::StdVector< Real >::reduce(), ROL::StdVector< Real >::scale(), ROL::StdVector< Real >::set(), ROL::StdVector< Real >::setScalar(), and ROL::StdVector< Real >::StdVector().