|
ROL
|
Provides the std::array implementation of the ROL::Vector interface. More...
#include <ROL_StdArray.hpp>
Inheritance diagram for ROL::StdArray< Real, array_size, pool_size >:Public Types | |
| using | data_type = std::array< Real, array_size > |
Public Member Functions | |
| StdArray () | |
| Real & | operator[] (std::size_t i) |
| const Real & | operator[] (std::size_t i) const |
| std::array< Real, array_size > & | get_array () |
| const std::array< Real, array_size > & | get_array () 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< Vector< Real > > | basis (const int i) const |
| Return i-th basis vector. | |
| int | dimension () const |
| Return dimension of the vector space. | |
| void | zero () |
| Set to zero vector. | |
| 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 alpha) |
| Set \(y \leftarrow C\) where \(C\in\mathbb{R}\). | |
| void | randomize (const Real l=-1.0, const Real u=1.0) |
| Set vector to be uniform random between [l,u]. | |
| virtual void | print (std::ostream &outStream) const |
Public Member Functions inherited from ROL::Vector< Real > | |
| virtual | ~Vector () |
| 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 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. | |
Static Public Member Functions | |
| static void | initialize_pool () |
| static std::size_t | pool_count () |
Private Member Functions | |
| StdArray (Ptr< std::array< Real, array_size > > p) | |
| const std::array< Real, array_size > & | _array (const Vector< Real > &x) const |
Private Attributes | |
| Ptr< std::array< Real, array_size > > | data |
Static Private Attributes | |
| static std::array< std::array< Real, array_size >, pool_size > | pool |
| static std::array< Ptr< std::array< Real, array_size > >, pool_size > | pool_ptr |
Provides the std::array implementation of the ROL::Vector interface.
Definition at line 28 of file ROL_StdArray.hpp.
| using ROL::StdArray< Real, array_size, pool_size >::data_type = std::array<Real,array_size> |
Definition at line 31 of file ROL_StdArray.hpp.
|
inline |
Definition at line 33 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data, and ROL::StdArray< Real, array_size, pool_size >::pool_ptr.
|
inlineprivate |
Definition at line 144 of file ROL_StdArray.hpp.
|
inline |
Definition at line 46 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inline |
Definition at line 47 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inline |
Definition at line 49 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
Referenced by ROL::StdArray< Real, array_size, pool_size >::_array().
|
inline |
Definition at line 50 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
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 >.
Definition at line 52 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
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 >.
Definition at line 57 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
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 62 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
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 >.
Definition at line 67 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
Referenced by main().
|
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 >.
Definition at line 71 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Returns \( \| y \| \) where \(y = \mathtt{*this}\).
@return A nonnegative number equal to the norm of \f$\mathtt{*this}\f$.
---
Implements ROL::Vector< Real >.
Definition at line 78 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
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 >.
Definition at line 84 of file ROL_StdArray.hpp.
Referenced by ROL::StdArray< Real, array_size, pool_size >::basis(), and main().
|
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 >.
Definition at line 88 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::clone(), and ROL::StdArray< Real, array_size, pool_size >::zero().
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 >.
Definition at line 96 of file ROL_StdArray.hpp.
|
inlinevirtual |
Set to zero vector.
Uses #scale by zero for the computation. Please overload if a more efficient implementation is needed. ---
Reimplemented from ROL::Vector< Real >.
Definition at line 98 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
Referenced by ROL::StdArray< Real, array_size, pool_size >::basis().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 100 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 104 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::_array(), and ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 111 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
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 117 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
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 119 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
Referenced by main().
|
inlinevirtual |
Reimplemented from ROL::Vector< Real >.
Definition at line 126 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::data.
|
inlinestatic |
Definition at line 131 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::pool, and ROL::StdArray< Real, array_size, pool_size >::pool_ptr.
Referenced by main().
|
inlinestatic |
Definition at line 136 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::pool_ptr.
Referenced by main().
|
inlineprivate |
Definition at line 146 of file ROL_StdArray.hpp.
References ROL::StdArray< Real, array_size, pool_size >::get_array().
Referenced by ROL::StdArray< Real, array_size, pool_size >::applyBinary(), ROL::StdArray< Real, array_size, pool_size >::axpy(), ROL::StdArray< Real, array_size, pool_size >::dot(), ROL::StdArray< Real, array_size, pool_size >::plus(), and ROL::StdArray< Real, array_size, pool_size >::set().
|
private |
Definition at line 150 of file ROL_StdArray.hpp.
Referenced by ROL::StdArray< Real, array_size, pool_size >::applyBinary(), ROL::StdArray< Real, array_size, pool_size >::applyUnary(), ROL::StdArray< Real, array_size, pool_size >::axpy(), ROL::StdArray< Real, array_size, pool_size >::dot(), ROL::StdArray< Real, array_size, pool_size >::get_array(), ROL::StdArray< Real, array_size, pool_size >::get_array(), ROL::StdArray< Real, array_size, pool_size >::norm(), ROL::StdArray< Real, array_size, pool_size >::operator[](), ROL::StdArray< Real, array_size, pool_size >::operator[](), ROL::StdArray< Real, array_size, pool_size >::plus(), ROL::StdArray< Real, array_size, pool_size >::print(), ROL::StdArray< Real, array_size, pool_size >::randomize(), ROL::StdArray< Real, array_size, pool_size >::reduce(), ROL::StdArray< Real, array_size, pool_size >::scale(), ROL::StdArray< Real, array_size, pool_size >::set(), ROL::StdArray< Real, array_size, pool_size >::setScalar(), ROL::StdArray< Real, array_size, pool_size >::StdArray(), and ROL::StdArray< Real, array_size, pool_size >::zero().
|
staticprivate |
Definition at line 153 of file ROL_StdArray.hpp.
Referenced by ROL::StdArray< Real, array_size, pool_size >::initialize_pool().
|
staticprivate |
Definition at line 154 of file ROL_StdArray.hpp.
Referenced by ROL::StdArray< Real, array_size, pool_size >::initialize_pool(), ROL::StdArray< Real, array_size, pool_size >::pool_count(), and ROL::StdArray< Real, array_size, pool_size >::StdArray().